akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(int& a){printf("%d",a);}
//void print(long long& a){printf("%lld",a);}
void print(double& a){printf("%.15lf",a);}
template<class T> void print(T& a){cout<<a;}
template<class T> void print(vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(Head& head, Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(T& a){cerr<<a;}
template<class T> void dprint(vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(Head& head, Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    ll a,b;
    while(scanf("%lld %lld",&a,&b)!=EOF){
        printf("%lld %lld\n",__gcd(a,b),a*b/__gcd(a,b));
    }
}


Measured memory_bytes: 3116
def gcd(a, b):
    if b == 0:
        return a
    g = gcd(b, a % b)
    return g

n = input()
a_list = map(int, raw_input().split())

gs1 = [None] * n
gs1[0] = a_list[0]
for i in xrange(1, n):
    gs1[i] = gcd(gs1[i - 1], a_list[i])

gs2 = [None] * n
gs2[n - 1] = a_list[n - 1]
for i in reversed(xrange(n - 1)):
    gs2[i] = gcd(gs2[i + 1], a_list[i])

max_g = 0
for exclude in xrange(n):
    if exclude == 0:
        g = gs2[1]
    elif exclude == n - 1:
        g = gs1[n - 2]
    else:
        g = gcd(gs1[exclude - 1], gs2[exclude + 1])
    if g > max_g:
        max_g = g
print(max_g)


Measured memory_bytes: 11340
#include <iostream>
#include <deque>

using namespace std;

void push(int d, int x, deque<int> &deq) {
  if(d == 0) {
    deq.push_front(x);
  }
  else if(d == 1) {
    deq.push_back(x);
  }
}

void pop(int d, deque<int> &deq) {
  if(d == 0) {
    deq.pop_front();
  }
  else if(d == 1) {
    deq.pop_back();
  }
}

int main(void) {
  int q;
  cin >> q;
  deque<int> deq;

  for(int i = 0; i < q; i++) {
    int command, x, d, p;
    cin >> command;
    switch(command) {
      case 0: 
        cin >> d;
        cin >> x;
        push(d, x, deq);
        break;
      case 1:
        cin >> p;
        cout << deq[p] << endl;
        break;
      case 2:
        cin >> d;
        pop(d, deq);  
        break;
    }
  }
  
}


Measured memory_bytes: 4568
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;

#define N 805
int h,w,k;
char map[N][N];

void dps(int si,int sj){
    queue<int>q;
    q.push(si);q.push(sj);q.push(0);
    while(!q.empty()){
        int i=q.front();q.pop();
        int j=q.front();q.pop();
        int n=q.front();q.pop();
        if(n<k){
            if(map[i+1][j]=='.'){
                map[i+1][j]='S';
                q.push(i+1);q.push(j);q.push(n+1);
            }
            if(map[i][j+1]=='.'){
                map[i][j+1]='S';
                q.push(i);q.push(j+1);q.push(n+1);
            }
            if(map[i-1][j]=='.'){
                map[i-1][j]='S';
                q.push(i-1);q.push(j);q.push(n+1);
            }
            if(map[i][j-1]=='.'){
                map[i][j-1]='S';
                q.push(i);q.push(j-1);q.push(n+1);
            }
        }
        
    }
}

int main(){
    cin>>h>>w>>k;
    for(int i=1;i<=h;i++)scanf("%s",&map[i][1]);
    int si=-1,sj=-1;
    for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
        if(map[i][j]=='S'){
            si=i;sj=j;
        }
    }
    dps(si,sj);
    int min=10000;
    for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
        if(map[i][j]=='S'){
            if(min>i-1)min=i-1;
            if(min>j-1)min=j-1;
            if(min>w-j)min=w-j;
            if(min>h-i)min=h-i;
        }
    }
    printf("%d",(min+k-1)/k+1);
    
    return 0;
}

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

int main(){
	int n, q;
	ll k;
	cin >> n >> k >> q;
	vector<ll> a(n, k);
	for(int  i = 0; i < q; i++){
		int tmp; cin >> tmp;
		a[--tmp]++;
	}
	rep(i, n){
		a[i] -= q;
		if(a[i] > 0) puts("Yes");
		else puts("No");
	}
}


Measured memory_bytes: 1408
n=input()
a = list(map(int,input().split()))

def chk(a,t):
    ans=0
    x=0
    for i in a:
        x+=i
        if t and x<1:
            ans+=1-x
            x=1
        elif not t and x>-1:
            ans+=x+1
            x=-1
        t= not t
    return ans

print(min(chk(a,True),chk(a,False)))


Measured memory_bytes: 85608
n,m=map(int,input().split())

mlist=[]
for i in range(m):
    mlist.append(list(map(int,input().split())))
    mlist[i].append(i)

mlist.sort(key=lambda x:x[1])

tlist={}

for indlist in mlist:
    ken=indlist[0]
    if ken in tlist:
        indlist[1]=tlist[ken]+1
        tlist[ken] = tlist[ken]+1
    else:
        indlist[1]=1
        tlist[ken]=1

mlist.sort(key=lambda x:x[2])

for result in mlist:
    pref=str(result[0])
    ord=str(result[1])
    output=""
    leng=len(pref)
    for i in range(6-leng):
        output +="0"
    output += pref

    leng=len(ord)
    for i in range(6-leng):
        output +="0"
    output += ord

    print(output)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc148_e() {
	ll N;
	cin >> N;

	ll ans = 0;

	if (N % 2 == 1) {
		ans = 0;
	}
	else {
		for (ll v5 = 10; v5 <= N; v5 *= 5) {
			ans += N / v5;
		}
	}
	
	cout << ans << "\n";
}

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

	solve_abc148_e();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

struct UnionFind {  // UnionFind uni(N);
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> siz; // 素集合のサイズを表す配列(1 で初期化)

    UnionFind(int N) : par(N), siz(N, 1){ //最初は全てが根であるとして初期化、頂点数N
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        siz[ry] += siz[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    int N,M;cin >> N >> M;
    vector<int> K(N);
    vector<vector<int>> L(N);
    rep(i,N){
        cin >> K[i];
        rep(j,K[i]){
            int c;cin >> c;
            L[i].push_back(c);
        }
    }
    map<int,set<int>> m;
    UnionFind uni(N);

    rep(i,N){
        for(auto t : L[i]){
            m[t].insert(i);
        }
    }

    for(auto t : m){
        int tmp = -1;
        for(auto s : t.S){
            if(tmp != -1){
                uni.unite(tmp,s);
            }
            tmp = s;            
        }
    }

    if(uni.size(0) == N)cout << "YES" << endl;
    else cout << "NO" << endl;

}

Measured memory_bytes: 17152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

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

	rep(i,3){
		if(s[i] == s[i+1]){
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

# 解説AC
if n <= 2:
    print(int(t == a))
    exit()

ans = 1
for i in range(1, n - 1):
    if ((t[i - 1] < t[i] and t[i] > a[i])
        or (a[i] > a[i + 1] and t[i] < a[i])):
            print(0)
            break
    elif t[i - 1] == t[i] and a[i] == a[i + 1]:
        ans = ans * min(t[i], a[i]) % mod
else:
    print(ans)


Measured memory_bytes: 97600
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
/*
int main(){
    pair<pair<string,int>,int> p[5];
    for(int i=0; i<5; i++){
        string s; cin >> s;
        int a; cin >> a;
        p[i] = make_pair(make_pair(s,a),5-i);
    }

    sort(p,p+5);
    puts("");
    for(int i=0; i<5; i++){
        cout << p[i].first.first << " " << p[i].first.second << " "  << p[i].second << endl;
    }
    return 0;
}
*/

int main(){
    int n;
    //1番に都市名のstring,2番目に得点のint,3番目に元々の順番を入れる
    pair<pair<string,int>,int> sp[110];
    cin >> n;
    for(int i=0; i<n; i++){
        string s; cin >> s;
        int p; cin >> p;
        //↓ここでpをマイナスにするのがポイント！！マイナスにすることで昇順の逆==>降順を求めることができる！！
        sp[i]=make_pair(make_pair(s,-p),i);
    }
    //pair<string.int>をソート
    //pair全体のソートだからstringとintを組み合わせた昇順が考慮される
    sort(sp,sp+n);
    for(int i=0; i<n; i++){
        //参照してるのは元の順番、0から始まってるから＋１
        cout << sp[i].second+1 << endl;
    }
}


Measured memory_bytes: 256
import java.awt.geom.Point2D;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		Point2D.Double p[];
		String str[];
		
		p = new Point2D.Double[4];
		while (sc.hasNext()) {
			str = sc.nextLine().split(" ");
			for (int i = 0; i < 4; i++) {
				p[i] = new Point2D.Double(Double.valueOf(str[2 * i]), Double.valueOf(str[2 * i + 1]));
			}
			double dx1, dx2, dy1, dy2;
			dx1 = p[1].x - p[0].x;
			dy1 = p[1].y - p[0].y;
			dx2 = p[2].x - p[3].x;
			dy2 = p[2].y - p[3].y;
			if (dx1 * dx2 + dy1 * dy2 == 0) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 12000
# Acceptance of input

import sys

file_input = sys.stdin

X, Y, E = map(int, file_input.readline().split())

v_num = X + Y + 2

adj_mat = [[0] * (v_num) for i in range(v_num)]

for line in file_input:
    x, y = map(int, line.split())
    adj_mat[x][X + y] = 1

s = X + Y
t = s + 1

for i in range(X):
    adj_mat[s][i] = 1

for i in range(X, s):
    adj_mat[i][t] = 1

# Ford???Fulkerson method

import collections

# BFS for residual capacity network
def bfs(start, goal, parent):
    unvisited = [True] * v_num
    queue = collections.deque()
    queue.append(start)
    unvisited[start] = False
    while queue:
        u = queue.popleft()
        for v, r_capacity in enumerate(adj_mat[u]):
            if unvisited[v] and (r_capacity > 0):
                queue.append(v)
                unvisited[v] = False
                parent[v] = u
                if v == goal:
                    return not unvisited[goal]

def ford_fulkerson(source, sink):
    parent = [None] * v_num
    max_flow = 0
    while bfs(source, sink, parent):
        aug_path_flow = 10000
        v = sink
        while (v != source):
            aug_path_flow = min(aug_path_flow, adj_mat[parent[v]][v])
            v = parent[v]
        max_flow += aug_path_flow
        v = sink
        while (v != source):
            u = parent[v]
            adj_mat[u][v] -= aug_path_flow
            adj_mat[v][u] += aug_path_flow
            v = u
    return max_flow

# output
print(ford_fulkerson(s, t))

Measured memory_bytes: 8416
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<string> S(n);
	rep(i, n) cin >> S[i];
	vector<int> cnt(n);
	int both = 0, head = 0, hip = 0;
	rep(i, n) {
		if (S[i].front() == 'B' && S[i].back() == 'A') both++;
		else if (S[i].front() == 'B') head++;
		else if (S[i].back() == 'A') hip++;
		rep(j, S[i].size() - 1) {
			if (S[i].substr(j, 2) == "AB") cnt[i]++;
		}
	}
	int ans = 0;
	if (both > 1) {
		ans += (both - 1);
		both = 1;
	}
	if (both == 1) {
		if (hip > 0 && head > 0) {
			ans += 2;
			hip--;
			head--;
		}
		else if (hip > 0 && head == 0) {
			ans++;
			hip--;
		}
		else if (hip == 0 && head > 0) {
			ans++;
			head--;
		}
	}
	ans += min(hip, head);
	rep(i, n) ans += cnt[i];
	dunk(ans);
	return 0;
}

Measured memory_bytes: 896
# A - Sharing Cookies

# 3匹のヤギにクッキーを渡したい
# A 枚入ったクッキーが入った缶
# B 枚入ったクッキーが入った缶
# A B 缶を持っている。

#  A, B, A + B のいずれかの枚数をヤギに渡すことができる

# 3匹のヤギが同じ枚数食べれるように渡せるか判定する
# 可能なら Possible    不可能なら Impossible

# A B を標準入力で取得
A, B = map(int, input().split())
# print(A, B)

# A の場合 Bの場合 A + B の場合で分ける
# それぞれの余りが 0 の時 Possible
# それ以外は Impossible

if A % 3 == 0:
    answer = "Possible"
elif B % 3 == 0:
    answer = "Possible"
elif (A + B) % 3 ==0:
    answer = "Possible"
else:
    answer = "Impossible"

# 結果を出力
print(answer)


Measured memory_bytes: 9108
#include<iostream>
using namespace std;
int main(){
int n;
long long a;
long long l=1000000;
long long b=-1000000;
long long sum=0;
cin >> n;
for(int i=0; i<n; i++){
cin >> a;
if(a<l)l=a;
if(a>b)b=a;
sum+=a;
}
cout << l << " " << b << " " << sum <<endl;
return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(13);
  a[0]++;
  rep(i,n){
    ll d;
    cin>>d;
    a[d]++;
    if(a[d]>=3) {
      COUT(0);
      return 0;
    }
  }
  if(a[0]>=2||a[12]>=2){
    COUT(0);
    return 0;
  }
  ll ans=0;
  for(int bit=0;bit<(1<<11);bit++){
    vll u(0);
    if(a[0]) u.pb(0);
    if(a[12]) u.pb(12);
    for(int i=0;i<11;i++){
      if(a[i+1]==2){
        u.pb(i+1);
        u.pb(24-i-1);
      }
      if(a[i+1]==1){
        if(bit&(1<<i)){
          u.pb(i+1);
        }
        else{
          u.pb(24-i-1);
        }
      }
    }
    sort(all(u));
    ll cu=INF;
    for(int i=1;i<sz(u);i++){
      cu=min(u[i]-u[i-1],cu);
    }
    cu=min(cu,min(u[sz(u)-1]-u[0],24-u[sz(u)-1]+u[0]));
    ans=max(ans,cu);
  }
  COUT(ans);
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
 
mod_dict = dict()
S_mod = [0]
s = 0
for a in A:
    s += a
    mod = s % M
    S_mod.append(mod)
    if not mod in mod_dict.keys():
        mod_dict[mod] = 1
    else:
        mod_dict[mod] += 1
 
if 0 in mod_dict.keys():
    count = mod_dict[0]
else:
    count = 0
for key in mod_dict.keys():
    count += (mod_dict[key] - 1) * mod_dict[key] / 2
 
print(int(count))

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007)
#define IINF (1<<28)
#define LINF (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"

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

  int N, K;

  void init() {
    cin >> N >> K;
  }

  void solve() {
    int ans = 0;
    while(N>0) {
      N /= K;
      ans++;
    }
    cout << ans << "\n";
  }
}

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

Measured memory_bytes: 256
import std.algorithm;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;

auto solve(uint N, uint Q, uint[] a, uint[] b, uint[] p, uint[] x){
    auto edges = new uint[][](N + 1, 0);
    foreach (ai, bi; zip(a, b)) {
        edges[ai] ~= bi;
        edges[bi] ~= ai;
    }

    auto nodes = new uint[](N + 1);
    foreach (pi, xi; zip(p, x)) {
        nodes[pi] += xi;
    }

    auto visited = new bool[](N + 1);
    
    dig(nodes, edges, 1, 0, visited);

    return nodes[1 .. $].map!(to!string).join(" ");
}

void dig(uint[] nodes, uint[][] edges, uint nodei, uint acc, bool[] visited) {
    visited[nodei] = true;
    acc = (nodes[nodei] += acc);
    edges[nodei].filter!(i => !visited[i]).each!(i => dig(nodes, edges, i, acc, visited));
}

void main(){
    auto input = stdin.byLine.map!split.joiner;

    uint N;
    N = input.front.to!uint;
    input.popFront;

    uint Q;
    Q = input.front.to!uint;
    input.popFront;

    uint[] a = new uint[](cast(size_t) (N-1));
    uint[] b = new uint[](cast(size_t) (N-1));
    foreach (i; 0 .. cast(size_t) (N-1)) {
        a[i] = input.front.to!uint;
        input.popFront;
        b[i] = input.front.to!uint;
        input.popFront;
    }

    uint[] p = new uint[](cast(size_t) (Q));
    uint[] x = new uint[](cast(size_t) (Q));
    foreach (i; 0 .. cast(size_t) (Q)) {
        p[i] = input.front.to!uint;
        input.popFront;
        x[i] = input.front.to!uint;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, Q, a, b, p, x);
    else
        solve(N, Q, a, b, p, x).writeln;
}


Measured memory_bytes: 73980
from heapq import heappush, heappop

q = []
N, M = map(int, input().split())
A = map(int, input().split())

for a in A:
    heappush(q, -a)

for _ in range(M):
    item = (-1 * heappop(q)) // 2
    heappush(q, -1 * item)

print(-1 * sum(q))


Measured memory_bytes: 14180
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  solve();
  return 0;
}

void solve() {
  int a, b, h;
  std::cin >> a >> b >> h;
  cout((a + b) * h / 2);
}


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

import numpy as np
dp = [np.Inf for i in range(N)]

# 初期化
dp[0] = 0; 
dp[1] = np.abs(A[1] - A[0]);

for i in range(2,N):
  dp[i] = min(dp[i-1] + np.abs(A[i] - A[i-1]),
              dp[i-2] + np.abs(A[i] - A[i-2]))
  
print(dp[-1])

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

void add(int num[],int *pa){
	*pa=(*pa)-1;
	num[(*pa)-1]+=num[*pa];
	num[*pa]=0;
}

void minus(int num[],int *pa){
	*pa=(*pa)-1;
	num[(*pa)-1]-=num[*pa];
	num[*pa]=0;
}

void multiply(int num[],int *pa){
	*pa=(*pa)-1;
	num[(*pa)-1]*=num[*pa];
	num[*pa]=0;
}

int main(){
	int i,n,j,k,num[200];
	char s[1000];int curnum=0;
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			add(num,&curnum);
		}
		else if(s[0]=='-'){
			minus(num,&curnum);
		}
		else if(s[0]=='*'){
			multiply(num,&curnum);
		}
		else{
			sscanf(s,"%d",&num[curnum]);
			curnum++;
		}
	}
	printf("%d\n",num[0]);
}


Measured memory_bytes: 2736
#include <stdio.h>

int main(void)
{
	float s500, s1000;
	
	while (~scanf("%f %f", &s500, &s1000)){
		if (s500 < 35.50 && s1000 < 71.0){
			puts("AAA");
		} else if (s500 < 37.50 && s1000 < 77.0){
			puts("AA");
		} else if (s500 < 40.0 && s1000 < 83.0){
			puts("A");
		} else if (s500 < 43.0 && s1000 < 89.0){
			puts("B");
		} else if (s500 < 50.0 && s1000 < 105.0){
			puts("C");
		} else if (s500 < 55.0 && s1000 < 116.0){
			puts("D");
		} else if (s500 < 70.0 && s1000 < 148.0){
			puts("E");
		} else {
			puts("NA");
		}
	}
	
	return (0);
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {

	int N;
	ArrayList<Integer>[] graph;

	@SuppressWarnings("unchecked")
	public void solve() {
		N = nextInt();

		graph = new ArrayList[N];
		for(int i = 0;i < N;i++){
			graph[i] = new ArrayList<>();
		}

		for(int i = 0;i < N-1;i++){
			int a = nextInt()-1;
			int b = nextInt()-1;

			graph[a].add(b);
			graph[b].add(a);
		}

		int[][] color = new int[N][2];
		for(int i = 0;i < N;i++){
			color[i][0] = Integer.MAX_VALUE;
			color[i][1] = Integer.MAX_VALUE;
		}

		bfs(0,color);
		bfs(1,color);

		int count = 0;

		for(int i = 0;i < N;i++){
			if(color[i][0] <= color[i][1]){
				count++;
			}
		}

		out.println(count > N - count ? "Fennec" : "Snuke");
	}

	private void bfs(int ind,int[][] color){
		ArrayDeque<int[]> q = new ArrayDeque<int[]>();

		if(ind == 0){
			q.add(new int[]{0,0});
		}else{
			q.add(new int[]{N-1,0});
		}

		boolean[] used = new boolean[N];

		while(q.size() > 0){

			int[] d = q.poll();

			int now = d[0];
			int time = d[1];
			if(used[now])continue;
			used[now] = true;
			color[now][ind] = time;

			for(int next : graph[now]){
				if(used[next])continue;
				q.add(new int[]{next,time + 1});
			}
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 54192
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        System.out.println(combi(n) + combi(m));
    }

    static int combi(int a) {
        if(a == 1 || a == 0) {
            return 0;
        }else if(a == 2) {
            return 1;
        }else {
            return a * (a-1) / 2;
        }
    }
}

Measured memory_bytes: 21972
n, k = gets.chomp.split.map(&:to_i)
kn = (Math.log(k) / Math.log(2)).ceil
count = Rational(0, 1)
pos = n + 1
(kn + 1).times do |i|
  nextpos = k.fdiv(2 ** i).ceil
  if pos >= nextpos then
    count += Rational(pos - nextpos, n * (2 ** i))
    pos = nextpos
  end
end
puts count.to_f


Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };




int main(){
	int n;
	string s;
	cin >> n >> s;

	int cntr = 0;
	int cntb = 0;
	rep(i, 0, n) {
		if (s[i] == 'R')cntr++;
		else cntb++;
	}

	if (cntr > cntb)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc,char* argv[]){
  int furui[1000000];
  int f,tmp;
  int n,count;

  for(tmp = 0;tmp < 1000000;++tmp){
    furui[tmp] = 1; 
  }
  furui[0] = furui[1] = 0;
  
  for(f = 2;f <= 1000; ++f){
    if(furui[f] == 0){continue;}
    for(tmp = 0;tmp < 1000000;++tmp){
      if(furui[tmp] == 0){continue;}
      if(tmp%f == 0 && tmp!= f){
	furui[tmp] = 0;
      }
    }
  }
  
  while(scanf("%d",&n) != EOF){
    count = 0;
    for(tmp = 0;tmp <= n;++tmp){
      if(furui[tmp] == 1){++count;}
    }
    
    printf("%d\n",count);
  }
  
  return 0;
}

Measured memory_bytes: 4316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<ctime>
#include<iomanip>
using namespace std;
int a[200008];
int e[200008];
int res[200008];
int n;
int check(int mid)
{
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=mid)e[i]=1;else e[i]=0;
	}
	int befi=0,beft=0;
	for(int i=1;i<n;i++)
	{
		if(e[i]==e[i+1])
		{
			if(befi==0)
			{
				for(int j=befi+1;j<=i+1;j++) res[j]=e[i];
			}
			else
			{
				if(e[i]==beft)
				{
					for(int j=befi+1;j<=i-1;j++) res[j]=e[i];
				}
				if(e[i]!=beft)
				{
					int brd=(befi+1+i-1)/2;
					for(int j=befi+1;j<=brd;j++) res[j]=beft;
					for(int j=brd+1;j<=i-1;j++) res[j]=e[i];
				}res[i]=res[i+1]=e[i+1];
			}
			befi=i+1,beft=e[i];
		}
	}
	for(int i=befi+1;i<=n;i++) 
	{
		if(befi!=0)res[i]=beft;
		else res[i]=e[1];
	}
//	for(int i=1;i<=n;i++) cout<<mid<<"--"<<res[i]<<" ";cout<<"\n\n";
	return res[n/2+1];
}
int main()
{
	cin>>n;n=n*2-1;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int l=1,r=n;int ans=0;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid))
		{
			l=mid+1;ans=mid;
		}
		else
		{
			r=mid-1;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 2560
#include <functional>
#include <list>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <deque>
#include <stack>
#include <cassert>
using namespace std;
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define ALL(x) (x).begin(),(x).end()
#define CASET2 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d:\n", case_n++) : 0), ___T-- > 0)
#define CASET1 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d: ", case_n++) : 0), ___T-- > 0)
#define CASET int ___T; scanf("%d ", &___T); while (___T-- > 0)
#define SZ(X) ((int)(X).size())
#define LEN(X) strlen(X)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define PER1(i,a,b) for(int i=(a);i>=(b);i--)
#define REPL(i,x) for(int i=0;x[i];i++)
#define PER(i,n) for(int i=(n)-1;i>=0;i--)
#define RI1(x) scanf("%d",&x)
#define RI2(x,y) RI1(x), RI1(y)
#define RI3(x,y...) RI1(x), RI2(y)
#define RI4(x,y...) RI1(x), RI3(y)
#define RI5(x,y...) RI1(x), RI4(y)
#define RI6(x,y...) RI1(x), RI5(y)
#define GET_MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define RI(argv...) GET_MACRO(argv, RI6, RI5, RI4, RI3, RI2, RI1)(argv)
#define DRI(argv...) int argv;RI(argv)
#define WRI(argv...) while (RI(argv) != EOF)
#define DWRI(x...) int x; WRI(x)
#define RS(x) scanf("%s",x)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define X first
#define Y second
#define V(x) vector<x >

typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
const int INF = 1000000000;

void print(int i) { printf("%d", i); }
void print(LL i);
template<class T> void PI(T i) { print(i); puts(""); }
template<class T> void PIS(T i) { print(i); printf(" "); }

template<class T>
void PV(T const &v, int N) {
    REP(i, N) {
        print(v[i]);
        printf("%c", i == N-1 ? '\n' : ' ');
    }
}

template<class T> void PV(T const &v) { PV(v, SZ(v)); }

template<class T, class S> bool has_bit(T mask, S i) { return (mask >> i) & 1; }
long long shift(int i) { return 1ll << i; }

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
int popcount(int x) { return __builtin_popcount(x); } 
int popcount(long long x) { return __builtin_popcountll(x); } 

#include <unordered_set>
#include <unordered_map>
#define EB emplace_back
#define RL(x) scanf("%lld", &(x))
#define PL(x) printf("%lld\n", x)
#define DRL(x) LL x; RL(x)

int main() {
    DRI(N, A, B);
    int f[3] = {};
    REP(i, N) {
        DRI(p);
        if (p <= A) {
            f[0]++;
        } else if (p <= B) {
            f[1]++;
        } else {
            f[2]++;
        }
    }
    PI(min(f[0], min(f[1], f[2])));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
    int A[3]={},dsum;

    cin>>A[0]>>A[1]>>A[2];

    sort(A,A+3);

    
    cout<<abs(A[2]-A[1])+abs(A[1]-A[0])<<endl;

    return 0;
}


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

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;
const double PI=acos(-1);

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double ans;
    if(2 * x >= a * a * b){
        double num = 2 * ((a * a * b) - x) / (a * a * a);
        ans = atan(num);
    }else{
        double num;
        num = (a * b * b) / (2 * x);
        ans = atan(num);
    }
    ans = ans * (360 / (2 * PI));
    printf("%.12lf\n", ans);
}

