akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val)
	{
		fill((T *)array, (T *)(array + N), val);
	}

	const ll INF = 1e18;
	const ll mod = 1e9 + 7;

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

	int main(){
		IOS;
		int n,m;
		cin >> n >> m;
		vec<vec<ll>> a(n + 1,vec<ll>(n + 1,mod));
		vec<vec<ll>> path(n + 1,vec<ll>(n + 1,mod));
		vec<vec<bool>> used(n + 1,vec<bool>(n + 1,false));
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= n;j++)path[i][j] = j;
			a[i][i] = 0;
		}
		REP(i,m){
			int x, y, c;
			cin >> x >> y >> c;
			a[x][y] = a[y][x] = c;
		}
		for(int k = 1;k <= n;k++){
			for(int i = 1;i <= n;i++){
				for(int j = 1;j <= n;j++){					
					if(a[i][k] + a[k][j] < a[i][j]){
						path[i][j] = path[i][k];
						a[i][j] = a[i][k] + a[k][j];
					}
				}
			}
		}
		
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= n;j++){
				int from = i;
				int next = path[i][j];
				while(from != j){
					used[from][next] = true;
					from = next;
					next = path[next][j];
				}
			}
		}
		ll cnt = 0;
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= n;j++){
				if(used[i][j])cnt++;
			}
		}
		dump(m - (cnt / 2));
	}

Measured memory_bytes: 384
import java.util.*;

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

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int h = sc.nextInt();

        if (n%h==0){
            System.out.println(n/h);
        }else {
            System.out.println(n/h+1);
        }
    }
}






Measured memory_bytes: 23636
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

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

   int cnt=0;
   cnt = k/2 * ((k+1)/2);

   cout << cnt << endl;



   return 0;
}

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


using namespace std;
int main(){
    int N,X;
    int donut = 0;
    cin >> N >> X;
    int tmp;
    vector<int> m;
    for(int i=0;i < N;i++){
        cin >> tmp;
        m.push_back(tmp);
    }
    sort(m.begin(),m.end());
    for(int j=0;j < m.size();j++){
        if(X - m[j] >= 0){
            X -= m[j];
            donut++;
        }else{
            cout << donut << endl;
            return 0;
        }
    }

    for(int k=0;k < m.size();k++){
       int tmp2 = X / m[k];
       donut += tmp2;
       X = X - tmp2 * m[k];
    }
    cout << donut << endl;

}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

ok = 1
sum_A = sum(A)
M, mod = divmod(sum_A, (N * (N + 1)) // 2)
if mod != 0:
    ok = 0

diff = [0] * N
for i in range(N):
    diff[i] = A[i] - A[i - 1]
count = 0
for i in range(N):
    x, mod = divmod(diff[i] - (1 - N) * M, N)
    count += (M - x)
    if mod != 0 or x < 0 or x > M:
        ok = 0
if count != M:
    ok = 0

if ok:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 62704
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int h,w,k,total=0;
	cin>>h>>w>>k;
	vector<vector<int>> arr(h,vi(w,0));
	vi rows(h,0),cols(w,0);
	for(int i=0;i<h;i++) {
		for(int j=0;j<w;j++) {
			char c;
			cin>>c;
			if(c=='#')arr[i][j]++,total++,cols[j]++,rows[i]++;
		}
	}
	int ans = 0;
	//set<set<pair<int,int>>> crs;
	vi all(h+w);
	for(int i=0;i<h+w;i++)all[i]=i;
	//int icnt=0;
	for(int i=0;i<1<<(h+w);i++) {
		//icnt++;
		vi r,c;
		for(int j=0;j<h+w;j++) {
			if((i>>j)&1) {
				if(j<h)r.PUB(j);//,cerr<<j;
				else c.PUB(j-h);//,cerr<<j-h;
			}
		}
		//set<pair<int,int>> icrs;
		int del = 0;
		// if(r.size()>0&&c.size()>0){
			for(int ri:r) {
				for(int ci:c) {
					del-=arr[ri][ci];
					//icrs.insert({ri,ci});
				}
			}
		// } else if(r.size()>0) {
			for(int ri:r){del+=rows[ri];}//icrs.insert({ri,-1});}
		// } else if(c.size()>0)
			for(int ci:c)del+=cols[ci];//,icrs.insert({-1,ci});
		if(total-del==k){
			ans++;
		}
		//crs.insert(icrs);
	}
	cout<<ans;
	//cerr<<crs.size();
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
	ll x;
	cin>>x;
	return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 
 
vector <vector <int> > g;
vector <int> val;
vector <int> a;
 int dfs(vector <bool> &visited,int s);
 vector <int> test;
  vector <int> ans;
  void rerooting(int s,vector <bool> &visited);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll r=nxtl(),c=nxtl();
    if(r==1||c==1)
    {
        cout<<"1\n";
        return 0;
    }
    cout<<((r*(c-1))/2)+(r+1)/2<<endl;

    return 0;   
}


 
 


