akhauriyash/Code-Regression huggingface dataset:
# D - .. (Double Dots)
from collections import deque


def main():
    N, M, *AB = map(int, open(0).read().split())

    graph = [[] for _ in range(N + 1)]
    for a, b in zip(*[iter(AB)] * 2):
        graph[a].append(b)
        graph[b].append(a)

    # bfs
    depth = [1 << 30] * (N + 1)
    depth[1] = 0
    queue = deque([(1, 0)])
    while queue:
        u, cur_depth = queue.popleft()
        next_depth = cur_depth + 1
        for v in graph[u]:
            if depth[v] > next_depth:
                depth[v] = next_depth
                queue.append((v, next_depth))

    # place signposts
    signposts = [0] * (N + 1)
    for u, cur_depth in enumerate(depth[2:], 2):
        prev_depth = cur_depth - 1
        for v in graph[u]:
            if depth[v] == prev_depth:
                signposts[u] = v
                break

    print("Yes")
    print("\n".join(map(str, signposts[2:])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 56528
#include<stdio.h>
#include<math.h>
int main(){
  char s[3][101];
  int a[3]={0,0,0};
  int t=0;
  scanf("%s %s %s",s[0],s[1],s[2]);
  while(1){
    if(s[t][a[t]]=='\0'){printf("%c",'A'+t);return 0;}
    a[t]++;
    t=s[t][a[t]-1]-'a';
  }
}


Measured memory_bytes: 128
input_line=[]
input_line= input().rstrip().split(' ')

matA = [[1 for i in range(int(input_line[1]))] for j in range(int(input_line[0]))]

for i in range(int(input_line[3])):
    for j in range(int(input_line[2])):
         matA[i][j]=0

for i in range(int(input_line[3]),int(input_line[0])):
    for j in range(int(input_line[2]),int(input_line[1])):
        matA[i][j]=0

for i in range(int(input_line[0])):
    for j in range(int(input_line[1])):
        print(matA[i][j],end="")
    print()


Measured memory_bytes: 15348
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int h[] = new int[N];
        for (int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
        }
        Arrays.sort(h);
        int min = Integer.MAX_VALUE;
        for (int i = K - 1; i < N; i++) {
            int l = i - K + 1;
            if (min > h[i] - h[l]) {
                min = h[i] - h[l];
            }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 51448
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

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; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}


signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    int c[200005];
    int ans = 0;

    cin >> n;
    rep(i, n) cin >> c[i];

    sort(c, c + n);
    reverse(c, c + n);
    int so = mod_pow(4, n, MOD) * modinv2(2, MOD) % MOD;
    rep(i, n) {
        int now = so * (i + 1) % MOD;
        int before = so * i % MOD;
        int x = (now - before * modinv2(2, MOD)) % MOD;
        if (x < 0) {
            x += MOD;
        }
        ans += x * c[i] % MOD;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)

int board[10001];

int pop(int x) {
  int n = 0;
  while(x != 0) {
    n = n + 1;
    x &= (x-1);
  }
  return n;
}

int main() {
  int n,i,j,k,r,c;
  while(scanf("%d %d", &r, &c), r|c) {
    memset(board, 0, sizeof(board));
    rep(i,r) {
      rep(j,c) {
	scanf("%d", &k);
	if(k) board[j] |= (1<<i);
      }
    }

    int ans = 0,tt,t;
    rep(i,(1<<r)) {
      t = 0;
      rep(j,c) {
	tt = pop(board[j] ^ i);
	t += max(tt, r-tt);
      }
      ans = max(ans, t);
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 808
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  string s;cin>>s;
  char first = s[0];
  int i=0;
  while(i<n && k>0){
    if(s[i]==first){
      i++;
    }else{
      while(i<n && s[i]!=first){
        s[i++] = first;
      }
      k--;
    }
  }
  int result = 0;
  for(int i=0;i<n-1;++i){
    if(s[i]==s[i+1])result++;
  }
  cout<<result<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;



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

    ll n,k;
    cin >> n >> k;
    
    if(n%k > k-(n%k)){
        cout <<  k-(n%k) << "\n";
    }else{
        cout << n%k << "\n";
    }
    
}   

Measured memory_bytes: 256
#include <stdio.h>
void Print_a_Rectangle(unsigned int H, unsigned int W)
{
    unsigned short i,j;
    for(i=1;i<=H;i++){
        for(j=1;j<=W;j++){
            printf("#");
        }
        printf("\n");
    }
}

int main()
{
    unsigned int H,W;
    while(1)
    {
        scanf("%d %d",&H,&W);
        if((H==0)&&(W==0))
        {
            break;
        }
        else
        {
            Print_a_Rectangle(H,W);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2100
A, B, C, K = map(int, input().split())
 
if K > A:
    K = K-A
    if K > B:
        K = K-B
        if K > C:
            print(A-C)
        else:
            print(A-K)
    else:
        print(A)
else:
    print(K)

Measured memory_bytes: 9168
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

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

  int total = 0;
  int l = 0, r = N - 1;
  while (true) {
    while (S[l] == 'R' && l < N) ++l;
    while (S[r] == 'W' && r >= 0) --r;

    if (l < r) {
      S[l] = 'R';
      S[r] = 'W';
      ++total;
    } else {
      break;
    }
  }
  cout << total << endl;
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    int X, N;
    cin >> X >> N;
    map<int, int> cnt;
    rep(i, N) {
        int a; cin >> a;
        cnt[a]++;
    }

    int bestMin = 1e8, ans = 0;
    for (int x = 0; x < 1000; ++x) {
        if (cnt[x] == 0 and bestMin > abs(x - X)) {
            bestMin = abs(x-X);
            ans = x;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll INF = 1e5+1;
int main()
{
      int n,W;
      cin >> n >> W;
      vector< vector<ll> > a(n);
      for(int i=0;i<n;i++)
      {
            ll w,v;
            cin >> w >> v;
            a[i].push_back(w);
            a[i].push_back(v);
      }
      ll dp[W+1]={0};
      for(int i=0;i<n;i++)
      {
            for(int j=W;j>=a[i][0];j--)
            {
                  dp[j] = max( dp[j],a[i][1]+dp[j-a[i][0]] );
            }
      }
      cout << dp[W] << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[100005][2];
vector<ll> adj[100005];
ll mod=1e9L+7;
ll f(ll s,ll c,ll p)
{
	if(dp[s][c]!=-1)
		return dp[s][c];
	ll a=1;
	for(auto x:adj[s])
	{
		if(x!=p)
		{
			if(c==1)
				a=(a*(f(x,0,s)+f(x,1,s)))%mod;
			else
				a=(a*f(x,1,s))%mod;
		}
	}
//	cout<<s<<" "<<c<<" "<<a<<"\n";
	return dp[s][c]=a;
}
int main()
{
	ll n,i;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(ll i=0;i<n-1;i++)
	{
		ll a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);	
	}
	ll ans;
	ans=(f(1,0,-1)+f(1,1,-1))%mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 14208
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  string S, T; cin >> S >> T;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] != T[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3588
#include<stdio.h>
int main()
{
    int H,W,m=0,n,i,j=1;
    scanf("%d %d",&H,&W);
    scanf("%d",&n);
    int a[n+1],b[H*W+1];
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
        m+=a[i];
        for(;j<=m;j++)
            b[j]=i;
    }
    for(i=0;i<H/2;i++){
        for(j=2*W*i+1;j<=W*(2*i+1);j++)
            printf("%d ",b[j]);
        printf("\n");
        for(j=2*W*(i+1);j>W*(2*i+1);j--)
            printf("%d ",b[j]);
        printf("\n");
    }
    if(H%2) {
        for(j=(H-1)*W+1;j<=H*W;j++)
            printf("%d ",b[j]);
    }
    return 0;
}

Measured memory_bytes: 256
#他人の参考
def count_0(data):
    five=[5,25,125,625,3125,15625,78125]
    tmp=0
    for i in range(len(five)):
        if data>=five[i]:
            tmp+=data//five[i]
        else:
            break
    return tmp

while True:
    data=int(input())
    if data==0:
        break
    print(count_0(data))



Measured memory_bytes: 5592
n,q = list(map(int,input().split()))
s = list(input())
num = list()
check = [0]*n
for i in range(1,n):
        if s[i-1] == "A" and s[i] == "C":
                check[i] = check[i-1]+1
        else:
                check[i] = check[i-1]
ans = 0
for i in range(0,q):
        num = list(map(int,input().split()))
        ans = check[num[1]-1]-check[num[0]-1]
        print(ans)

Measured memory_bytes: 6944
#include<stdio.h>
#include<string.h>
int main(){
  int N;
  double x[11];
  char u[256];
  int i;
  double sum=0;
  
  scanf("%d",&N);
  for(i=1;i<=N;i++){
  scanf("%lf",&x[i]);
  scanf("%s",&u[i]);
  }
  
  for(i=1;i<=N;i++){
  if(u[i]=='B'){
  sum=sum+(x[i]*380000);
  }
  else
    sum=sum+x[i];

  }

  printf("%f\n",sum);
  return 0;
} 

Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<vector>
#include<queue>

using namespace std;

int main()
{
    int N, j, k;  cin >> N;
    long long y, ans, x;
    queue<int> que;
    vector<int> prime(N,0);
    prime[0] = 2;
    prime[1] = 3;

    k = 2;
    for(int i=4; i<=N; i++){
        j = 2;
        while(j <= sqrt(i)){
            if(i%j == 0)    break;
            if(j+1 > sqrt(i)){
                prime[k] = i;
                k++;
            }
            j++;
        }
    }

    for(int i=0; i<=N; i++){
        x = prime[i];
        if(x == 0)   break;
        y = 0;
        j = 1;
        while(pow(x,j) <= N){
            y += N/pow(x,j);
            j++;
        }
        que.push(y);
    }
    ans = 1;
    while(!que.empty()){
        y = que.front();
        //cout << y << '\n';
        que.pop();
        y %= 1000000007;
        ans = ans*(y+1)%1000000007;
    }
    cout << ans;
}

Measured memory_bytes: 3996
#include <stdio.h>

int main() {
    double w, h, x, y;
    scanf("%lf %lf %lf %lf", &w, &h, &x, &y);

    printf("%f ", w * h / 2);
    printf("%d\n", (x == w / 2 && y == h / 2) ? 1 : 0);
}

Measured memory_bytes: 128
#include <iostream>
#include <set>

using namespace std;

int main()
{
    int n;
    set<int> d;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        d.insert(tmp);
    }

    cout << d.size() << endl;

    return 0;
}
    

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace _20200328
{
    class Program
    {
        static void Main()
        {
            var firstLine = Console.ReadLine().Split(' ');
            var n = int.Parse(firstLine[0]);
            var x = int.Parse(firstLine[1]) - 1;
            var y = int.Parse(firstLine[2]) - 1;
            var kList = new List<int>();
            for (var ptr = 0; ptr < n; ++ptr)
            {
                kList.Add(0);
            }
            for (var i = 0; i < n - 1; ++i)
            {
                for (var j = i + 1; j < n; ++j)
                {
                    //Console.WriteLine("({0}, {1}) {2}", i+1, j+1, CalcDistance(x, y, i, j));
                    ++kList[CalcDistance(x, y, i, j)];
                }
            }
            for (var ptr = 1; ptr < n; ++ptr)
            {
                Console.WriteLine(kList[ptr]);
            }
        }
        static int CalcDistance(int x, int y, int i, int j)
        {
            int under = int.MaxValue;
            if (i <= x && y <= j)
            {
                return j - i - y + x + 1;
            }
            if (i <= x && x < j && j < y)
            {
                under = x - i + 1 + y - j;
            }
            else if (x < i && j < y)
            {
                under = i - x + 1 + y - j;
            }
            else if (x < i && i < y && y <= j)
            {
                under = i - x + 1 + j - y;
            }
            return (under < j - i) ? under : j - i;
        }
    }
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int h[125252];
ll dp[125252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",h+i);
  fill(dp,dp+n,1ll<<60);
  dp[0] = 0;
  REP(i,n-1)FOR(j,i+1,i+3)if(j<n)CHMIN(dp[j],dp[i]+abs(h[i]-h[j]));
  printf("%lld\n",dp[n-1]);
  return 0;
}


Measured memory_bytes: 1408
open System

let [| n; y |] =
    stdin.ReadLine().Split(' ') |> Array.map int

seq {
    for i in [ 0 .. n ] do
        for j in [ 0 .. (n - i) ] do
            yield (i, j, n - i - j)
}
|> Seq.tryFind (fun (a, b, c) -> a * 10000 + b * 5000 + c * 1000 = y)
|> (fun opt -> if Option.isSome opt then Option.get opt else (-1, -1, -1))
|> fun (a, b, c) -> printfn "%d %d %d" a b c


Measured memory_bytes: 21992
#include "bits/stdc++.h"
using namespace std;
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define pb push_back
#define nl cout << "\n"
#define endl "\n"
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c.size())
#define mp make_pair
#define mt make_tuple
#define get(x,c) get<x>(c)
#define trav(a,x) for(auto a=x.begin() ; a!=x.end() ; a++)
#define rep(i,n) for(int i=0 ; i<n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pll>
#define f first
#define s second

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x,ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x,ll ex ,ll md) {ll ans = 1ll;while(ex > 0){if(ex & 1ll) ans = (ans*x)%md; ex >>= 1ll;x=(x*x)%md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 1e5 + 11;
ll n;
void solve(){
    cin>>n;
    ll ct =0 ;
    for(ll i =1  ;i<=n ;i++){
    ll x;
    cin >> x;
        if(i&1 && x&1) ct++;
    }
    cout << ct <<endl;
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC = 1;
    // cin >> NTC;
    ll PTC = 0;
    while(PTC++ < NTC){
        // cout << "Case #" << PTC << ":" << ' ';
        solve();
        cout << "\n";
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3800
/**
*    author:  yuya1234
*    created: 10.07.2020 15:33:42
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  ll n,m;
  cin>>n>>m;

  ll ans=0;
  if(m/2>=n)
  {
    ans+=n;
    m-=n*2;
    n=0;
    ans+=m/4;
  }
  else
  {
    ans+=m/2;
    m=0;
    n-=m/2;
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int,int>P;
main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b==c+d)cout<<"Balanced"<<endl;
  else if(a+b>c+d)cout<<"Left"<<endl;
  else cout<<"Right"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
 
#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif
 
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
 
clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}


int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
 	
 	string s;
 	cin >> s;
 	if (s[2] == s[3] && s[4] == s[5]) {
 		cout << "Yes\n";
 	} else {
 		cout << "No\n";
 	}

	return 0;
}





Measured memory_bytes: 3564
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] ary =  br.readLine().split(" ");
		int[] stack = new int[ary.length];
		int stackCount = -1;
		for(int i = 0 ; i < ary.length ; i++){
			if(ary[i].equals("+")){
				stack[stackCount - 1] = stack[stackCount - 1] + stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("-")){
				stack[stackCount - 1] = stack[stackCount - 1] - stack[stackCount];
				stackCount--;
			}else if(ary[i].equals("*")){
				stack[stackCount - 1] = stack[stackCount - 1] * stack[stackCount];
				stackCount--;
			}else{
				stack[++stackCount] = Integer.parseInt(ary[i]);
			}
		}

		System.out.println(stack[stackCount]);
	}

}

Measured memory_bytes: 24180
char len[3], used[3], s[3][100], d, i;

void rec(char t){
        if(used[t]++>=len[t]) putchar('A'+t);
        else rec(s[t][used[t]-1]);
}

int main(){
        for(i=0; i<3; i++){
                while((d=getchar())!='\n'){
                        s[i][len[i]++] = d-'a';
                }
        }
        rec(0);
        return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=1000000007;
inline int ad(int x){return x>=mod?x-mod:x;}
inline int dec(int x){return x<0?x+mod:x;}
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
int f[100010];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
   	int n=read(),m=read();
   	for(int i=1;i<=m;i++)f[i]=i;
   	for(int i=1;i<=m;i++)
   	{
   		for(int j=2*i;j<=m;j+=i)f[j]=dec(f[j]-f[i]);
   	}
   	int ans=0;
   	for(int i=1;i<=m;i++)ans=ad(ans+1LL*f[i]*power(m/i,n)%mod);
   	pr2(ans);
    return 0;
}

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
ll ans = 0;
ll N,M,Q;
vector<ll> a(51);
vector<ll> b(51);
vector<ll> c(51);
vector<ll> d(51);
void dfs(vector<ll> &A){
    if(A.size() == N){
        ll tmp = 0;
        rep(i,Q){
            if(A[b[i]] - A[a[i]] == c[i]){
                tmp+=d[i];
            }
        }
        chmax(ans,tmp);
        return ;
    }
    if(A.size() == 0){
        rep3(v,1,M+1){
            A.pb(v);
            dfs(A);
            A.pop_back();  
        }
    }else{
        rep3(v,A[A.size()-1],M+1){
            A.pb(v);
            dfs(A);
            A.pop_back();  
        }
    }
    
}

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

    rep(i,Q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;
        b[i]--;
    }
    vector<ll>num;
    dfs(num);

    
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3596
n = int(input())
mymap = {}
for x in range(n):
	inp = input()
	if inp in mymap:
		mymap[inp] += 1
	else:
		mymap[inp] = 0

sorted_map = sorted(mymap.items(), key=lambda kv: kv[1], reverse = True )

maxi = sorted_map[0][1]
# print(maxi)

answer = []

for x in sorted_map:
	if x[1] == maxi:
		answer.append(x[0])
	else:
		break

answer.sort()

for x in answer:
	print(x)

Measured memory_bytes: 45788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

vector<ll> g(51), h(51);

ll solve(ll n, ll x){
    if(n==0){
        return x;
    }
    if(x==0) return 0;
    if(x == g[n]) return h[n];
    if(x <= g[n-1]+1){
        return solve(n-1, x-1);
    }
    return 1 + h[n-1] + solve(n-1, x-2-g[n-1]);
}


int main(){
    ll n,x; cin>>n>>x;
    g[0]=1; h[0]=1;
    for(ll i=1; i<=50; i++) g[i]=2*g[i-1]+3;
    for(ll i=1; i<=50; i++) h[i]=2*h[i-1]+1;

    cout << solve(n, x) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
C=input()
L=[0]*(n+1)
R=[0]*(n+1)
for i in range(n):
  if C[i]=="W":
    L[i+1]=L[i]+1
  else:
    L[i+1]=L[i]
  if C[n-1-i]=="R":
    R[n-i-1]=R[n-i]+1
  else:
    R[n-i-1]=R[n-i]
ans=n
for i in range(n+1):
  cur=max(L[i],R[i])
  ans=min(ans,cur)
print(ans)



Measured memory_bytes: 71200
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;

long long A = 2, B = 1, C = 0;

if (N == 1) cout << B << endl;
else {
        for (int i = 2; i <= N; ++i) {
                C = A + B;
                A = B;
                B = C;
        }   
cout << C << endl;
}
}

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

const int MaxN = 3010;
int n, a[MaxN];
vector <int> e[MaxN];

bool dfs(int x, int par) {
    bool ret = false;
    for (int y : e[x])
        if (y != par)
           ret |= !dfs(y, x) & (a[x] > a[y]);
    return ret;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int x, y;
    for (int i = 0; i < n - 1; i++) {
        cin >> x >> y;
        e[--x].push_back(--y);
        e[y].push_back(x);
    }
    for (int i = 0; i < n; i++)
        if (dfs(i, i))
           cout << i + 1 << " ";
	return 0;
}

Measured memory_bytes: 640
<?php
fscanf(STDIN, '%d %d', $N, $M);
for($i = 0; $i < $M + 1; $i++) {
    if ($i < $M) {
        $s[$i] = array_map('intval', explode(' ', trim(fgets(STDIN))));
        $k[] = array_shift($s[$i]);
    } else {
        $p = array_map('intval', explode(' ', trim(fgets(STDIN))));
    }
}

$cnt = 0;
for ($i = 0; $i < 2 ** $N; $i++) {
    for ($j = 0; $j < $N; $j++) {
        if (($i >> $j) & 1) $switch[$j] = true;
        else $switch[$j] = false;
    }
    
    $flag = true;
    for($j = 0; $j < $M; $j++) {
        $s_cnt = 0;
        foreach ($s[$j] as $v) {
            if ($switch[$v - 1]) $s_cnt++;
        }
        if ($s_cnt % 2 !== $p[$j]) {
            $flag = false;
            break;
        }
    }
    if ($flag) $cnt++;
}
echo $cnt . PHP_EOL;

Measured memory_bytes: 4604
n=int(input())
distance=[list(map(int,input().split())) for i in range(n)]

import itertools
import math
temp=[i for i in range(n)]
perm=list(itertools.permutations(temp))

sm=0
count=0
for route in perm:
    count+=1
    temp_dis=0
    route_list=list(route)
    for i in range(1,n):
        j=route_list[i]
        k=route_list[i-1]
        temp_dis+=math.sqrt((distance[j][0]-distance[k][0])**2+(distance[j][1]-distance[k][1])**2)
    sm+=temp_dis
ans=sm/count
print('{:.9f}'.format(ans))


Measured memory_bytes: 7972
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
        if((a+b+c)%2==1){
            out.println(0);
        }else if(a==b&&b==c&&c==a){
            out.println(-1);
        }else {
            int ans=0;
            while (a%2+b%2+c%2==0){
                ans++;
                int tempA=(b+c)/2;
                int tempB=(a+c)/2;
                int tempC=(b+a)/2;
                a=tempA;
                b=tempB;
                c=tempC;
            }
            out.println(ans);
        }
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<vector>
 
using namespace std;
 
int main(void){
 
  int n, ans = 0;
  
  cin >> n;
  
  vector<int> d(n);
  
  for(int i = 0;i < n;i++){
    cin >> d[i];
  }
  
  for(int i = 0;i < n-1;i++){
    for(int j = i+1;j < n;j++){
      ans += d[i] * d[j];
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
acl=["WA"]*n
wal=[0]*n
ans=0
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if(acl[p]=="WA"):
        if s=="WA":
            wal[p]+=1
        else:
            ans+=wal[p]
            acl[p]="AC"
print(acl.count("AC"),ans)


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N, int K);
  size_t mN;
  int mK;
  vector<vector<int>> mTree;
  vector<int> mRes, mMemo;
};

Tmp::Tmp(int N, int K)
  : mN(N)
  , mK(K)
  , mTree(N, vector<int>())
  , mRes(N, -1)
  , mMemo(N)
{}

void solve(void)
{
  int N, K; cin >> N >> K;

  Tmp t(N, K);
  for (int i = 1; i <= N-1; ++i) {
    int a, b; cin >> a >> b;
    --a; --b;
    t.mTree[a].push_back(b);
    t.mTree[b].push_back(a);
  }
  std::deque<int> que{};
  que.push_back(0);
  t.mRes[0] = K;
  t.mMemo[0] = 0;
  while (!que.empty()) {
    auto i = que.front();
    que.pop_front();
    int k = K - (1 + t.mMemo[i]);
    for (const auto& n : t.mTree[i]) {
      if (t.mRes[n] != -1) {
        continue;
      }
      t.mRes[n] = k;
      ++t.mMemo[n];
      --k;
      que.push_back(n);
    }
  }
  auto ans = boost::accumulate(t.mRes, cpp_int(1), [](auto a, auto b){
    return (a * b + MOD) % MOD;
  });
  ans %= MOD;
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 7288
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(A+1):
    for j in range(B+1):
        if (X - (500*i+100*j)) % 50 == 0 and X - (500*i+100*j) >= 0 and (X - (500*i+100*j)) // 50 <= C:
            ans += 1
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N,i;
	cin>>N;
	vector<int> B(N-1),A(N);
	for (i=0;i<N-1;i++){
		cin>>B[i];
	}
	A[0]=B[0];
	A[1]=B[0];
	for (i=1;i<N-1;i++){
		A[i]=min(A[i],B[i]);
		A[i+1]=B[i];
	}
	int ans=0;
	for (i=0;i<N;i++){
		ans+=A[i];
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <unistd.h>
int fix(int n){
    return n+2501;
}
int Z[5000][5000];
int distance(double a,double b,double c,double d){
    if(Z[fix(a)][fix(b)]==0){
     
        return std::pow(a-c,2)+std::pow(b-d,2);
    }else{
        return 10000000;
    }
}

int search(int sx,int sy,int tx,int ty){
    Z[fix(sx)][fix(sy)]=1;
    Z[fix(tx)][fix(ty)]=0;
    while(sx!=tx||sy!=ty){
        double N=distance(sx,sy-1,tx,ty);
        double S=distance(sx,sy+1,tx,ty);
        double E=distance(sx+1,sy,tx,ty);
        double W=distance(sx-1,sy,tx,ty);

        

        if(std::min({N,S,E,W})==N){
            sy-=1;
            std::cout<<"D";
            Z[fix(sx)][fix(sy)]=1;
            continue;
        }
        if(std::min({N,S,E,W})==S){
            sy+=1;
            Z[fix(sx)][fix(sy)]=1;
            std::cout<<"U";
            continue;
        }
        if(std::min({N,S,E,W})==E){
            std::cout<<"R";
            sx+=1;
            Z[fix(sx)][fix(sy)]=1;
            continue;
        }
        if(std::min({N,S,E,W})==W){
            std::cout<<"L";
            sx-=1;
            Z[fix(sx)][fix(sy)]=1;
            continue;
        }
    }

}

int main(){
    
    int sx,sy,tx,ty;
    std::cin>>sx>>sy>>tx>>ty;
    search(sx,sy,tx,ty);
    search(tx,ty,sx,sy);
    search(sx,sy,tx,ty);
    search(tx,ty,sx,sy);
    std::cout<<std::endl;

}

Measured memory_bytes: 41216
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を文字の配列で返却する
def gets_nsp_list()
  gets.chomp.split("")
end

N = gets_nsp_list.last

hon = %w(2 4 5 7 9)
pon = %w(0 1 6 8)
bon = %w(3)

if hon.include?(N)
  puts "hon"
elsif pon.include?(N)
  puts "pon"
elsif bon.include?(N)
  puts "bon"
end

Measured memory_bytes: 14612
N,K=map(int,input().split(' '))
mod =10**9+7
dp=[pow(K//i,N,mod) for i in range(1,K+1)]
for i in range(K,1,-1):
    tmp=[1]
    for j in range(2,int(pow(i+1,0.5))+1):
        if i%j==0:
            tmp.append(j)
            if i != j*j:
                tmp.append(i//j)
    for k in tmp:
        dp[k-1] -=dp[i-1]
ans = 0
for n,i in enumerate(dp):
    ans += (n+1)*i
    ans %=mod
print(ans)

Measured memory_bytes: 73952
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
  int n; cin >> n;
  vector<pair<int, int> > p(n);
  rep(i, n){
    int x, l; cin >> x >> l;
    p[i] = make_pair(x+l, x-l);
  }

  sort(all(p));
  int cnt = 0;
  int r = -INF;
  rep(i, n){
    if(r <= p[i].second){
      cnt++;
      r = p[i].first;
    }
  }

  cout << cnt << endl;
 
  return 0;
}



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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

struct Point{
    double X,Y;
    Point(double X_=0,double Y_=1):X(X_),Y(Y_) {}
    Point operator + (double Theta){
        return Point( cos(Theta)*X-sin(Theta)*Y , sin(Theta)*X+cos(Theta)*Y );
    }
    double operator - (const Point &t){
        return sqrt( (X-t.X)*(X-t.X)+(Y-t.Y)*(Y-t.Y) );
    }
}Hour,Mint;

int main(){
    Hour.Y=read();
    Mint.Y=read();
    double H=read(),M=read();
    Hour=Hour+(H+M/60)/6*acos(-1);
    Mint=Mint+M/30*acos(-1);
    printf("%.11lf",Hour-Mint);
    output();
    return 0;
}

Measured memory_bytes: 4092
N , K = gets.split.map!{|n| n.to_i}
t = Array.new(N)

for i in 1..N
    t[i-1] = gets.split.map!{|n| n.to_i}
end

t = t.sort{|a , b| -a[1] <=> -b[1]}

max = 0
variety = Hash.new(0)
t.each_with_index do |value , index|
    if index >= K
        break
    end
    
    value[2] = variety[value[0]]
    variety[value[0]] += 1
    max += value[1]
end

max += variety.size ** 2
a = max

for i in 1..K
    if t[K-i][2] == 0
        next
    end

    while K < t.size && variety[t[K][0]] != 0
        t.delete_at(K)
    end

    if K >= t.size
        break
    end

    a += t[K][1] - t[K-i][1] + 2 * variety.size + 1
    if max < a
        max = a 
    end
    variety[t[K][0]] += 1

end

puts max

Measured memory_bytes: 16360
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  string s;cin>>s;
  ans(s=="ABC","ARC","ABC");
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
/*
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
#define  P = pair<int, int>;
*/


int main(){

  string s;
  cin>>s;

  if(s.length() == 1){
    cout<<s[0]<<endl;
     return 0; }

  if(s.length() > 1){
  cout<<s[0];
  }

  for(int i=1;i<s.length();i++){
     if(i%2 == 0)
    cout<<s[i];
  }

return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

struct node
{
  int p;
  int l, r;
} typedef node;

int parent(int);
int left(int);
int right(int);
void insert(int);

int A[251];
node H[251];

int main()
{
  int i;
  int n;

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

  for(i = 1; i <= n; i++)
    {
      printf("node %d: key = %d, ", i, A[i]);
      if(H[i].p != -1)
	printf("parent key = %d, ", A[H[i].p]);
      if(H[i].l != -1)
	printf("left key = %d, ", A[H[i].l]);
      if(H[i].r != -1)
	printf("right key = %d, ", A[H[i].r]);
      printf("\n");
    }

  return 0;
}

int parent(int i)
{
  return i / 2;
}

int left(int i)
{
  return 2 * i;
}

int right(int i)
{
  return 2 * i + 1;
}

void insert(int i)
{
  H[i].l = -1;
  H[i].r = -1;

  if(i == 1)
    {
      H[i].p = -1;
      return;
    }
  H[i].p = parent(i);

  if(left(H[i].p) == i)
    H[H[i].p].l = i;
  else 
    H[H[i].p].r = i;
}

Measured memory_bytes: 604
package main

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

func solve() {
	s := getRunes()
	n := len(s)

	cntL := 0
	cntR := 0
	now := s[0]
	ans := 0
	for i, r := range s {
		if r == '<' {
			cntL++
		} else {
			cntR++
		}
		now = r

		if (i == n-1) || ((now == '>') && (now != s[i+1])) {
			x := cntL*(cntL+1)/2 + cntR*(cntR+1)/2 - min(cntL, cntR)
			ans += x
			cntL, cntR = 0, 0
		}
	}

	fmt.Fprintln(wr, ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

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

func main() {
	buf := 500001
	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: 3712
n = int(input())
a = list(map(int, input().split()))
index = [0]*n
if n%2==0:
    m = n//2
    for i in range(n):
        if i%2==0:
            index[m+i//2] = i
        else:
            index[m-(i+1)//2] = i
else:
    m = (n-1)//2
    for i in range(n):
        if i%2==0:
            index[m-i//2] = i
        else:
            index[m+(i+1)//2] = i

ans = [0]*n
for i in range(n):
    ans[i] = a[index[i]]
print(*ans)

Measured memory_bytes: 26672
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
using namespace std;

long long gcd(long long a, long long b) {
  if(b > a) {
    long long tmp = b;
    b = a;
    a = tmp;
  }

  long long r = a % b;
  while(r > 0) {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

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

  long long ans = gcd(a[0], a[1]);
  for(int i=2;i<n;++i) {
    ans = gcd(ans, a[i]);
  }

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

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

int main() {
  int L, R, d;
  cin >> L >> R >> d;

  int cnt = 0;
  rep(i,L,R)
    if (i % d == 0) cnt++;

  cout << cnt << endl;
  return 0;
}


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

using namespace std;

using ll = long long;

#define clr(a) (a.clear())
#define sz(x) (int)x.size()
#define mem(a,b) memset(a, b, sizeof(a))
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define pb push_back
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);

#define X first
#define Y second

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

const ll inf = 1;
const ll mod = 1E9;


#define SZ 100010

ll f(ll n) {
    return n * (n + 1) / 2;
}

int main() {
#if defined JESI
//        freopen("1.txt", "r", stdin);
//        freopen("2.txt", "w", stdout);
#endif

    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    ll n = sz(s);
    ll ans = f(n);

    vector<ll> cnt(26, 0);
    for (auto x: s) cnt[x - 'a']++;

    for (int i = 0; i < 26; i++) {
        ans -= f(cnt[i]);
    }

    cout << ans + 1 << endl;

    return 0;
}






Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
using namespace std;
int main()
{
    
    int a,b,c,d,e,k;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    cin >> k;
    if (e - a <= k)
        cout << "Yay!";
    else
        cout << ":(";
}


Measured memory_bytes: 256
<?php
ini_set('error_reporting', E_ALL & ~E_NOTICE);

// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d", $N);

$neg = $N < 0;
if ($neg) {
	$N = -$N;
}
$bin = decbin($N);
if (DEBUG) {
	echo $bin . PHP_EOL;
}

$array = str_split($bin);
$array = array_reverse($array);

$cursor = 0;
while (true) {
	if (!isset($array[$cursor])) {
		break;
	}
	if ($array[$cursor] == 2) {
		$array[$cursor] = 0;
		$array[$cursor + 1]++;
	}
	if ($neg) {
		if ($cursor % 2 == 0) {
			if ($array[$cursor] == 1) {
				$array[$cursor + 1]++;
			}
		}
	} else {
		if ($cursor % 2 == 1) {
			if ($array[$cursor] == 1) {
				$array[$cursor + 1]++;
			}
		}
	}
	if (DEBUG) {
		echo implode("", array_reverse($array)) . PHP_EOL;
	}

	$cursor++;
}

if (DEBUG) {
	var_dump($array);
}

$array = array_reverse($array);
echo implode("", $array);


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

l = []
for i in range(N):
    s = input()
    s = sorted(s)
    l.append("".join(s))
    
import collections

c = collections.Counter(l)
#print(c)
issubclass(type(c), dict)
C = list(c.values())
#print(C)

count = 0
for i in C:
    count += i * (i-1) // 2
    
print(count)

Measured memory_bytes: 19788