Measured memory_bytes: 3928
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    string s;
    cin >> s;
    rep(i,3){
        if(s[i]=='1')s[i]='9';
        else if(s[i]=='9')s[i]='1';
    }
    cout << s << endl;
    return 0;

}

Measured memory_bytes: 256
# def makelist(n, m):
#     return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# 
# s = input()


n, a, b = map(int, input().split())
ar = "Alice"
bo = "Borys"

if (b - a) % 2 == 0:
    print(ar)
else:
    print(bo)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int ni,nj;
V<P<int,int> > ans;
bool anf;
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	int x,y,k;
	cin>>k>>x>>y;
	int f1,f2;
	if(x<0)f1=-1;else f1=1;
	if(y<0)f2=-1;else f2=1;
	if(abs(x)>abs(y))swap(x,y),anf=1;
	x=abs(x);y=abs(y);
	if(x+y==k){
		if(anf)swap(x,y);
		cout<<"1\n"<<x*f1<<' '<<y*f2<<'\n';RE 0;
	}
	int t=x+y;
	if((t&1)&&!(k&1)){
		cout<<-1;RE 0;
	}
	int s=t/k+(t%k!=0);
	s*=k;
	while((s-t)&1||s/k<=1)s+=k;
	int d=(s-t)>>1;
	while(d>=k){
		nj-=k;d-=k;ans.PB(MP(ni,nj));
	}
	ni-=d;nj+=k-d;ans.PB(MP(ni,nj));
	while(ni+k<=x){
		ni+=k;ans.PB(MP(ni,nj));
	}
	while(nj+k<=y){
		nj+=k;ans.PB(MP(ni,nj));
	}
	if(ni!=x||nj!=y){
		ans.PB(MP(x,y));
	}
	cout<<ans.size()<<'\n';
	for(int i=0;i<ans.size();i++){
		if(anf)swap(ans[i].F,ans[i].S);
		cout<<ans[i].F*f1<<' '<<ans[i].S*f2<<'\n';
	}
	RE 0;
}