Measured memory_bytes: 256
N,M=map(int,input().split())
H=list(map(int,input().split()))
L=[0]*N
for i in range(M):
    A,B=map(int,input().split())
    L[A-1]=max(L[A-1],H[B-1])
    L[B-1]=max(L[B-1],H[A-1])
ans=0
for j in range(N):
    if H[j]>L[j]:
        ans+=1
print(ans)

        



    









        

    









    

        




    















    



    





    






        






    
















        


























            
    


    


    
    














    


    














Measured memory_bytes: 19740
S = list(input())

lenS = len(S)
ans = 0

for i in range(1, lenS+1):
    for j in range(lenS-i+1):
        tmp = S[j:j+i]
        if set(tmp).issubset(['A', 'C', 'G', 'T']):
            #print(tmp)
            ans = max(len(tmp), ans)

print(ans)


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

#define M_PI 3.14159265358979323846

using namespace std;

//typedef
//-------------------------#include <bits/stdc++.h>

#define M_PI 3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}
inline int readInt()
{
    int x;
    scanf("%d", &x);
    return x;
}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const int INF = 2147483647;

const int dxy[5] = {-1, 0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    int H, W;
    cin >> H >> W;

    vector<string> v;
    for (int i = 0; i < H; i++)
    {
        string s;
        cin >> s;
        v.push_back(s);
    }

    queue<pair<int, int>> q;
    vector<vector<int>> dist(H, vector<int>(W, -1));

    dist[0][0] = 0;
    q.push(make_pair(0, 0));

    while (q.size())
    {
        pair<int, int> p = q.front();
        q.pop();

        int y = p.first, x = p.second;

        for (int i = 0; i < 4; i++)
        {
            int ny = y + dxy[i], nx = x + dxy[i + 1];
            if (ny >= 0 && ny < H && nx >= 0 && nx < W && dist[ny][nx] == -1 && v[ny][nx] == '.')
            {
                dist[ny][nx] = dist[y][x] + 1;
                q.push({ny, nx});
            }
        }
    }

    if (dist[H - 1][W - 1] == -1)
    {
        cout << -1 << endl;
    }
    else
    {
        int cnt = 0;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (v[i][j] == '.')
                    cnt++;
            }
        }
        cout << cnt - dist[H - 1][W - 1] - 1 << endl;
    }

    return 0;
}


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

