akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for(int i=0; i<n; i++) {
      double xa = sc.nextDouble();
      double ya = sc.nextDouble();
      double ra = sc.nextDouble();
      double xb = sc.nextDouble();
      double yb = sc.nextDouble();
      double rb = sc.nextDouble();
      double dist = Math.sqrt(Math.pow(xa-xb, 2) + Math.pow(ya-yb, 2));
      if(ra > rb && dist < ra - rb) {
        System.out.println(2);
      }
      else if(rb > ra && dist < rb - ra) {
	System.out.println(-2);
      }
      else if(dist <= ra + rb && dist >= ra - rb) {
	System.out.println(1);
      }
      else {
        System.out.println(0);
      }
    }    
  }
}

Measured memory_bytes: 28272
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	int n, m, t;
	cin>>n>>m>>t;
	vi a(n);
	rep(i, n) cin>>a[i];
	ll ans = (ll)a[0] - m;
	for(int i = 1; i < n; i++){
		ans += max(a[i] - a[i - 1] - m*2, 0);
	}
	ans += max(t-a[n-1]-m, 0);
	cout<<ans<<endl;
}

Measured memory_bytes: 3104
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(long long(a), long long(b), long long(c)) {
	return max(max(a,b), c);
}
int Min(long long(a), long long(b), long long(c)) {
	return min(min(a, b), c);
}

int cnt(ll N) {
	int digits = 0;

	while (N > 0) {
		N /= 10;
		digits++;
	}

	return digits;
}



int main() {
	ll A,B,N,a,c,an;
	cin >>A>>B>>N;
	
	a = A / B;
	c = A % B;
	N = min(N, B - 1);

	cout << a*N+(c*N)/B << endl;

}


Measured memory_bytes: 3632
input()
a=list(map(int,input().split()))
n=int(input())
b=list(map(int,input().split()))
d={}


def s(bannpei):
    i=0
    c=b+[bannpei]
    while c[i]!=bannpei:
        i+=1
    if i==n:
        return False
    return True
for r in a:
    if s(r):
        d[r]=1
print(sum(d.values()))


Measured memory_bytes: 6548
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int p = sc.nextInt();
        int odd = 0;
        for (int i = 0; i < n; i++) {
           if( sc.nextInt() % 2 == 1 ) {
               odd++;
           }
        }
        if( odd == 0 ) {
            if( p == 0 ) {
                System.out.println((long)Math.pow(2, n));
            } else {
                System.out.println(0);
            }
        } else {
            System.out.println( (long)Math.pow(2, n-1));
        }
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    long double res = powl(n / k, 3);
    if (k % 2 == 0) 
        res += powl(2 * n / k - n / k, 3);
    cout << (long long)(res) << '\n';
}


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

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

    string s;
    cin >> s;

    long long n = s.size();

    map<char, long long> mp;
    REP(i, n) mp[s[i]]++;

    long long alc = n * (n - 1) / 2;
    alc++;   //original

    for(auto x : mp){
        if(x.second >= 2){
            alc -= x.second * (x.second - 1) / 2;
        }
    }
    cout << alc << endl;

    return 0;
}


Measured memory_bytes: 720
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main(void) {
    int n, m;
    cin >> n >> m;

    vector<int> c(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        c[a - 1]++;
        c[b - 1]++;
    }

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

    return 0;
}


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

int main(){
  struct Edge{int from, to, cost;} e[2005];
  int n, m, i, j, k;
  long long d[1005], a[2];
  
  scanf("%d%d", &n, &m);
  for(i = 0; i < m; i++)
    scanf("%d%d%d", &e[i].from, &e[i].to, &e[i].cost);
  
  for(i = 1; i <= n; i++) d[i] = INF;
  d[1] = 0; 
  
  for(i = 0; i < 2; i++){
    for(j = 0; j < n; j++)
      for(k = 0; k < m; k++)
        if(d[e[k].from] != INF && d[e[k].to] < d[e[k].from] + e[k].cost)
          d[e[k].to] = d[e[k].from] + e[k].cost;
    a[i] = d[n];
  }
  if(a[0] != a[1]) printf("inf\n");
  else printf("%lld\n", a[0]);
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        //入力準備
        Scanner sc = new Scanner(System.in);
        int x,y;
        
        //入力値の受け取り
        while(true){
            x = sc.nextInt();
            y = sc.nextInt();
            if(x == 0 && y == 0) break;
            
            if(x < y){
                System.out.println(x + " " + y);
            }else{
                System.out.println(y + " " + x);
            }
        }
    }
}