Measured memory_bytes: 3952
#define y1 askjdkasldjlkasd
#include <bits/stdc++.h>
#undef y1

using namespace std;

#define pb push_back
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<ll> vll;

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while (0)
#endif

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

///////////////////////////////////////////////////

const int MAX = 5e5 + 41;

int n;
char s[MAX];
int a[MAX];

void solve () {
	fi(1, n) {
		if (s[i] == '<') {
			a[i] = max(a[i], a[i - 1] + 1);
		}
	}
	fdi(n - 1, 0) {
		if (s[i + 1] == '>') {
			a[i] = max(a[i], a[i + 1] + 1);
		}
	}
	ll ans = accumulate(a, a + n + 1, 0LL);	
	printf("%lld\n", ans);
//	dbg0(a, n + 1);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif
	
	scanf("%s", s + 1);
	n = strlen(s + 1);
	solve();

	exit();
	return 0;
}





Measured memory_bytes: 2688
import math

target = int(input())
while True:
  eval_val = int(math.sqrt(target))
  not_sosuu = False
  for i in range(2,eval_val):
    if target % i == 0:
      not_sosuu = True
      break

  if not_sosuu == False:
    print(str(target))
    break
  else:
    target += 1

Measured memory_bytes: 3060
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    string x;
    cin >> x;

    int s = 0;
    int num = 0;
    REP(i, x.size()) {
        char c = x[i];
        if (c == 'S') {
            s++;
        }
        else {
            if (s > 0) {
                s--;
                num++;
            }
        }
    }
    cout << x.size() - num * 2 << endl;
    return 0;
}