int main()
{
	int k, a, b;
	cin >> k >> a >> b;
	for (int i = a; i <= b; ++i)
	{
		if (i % k == 0)
		{
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3568
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  while(1){
      int n;
      cin>>n;
      if(n==0)return 0;
      V<V<ll>> a(n,V<ll>(5));
      for(int i=0;i<n;i++)for(int j=0;j<5;j++)cin>>a[i][j];
      ll ans=0;
      while(1){
          bool make=false;
          for(int i=0;i<n;i++){
              ll bfo=a[i][0],cnt=1,ind=0;
              for(int j=1;j<5;j++){
                  if(bfo!=-1&&j!=4&&bfo==a[i][j])cnt++;
                  else{
                      if(bfo!=-1&&bfo==a[i][j])cnt++;
                      if(bfo!=-1&&cnt>=3){
                          make=true;
                        ans+=bfo*cnt;
                        for(int k=ind;k<ind+cnt;k++)a[i][k]=-1;
                      }
                      cnt=1;bfo=a[i][j];
                      ind=j;
                  }
              }
          }
          if(!make)break;
          for(int i=n-1;i>=1;i--){
              for(int j=0;j<5;j++)if(a[i][j]==-1){
                  for(int k=i;k>=0;k--)if(a[k][j]!=-1){
                      swap(a[k][j],a[i][j]);
                      break;
                  }
              }
          }
      }
     cout<<ans<<"\n";
  }
}


Measured memory_bytes: 3152
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(i, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int main() { 
    string S = In<string>();
    string T = In<string>();
    int ans = 0;
    for(int i = 0; i < 3; i++){
        if(S[i] == T[i])
            ans++;
    }
    cout << ans << endl;
}

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

#define nl '\n'

using namespace std;

typedef long long ll;

void solve() {
  int sum = 15;
  for (int i = 0; i < 5; ++i) {
    int inp;
    cin >> inp;
    sum -= inp;
  }
  cout << sum;
}

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

  // int t;
  // cin >> t;
  // while (t--) {
  solve();
  // }

  return 0;
}

Measured memory_bytes: 3656
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

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

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

int main() {
    ll N;
    cin >> N;
    vl T(N);
    rep(i, N){
        cin >> T[i];
    }

    ll a;
    ll tmp;
    if(N == 1){
        cout << T[0] << endl;
        return 0;
    }

    rep(i, N-1){
        if(i == 0){
            a = lcm(T[i], T[i+1]);
        }else{
            a = lcm(tmp, T[i+1]);
        }
        tmp = a;
    }
    cout << a << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp108 {
    class Program {
        static void Main(string[] args) {
            long n = long.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var V = new long[n];
            V[0] = a[0];
            for (int i = 1; i < n; i++) {
                V[i] = V[i - 1] + a[i];
            }

            //パターンA
            //[偶数]までの和が正で、[奇数]までの和が負のパターン
            long cost_A = 0;
            bool open_A = true;
            long nowsum_A = 0;
            for (int i = 0; i < n; i++) {
                if (open_A) {
                    if (i % 2 == 0) {
                        if (V[i] <= 0) {
                            open_A = false;
                        }
                    } else {
                        if (V[i] >= 0) {
                            open_A = false;
                        }
                    }
                    if (i >= 1) {
                        nowsum_A = V[i - 1];
                    }
                } 
                
                if (!open_A) {
                    nowsum_A += a[i];
                    if (i % 2 == 0) {
                        if (nowsum_A <= 0) {
                            cost_A += Math.Abs(nowsum_A - 1);
                            nowsum_A = 1;
                        }
                    } else {
                        if (nowsum_A >= 0) {
                            cost_A += Math.Abs(nowsum_A - (-1));
                            nowsum_A = -1;
                        }
                    }
                }
            }


            //パターンB
            //[偶数]までの和が負で、[奇数]までの和が正のパターン
            long cost_B = 0;
            bool open_B = true;
            long nowsum_B = 0;
            for (int i = 0; i < n; i++) {
                if (open_B) {
                    if (i % 2 == 1) {
                        if (V[i] <= 0) {
                            open_B = false;
                        }
                    } else {
                        if (V[i] >= 0) {
                            open_B = false;
                        }
                    }
                    if (i >= 1) {
                        nowsum_B = V[i - 1];
                    }
                }

                if (!open_B) {
                    nowsum_B += a[i];
                    if (i % 2 == 1) {
                        if (nowsum_B <= 0) {
                            cost_B += Math.Abs(nowsum_B - 1);
                            nowsum_B = 1;
                        }
                    } else {
                        if (nowsum_B >= 0) {
                            cost_B += Math.Abs(nowsum_B - (-1));
                            nowsum_B = -1;
                        }
                    }
                }
            }


            Console.WriteLine(Math.Min(cost_A, cost_B));

        }
    }
}


Measured memory_bytes: 29788
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <ctime>
using namespace std;
typedef long long ll;
const int N=1e5+5;
const int INF=1e9-5;

main()
{
    string s;
    cin>>s;
    int ans=0,cnt=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='1')
            ans++;
        else
            cnt++;
    }
    if(ans==cnt)
        cout<<s.size()<<endl;
    else
        cout<<s.size()-abs(ans-cnt)<<endl;
}

Measured memory_bytes: 512
N = int(input())
A, B, C = map(list, ([input(), input(), input()]))
cnt = 0
for i in range(N):
  a = 0
  if A[i] == B[i]:
    a += 1
  if B[i] == C[i]:
    a += 1
  if C[i] == A[i]:
    a += 1
  if a == 0:
    cnt += 2
  elif a == 1:
    cnt += 1

print(cnt)

Measured memory_bytes: 3064
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    cout << n / 3 << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    int[] buka = new int[N+1];
	    int a = 0;
	    for(int i = 2; i <= N; i++) {
	        a = sc.nextInt();
	        buka[a] += 1;
	    }
	    
	    for(int i = 1; i <= N; i++) {
	        System.out.println(buka[i]);
	    }
	}
}