Measured memory_bytes: 36052
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    
    ll N,M;cin>>N>>M;
    ll NN=N,MM=M;
    if(2*N<=M){
        cout<<(M-2*N)/4+N<<endl;
    }
    else{
        cout<<M/2<<endl;
    }
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
#define pll pair<ll, ll>
#define vpl vector<pll>
#define vb vector<bool>
#define PB push_back
#define MP make_pair
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=s; i>=e; i--)
#define vasort(v) sort(v.begin(), v.end())
#define vdsort(v) sort(v.begin(), v.end(),greater<int>())
#define F first
#define S second

#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6

#define mz(a)   memset(a,0,sizeof(a))
#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main() {
    zoom;
    ll n;
    in1(n);
    ll c=n%1000;
    if (c==0) out1(0);
    else out1(1000-c);
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define M 1000000007

int main()
{
   ll n, m;
   cin >> n >> m;
   vector<ll> A(n+1, 0), cnt(n+2, 0);
   for(ll i = 0; i <= n; i++)
        A[i] = i + 100;
    for(ll i = 1; i <= n; i++)
        A[i] = (A[i-1] + A[i])%M;
    for(ll i = 1; i <= n+1; i++){
        ll sumL = A[i-1]%M;
        ll sumR = (A[n]%M- (n-i >= 0 ? A[n-i]%M : 0) + M)%M;
        cnt[i] = (sumR - sumL + 1%M + M)%M;
    }
    ll ans = 0;
    for(ll k = m; k <= n+1; k++)
        ans = (ans%M + cnt[k]%M)%M;
    cout << ans << "\n";
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  cout << max(a + b, max(a - b, a * b)) << endl;
}


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

#define endl '\n'

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

    int n; cin >> n;
    int a[n];
    set<int> sla;
    for (int i=0; i<n; i++){
        cin >> a[i];
        sla.insert(a[i]);
    }
    if (sla.size() == n) cout << "YES\n";
    else cout << "NO\n";
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
#include <queue>
#include <cstring>
#define mp make_pair
#define pb push_back
#define p push

#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long int

#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE 1000000007
#define MAXN 100005

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;