Measured memory_bytes: 720
#include<iostream>
#include<algorithm>

using namespace std;

#define INFTY 1000000001

typedef struct card{
  char mark;
  int num;
} card;

//安定で高速
void merge(card *A, int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int i, j;

  card L[n1 + 10], R[n2 + 10];
  for(i = 0;i < n1;i++) L[i] = A[left + i];
  for(i = 0;i < n2;i++) R[i] = A[mid + i];

  L[n1].num = INFTY;
  R[n2].num = INFTY;

  i = 0;
  j = 0;

  for(int k = left;k < right;k++){
    if(L[i].num <= R[j].num){
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(card *A, int left, int right){
  if(left + 1 < right){
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int partition(card *A, int p, int r){
  int x = A[r].num;
  int i = p - 1;
    for(int j = p;j < r;j++){
      if(A[j].num <= x){
        i++;
        swap(A[i], A[j]);
      }
    }
    swap(A[i + 1], A[r]);
  return i + 1;
}

void quicksort(card *A, int p, int r){
  if(p < r){
    int q = partition(A, p, r);
    quicksort(A, p, q - 1);
    quicksort(A, q + 1, r);
  }
}

int main(){

  int n;
  card a[100010], b[100010];

  cin >> n;
  for(int i = 0;i < n;i++){
    char mark;
    int num;

    cin >> mark >> num;
    a[i].mark = mark;
    a[i].num = num;
    b[i].mark = mark;
    b[i].num = num;
  }

  quicksort(a, 0, n - 1);
  mergeSort(b, 0, n);

  bool flag = true;
  for(int i = 0;i < n;i++){
    if(a[i].mark != b[i].mark){
      flag = false;
      break;
    }
  }

  if(flag) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  for(int i = 0;i < n;i++) cout << a[i].mark << ' ' << a[i].num << endl;

  return 0;
}



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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);

  int N, K; cin >> N >> K;
  vector<ll> v(N);
  for(int i = 0; i < N; i++){
    cin >> v[i];
  }

  for(int i = K; i < N; i++){
    if(v[i] > v[i-K]) { 
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 4836
#include<bits/stdc++.h>
#include<ext/pb_ds/priority_queue.hpp>
#define For(i,a,b) for(i=(a);i<=(b);++i)
#define Forward(i,a,b) for(i=(a);i>=(b);--i)
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define Chkmin(a,b) a=a<b?a:b
#define Chkmax(a,b) a=a>b?a:b
using namespace std;
using namespace __gnu_pbds;
template<typename T>inline void read(T &x)
{
    T s=0,f=1;char k=getchar();
    while(!isdigit(k)&&(k^'-'))k=getchar();
    if(!isdigit(k)){f=-1;k=getchar();}
    while(isdigit(k)){s=s*10+(k^48);k=getchar();}
    x=s*f;
}

typedef long long ll;

static string s;

static int w;

inline void solve()
{
	cin>>s;
	read(w);
	static int cnt=w-1;
	for(char t:s)
	{
		++cnt;
		if(cnt<w)continue;
		putchar(t);
		cnt=0;
	}
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
n = int(input())
As = input().split()
A = [int(i) for i in As]
c = 0

for i in range(n-1):
    mini = i
    j = i
    while n > j:
        if A[j] < A[mini]:
            mini = j
        j += 1
    if i != mini:
        w = A[i]
        A[i] = A[mini]
        A[mini] = w
        c += 1

for i in range(n-1):
    print("{} ".format(A[i]), end="")
print(A[n-1])
print(c)



Measured memory_bytes: 5608
#include <bits/stdc++.h>
 
using namespace std;
 
struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};
 
 
template< typename T, typename F >
T boruvka(int N, F f) {
  vector< int > rev(N), belong(N);
  UnionFind uf(N);
  T ret = T();
  while(uf.size(0) != N) {
    int ptr = 0;
    for(int i = 0; i < N; i++) {
      if(uf.find(i) == i) {
        belong[i] = ptr++;
        rev[belong[i]] = i;
      }
    }
    for(int i = 0; i < N; i++) {
      belong[i] = belong[uf.find(i)];
    }
    auto v = f(ptr, belong);
    bool update = false;
    for(int i = 0; i < ptr; i++) {
      if(~v[i].second && uf.unite(rev[i], rev[v[i].second])) {
        ret += v[i].first;
        update = true;
      }
    }
    if(!update) return -1; // notice!!
  }
  return ret;
}
 
template< typename T >
struct edge {
  int src, to;
  T cost;
 
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
 
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
 
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
 
  operator int() const { return to; }
};
 
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
 
int main() {
  int V, E;
  cin >> V >> E;
  Edges< int > g;
  for(int i = 0; i < E; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    g.emplace_back(x, y, z);
  }
  const int INF = 1 << 30;
  auto f = [&](int sz, vector< int > belong) {
    vector< pair< int, int > > ret(sz, {INF, -1});
    for(auto &e : g) {
      if(belong[e.src] == belong[e.to]) continue;
      ret[belong[e.src]] = min(ret[belong[e.src]], make_pair(e.cost, belong[e.to]));
      ret[belong[e.to]] = min(ret[belong[e.to]], make_pair(e.cost, belong[e.src]));
    }
    return ret;
  };
  cout << boruvka< int, decltype(f) >(V, f) << endl;
}


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

int main(void) {
  int A, B, C;
  cin >> A >> B >> C;
  if (A==B && B!=C) {
    cout << "Yes" << endl;
  } else if (B==C && B!=A) {
    cout << "Yes" << endl;
  } else if (C==A && A!=B) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if (n % 2 == 0)
      System.out.println((double)(n / 2) / n);
    else
      System.out.println(((double)(n + 1) / 2) / n);
  }
}


Measured memory_bytes: 35844
#include <iostream>
#include <vector>

using namespace std;

void PrintTestCase(vector<int> Data){
    for (int i = 0; i>=0; i++) {
        if (Data[i] == 0)
            break;
        cout << "Case " << i+1 << ": " << Data[i] << endl;
    }
}

int main(){
    // ---------------------------
    // ITP_1_3_A: Many Hello World
//    HelloWorldloop(1000);
    // ---------------------------

    // ---------------------------
    // ITP_1_3_B: Print Test Case
    std::vector<int> data;
    int in;
    for (int i = 0; i >= 0; i++){
        std::cin >> in;
        data.push_back(in);
        if (data[i] == 0) {
            PrintTestCase(data);
            break;
        }
    }
    // ---------------------------

    // ---------------------------
    // ITP_1_3_C: Small, Large, or Equal
    // ---------------------------

    // ---------------------------
    // ITP_1_3_D: Small, Large, or Equal
    // ---------------------------

    return 0;
}


Measured memory_bytes: 3236