akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

ll a[100000];
int b[100000];

int main(void) {
    int i, n;
    scanf("%d",&n);
    REP (i,n) scanf("%lld%d",&a[i],&b[i]);
    ll ans = 0;
    RREP (i,n) {
        a[i] += ans;
        if (a[i] % b[i] == 0) continue;
        int x = b[i] - a[i] % b[i];
        ans += x;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1408
N, M = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7
H =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

AB=[]
for m in range(M):
	a,b = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7
	AB.append([a-1,b-1])

X=[0]*N
for a,b in AB:
	
	X[a] = max(X[a], H[b])
	X[b] = max(X[b], H[a])

ans=0
for i in range(N):
	if H[i] > X[i]: ans += 1

print(ans)
	

Measured memory_bytes: 28884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  ll n, d;
  cin >> n >> d;

  vector<ll> x(n), y(n);

  for (ll i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }

  int count = 0;
  for (ll i = 0; i < n; i++) {
    if (d * d >= x[i] * x[i] + y[i] * y[i]) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 6348
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.ReadLine();
        }

        public void Solve(ConsoleInput cin)
        {
            char[] list = cin.Read.ToCharArray();

            if (list[0] == list[1] && list[1] == list[2]) Console.WriteLine("Yes");
            else if (list[1] == list[2] && list[2] == list[3]) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long num) { var ret = new string[num]; for (long i = 0; i < num; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long num) { var ret = new int[num]; for (long i = 0; i < num; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long num) { var ret = new long[num]; for (long i = 0; i < num; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 222;
int l[MAXN];
int main()
{
        // freopen("../in.txt","r",stdin);
        // freopen("../out.txt","w",stdout);
        int w, h, x, y;
        while(cin>>w>>h>>x>>y)
        {
                if(x*2==w&&y*2==h)
                        printf("%.6f 1\n",(double)w*h/2.0);
                else
                        printf("%.6f 0\n",(double)w*h/2.0);

        }
        return 0;
}


Measured memory_bytes: 384
import itertools

N = int(input())
P = list(map(str,input().split()))
Q = list(map(str,input().split()))

A = sorted(P)
count=0

for v in itertools.permutations(A, N):
    if P == list(v):
        p_cou = count
    if Q == list(v):
        q_cou = count
    count += 1

print(abs(q_cou-p_cou))

Measured memory_bytes: 3064
#include <iostream>

int main(void)
{
    int a, b, c;

    std::cin >> a;
    std::cin >> b;
    std::cin >> c;

    if (b < c && a < b) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3088
import sys
import bisect

# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    S = list(input())
    T =list(input())

    G =[[] for _ in range(26)]

    orda =ord("a")

    for i in range(len(S)):
        G[ord(S[i])-orda].append(i)

    count =0
    p=-1
    for j in range(len(T)):
        tord = ord(T[j]) -orda
        if G[tord]!=[]:
            if G[tord][-1]<p+1:
                p=-1
                count+=1

            gp =bisect.bisect_left(G[tord],p+1)
            p =G[tord][gp]

        else:
            print(-1)
            exit()


    print(count * len(S)+p+1)





if __name__ == "__main__":
    main()


Measured memory_bytes: 87512
import sys

sys.setrecursionlimit(100000)

timer = 0

def dfs(current, prev, g, visited, prenum, parent, lowest):
    global timer
    prenum[current] = timer
    lowest[current] = timer
    timer += 1

    visited[current] = True

    for i in range(len(g[current])):
        next_node = g[current][i]
        if not visited[next_node]:
            parent[next_node] = current
            dfs(next_node, current, g, visited, prenum, parent, lowest)
            lowest[current] = min(lowest[current], lowest[next_node])
        elif next_node != prev:
            lowest[current] = min(lowest[current], prenum[next_node])


def art_points(n, g):
    visited = [False] * n
    INFTY = 1 << 20
    prenum = [INFTY] * n
    parent = [INFTY] * n
    parent[0] = -1
    lowest = [INFTY] * n
    global timer
    timer = 1
    dfs(0, -1, g, visited, prenum, parent, lowest)

    ap = set()
    np = 0
    for i in range(1, n):
        p = parent[i]
        if p == 0:
            np += 1
        elif prenum[p] <= lowest[i]:
            ap.add(p)
    if np > 1:
        ap.add(0)
    for line in sorted(ap):
        print(line)


if __name__ == '__main__':
    n, m = [int(v) for v in input().split()]
    g = [[] for i in range(n)]
    for i in range(m):
        s, t = [int(v) for v in input().split()]
        g[s].append(t)
        g[t].append(s)

    art_points(n, g)


Measured memory_bytes: 19792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N;
LL H[5001], P[5001];
LL dp[5001][5001];

int main(void)
{
	cin >> N;
	vector<pair<LL, LL>>vec;
	for (int i = 0; i < N; ++i) {
		cin >> H[i] >> P[i];
		vec.push_back({ P[i] + H[i],H[i] });
	}
	sort(vec.begin(), vec.end());

	for (int i = 0; i < N; ++i) {
		P[i] = vec[i].first - vec[i].second;
		H[i] = vec[i].second;
	}
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= i; ++j) {
			if (dp[i][j] <= H[i]) {
				dp[i + 1][j + 1] =
					min(dp[i + 1][j + 1],
						dp[i][j] + P[i]);
			}
			dp[i + 1][j] =
				min(dp[i + 1][j],
					dp[i][j]);
		}
	}
	for (int i = N; i >= 0; --i) {
		if (dp[N][i] <= 1e13) {
			cout << i << endl;
			return 0;
		}
	}
	return -1;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int dp1[300000],dp2[300000];
int sum[300000];

int main(){
	int n,K,C;cin>>n>>K>>C;C++;
	string s;cin>>s;
	int Max=0;
	rep(i,n){
		if(i-C>=0)Max=max(Max,dp1[i-C]);
		if(s[i]=='o')dp1[i]=Max+1;
		else dp1[i]=Max;
	}
	for(int i=1;i<n;i++){
		dp1[i]=max(dp1[i],dp1[i-1]);
	}
	Max=0;
	for(int i=n-1;i>=0;i--){
		if(i+C<n)Max=max(Max,dp2[i+C]);
		if(s[i]=='o')dp2[i]=Max+1;
		else dp2[i]=Max;
	}
	for(int i=n-2;i>=0;i--){
		dp2[i]=max(dp2[i],dp2[i+1]);
	}
	rep(i,n){
		if(dp1[i]>=K)sum[i+1]++;
		if(i&&dp2[i]>=K){
			sum[0]++;
			sum[i]--;
		}
		if(i+C<n&&dp1[i]+dp2[i+C]>=K){
			sum[i+1]++;
			sum[i+C]--;
		}
		if(i+C+1<n&&dp1[i]+dp2[i+C+1]>=K){
			sum[i+1]++;
			sum[i+C+1]--;
		}
	}
	for(int i=1;i<n;i++)sum[i]+=sum[i-1];
	rep(i,n){
		if(s[i]=='o'&&!sum[i])cout<<i+1<<endl;
	}
}

Measured memory_bytes: 4228
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	int n;
	int a[100000];
	cin>>n;
	for(int i=0;i<100001;i++) a[i]=0;
	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		a[k]++;
	}
	int ans=0,tmp;
	for(int i=0;i<100001;i++){
		if(i==0) tmp=a[i]+a[i+1];
		else if(i==100000) tmp=a[i-1]+a[i];
		else tmp=a[i-1]+a[i]+a[i+1];
		if(ans<tmp) ans=tmp;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
n, m, x, y = map(int, input().split())
xn = list(map(int, input().split()))
ym = list(map(int, input().split()))

xn.sort()
ym.sort()

for z in range(x+1,y+1):
    if xn[-1]< z <=ym[0]:
        print('No War')
        exit()
print('War')


Measured memory_bytes: 9184
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define int long long
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

main(void){
	scanf("%lld",&n);
	FOR{
		scanf("%lld",&a[i]);
	}
	FOR{
		for(int j=i+1;j<=n;j++)cev+=a[i]*a[j];
	}
	printf("%lld\n",cev);
	return 0;
}


Measured memory_bytes: 256
S = input()
first = S[0]
inverse = str(1-int(first))
unit = first+inverse
if len(S) % 2 == 0:
  sample = unit*(len(S)//2)
else:
  sample = unit*(len(S)//2)+first

count = 0
for k in range(len(S)):
  if S[k] != sample[k]:
    count += 1

print(count)


Measured memory_bytes: 3188
#include<stdio.h>

int gcd(int,int);

int main(){
  int x,y;

  scanf("%d %d",&x,&y);
  
  printf("%d\n",gcd(x,y));
   
  return 0;
}
int gcd(int a,int b){
  int ex,r;
  
  if( a < b ){
    ex = a ;
    a = b;
    b = ex;
  }
  while( b > 0 ){
    r = a % b;
    a = b;
    b = r;
  }

  return a;
}



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

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0); //cinとcoutの同期切り
    ios::sync_with_stdio(false); //iostreamとstdioの同期切り

    string S;
    cin >> S;

    string word[4] = {"dream", "dreamer", "erase", "eraser"};
    
    reverse(S.begin(), S.end());
    REP(i, 4) reverse(word[i].begin(), word[i].end());

    bool flag;

    REP(i, S.size()){
        flag = false;
        REP(j, 4){
            cerr << S.substr(i, word[j].size()) << " " << word[j] << endl;
            if(S.substr(i, word[j].size()) == word[j]){
                i += word[j].size() - 1;
                flag = true;
                break;
            }
        }
        if(!flag){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

/*****************************************************************************/
/*****                                                                   *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3"                *****/
/*****   std::cout << std::fixed;                                        *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3.00"             *****/
/*****                                                                   *****/
/*****************************************************************************/

Measured memory_bytes: 512
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, R = LI()
print(R + 100 * max(0, 10 - N))

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

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

	int n, m;
	cin >> n >> m;
	vector<vector<int>> c(m);
	while (n--) {
		int a, b;
		cin >> a >> b;
		if (a <= m)
			c[a - 1].push_back(b);

	}
	int r = 0;
	priority_queue<int> q;
	for (auto& l : c) {
		for (int x : l) {
			q.push(x);
		}
		if (!q.empty()) {
			r += q.top();
			q.pop();
		}
	}
	cout << r << '\n';
	return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

ll check(int N, vector<ll> a){
    sort(a.begin(), a.end(), greater<ll>());
    
    ll K = 0;
    while(true){
        bool change = false;
        for(int i=0;i<N;i++){
            if(a[i] + K >= N){
                change = true;
                ll b = a[i] + K;
                ll k = b / N;
                a[i] -= k * (N + 1);
                K += k;
            }
        }
        if(!change){
            break;
        }
    }
    return K;
}

vector<ll> solve(ll K){
    vector<ll> a;
    int N = 50;
    if(K <= N){
        N = K;
        a.assign(N, N);
    }else{
        ll k = K / N;
        a.assign(N, N - 1 + k);
        ll k_mod = K % N;
        for(int i=0;i<k_mod;i++){
            a[i]++;
        }
        for(int i=k_mod;i<N;i++){
            a[i] -= k_mod;
        }
    }
    return a;
}

int main(){
    ll K;
    cin >> K;

    if(K == 0){
        cout << 2 << endl;
        cout << 0 << " " << 0 << endl;
    }else if(K == 1){
        cout << 2 << endl;
        cout << 2 << " " << 0 << endl;
    }else{
        vector<ll> a = solve(K);
        cout << a.size() << endl;
        cout << a[0];
        for(int i=1;i<a.size();i++){
            cout << " " << a[i];
        }
        cout << endl;
    }

    return 0;
}

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

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

    long long n, p;
    cin >> n >> p;

    if(n == 1){
        cout << p << endl;
        return 0;
    }

    long long tmp = p;

    map<long long, long long> mp;
    for(long long i = 2; i * i <= p; i++){
        if(tmp == 1) break;
        if(tmp % i == 0){
            long long cnt = 0;
            while(tmp % i == 0){
                tmp /= i;
                cnt++;
            }
            mp[i] = cnt;
        }
    }

    long long ans = 1;
    for(auto x : mp){
        for(int i = 0; i < x.second / n; i++){
            ans *= x.first;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right

N = int(input())
dic = []
ans = 0

for i in range(N):
  S = "".join(sorted(input()))
  dic.append(S)

dic.sort()

for i in range(N):
  S = dic[i]
  r = bisect_right(dic, S)
  ans += r-i-1


print(ans)

Measured memory_bytes: 58456
n,m = map(int,input().split())
a = [input().split() for i in range(m)]
p = [int(i[0]) for i in a]
q = [j[1] for j in a]

ac = 0
wa = 0
wa_c = [0]*n
ac_c = [False]*n

for t in range(m):
    if ac_c[p[t]-1]:
        continue
    if q[t] == "AC":
        ac += 1
        ac_c[p[t]-1] = True
        wa += wa_c[p[t]-1]
    else:
        wa_c[p[t]-1] += 1
print(ac,wa)

Measured memory_bytes: 38628
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main()
{
	long long a, b, k;
	cin >> a >> b >> k;

	if (a >= k)
	{
		printf("%lld %lld", a - k, b);
	}
	else
	{
		printf("0 %lld", a + b - k > 0 ? a + b - k : 0);
	}

	return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
N, M = map(int, input().split())
a = [-int(a) for a in input().split()]
heapify(a)
for _ in range(M):
  heappush(a, heappop(a) / 2)
print(-sum(int(x) for x in a))


Measured memory_bytes: 14180
x,n = map(int,input().split())

if n == 0:
    print(x)
    exit()

a = list(map(int,input().split()))

ans = 0
for i in range(1,102):
    if i in a:
        continue
    if abs(x-ans) > abs(x-i):
        ans = i
print(ans)


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

#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
    int N;
    cin >> N;
    int count2 = 0;
    int count4 = 0;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        if(a%4 == 0){
            count4++;
        }else if(a%2 == 0){
            count2++;
        }
    }
    
    if(count4 * 2 + 1 * (bool)count4 + max(count2-1,0) >= N || count2 == N){
        cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long nPr(int n, int r){
  if(n<0 || r<0 || n<r)return 0;
  return (fac[n]*finv[n-r])%MOD;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  COMinit();
  ll n,m;
  cin >> n >> m;
  
  ll ans = 0;
  for(ll i=0;i<=n;i++){
    ll a=COM(n,i)*nPr(m,i);
    a%=MOD;
    a*=nPr(m-i,n-i);
    a%=MOD;
    a*=nPr(m-i,n-i);
    a%=MOD;
    if(i&1)ans -= a;
    else ans += a;
    if(ans > MOD) ans%=MOD;
    else ans+=MOD;
  }
  cout << (ans+MOD)%MOD << endl;
  return 0;
}


Measured memory_bytes: 15528
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
 
    int N,A=0,B=0,a[100];

    cin >> N;

    for(int i=0;i<N;i++)cin >> a[i];

    sort(a, a+N , greater<int>());

    for(int i=0;i<N;i++){
        if(i%2==0){
            A = A + a[i];
        }else{
            B = B + a[i];
        }
    }

    cout << A-B <<endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
total,min_total = 0, 1
for s in S:
    total += 1 if s == '(' else -1
    if total < min_total:
        min_total = total    
print('('*-min_total+S+')'*(total-min_total) if min_total<0 else S+')'*total)

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

vector<int> erat(int n) {
    vector<int> primes(n);
    for (int i = 2; i < n; ++i) primes[i] = i;
    for (int i = 2; i*i < n; ++i)
        if (primes[i])
            for (int j = i*i; j < n; j+=i) primes[j] = 0;
    // ?´???°?????????vector???????´?????????´????????\?????????????????? (0 ??§??????????´??????¨??????)
    primes.erase(remove(primes.begin(), primes.end(), 0), primes.end());
    return primes;
}

signed main() {
    int n;
    while(cin >> n, n) {
        int up = erat(2*n+1).size();
        int dn = erat(n+1).size();
        cout << up - dn << endl;
    }
    return 0;
}

Measured memory_bytes: 5924
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int a[] = new int[n];
		int b[] = new int[n];
		int c[] = new int[n];
		for ( int i = 0; i < n; i++ ) {
			a[i] = in.nextInt();
			b[i] = in.nextInt();
			c[i] = in.nextInt();
		}

		int dpA[] = new int[n];
		int dpB[] = new int[n];
		int dpC[] = new int[n];
		dpA[0] = a[0];
		dpB[0] = b[0];
		dpC[0] = c[0];

		for ( int i = 1; i < n; i++ ) {
			dpA[i] = a[i] + Math.max(dpB[i - 1], dpC[i - 1]);
			dpB[i] = b[i] + Math.max(dpA[i - 1], dpC[i - 1]);
			dpC[i] = c[i] + Math.max(dpB[i - 1], dpA[i - 1]);
		}

		System.out.println(Math.max(dpA[n - 1], Math.max(dpB[n - 1], dpC[n - 1])));
		in.close();
	}
}

Measured memory_bytes: 92648
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve(); int main() { solve(); return 0; }

void solve() {
  char n;
  cin >> n;
  if (isupper(n)) cout << "A" << endl;
  else cout << "a" << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359

struct st {
  vector<st> *pre;
  vector<st> *next;
  ll max;
};

int main() {
  char A;
  cin >> A;
  if (A >= 'A' && A <= 'Z') {
    cout << "A" << endl;
  } else {
    cout << "a" << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.InputMismatchException;


public class Main {
	
	private static int[][] cache;
	private static int[] r;
	private static int[] c;
	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int n = sc.nextInt();
		r = new int[n];
		c = new int[n];

		for (int i = 0; i < n; i++) {
			r[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}

		// 再帰的トップダウン型、履歴管理
		cache = new int[n][n];
		for (int i = 0; i < n; i++) {
			Arrays.fill(cache[i], Integer.MIN_VALUE);
		}

		int ret = mcm(0, n -1);
		
		System.out.println(ret);
		
		sc.close();
	}
	
	private static int mcm(int i, int j) {
		if (cache[i][j] >= 0) {
			return cache[i][j];
		}
		
		if (i == j) {
			cache[i][j] = 0;
			return 0;
		} else {
			int min = Integer.MAX_VALUE;
			for (int k = 0; k < j - i; k++) {
				assert c[i+k] == r[i+k+1];
				min = Math.min(min, mcm(i, i + k) + r[i] * r[i+k+1] * c[j] + mcm(i + k + 1, j));
			}
			cache[i][j] = min;
			return min;
		}
	}

	@SuppressWarnings("unused")
	private static class Scanner {
		InputStreamReader isr;
		BufferedReader br;
		StreamTokenizer st;

		private Scanner() {
		}

		Scanner (InputStream in) {
			isr = new InputStreamReader(in);
			br = new BufferedReader(isr);
			st = new StreamTokenizer(br);
		}

		String next() throws RuntimeException  {
			try {
				if (st.nextToken() != StreamTokenizer.TT_WORD) {
				}
			} catch (IOException e) {
				throw new IllegalStateException();
			}

			return st.sval;
		}

		int nextInt() throws RuntimeException {
			try {
				if (st.nextToken() != StreamTokenizer.TT_NUMBER) {
					throw new InputMismatchException();
				}
			} catch (IOException e) {
				throw new IllegalStateException();
			}

			return (int)st.nval;
		}

		void close() {
		}
	}
}

Measured memory_bytes: 21236
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }

    ll root(ll x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    ll size(ll x) {
        return -par[root(x)];
    }
};

int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int n,m;
    cin >> n >> m;
    UnionFind tr(n);
    vector<int> a(m);
    vector<int> b(m);
    rep(i,m){
      cin >> a[i] >> b[i];
      --a[i], --b[i];
    }
    int ans = 0;
    rep(i,m){
      UnionFind tr(n);
      rep(j,m){
        if(i == j) continue;
        tr.merge(a[j],b[j]);
      }
      if((!tr.issame(a[i],b[i]))) ans++; 
    }
    print(ans);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int n,x,t,i,y;
    scanf("%d%d%d",&n,&x,&t);
    i=n%x;
    y=n/x;
    if(i==0)
        printf("%d",y*t);
    if(i!=0)
        printf("%d",(y+1)*t);

    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define F first
#define S second
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

li a[10000], sum[10000];

int main(){
	li n;
	cin>>n;
	while(n>0){
		rin{cin>>a[i];}
		
		sum[0]=0;
		rin{
			sum[i+1]=a[i]+sum[i];
		}
		li res=-100000*5005;
		
		rep(i,n){
			repp(j,i+1,n+1){
				res=max(res,sum[j]-sum[i]);
			}
		}
		cout<<res<<endl;
		
		cin>>n;
	}
	
	return 0;
}

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

struct Node {
    int key;
    Node *parent, *lc, *rc;
};

Node *root, *NIL;

void pre(Node *n) { // 先行順巡回
    if (n == NIL) return;
    cout << " " << n->key;
    pre(n->lc);
    pre(n->rc);
}

void in(Node *n) { // 中間順巡回
    if (n == NIL) return;
    in(n->lc);
    cout << " " << n->key;
    in(n->rc);
}

void insert(int k) {
    Node *y = NIL;
    Node *x = root;

    Node *z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->lc = NIL;
    z->rc = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->lc;
        } else {
            x = x->rc;
        }
    }
    z->parent = y;

    if (y == NIL) {
        root = z;
    } else if (z->key < y->key) {
        y->lc = z;
    } else {
        y->rc = z;
    }
}

bool find(Node *r, int k) {
    if (r == NIL) return false;
    if (r->key == k) {
        return true;
    } else {
        if (r->key < k) {
            return find(r->rc, k);
        } else { // r->key > k
            return find(r->lc, k);
        }
    }
}

Node* getMin(Node *x) {
    while (x->lc != NIL) {
        x = x->lc;
    }
    return x;
}

Node* getSuccessor(Node *x) {
    if (x->rc != NIL) return getMin(x->rc);

    Node *y;
    y= x->parent;
    while (y != NIL || x == y->rc) {
        x = y;
        y = y->parent;
    }
    return y;
}

void deleteNode(int k) {
    Node *r = root;
    while (r->key != k && r != NIL) {
        if (r->key < k) {
            r = r->rc;
        } else {
            r = r->lc;
        }
    }
    if (r == NIL) return;

    Node *x, *y;
    // 消す節点を決める
    if (r->lc == NIL || r->rc == NIL) y = r;
    else y = getSuccessor(r);
    // 消す節点の子を確認する
    if (y->lc != NIL) x = y->lc;
    else x = y->rc;

    // 消す節点の子の編集
    if (x != NIL) // 消す節点に子がいれば、その親には消す節点の親を設定
        x->parent = y->parent;

    // 消す節点の親の編集
    if (y->parent == NIL) { // 消す節点が全体の根
        root = x;
    } else if (y == y->parent->lc) { // 消す節点が、その親からみたときの左
        y->parent->lc = x;
    } else { // y == y->parent->rc // 消す節点が、その親から見たときの右
        y->parent->rc = x;
    }

    if (y != r) r->key = y->key;

    free(y);
}

int main() {
    int n, i;
    cin >> n;

    string op;
    int input;
    rep(i, n) {
        cin >> op;
        if (op == "insert") {
            cin >> input;
            insert(input);
        } else if (op == "print") {
            in(root);
            cout << endl;
            pre(root);
            cout << endl;
        } else if (op == "find") {
            cin >> input;
            if (find(root, input)) cout << "yes" << endl;
            else cout << "no" << endl;
        } else if (op == "delete") {
            cin >> input;
            deleteNode(input);
        }
    }

    return 0;
}



Measured memory_bytes: 21904
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	int d;
	while(cin>>d,d){
		int n,m;
		cin>>n>>m;
		vi in(n-1);
		rep(i,n-1)cin>>in[i];
		in.pb(0);
		sort(all(in));
		int out=0;
		while(m--){
			int a;
			cin>>a;
			int t=lower_bound(all(in),a)-in.begin();
			// 0 8 12 16
			int s=inf;
			if(t!=n)s=in[t]-a;
			else s=d-a;
			if(t)s=min(s,a-in[t-1]);
			out+=s;
		}
		cout<<out<<endl;
	}
}

Measured memory_bytes: 1796
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;
vector<double> p;

double memo[3001][3001];

double dp() {
	memo[0][0] = 1;
	for (int i = 1;i <= N;i++) {
		for (int j = 0;j <= i;j++) {
			memo[i][j] = memo[i - 1][j] * (1 - p[i - 1]);
			if (j > 0) memo[i][j] += memo[i - 1][j - 1] * p[i - 1];
		}
	}
	double tmp = 0;
	for (int i = N / 2 + 1;i <= N;i++) {
		tmp += memo[N][i];
	}
	return tmp;
}

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

	cin >> N;
	p.resize(N);
	REP(i, N) cin >> p[i];
	printf("%.10lf\n", dp());
	
	return 0;
}

Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

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


int main() {
  int a[3][3];
  rep(i, 3) rep(j, 3) cin>>a[i][j];
  int n; cin>>n;
  rep(i, n) {
    int b; cin>>b;
    rep(j, 3) rep(k, 3) if (a[j][k] == b) a[j][k] = 0;
  }
  bool flag = false;
  rep(i, 3) if (a[i][0]==0 and a[i][1]==0 and a[i][2]==0) flag = true;
  rep(i, 3) if (a[0][i]==0 and a[1][i]==0 and a[2][i]==0) flag = true;
  if (a[0][0]==0 and a[1][1]==0 and a[2][2]==0) flag = true;
  if (a[0][2]==0 and a[1][1]==0 and a[2][0]==0) flag = true;
  if (flag) print("Yes");
  else print("No");

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int l=sc.nextInt();
        String a[]=new String[n];
        for(int i=0;i<n;i++){
        	a[i]=sc.next();
        }
        Arrays.sort(a);
         for(int i=0;i<n;i++){
        	System.out.print(a[i]);
        }
    }
}


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

using namespace std;
using ll = long long;
#define endl '\n'
#define all(v) v.begin(), v.end()

int main() {
    int d, s, t;
    cin >> d >> t >> s;
    if (d <= t*s) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

string s;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s;
	reverse(s.begin(), s.end());

	string candidate[4] = {"dream", "dreamer", "erase", "eraser"};
	for(int i = 0; i < 4; i++) reverse(candidate[i].begin(), candidate[i].end());
	int i = 0;
	while(i < s.size()) {
		bool flag = false;
		for(int j = 0; j < 4; j++) {
			string d = candidate[j];
			if(s.substr(i, d.size()) == d) {
				i += d.size();
				flag = true;
				if(flag) break;
			}
		}
		
		if(!flag) {
			cout << "NO" << endl;
			return 0;
		}


	}
	cout << "YES" << endl;
}
	


Measured memory_bytes: 512
#ABC088-C
grid = [list(map(int,input().split())) for _ in range(3)]
flg = True
b1 = grid[0][0]
b2 = grid[0][1]
b3 = grid[0][2]
if grid[1][0] - b1 == grid[1][1] - b2 == grid[1][2] - b3:
    a2 = grid[1][0] - b1
else:
    flg = False
if grid[2][0] - b1 == grid[2][1] - b2 == grid[2][2] - b3:
    a3 = grid[2][0] - b1
else:
    flg = False
    
if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

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

class CompareDist
{
public:
    bool operator()(PLL n1,PLL n2) {
				if(n1.first!=n2.first) return n1.first<n2.first;
				else return n1.second<n2.second;
    }
};


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll wa(ll x){
  return x*(1+x)/2;
}


signed main(){
	string s; cin>>s;
  ll n = s.size();
  ll l = 0, g = 0, ans = 0;
  queue<ll> L, G;
  rep(i,n-1){
    if(s[i]=='>') l++;
    else g++;

    if(s[i]!=s[i+1]){
      if(l){
        L.push(l);
        cerr << -l << endl;
        l=0;
      }else{
        G.push(g);
        cerr << g << endl;
        g=0;
      }
    }
  }
  if(s[n-1]=='<') G.push(g+1), cerr<<g+1<<endl;
  else L.push(l+1), cerr<<-l-1<<endl;

  cerr << "INPUT END"<< endl;
  if(s[0]=='>') ans+=wa(L.front()), L.pop();
  while(!L.empty()&&!G.empty()){
    l=L.front(); L.pop();
    g=G.front(); G.pop();
    ans += wa(max(g,l))+wa(min(g,l)-1);
    cerr << ans << ' ';
  }
  if(s[n-1]=='<') ans+=wa(G.front()), G.pop();
  cerr << endl;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2844
/*
　　　　　／＞　 フ
　　　　　| 　_　 _|
　 　　　／`ミ _x 彡
　　 　 /　　　 　 |
　　　 /　  ヽ　　 ?
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)_)
　＼二つ
 */

#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}

template<typename F>
inline void write(F x, char ed = '\n') {
	static short st[30];short tp=0;
	if(x<0) putchar('-'),x=-x;
	do st[++tp]=x%10,x/=10; while(x);
	while(tp) putchar('0'|st[tp--]);
	putchar(ed);
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

const int N = 6005;
const int P = 924844033;
ll inv[N], jie[N], f[N];
int C(int n, int m) {
	if (n < m || n < 0) return 0;
	return jie[n] * inv[m] % P * inv[n-m] % P;
}

int n, k;
void solve(int len) {
//	for (int i = 0;i <= len; i++)
//		write(C(len - i + 1, i));
	for (int i = n;i >= 0; i--) 
		for (int j = 1;j <= min(i, len); j++)
			f[i] = (f[i] + f[i-j] * (C(len - j + 1, j))) % P;
}

int main() {
	read(n), read(k); f[0] = 1;
	inv[0] = inv[1] = jie[0] = jie[1] = 1;
	for (int i = 2;i <= n; i++)
		inv[i] = inv[P % i] * (P - P / i) % P;
	for (int i = 1;i <= n; i++) 
		inv[i] = inv[i] * inv[i-1] % P, 
		jie[i] = jie[i-1] * i % P;
	for (int i = 1;i <= k; i++) solve((n - i) / k), solve((n - i) / k);
	ll ans = 0;
	for (int i = 0;i <= n; i++) {
		if (i & 1) ans -= f[i] * jie[n-i];
		else ans += f[i] * jie[n-i];
		ans %= P; 
	} 
	write((ans + P) % P);
	return 0;
}

Measured memory_bytes: 3120
function main( input ){

  input = input.split( /\n/ )

  var nk = input[0].split( /\s/ )
  var ls = input[1].split( /\s/ )

  var N = Number( nk[0] )
  var K = Number( nk[1] )

  for( var i=0; i<ls.length; i++ )
    ls[i] = Number( ls[i] )

  ls.sort( function( a, b ){
    if( a > b ) return -1
    if( a < b ) return  1
    return 0
  } )

  var sum = 0
  ls = ls.splice( 0, K )

  for( var i=0; i<ls.length; i++ )
    sum += ls[i]

  console.log( sum )

}

main(
  require( 'fs' )
    .readFileSync( '/dev/stdin', 'utf8' )
)


Measured memory_bytes: 21064
#abc 165
# d
a,b,n = map(int,input().split())
nmax = 0

# for i in range(0,min(b,n+1)):
#     ni = int(a*i/b)
#     if ni > nmax:
#         nmax = ni
# print(nmax)

q = min(b-1,n)
ni = int(a*q/b)
if ni > nmax:
        nmax = ni
print(nmax)

Measured memory_bytes: 9168
#include <iostream>

using namespace std;

int main(){
  //点1 → 2の変位ベクトルのx成分をx y成分をyとする。
  int x1, y1, x2, y2, x, y;
  cin >> x1 >> y1 >> x2 >> y2;
  
  x = x2 - x1;
  y = y2 - y1;
  
  //点3 = x2 - y,y2 + x;
  //点4 = x1 - y,y1 + x;
  
  cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x;
}

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

typedef long long ll;

int main() {
    int N, a, b;
    ll K;
    cin >> N >> K;
    vector<ll> c(100001, 0);
    rep(i, N) {
        cin >> a >> b;
        c[a] += b;
    }
    rep(i, 100001) {
        K -= c[i];
        if (K < 1) {
            cout << i << endl;
            return 0;
        }
    }
}

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

int main() {
	int x, y;
	cin >> x >> y;
	while(x != 0 || y != 0) {
		if(x > y) cout << y << " " << x << endl;
		else cout << x << " " << y << endl;
		cin >> x >> y;
	}
		
}


Measured memory_bytes: 3080
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int k, x;
  readf("%s %s\n", &k, &x);
  foreach (i; max(-1_000_000, x - k + 1)..min(1_000_000, x + k - 1) + 1) {
    writef("%s ", i);
  }
  writeln("");
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int q1, b, c1, c2, q2;

int check (int x )
{
	int y = (b - c1*x)/c2;

	if (x + y < q1 ) return -1;
	if (y < 0 ) return -1;
	if (b - c1*x < 0 ) return -1;
	
	return y;
}

int main()
{

	while (cin >> q1 >> b >> c1 >> c2 >> q2 && q1 ){

		int x, y;
		int l = 0;
		int r = q2;

		while (l <= r ){
			x = (l + r )/2;
			if ((y = check(x ) ) == - 1 ){
				r = x - 1;
			}else{
				l = x + 1;
			} // end if
		} // end while
		x = min (l, r );
		y = check(x );

		if (x <= 0 ){
			cout << "NA" << endl;
		}else{
			cout << x << ' ' << y << endl;
		} // end if
	} // end while

	return 0;
}

Measured memory_bytes: 0