Measured memory_bytes: 61664
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
    deque<int> dq;
    int n,a;
    cin>>n;
    rep(i,0,n){
        cin>>a;
        if(i%2==1){
            dq.push_back(a);
        }else{
            dq.push_front(a);
        }
    }
    if(n%2==0){
        reverse(dq.begin(),dq.end());
    }
    rep(i,0,n){
        if(i)cout<<" ";
        cout<<dq[i];
    }
    cout<<endl;
}

Measured memory_bytes: 2944
from collections import deque


def main():
    h, w = map(int, input().split())
    graph = [list(input()) for _ in range(h)]
    ans = 0

    dist = [[-1 for _ in range(w)] for _ in range(h)]

    black = deque()
    for r in range(h):
        for c in range(w):
            if graph[r][c] == "#":
                black.append((r, c))
                dist[r][c] = 0

    while black:
        r, c = black.popleft()
        ans = max(ans, dist[r][c])
        for dr, dc in ((-1, 0), (1, 0), (0, -1), (0, 1)):
            nr = r + dr
            nc = c + dc
            if not (0 <= nr < h and 0 <= nc < w):
                continue
            if dist[nr][nc] == -1:
                dist[nr][nc] = dist[r][c] + 1
                black.append((nr, nc))

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 149596
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, C;
std::vector<std::pair<LL, std::pair<LL, LL>>>qs(112345);
std::set<std::pair<LL, LL>>ends;

int main()
{
	in >> N >> C;
	rep(i, N) { in >> qs[i].first >> qs[i].second.first >> qs[i].second.second; }

	std::sort(qs.begin(), qs.begin() + N);
	rep(i, N)
	{
		int seek = 0;
		LL begin = qs[i].first, end = qs[i].second.first, chn = qs[i].second.second;
		bool flag = true;
		for (auto& j : ends)
		{
			if ((j.second == chn && j.first == begin)
				|| (j.first < begin))
			{
				ends.erase(j);
				ends.insert(std::make_pair(end, chn));
				flag = false;
				break;
			}
			++seek;
		}
		if (flag) { ends.insert(std::make_pair(end, chn)); }
	}

	out << ends.size() << std::endl;
	return 0;
}

Measured memory_bytes: 2944
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner; 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		ArrayList<HashSet<Integer>> adj = new ArrayList<HashSet<Integer>> ();
		for(int i=0; i<n; i++)adj.add(new HashSet<Integer>());
		
		for(int i=0; i<m; i++) {
			int x = sc.nextInt() - 1 , y = sc.nextInt() - 1;
			adj.get(x).add(y);
		}
		
		for(int x : adj.get(0)) {
			if(adj.get(x).contains(n-1)) {
				System.out.println("POSSIBLE");
				return;
			}
		}
		System.out.println("IMPOSSIBLE");
	}
}