int main(){
    IOS
    ll n ,m;
    cin >>n>>m;
    map<int , int> mm ;

    int mx =1;
    int mn =n;
    for (int a,b,i = 0; i <m ; ++i) {
       cin >> a>>b;
       mx = max(mx,a);
       mn = min(mn,b);
    }
    if(mn < mx)cout <<0<<endl;
    else cout << mn - mx +1 <<endl;


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n, a[55], sei, fu, ma, mi;
int main(void){
    // Your code here!
    cin >> n;
    cout << 2 * n - 2 << endl;
    for (ll i = 1; i <= n; i++){
        cin >> a[i];
        if (a[i] > 0){
            if (a[i] >= sei){
                ma = i, sei = a[i];
            }
        } else {
            if (a[i] <= fu){
                mi = i, fu = a[i];
            }
        }
    }
    if (sei > -fu){
        for (ll i = 1; i <= n; i++){
            if (i == ma) continue;
            cout << ma << ' ' << i << endl;
        }
        for (ll i = 1; i < n; i++){
            cout << i << ' ' << i + 1 << endl;
        }
    } else {
        for (ll i = 1; i <= n; i++){
            if (i == mi) continue;
            cout << mi << ' ' << i << endl;
        }
        for (ll i = n; i > 1; i--){
            cout << i << ' ' << i - 1 << endl;
        }
    }
}


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

int main(){
	long long int q,h,s,d,n,gokei=0;cin>>q>>h>>s>>d>>n;
  	n=n*100;
  	if(q*2<h) h=q*2;
  	if(h*2<s) s=h*2;
  	if(s*2<d) d=s*2;
  	gokei+=n/200*d;n=n%200;
  	gokei+=n/100*s;n=n%100;
  	gokei+=n/100*h;n=n%50;
  	gokei+=n/100*q;n=n%25;
  	cout<<gokei<<endl;  	
}    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string S;cin >> S;
  sort(all(S));
  YesNo(S[0]==S[1]&&S[2]==S[3]&&S[1]!=S[2]);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue<long long int> 
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
 
int solve(int a[],int n,int i,int dp[])
{
    if(i==n)
        return 0;
    if(i==(n-1))
        return abs(a[n-1]-a[n]);
    else
    {
        ll x,y;
        if(dp[i+1]==-1)
            dp[i+1] = solve(a,n,i+1,dp);
        if(dp[i+2]==-1)
            dp[i+2] = solve(a,n,i+2,dp);
        x = abs(a[i]-a[i+1]) + dp[i+1];
        y = abs(a[i]-a[i+2]) + dp[i+2];
        dp[i] = min(x,y);
        return dp[i];
    }
}
int main()
{
    flash;
    int t,n,i;
    t=1;
    int dp[100001];
    while(t--)
    {
        cin>>n;
        int a[n];
        memset(dp,-1,sizeof(dp));
        FOR(i,0,n)  cin>>a[i];
        cout<<solve(a,n-1,0,dp)<<endl;
        
    }
}

Measured memory_bytes: 8832
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
	ll H, W;
	cin >> H >> W;
	vector<string> s(H);
	vector<vector<ll>> l(H, vector<ll>(W)), r(H, vector<ll>(W)), u(H, vector<ll>(W)), d(H, vector<ll>(W));


	for (ll i = 0; i < H; i++)
	{
		cin >> s[i];
	}
	for (ll i = 0; i < H; i++)
	{
		ll stepl = 0;
		ll stepr = 0;
		for (ll j = 0; j < W; j++)
		{
			if (s[i][j] == '.') {
				stepr++;
				r[i][j] = stepr;
			}
			else {
				stepr = 0;
				r[i][j] = stepr;
			}
			if (s[i][W - j - 1] == '.') {
				stepl++;
			}
			else {
				stepl = 0;
			}
			l[i][W - j - 1] = stepl;
		}
	}
	for (ll j = 0; j < W; j++)
	{
		ll stepd = 0;
		ll stepu = 0;
		for (ll i = 0; i < H; i++)
		{
			if (s[i][j] == '.') stepd++;
			else stepd = 0;
			if (s[H - i - 1][j] == '.') stepu++;
			else stepu = 0;
			d[i][j] = stepd;
			u[H - i - 1][j] = stepu;
		}
	}
	ll ans = 0;
	for (ll i = 0; i < H; i++)
	{
		for (ll j = 0; j < W; j++)
		{
			ans = max(ans, u[i][j] + d[i][j] + l[i][j] + r[i][j] - 3);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 129664
import java.util.*;

public class Main {
  public static long gcd(long number_a, long number_b) {
    long temp_number;
    if(number_a < number_b) {
      temp_number = number_a;
      number_a = number_b;
      number_b = temp_number;
    }
    while((temp_number =number_a % number_b) != 0) {
      number_a = number_b;
      number_b = temp_number;
    }
    return number_b;
  }

  public static long lcm(long number_a, long number_b) {
    return (number_a * number_b) / gcd(number_a, number_b);
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long start, end, i, number_c, number_d, number_cd, temp_start, temp_end, count;
    long count_c = 1;
    long count_d = 1;
    long count_cd = 1;
    start = Long.parseLong(sc.next());
    end = Long.parseLong(sc.next());
    number_c = Long.parseLong(sc.next());
    number_d = Long.parseLong(sc.next());
    number_cd = lcm(number_c, number_d);
    temp_start = start / number_c;
    temp_end = end / number_c;
    if(start % number_c != 0) temp_start += 1;
    count_c += (temp_end - temp_start);

    temp_start = start / number_d;
    temp_end = end / number_d;
    if(start % number_d != 0) temp_start += 1;
    count_d += (temp_end - temp_start);

    temp_start = start / number_cd;
    temp_end = end / number_cd;
    if(start % number_cd != 0) temp_start += 1;
    count_cd += (temp_end - temp_start);
    count = (end - start + count_cd + 1) - (count_c + count_d);
    System.out.println(count);
  }
}


Measured memory_bytes: 21204
import java.util.Scanner;

// 東京海上日動プログラミングコンテスト2020
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long a = in.nextLong();
        long v = in.nextLong();
        long b = in.nextLong();
        long w = in.nextLong();
        long t = in.nextLong();
        
        long diff = Math.abs(a-b);
        boolean reachable = (v*t)-diff>=(w*t) || diff==0;
        System.out.println(reachable ? "YES" : "NO");
    }
}


Measured memory_bytes: 35768
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=3e5+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;

int n,k,q;
int a[N];
int main()
{
   	
 	
    	scanf("%d%d%d",&n,&k,&q);
   	 for(int i=0;i<q;i++){
   	 	int x;
        	scanf("%d",&x);
        	x--;
        	a[x]++;
    	}
    	for(int i=0;i<n;i++){
       	 if (a[i]+k>q)
            printf("Yes\n");
        else
            printf("No\n");
    }	
 	


}


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I1000000007 (1000000007)
#define I998244353   (998244353)
#define IINF             (1<<28)
#define LINF           (1LL<<60)
#define ALL(a)         (a).begin(), (a).end()
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  int N, K;
  vector<double> P, SUM;

  void init() {
    cin >> N >> K;
    P.resize(N);
    SUM.resize(N+1, 0);
    rep(i, N) {
      cin >> P[i];
      SUM[i+1] = SUM[i] + (P[i] + 1.0) / 2.0;
    }
  }

  void solve() {
    double ans = 0.0;
    rep(i, N-K+1) chmax(ans, SUM[i+K]-SUM[i]);
    cout << fixed << setprecision(12) << ans << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main() {
	ll n, q, ans = 0;
	cin >> n;
	ll a[100001] = {};
	rep(i,n) {
		int x;
		cin >> x;
		ans += x;
		a[x]++;
	}
	cin >> q;
	vector<ll> b(q), c(q);
	rep(i,q) cin >> b[i] >> c[i];
	rep(i,q) {
		a[c[i]] += a[b[i]];
		ans += (c[i] - b[i]) * a[b[i]];
		a[b[i]] = 0;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
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 (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    LL Y;cin >> Y;
    int a = -1;
    int b = -1;
    int c = -1;
    LL ans;
    bool ok = false;
    if(1000*N == Y){
        a = 0;
        b = 0;
        c = N;
    }
    else if(5000*N == Y){
        a = 0;
        b = N;
        c = 0;
    }
    else if(10000*N == Y){
        a = N;
        b = 0;
        c = 0;
    }
    else if(1000*N < Y){
        rep(i,N) {
            rep(j,N-i){
                ans = 10000*i + 5000*j + 1000*(N-i-j);
                if(ans == Y){
                    ok = true;
                    a = i;
                    b = j;
                    c = (N-i-j);
                    break;
                }
            }
            if(ok)break;
        }
    }

    cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int ans[500][500];
void separate(int s, int g, int r){
    if(g-s<=1){
        return;
    }
    int mid=(s+g)/2;
    for(int i=s; i<mid; i++){
        for(int j=mid; j<g; j++){
            //cout << i << ' ' << j << ' ' << r << endl;
            ans[i][j]=r;
        }
    }
    separate(s, mid, r+1);
    separate(mid, g, r+1);
}

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

    separate(0,N,1);

    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            cout << ans[i][j];
            if(j<N-1){
                cout << ' ';
            }
        }
        cout << '\n';
    }
}

Measured memory_bytes: 4512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

using namespace std;
using ll = long long;

int main(){
    string s;
    cin>>s;
    bool ok=true;
    if(s.length() %2 == 0){
        for(int i=0;i<s.length()-1;i+=2){
            if(!(s[i]=='h' && s[i+1] == 'i')) ok=false;
        }
    }
    else ok=false;
    
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
N, M=map(int, input().split())
lst=[None]*M
for i in range(M):
    lst[i]=tuple(map(int, input().split()))

#print(N, M, lst)
digit=[]
for _ in range(N):
    digit.append([])

for val in lst:
    digit[val[0]-1].append(val[1])
#print(digit)

num=0

if N==3 and 0 in digit[0]:
    print(-1)
elif N==2 and 0 in digit[0]:
    print(-1)
else:
    for i in range(N):
        if len(set(digit[i]))>=2:
            print(-1)
            break
        elif digit[i]:
            num+=digit[i][0]*10**(N-i-1)
        else:
            if i==0 and N>=2:
                num += 1 * 10 ** (N - i - 1)
    else:
        print(num)



Measured memory_bytes: 3064
package main

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

const mod = 1000000007

func solve() {
	n := getInt()
	m := make(map[int]int)
	for num := 1; num <= n; num++ {
		numm := factorize(num)
		for k, v := range numm {
			m[k] += v
		}
	}

	ans := 1
	for k, v := range m {
		if k == 1 {
			continue
		}

		x := (v + 1) % mod
		ans = (ans * x) % mod
	}

	fmt.Fprintln(wr, ans)
}

func factorize(n int) map[int]int {
	m := make(map[int]int)
	for n%2 == 0 {
		n /= 2
		m[2]++
	}

	for i := 3; i*i <= n; i += 2 {
		if n%i != 0 {
			continue
		}
		for n%i == 0 {
			n /= i
			m[i]++
		}
	}

	if n != 1 {
		m[n]++
	}
	return m
}

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 896
N = int(input())

L = [0 for i in range(N+1)]

if N == 1:
  print(1)

else:
  L[0] = 2
  L[1] = 1

  for n in range(2,N+1):
    L[n] = L[n-1] + L[n-2]
    
  print(L[N])

Measured memory_bytes: 9020
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	int x, y;

	cin >> x >> y;

	if (x==1 || x== 3 || x==5 || x==7 || x==8 || x==10 || x==12) {
		if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else if(x==4 || x==6||x==9||x==11){
		if (y == 4 || y == 6 || y == 9 || y == 11) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		if (x==2 && y==2) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

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

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        for(int i=0;i<s.length();i++){
        	if(s.charAt(i)=='1'){
        		System.out.print(9);
        	}
        	else{
        		System.out.print(1);
        	}
        }
        System.out.println();
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<int> vec;
    rep (i, 0, N) {
        int in; cin >> in;
        vec.push_back(in);
    }
    int max_val = *max_element(vec.begin(), vec.end());
    vector<int>::iterator iter = find(vec.begin(), vec.end(), max_val);
    size_t index = distance(vec.begin(), iter);
    vec.erase(vec.begin() + index);
    int sum = std::accumulate(vec.begin(), vec.end(), 0) + (max_val / 2);
    cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[]args){  
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int max=0;
    for(int i=0;i*i<=n;i++){
        max=i*i;
    }
    System.out.println(max);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N;
    string S[214514];
    cin >> N;
    REP(i,N){
        cin >> S[i];
    }
    sort(S,S+N);
    map<string,int> M;
    REP(i,N){
        M[S[i]]++;
    }
    int mx=0;
    REP(i,N){
        mx=max(mx,M[S[i]]);
    }
    REP(i,N){
        if(M[S[i]]==mx){
            M[S[i]]=0;
            cout << S[i] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 26880
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

ll N;
vector<ll> A;

void input() {
    cin >> N;
    A.resize(N);
    for (auto& v : A)
        cin >> v;
//    N = 5;
//    A = {3, 11, 14, 5, 13};
}

ll solve() {
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    unordered_map<ll, int> fmap;
    for (ll i = 0; i < N; i++) {
        fmap[A[i]]++;
    }
    
    ll ans = 0;
    for (auto a : A) {
        if (fmap[a] <= 0)
            continue;
        ll to = 1;
        while (to <= a)
            to <<= 1;
        auto pair = to - a;
        if (fmap.find(pair) != fmap.end() &&
            fmap[pair] >= (pair == a ? 2 : 1)) {
            ans++;
            fmap[a]--;
            fmap[pair]--;
        }
    }
    
    return ans;
}


int main() {
    input();
    cout << solve() << endl;;
    
    return 0;
}



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

int cnt[4];

int main(){
	int n; cin >> n;
	while( n-- ){
		string s; cin >> s;
		if( s == "AC" ) ++cnt[0];
		if( s == "WA" ) ++cnt[1];
		if( s == "TLE" ) ++cnt[2];
		if( s == "RE" ) ++cnt[3];
	}
	cout << "AC x " << cnt[0] << endl;
	cout << "WA x " << cnt[1] << endl;
	cout << "TLE x " << cnt[2] << endl;
	cout << "RE x " << cnt[3] << endl;
}

Measured memory_bytes: 3628
from bisect import bisect_left as bisect
from collections import defaultdict


s, t = input(), input()
lens, sets = len(s), set(s)

if not all(i in sets for i in t):
    print(-1)
    exit()

alp = defaultdict(list)
for i, si in enumerate(s):
    alp[si].append(i)

ans, cnt = 1 - lens, 0
for i in t:
    ans += lens * (cnt == 0)
    num = bisect(alp[i], cnt)
    ans += lens * (num == len(alp[i]))
    cnt = (alp[i][num % len(alp[i])] + 1) % lens 
print(ans + (cnt - 1) % lens)


Measured memory_bytes: 13724
using System;
using System.Linq;

class P
{
  static void Main()
  {
    var S = int.Parse(Console.ReadLine());
    var h = S / 3600;
    var m = S / 60 - h * 60;
    var s = S - h * 3600 - m * 60;
    Console.WriteLine("{0}:{1}:{2}", h, m, s);
  }
}

Measured memory_bytes: 9240
h, w = map(int, input().split())
ch, cw = map(lambda x: int(x)-1, input().split())
dh, dw = map(lambda x: int(x)-1, input().split())
S = [list(input()) for _ in range(h)]

from collections import deque
# 座標, 座標, ワープカウント
q = deque([[ch, cw, 0]])
wall = deque()
visited = [[-1] * w for _ in range(h)]
visited[ch][cw] = 0
ans = -2
while True:
    # つながっているエリアを探索
    while q:
        i, j, wc = q.popleft()
        if i == dh and j == dw:
            ans = wc
            break
        next_to_wall = False
        for mi, mj in ((-1, 0), (1, 0), (0, -1), (0, 1)):
            ni, nj = i + mi, j + mj

            if 0 <= nj < w and 0 <= ni < h:
                if S[ni][nj] == '.' and visited[ni][nj] != wc:
                    visited[ni][nj] = wc
                    q.append([ni, nj, wc])
                elif S[ni][nj] == '#':
                    next_to_wall = True
        if next_to_wall:
            wall.append([i, j, wc])
    else:
        # 飛ぶ場所がなかったら終了
        if not wall:
            ans = -1
    if ans > -2:
        break

    while wall:
        i, j, wc = wall.popleft()
        for wi, wj in ((-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2),
                        (-1, -2), (-1, -1), (-1, 1), (-1, 2),
                        (0, -2), (0, 2),
                        (1, -2), (1, -1), (1, 1), (1, 2),
                        (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)):
            ni, nj = i+wi, j+wj
            if (0 <= nj < w and 0 <= ni < h and S[ni][nj] == '.' and
                (visited[ni][nj] == -1 or visited[ni][nj] > wc+1)):
                visited[ni][nj] = wc+1
                q.append([ni, nj, wc+1])
print(ans)


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

typedef long long ll;

int main () {
	ll K;
	cin >> K;
	if (K%2==0 || K%5==0) {
		cout << -1 << endl;
		return 0;
	}

	if (K%7==0)
		K /= 7;

	ll L = 9*K;
	ll ans = 1, tmp = 10;
	while (tmp%L!=1) {
		tmp *= 10;
		tmp %= L;
		ans ++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    short N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N-1);
    for(int i=0;i<N-1;i++){
        cin >> B[i];
    }
    int sum = B[0] + B[N-2];

    //A[0] = B[0];
    
    for(int i=1; i<N-1; i++){
        sum += min(B[i-1], B[i]);
        //A[i] = min(B[i-1], B[i]);
    }

    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string s;
const int Kmax=1e7;
int sum[Kmax];
int R[Kmax];
 
int main()
{
    int n;
    cin>>n;
    cin>>s;
    int Max=0;
        for(int j=1;j<n;j++){
         sum[j]=sum[j-1];
         if(s[j-1]=='E'){
            sum[j]++;
			//printf("%d:%d\n",j,sum[j]);
         }
         }
        for(int k=n;k>0;k--){
        R[k-1]=R[k];
        if(s[k]=='W'){
        R[k-1]++;
        }
         sum[k-1]=sum[k-1]+R[k-1];
		// printf("%d:%d\n",k-1,sum[k-1]);
         
         Max=max(Max,sum[k-1]);
        }
        cout<<n-1-Max<<endl;
    return 0;
}

Measured memory_bytes: 3844
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<set>
#include<ctime>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
inline void write(int a){
	if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(int a){
	write(a); puts("");
}
inline int	read()//不管是正负数，都可以 
{
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
const int N=200005;
int nedge,flag,cd[N],n,m,nextt[N],son[N],ed[N];
inline void dfs(int p,int fa){
	if(flag)return; int sum=0;
	for(int i=son[p];i;i=nextt[i])if(ed[i]!=fa)dfs(ed[i],p);
	for(int i=son[p];i;i=nextt[i])if(ed[i]!=fa){
		if(!cd[ed[i]])sum++;
	}
	if(sum>1){
		flag=true; return;
	}
	cd[p]=sum;
}
inline void aedge(int a,int b){
	nextt[++nedge]=son[a]; cd[a]++;
	son[a]=nedge;
	ed[nedge]=b;
}
int main(){
	n=read();
	for(int i=1;i<n;i++){
		int s1=read(),s2=read();
		aedge(s1,s2); aedge(s2,s1);
	}
	dfs(1,0);
	if(flag||cd[1]==0)puts("First"); else puts("Second");
}



Measured memory_bytes: 2560
def sieve(n):
	p=[True]*n
	p[0]=p[1]=False
	for i in range(2,int(n**0.5)+1):
		if p[i]:
			for j in range(i*i,n,i):
				p[j]=False
	prime =[i for i in range(2,n) if p[i]]
	return prime


def function(n):
	return sum(A[:n])

A=sieve(110000)
while True:
	n=int(input())
	if n==0:
		break
	print(function(n))

	

Measured memory_bytes: 8568
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << setprecision(16);
    int x,y; cin >> x >> y;
    vector<string> a(x),b(y);
    rep(i,x) cin >> a[i];
    rep(i,y) cin >> b[i];
    rep(i,x-y+1) rep(j,x-y+1){
        bool check = true;
        rep(k,y) rep(l,y) if(a[i+k][j+l] != b[k][l]) check = false;
        if(check){
            yes();
            return 0;
        }
    }
    no();
    return 0;
}

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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ','){cerr << *sdbg++;}cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

const int N = 5E3 + 10;
const ll MOD = 1E9 + 7;

int n;
vector<int> E[N];
int sz[N];
ll f[N][N][2], g[N][2];
ll comp[N];

void DFS(int u, int pre){
	sz[u] = 1;
	f[u][0][0] = 0, f[u][0][1] = 0;
	f[u][1][0] = 1, f[u][1][1] = 0;
	for (auto &v: E[u]){
		if (v == pre)
			continue;
		DFS(v, u);

		fill_n(g[0], (sz[u] + sz[v] + 1) * 2, 0);
		for (int i = 0; i <= sz[u]; ++i)
			for (int j = 0; j <= sz[v]; ++j){
				g[i + j][0] = (g[i + j][0] + f[u][i][0] * f[v][j][0] + f[u][i][1] * f[v][j][1]) % MOD;
				g[i + j][1] = (g[i + j][1] + f[u][i][0] * f[v][j][1] + f[u][i][1] * f[v][j][0]) % MOD;
			}
		sz[u] += sz[v];
		eput(vector<ll>(g[0], g[0] + (sz[u] + 1) * 2));
		copy_n(g[0], (sz[u] + 1) * 2, f[u][0]);
	}
	for (int i = 2; i <= sz[u]; i += 2){
		f[u][0][0] = (f[u][0][0] + f[u][i][1] * comp[i]) % MOD;
		f[u][0][1] = (f[u][0][1] + f[u][i][0] * comp[i]) % MOD;
	}

	eput(vector<ll>(f[u][0], f[u][0] + (sz[u] + 1) * 2));
}

int main(){
	scanf("%d", &n);
	for (int i = 1; i < n; ++i){
		int u, v;
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	comp[0] = 1;
	for (int i = 2; i <= n; i += 2)
		comp[i] = comp[i - 2] * (i - 1) % MOD;
	DFS(1, 0);
	printf("%lld\n", (f[1][0][1] - f[1][0][0] + MOD) % MOD);
	return 0;
}


Measured memory_bytes: 391296
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
struct edge {
    int to, cost;
};

int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

auto factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////
signed main() {
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  vector<int>mae(0),usiro(0);
  rep(i,n){
    if(i%2!=n%2){
      //mae
      mae.push_back(a[i]);
    }
    else{
      //usiro
      usiro.push_back(a[i]);
    }
  }
  rep(i,mae.size()) cout<<mae[mae.size()-1-i]<<' ';
  rep(i,usiro.size()) cout<<usiro[i]<<' ';
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a == b && b == c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
using i64 = int64_t;
using P = pair<i64,i64>;

int main(){
    int W,H;
    while(cin >> W >> H, W != 0){
        vector<vector<char>> island(H,vector<char>(W));
        vector<vector<int>> terr(H,vector<int>(W,0));

        stack<P> bPile, wPile;
        rep(h, H) rep(w ,W){
            cin >> island[h][w];
            if(island[h][w] == 'B'){
                terr[h][w] = -2;
                bPile.push({h,w});
            } else if (island[h][w] == 'W') {
                terr[h][w] = 2;
                wPile.push({h,w});
            }
        } 

        auto f = [&](stack<P>& pile, int c){
            vector<vector<bool>> visited(H,vector<bool>(W,false));

            int d[4] = {1, -1, 0, 0};
            while(!pile.empty()){
                P p = pile.top();
                pile.pop();

                int h = p.first;
                int w = p.second;
                rep(i,4){
                    int nh = h + d[i];
                    int nw = w + d[i^2];
                    if(nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
                    if(visited[nh][nw] == true) continue;
                    if(terr[nh][nw] == 2 || terr[nh][nw] == -2) continue;

                    terr[nh][nw] += c;
                    visited[nh][nw] =true;
                    pile.push({nh,nw});
                }
            }
        };

        f(bPile, -1);
        f(wPile, 1);

        int black = 0;
        int white = 0;
        rep(h,H){
            rep(w,W){
                if(terr[h][w] == 1) white++;
                if(terr[h][w] == -1) black++;
            }
        }

        cout << black << " " << white << endl;
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n,m;cin>>n>>m;
    out("Yes");
    vvi g(n);
    rep(i,m){
        ll a,b;cin>>a>>b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    vi dis(n,inf);
    dis[0]=0;
    queue<ll> q;
    q.push(0);
    while(!q.empty()){
        auto t=q.front();q.pop();
        for(ll x:g[t])if(chmin(dis[x],dis[t]+1))q.push(x);
    }
    REP(i,1,n){
        for(ll x:g[i])if(dis[x]<dis[i]){
            out(x+1);
            break;
        }
    }
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[100000];
bool p[100000];

int main() {
	cin >> n;
	rep(i,n) {
		cin >> a[i];
		a[i]--;
	}
	
	int m = 0;
	int t = 0;
	while (true) {
		t++;
		if (p[m]) {
			cout << -1 << ln;
			break;
		}
		p[m] = true;
		m = a[m];
		if (m==1) {
			cout << t << ln;
			break;
		}
	}
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define mem(s,t) memset(s,t,sizeof(s))
#define pb(s) push_back(s)
#define inf 0x3f3f3f3f
#define mn 100010
typedef long long ll;
using namespace std;
int d[26];
int a[100];
int main()
{
	int n;scanf("%d",&n);++d[0];
	for(int i=0;i<n;++i){
		int t;
		scanf("%d",&t);
		++d[t];
		a[i]=t;
	}
	sort(a,a+n);
	for(int i=0;i<12;++i){
		if(d[i]>2||d[12]>1){
			printf("0");
			return 0;
		}
	}
	int ans=0;
	for(int bi=0;bi<(1<<n);++bi){
		mem(d,0);
		for(int i=0;i<n;++i){
			if((1<<i)&bi)++d[24-a[i]];
			else ++d[a[i]];
		}
		int dis=24,pre=0;
		for(int i=0;i<=24;++i){
			if(d[i]>1){dis=0;break;}
			else if(d[i]){dis=min(dis,i-pre);pre=i;}
		}
		dis=min(dis,24-pre);
		ans=max(ans,dis);
	}
	printf("%d",ans);

    return 0;
}


Measured memory_bytes: 256
def solve(n, k, q, a)
  return if k == 0
  (t = [q, a].min).downto(t/k) do |x|
    if n - x * x == 0 then @ans += 1
    else solve(n - x * x, k - 1, Math.sqrt(n - x * x).to_i, x)
    end
  end
end

while n = gets.to_i
  break if n == 0
  @ans = 0
  solve(n, 4, Math.sqrt(n).to_i, n)
  puts @ans
end

Measured memory_bytes: 8768
#!/usr/bin/env python3
N = int(input())
s = sorted([int(input()) for i in range(N)])

ans = sum(s)

if ans % 10 == 0:
    for i in s:
        if i % 10 == 0:
            pass
        else:
            ans -= i
            if ans % 10 != 0:
                break

if ans % 10 == 0 and ans == sum(s):
    print(0)
else:
    print(ans)


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

using i64 = long long int;

int main(){
    string s;
    priority_queue<int> que;
    while(cin >> s, s != "end"){
        if(s == "insert"){
            int k;
            cin >> k;
            que.push(k);
        }else{
            cout << que.top() << endl;
            que.pop();
        }
    }

    return 0;
}



Measured memory_bytes: 7108