Measured memory_bytes: 152240
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if (s[0] == s[1] and s[1] != s[2] and s[2] == s[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 256
let inputString;

process.stdin.on('data', (input) => {
  inputString += input;
});

process.stdin.on('end', () => {
  const inputArr = inputString.split('\n');
  insertionSort(inputArr[1].split(' ').map((str) => Number(str)));
});

const insertionSort = (nums) => {
  console.log(nums.join(' '));
  for(let i=1; i<nums.length; i++) {
    const v = nums[i]
    let j = i - 1;
    while (j >= 0 && nums[j] > v) {
      nums[j+1] = nums[j];
      j--;
    }
    nums[j+1] = v;
    console.log(nums.join(' '));
  }
};


Measured memory_bytes: 19392
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  uint32_t A, B, C, K = 0;
  std::cin >> A >> B >> C >> K;

  uint32_t k = 0;
  while(A >= B){
    B *= 2;
    k++;
  }
  while(B >= C){
    C *= 2;
    k++;
  }

  std::cout << (k <= K ? "Yes" : "No") << std::endl;

  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define m 1000000007
int main() {
	int n , k;
	int ans = 0;
	cin >> n >> k;
	int a[n+1];
	for(int i = 0 ; i <= n ; i++)a[i] = i;
	long long int pre[n+1], suf[n+1];
	memset(pre,0,sizeof(pre));
	memset(suf,0,sizeof(suf));
	for(int i = 0 ; i <= n; i++){
		if(i == 0)pre[i] = a[i];
		else pre[i] = pre[i-1]+a[i];
	}
	for(int i = n ; i>= 0;i--){
		if( i == n )suf[i] = a[i];
		else suf[i] = suf[i+1]+a[i];
	}
	int l = k-1;
	int r = n-k+1;
	while(l <= n && r >= 0){
		ans = (ans + (suf[r]-pre[l]+1))%m;
		l++;
		r--;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 7472
// ※※※ 解答不能 ※※※
// semiexp氏.
// https://atcoder.jp/contests/dwacon6th-prelims/submissions/9424749
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL MOD = 1e9 + 7;
#define ADD(X, Y) ((X) = ((X) + (Y) % MOD) % MOD)

int N, X, L[110];
LL dp[2][550][550]; // *, num segments, total length
int cnt[550];

LL invs[101010];
LL fact[101010], facti[101010], sums[101010];
LL C[1010][1010];

LL modpow(LL x, int p = MOD - 2){
    if(p == 0) return 1;
    LL tmp = modpow(x, p / 2);
    tmp = tmp * tmp % MOD;
    if(p % 2 == 1) tmp = tmp * x % MOD;
    return tmp;
}

LL comb(int x, int y){
    if(0 <= y && y <= x) return C[x][y];
    return 0;
}

LL waf(int x, int y){
    // x holes, y items
    return comb(x + y - 1, y);
}

int main(){
    scanf("%d %d", &N, &X);
    rep(i, N) scanf("%d", L + i);
    rep(i, N) ++cnt[L[i]];
    C[0][0] = 1;
    repx(i, 1, 1001){
        C[i][0] = 1;
        repx(j, 1, 1001) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
    }
    
    repx(i, 1, 1001) invs[i] = modpow(i);
    fact[0] = facti[0] = 1;
    repx(i, 1, 1001){
        fact[i] = fact[i - 1] * i % MOD;
        facti[i] = facti[i - 1] * invs[i] % MOD;
    }
    int t = 0;
    rep(j, X + 1) rep(k, X + 1) dp[t][j][k] = 0;
    dp[t][0][0] = 1;
    repr(i, X, 1){
        rep(j, X + 1) rep(k, X + 1) dp[1 - t][j][k] = 0;
        rep(j, X + 1){
            rep(k, X + 1){
                if(dp[t][j][k] == 0) continue;
                int s = k;
                for(int l = 0; s <= X; ++l, s += i) {
                    ADD(dp[1 - t][j + l][s], dp[t][j][k] * facti[l] % MOD);
                }
            }
        }
        rep(r, cnt[i]){
            rep(j, X + 1){
                rep(k, X + 1){
                    if(dp[1 - t][j][k]) dp[1 - t][j][k] = dp[1 - t][j][k] * max(0, k - j * (i - 1)) % MOD;
                }
            }
        }
        t = 1 - t;
    }
    LL ret = 0;
    repx(i, 1, X + 1){
        rep(j, X + 1){
            LL bas = dp[t][i][j];
            int n_range = i;
            int n_blank = X - j;
            LL tmp = bas * fact[i] % MOD * waf(n_range + 1, n_blank - n_range + 1) % MOD;
            if(n_blank % 2 == 1) tmp = MOD - tmp;
            ADD(ret, tmp);
        }
    }
    printf("%lld\n", ret);
    return 0;
}

Measured memory_bytes: 15872
//PLUS ULTRA

#include<bits/stdc++.h>
using namespace std;
     
     
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define mp make_pair
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define nfor(i,st,n) for(int i = st; i >= n ; i--)
#define ss second
#define ff first

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

const int N = 1e5 + 10 , mod =  1000000007;

void solve(){

	float pie = (6.28318530)/2;

	int r; cin >> r;

	printf("%0.4f\n", 2*pie*r);



}

int main(){
    //SPEED;

    solve();

    return 0;
}
      
       


Measured memory_bytes: 3764
n = int(input())
s = input()

start = ["SS", "SW", "WS", "WW"]

for st in start:
    ans = st
    for i in range(1, n):
        if s[i] == "o" and ans[i] == "S":
            if ans[i-1] == "S":
                ans += "S"
            else:
                ans += "W"
        elif s[i] == "x" and ans[i] == "S":
            if ans[i-1] == "S":
                ans += "W"
            else:
                ans += "S"
        elif s[i] == "o" and ans[i] == "W":
            if ans[i-1] == "S":
                ans += "W"
            else:
                ans += "S"
        elif s[i] == "x" and ans[i] == "W":
            if ans[i-1] == "S":
                ans += "S"
            else:
                ans += "W"

    if ans[0] == ans[-1]:
        ans = ans[:n]
        ok = False
        if s[0] == "o" and ans[0] == "S":
            if ans[-1] == ans[1]:
                ok = True
        elif s[0] == "x" and ans[0] == "S":
            if ans[-1] != ans[1]:
                ok = True
        elif s[0] == "o" and ans[0] == "W":
            if ans[-1] != ans[1]:
                ok = True
        elif s[0] == "x" and ans[0] == "W":
            if ans[-1] == ans[1]:
                ok = True
        if ok:
            print(ans[:n])
            exit()
print(-1)

Measured memory_bytes: 9420
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
import bisect
from functools import reduce
def main():
    def comb(n, r):
        numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])
        denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])
        return numerator * pow(denominator, mod - 2, mod) % mod

    mod = 10 ** 9 + 7
    N, A, B = MI()
    p = pow(2, N, mod) - 1
    a = comb(N, A)
    b = comb(N, B)
    ans = (p - a - b) % mod
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 128572
s = input()
n = 4

#AKIHABARAのAの箇所は4か所。それをbit全探索で一致するパターンがあるか判定
for i in range(2**n):
    tmp = ['','','','']
    for j in range(n):
        if ((i>>j)&1):
            tmp[j]='A'
    t = '{0[0]}KIH{0[1]}B{0[2]}R{0[3]}'.format(tmp) 
    if t==s:
        print('YES');exit()
print('NO')

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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  bool ok = true;
  for(int i = 0; i < n; ++i) {
    int x; cin >> x;
    if(x & 1) continue;
    ok &= ((x % 3 == 0) || (x % 5 == 0));
  }
  cout << (ok ? "APPROVED" : "DENIED") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 998244353;


const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}


int main(){
    ll n, a, b, k, ans = 0;
    cin >> n >> a >> b >> k;
    COMinit();
    for(ll i = 0; i <= n; i++){
        if ((k - a*i) % b != 0 || k < a*i) continue;
        ll j = (k - a*i) / b;
        ans += (COM(n, i) * COM(n, j)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15600
#include<iostream>
#define MAX 1000000;
using namespace std;
int main()
{
int t;
long min=MAX;
long max=-MAX;
long sum=0;
int n;
cin>>n;
for(int i=0;i<n;i++){
std::cin>>t;
if(min > t) min = t;
if(max < t) max = t;
sum = sum + t;

}
cout<<min<<" "<<max<<" "<<sum<<endl;
return 0;
}

Measured memory_bytes: 3096
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 998244353, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, m, k, ans, f[N], rf[N];
void add(int &a, int b) {
  b %= mod;
  a += b;
  a %= mod;
  if (a < 0) a += mod;
}
int mult(int a, int b) {
  a %= mod;
  b %= mod;
  a *= b;
  a %= mod;
  return a;
}
int power(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
main() {
  file("threesum");
  ios;
  cin >> n >> m >> k;
  f[0] = 1;
  fo(i, 1, n, 1) f[i] = f[i - 1] * i % mod;
  rf[n] = power(f[n], mod - 2);
  foo(i, n - 1, 0, 1) rf[i] = rf[i + 1] * (i + 1) % mod;
  auto c = [&](int n, int k) { return (f[n] * rf[k] % mod * rf[n - k] % mod); };
  fo(i, 0, k, 1) {
    ans += c(n - 1, i) * m % mod * power(m - 1, n - i-1) % mod;
    ans %= mod;
  }
  cout << ans;
  return 0;
}
/**
010

https://ioi2019.az/source/Tasks/Day1/Shoes/shoes.pdf - 100
https://ioi2019.az/source/Tasks/Day1/Split/split.pdf - 40
*/


Measured memory_bytes: 6740
#include<stdio.h>

int main(void)
{
  int a, b;

  scanf("%d %d", &a, &b);

  if(a == b)
    printf("a == b\n");
  else if(a > b)
    printf("a > b\n");
  else
    printf("a < b\n");

  return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll solve(int N, vi& a) {
    set<int> _s;
    rep(i,N) _s.insert(a[i]);
    map<int,int> _m;
    int id = 0;
    for (int si: _s) {
        _m[si] = id++;
    }
    int k = 0;
    rep(i,N) {
        int bi = _m[a[i]] % 2;
        if (bi != i%2) ++k;
    }
    k /= 2;
    return k;
}

int main() {
    int N;  cin >> N;
    vi a(N);
    rep(i,N) cin >> a[i];
    cout << solve(N,a) << endl;
    return 0;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    s += s;
    vector<int> last(26, -1);
    vector<vector<int>> res(n, vector<int>(26));
    for (int i = s.size() - 1; i >= 0; --i) {
        if (i < n)
            res[i] = last;
        last[s[i] - 'a'] = i;
    }
    int skip = 0, pos = 0;
    if (last[t[0] - 'a'] == -1) {
        cout << -1 << endl;
        return 0;
    }
    pos = last[t[0] - 'a'];
    for (int i = 1; i < t.size(); ++i) {
        if (res[pos][t[i] - 'a'] == -1) {
            cout << -1 << endl;
            return 0;
        }
        int tt = res[pos][t[i] - 'a'];
        if (tt >= n) {
            ++skip;
            pos = tt - n;
        }
        else
            pos = tt;
    }
    cout << skip * n + pos + 1 << endl;
    return 0;
}

Measured memory_bytes: 24812
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	if (a<=8&&b<=8){
		cout << "Yay!" << endl;
	}
	else{
		cout << ":(" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int moto,h,m,s;
	cin >> moto;
	h =moto/3600;
	m =(moto-h*3600)/60;
	s =moto-h*3600-m*60;
	
	cout << h << ":" << m << ":" << s << "\n";
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;


const llong mod = (llong)1e9 + 7;
llong n;
llong c[200005];

inline llong sum(llong x) {
    return (x * (x + 1) / 2) % mod;
}

llong pow_mod(llong n, llong m) {
    llong ret = 1;

    while (m) {
        if (m & 1) {
            ret = ret * n % mod;
        }

        n = n * n % mod;
        m = m >> 1;
    }

    return ret;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }

    llong ans = 0;
    sort(c, c + n, greater<>());
    for (int i = 0; i < n; i++) {
        ans += c[i] * (i + 2);
        ans %= mod;
    }
    ans *= pow_mod(4, n - 1);
    ans %= mod;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<ctime>
#include<set>
#include<climits>
#include<algorithm>
#include<queue>
using namespace std;
const int N=100010;
typedef set<int>::iterator It;
set<int> s[N];
queue<pair<int,int> > q;
int n,f[N];
int find(int x) {return f[x]==x?x:f[x]=find(f[x]);}
void insert(int x,int y)
{
	if(s[x].find(y)!=s[x].end()) q.push(make_pair(x,y));
	else
	{
		s[x].insert(y);
	    s[y].insert(x);
	}
}
int main()
{
	int i,j,x,y;
	scanf("%d",&n);
	for(i=1;i<=n;i++) f[i]=i;
	for(i=1;i<n;i++)
	{
	    scanf("%d%d",&x,&y);
		s[x].insert(y);
		s[y].insert(x);
	}
	for(i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		insert(x,y);
	}
	for(i=1;i<n;i++)
	{
		if(q.empty()) break;
		x=q.front().first,y=q.front().second;
		q.pop();
		x=find(x),y=find(y);
		if(s[x].size()<s[y].size()) swap(x,y);
		f[y]=x;
		s[x].erase(y);
		s[y].erase(x);
		for(It it=s[y].begin();it!=s[y].end();it++) 
		{
			insert(x,find(*it));
			s[find(*it)].erase(y);
		}
	}
	if(i==n) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 24320
# -*- coding: utf-8 -*-
import numpy as np
# 整数の入力
n = int(raw_input())
# スペース区切りの整数の入力
a = np.array(map(int, raw_input().split()))
# Sort
a = np.sort(a)[::-1]
# Points
Alice = np.sum(a[::2])
Bob = np.sum(a[1::2])
# Print
print Alice - Bob


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

long n, k;
string s;
int main() {
  cin >> n >> k >> s;
  long cnt = 0;
  for (int i = 1; i < n; ++i) {
    if (s[i] != s[i - 1]) ++cnt;
  }
  cout << (n - 1) - max<long>(0, cnt - 2 * k) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
using namespace std;

int main(){
	int x1,y1,x2,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << x2 - (y2 - y1) << " " <<  y2 + (x2 - x1) << " " << x1 - (y2 - y1) << " " << y1 + (x2 - x1) << endl; 
}

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

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

using ll = long long;
const ll INF = 1145141919;

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

    std::vector<ll> w, v;
    for(ll i=0; i<N; ++i){
        ll b; std::cin >> b; w.push_back(b);
        std::cin >> b; v.push_back(b);
    }

    const ll max_v = std::accumulate(v.begin(), v.end(), 0LL)+1;

    std::vector<std::vector<ll>> dp(N+1, std::vector<ll>(max_v, INF));

    dp.at(0).at(0) = 0;
    //i番までの品物で価値jを超えないように選んだ時の重さの総和の最小値
    for(ll i=0; i<N; ++i){
        for(ll j=0; j<max_v; ++j){
            if(j-v.at(i)>=0){
                chmin(dp.at(i+1).at(j), dp.at(i).at(j-v.at(i))+w.at(i));
            }
            chmin(dp.at(i+1).at(j), dp.at(i).at(j));
        }
    }

    ll ans= 0;
    for(ll j=0; j<max_v; ++j){
        if(dp.at(N).at(j)<=W){
            ans = std::max(j, ans);
        }
    }

    std::cout << ans;
    return 0;
}


Measured memory_bytes: 80256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n=int(input())
divisors=make_divisors(n)
if divisors[-1]**2==n:
    print(divisors[-1]*2-2)
else:
    print(divisors[-1]+divisors[-2]-2)

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

int main() {
	int a,b;
	while(cin>>a>>b){
		bool stat=0;
		for(int i=0;i<=a;i++){
			if(((2*i)+(4*(a-i)))==b){
				cout<<"Yes"<<'\n';
				stat=1;
				break;
			}
		}
		if(stat==0){
			cout<<"No"<<'\n';
		}
	}
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<58;
 
int main(){
    ll Q, H, S, D, N;
  	cin >> Q >> H >> S >> D >> N;
    chmin(H, 2*Q);
  	chmin(S, 2*H);
  	if(2*S < D){
      cout << S * N <<  endl;
      return 0;
    }
  	else{
      if(N % 2 == 0){
        cout << D * N / 2 << endl;
      	return 0;
      }
      else{
        cout << D * (N / 2) + S * (N % 2) << endl;
      	return 0;
      }
    }
}

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

int main(void){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(),greater<char>());

    if(s<t)
        cout << "Yes";
        else
            cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int D, G;
    cin >> D>>G;
    //cout << D << " " << G << endl;
    vector<int> p(D);
    vector<int> c(D);
    for(int i=0; i<D; i++){
        cin >> p[i] >> c[i];
    }
    

    //REP(i, D){
    //    cout << p[i] <<" " << c[i] << endl;
    //}

    int mincnt = 1E15;
    bitset<10> bset;
    REP(bit, 1<<D){
        long long sum =0;
        int cnt = 0;
        REP(i, D){
            if (bit & 1<<i){
                sum += 100*(i+1)*p[i] + c[i];
                cnt += p[i];
            }
        }
        if (sum >= G){
            if (cnt < mincnt){
                mincnt = cnt;
                bset =bit;
            }
        }
        else{
            for (int i = D-1; i >= 0; i--){
                if(bit & 1<<i) continue;
                REP(j, p[i]){
                    sum += (i+1)*100;
                    cnt += 1;
                    if (sum >= G){
                        if(cnt < mincnt) {
                            mincnt =cnt;
                            bset =bit;
                            }
                    }
                }
            }
        }
    }
    //cout << bitset<10>(bset) << endl;
    cout << mincnt << endl;

   return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
     
    double a = kbd.nextDouble();
    double b = kbd.nextDouble();
    double c = kbd.nextDouble();
    double d, s, l, h;
 
    /*
    if(c==90){
        s = a*b*0.5;
        d = Math.sqrt(a*a+b*b);     
        l = a+b+d;
        h = b;
    }
    */
 
    //else {
    s = 0.5*a*b*Math.sin(Math.toRadians(c));
 
    d = Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.toRadians(c)));
     
    l = a+b+d;
     
    h = s*2/a;
    //}
     
    System.out.println(s);  
    System.out.println(l);  
    System.out.println(h);
    }
}

Measured memory_bytes: 18288