akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <functional>
#include <sstream>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))           \
		{                           \
			goto Exit0;             \
		}                           \
}

typedef unsigned char			BYTE;
typedef int						BOOL;
typedef unsigned long			DWORD;
typedef long long				LLONG;

int main(int argc, char* argv[])
{
	char		chWord;

	cin >> chWord;

	if (chWord == 'a' || chWord == 'e' || chWord == 'i' || chWord == 'o' || chWord == 'u')
	{
		cout << "vowel" << endl;
	}
	else
	{
		cout << "consonant" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# cython: profile=True
import sys

YES = "POSSIBLE"  # type: str
NO = "IMPOSSIBLE"  # type: str


def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    AB = sorted(zip(a, b))
    s = set([b for a, b in AB if a == 1])
    g = set([a for a, b in AB if b == N])
    return YES if s & g else NO

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]"
    b = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    print(solve(N, M, a, b))

def test():
    import doctest
    doctest.testmod()

def perf():
    import cProfile
    cProfile.run("main()")

if __name__ == '__main__':
    #test()
    #perf()
    main()


Measured memory_bytes: 47316
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on
int N;
string S;

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

  if(N % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  for(int i = 0; i < N/2; i++) {
    if(S[i] != S[(N/2) + i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;


  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>

using namespace std;

int m,d;

inline bool pan(int x,int y)
{
	if(y%10<2 || y/10<2) return false;
	return x == (y%10)*(y/10);
}

int main()
{
	scanf("%d %d",&m,&d);
	
	int cnt=0;
	for(int i=1;i<=m;i++)
		for(int j=10;j<=d;j++)
			if(pan(i,j))
				cnt++;
	printf("%d\n",cnt);
	return 0;
} 

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = raw_input()

array = []

for i in range(0, len(s)-2):
    array.append(int(s[i:i+3]))

min = 1000000

for a in array:
    b = 753-a
    if b < 0: b = -b

    if min > b: min = b

print min

Measured memory_bytes: 2568
fun main(args: Array<String>) {
    val (n, m, x) = readLine()!!.split(" ").map { Integer.parseInt(it) }
    val a = readLine()!!.split(" ").map { Integer.parseInt(it) }
    println(Math.min(a.filter { it < x }.count(), a.filter { it > x }.count()))
}

Measured memory_bytes: 36024
#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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

ll n,m; cin >> n >> m;
map<ll, vector<pii>> mp;
rep(i,m) {
    ll p,y;
    cin >> p >> y;
    mp[p].push_back(make_pair(y, i));
}

vector<string> id(m);

for(auto x : mp) {
    vector<pii> cur = x.second;
    sort(all(cur));
    rep(j, SZ(cur)) {
        ll d = 1000000000000 + x.first * 1000000 + j + 1;
        string s = to_string(d);
        id[cur[j].second] = s.substr(1);
    }
}

rep(i,m) cout << id[i] << endl;
return 0;
}

Measured memory_bytes: 17920
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	long long X, Y;
	cin >> X;
	Y = X;
	long long happy = 0;
	X = X / 500;
	happy += 1000 * X;
	Y -= X * 500;
	Y = Y / 5;
	happy += Y * 5;
	cout << happy << endl;
}

Measured memory_bytes: 3604
#include <iostream>

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

using namespace std;

int main () {

    int n;
    cin >> n;
    long val[n] = {};

    rep(i, n) {
        cin >> val[i];
    }

    int total = 0;
    rep(i, n) {
        while(val[i] % 2 == 0 && val[i] > 0){
            total++;
            val[i] = val[i] / 2;
        }
    }

    cout << total << endl;
    return 0;
}


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

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

    if ((c - a - b) <= 0) {
        cout << "No" << endl;
        return 0;
    }

    if (4 * a * b < (c - a - b) * (c - a - b)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
from math import *
from sys import stdin,stdout
input=stdin.buffer.readline

n=int(input())
a=[int(x) for x in input().split()]
a.sort()
m=1
flag=1
for i in range(n):
	m=m*a[i]
	if(m>1000000000000000000):
		flag=0
		break
if flag==1:
	print(m)
else:
	print(-1)

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

ll dp[105][100005];
int main()
{
  ll n,W;
  ll we[105],va[105];
  cin >> n >> W;
  for(int i=0; i<n; i++) cin >> we[i] >> va[i];

  for(int i=0; i<n; i++){
    for(int j=0; j<=W; j++){
      if(we[i] <= j){
	dp[i+1][j] = max(dp[i][j - we[i]] + va[i] , dp[i][j]);
      } else {
	dp[i+1][j] = dp[i][j];
      }
    }
  }

  cout << dp[n][W] << endl;

  return 0;
}


Measured memory_bytes: 79360
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <iomanip>
#include <cmath>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>

#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long 
//#define int long long
#define ld long double
#define vi vector<ll>
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define iii pair<int,ii>
#define il pair<ll,ll>
#define vv vector
//#define endl '\n'
using namespace std;
const int MAXN = 200*1000 + 5;
const int INF = 1e9;

int bit[MAXN];
 
void add(int x, int val) {
	x += 1;
	while(x < MAXN) {
		bit[x] += val;
		x += x&(-x);
	}
}
 
int sum(int x) {
	x += 1;
	int ret = 0;
	while(x > 0) {
		ret += bit[x];
		x -= x&(-x);
	}
	return ret;
}


int main() {
	string s;
	cin >> s;
	int n = s.length();
	int finalPos[n];
	FOR(i,n)finalPos[i] = -1;

	deque<int> allPos[26];
	FOR(i,n)allPos[s[i]-'a'].pb(i);
	int ctr = 0;
	FOR(i,26)if(allPos[i].size()%2 == 1)ctr++;
	if(ctr > 1){
		cout << - 1 << endl;
		return 0;
	}
	// now lets assign which number should be which
	int ptr = 0;
	int odd = -1;
	FOR(i,n){
		if(finalPos[i] != -1)continue;
		if(allPos[s[i]-'a'].size() == 1){
			odd = i;
			continue;
		}
		finalPos[i] = ptr;
		int j = allPos[s[i]-'a'].back();
		finalPos[j] = n-ptr-1;
		ptr++;
		allPos[s[i]-'a'].pop_back();
		allPos[s[i]-'a'].pop_front();
	}
	if(odd != -1)finalPos[odd] = n/2;
	//FOR(i,n)cout << finalPos[i] << " ";cout << endl;

	ll ctffr = 0;
	FOR(i,n){
		ctffr += i-sum(finalPos[i]);
		add(finalPos[i],1);

	}
	cout << ctffr << endl;
	//FOR(i,n)cout << finalPos[i] << " ";cout << endl;
	return 0;
}

Measured memory_bytes: 5992
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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

int main() {
	ll N, M;
	cin >> N >> M;

	vector<string> A(N);
	vector<string> B(M);
	rep(i, N)cin >> A[i];
	rep(i, M)cin >> B[i];

	string ans = "No";

	rep(i, N - M + 1)rep(j, N - M + 1) {
		bool b = 1;

		rep(k, M)rep(l, M) {
			if (A[i + k][j + l] != B[k][l]) { b = 0; }
		}

		if (b == 1) { ans = "Yes"; }
	}

	cout << ans << endl;
	
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
string S;
cin >> S;
int cnt = 0,a = 0;
for (int i = 0;i < S.size();i++) {
    if (S.at(i) == 'A' || S.at(i) == 'T' || S.at(i) == 'G' || S.at(i) == 'C') {
        a++;
    } else a = 0;
    if (a > cnt) cnt = a;
}

cout << cnt << endl;

return 0;
}


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")



signed main() {

	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	A--; B--; C--; D--;
	string S;
	cin >> S;

	// AからCにいけるか
	bool AC = true;
	for (int i = A+1; i <= C; i++) {
		if (S[i - 1] == '#' && S[i] == '#') {
			AC = false; break;
		}
	}
	// BからDにいけるか
	bool BD = true;
	for (int i = B + 1; i <= D; i++) {
		if (S[i - 1] == '#' && S[i] == '#') {
			BD = false; break;
		}
	}
	//追い抜く必要がある
	bool oinuki = false;
	if (D < C) {
		// Bの位置で追い越せるか
		if (S[B - 1] == '.' && S[B + 1] == '.') {
			oinuki = true;
		}
		// Dの位置で追い越せるか
		else if (S[D - 1] == '.' && S[D + 1] == '.') {
			oinuki = true;
		}
		else if (B + 2 <= D) {
			// 3連続する'.'があるか
			for (int i = B + 2; i <= D; i++) {
				if (S[i - 2] == '.' && S[i - 1] == '.' && S[i] == '.') {
					oinuki = true;
					cerr << i << endl;
				}
			}
		}
		else {
			// #B.Dみたいなとき
			if (S[B+1] == '.' && S[B+2]=='.') {
				oinuki = true;
			}
		}
		if (AC && BD && oinuki) Yes;
		else No;
	}
	else {
		if (AC && BD) Yes;
		else No;
	}


	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N, M;
    cin >> N >> M;
    vector<int64_t>dp(N+1, 0);
    for (int64_t i=0; i<M; i++) {
        int64_t num;
        cin >> num;
        dp[num] = -1;
    }

    dp[0] = 1;
    for (int64_t i=1; i<=N; i++) {
        if (dp[i] == -1) continue;
        int64_t pattern = 0;
        if (dp[i-1] != -1) pattern += dp[i-1];
        if (i > 1 && dp[i-2] != -1) pattern += dp[i-2];
        dp[i] = pattern % 1000000007;
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 3952
#include<cstdio>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 1000003, mod = 1e9 + 7;
int n, m;
bool col[N], row[N];
int main(){
	scanf("%d%d", &n, &m);
	for(Rint i = 1;i <= n;i ++){
		int x;
		scanf("%d", &x);
		if(col[x]){puts("0"); return 0;}
		col[x] = true;
	}
	for(Rint i = 1;i <= m;i ++){
		int x;
		scanf("%d", &x);
		if(row[x]){puts("0"); return 0;}
		row[x] = true;
	}
	int ans = 1, c = 0, r = 0;
	for(Rint i = n * m;i;i --){
		int tc = c, tr = r;
		if(col[i]){tc = 1; ++ c;}
		if(row[i]){tr = 1; ++ r;}
		if(col[i] || row[i]) ans = (LL) ans * tc % mod * tr % mod;
		else ans = (LL) ans * (tc * tr - n * m + i) % mod;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define reps(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(i, n) reps(i, 0, n)
#define deps(i, a, n) for (int i = (a); i >= (n); --i)
#define dep(i, n) deps(i, n, 0)
#define inf 2147483647
#define int long long

signed main(void)
{
	int n, k; cin >> n >> k;
	int p[5005], c[5005];
	reps (i, 1, n + 1) cin >> p[i];
	reps (i, 1, n + 1) cin >> c[i];
	int a[5005] = {0}, r[2][3000], rn = 0, rp;
	reps (i, 1, n + 1)
	{
		if (a[i]) continue;
		rp = i;
		r[1][rn] = 0;
		while (1)
		{
			r[1][rn]++;
			a[rp] = rn;
			r[0][rn] += c[rp];
			rp = p[rp];
			if (rp == i) break;
		}
		rn++;
	}
	rn--;
	//reps (i, 1, n + 1) cout << a[i];
	//cout << endl;
	int ans = -2000000000;
	reps (i, 1, n + 1)
	{
		int ans2 = 0, k2 = k;
		int tmp = k / r[1][a[i]] - 1;
		if (r[0][a[i]] > 0)
		{
			if (tmp > 0)
			{
				ans2 = r[0][a[i]] * tmp, k2 -= tmp * r[1][a[i]];
				if (ans2 > ans) ans = ans2;
			}
		}
		else
		{
			k2 = 5005;
		}
		int q = i;
		rep (j, k2)
		{
			q = p[q];
			ans2 += c[q];
			if (ans2 > ans) ans = ans2;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

template<class T>bool ch1000000(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; }


const int MAX = 42;




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

  if(K % 2 == 0){
    cout << -1 << endl;
    return 0;
  }

  vector<ll> res(K, 0);
  ll cnt = 1;
  ll a = 7;
  while(true){
    if(a == 0){
      break;
    }else{
      while(a < K){
        a *= 10;
        a += 7;
        cnt++;
      }
      a %= K;
      if(res[a] == 1){
        cout << -1 << endl;
        return 0;
      }
      res[a] = 1;
    }
  }

  cout << cnt << endl;

  // cout << setprecision(8) << ans << endl;  // For double
}



Measured memory_bytes: 11060
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;


int main(){
    std::ios_base::sync_with_stdio(false);

    int n,k; cin >> n >> k;
    string s; cin >> s;
    
    rep(i,s.size()){
        if(i==k-1) cout << char(tolower(s[i]));
        else cout << s[i];
    }
    cout << '\n';

    return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())

MOD = 10 ** 9 + 7

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

c = Factorial(max(a, b) + 1, MOD)

def combination(n, r): #nCrを求める
    if n - r < r:
        r = n - r
    tmp = 1
    for i in range(n - r + 1, n + 1):
        tmp *= i
        tmp %= MOD
    tmp *= c.ifactorial(r)
    return tmp

MOD = 10 ** 9 + 7


ans = pow(2, n, MOD) - 1 #選ばないのを除く

ans -= combination(n, a)
ans %= MOD
ans -= combination(n, b)
ans %= MOD

print (ans)

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

int main() {
  string s;
  int ans = 0;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '1') {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int n,i;
        char s[101];

        scanf("%d\n",&n);

        for (i=1;i<=n;i++)
                scanf("%c",&s[i]);

        for (i=0;i<n;i++){
                if (s[i]=='Y'){
                        printf("Four\n");
                        return 0;
                }
        }

        printf("Three\n");

        return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

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

  int N = S.length();

  vector <ll> left_cnt(N + 1), right_cnt(N + 1);

  for (int i = 0; i < N; i++){
    if (S[i] == '<'){
      left_cnt[i + 1] = left_cnt[i] + 1;
    }else{
      left_cnt[i + 1] = 0;
    }
  }

  for (int i = N - 1; i >= 0; i--){
    if (S[i] == '>'){
      right_cnt[i] = right_cnt[i + 1] + 1;
    }else{
      right_cnt[i] = 0;
    }
  }

  ll ans = 0;
  for (int i = 0; i < N + 1; i++){
    ans += max(left_cnt[i], right_cnt[i]);
  }
  cout << ans<< endl;
  
  return 0;
}


Measured memory_bytes: 8708
"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const N = input[0];
  const S = input[1].trim().split(' ')[0];
  const T = input[1].trim().split(' ')[1];

  let ret = [];
  for(let i=0; i<N; i++){
    ret.push(S[i]);
    ret.push(T[i]);
  }

  console.log(ret.join(''));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include <iostream>
#include <tuple>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
        int n, q;
        vector<tuple<int,int,int>> events;
        vector<int> start_times;

        cin >> n >> q;

        for (int i = 0; i < n; i++)
        {
                int s, t, x;

                cin >> s >> t >> x; 
                events.push_back(make_tuple(s - x, 1, x));
                events.push_back(make_tuple(t - x, -1, x));
        }
        sort(events.begin(), events.end());

        for (int i = 0; i < q; i++)
        {
                int d;
                cin >> d;
                start_times.push_back(d);
        }

        set<int> set;
        auto it = events.begin();
        for (int i = 0; i < start_times.size(); i++)
        {
                int d = start_times[i];

                while (it != events.end())
                {
                        int t, meth, x;
                        tie(t, meth, x) = *it;

                        if (t <= d)
                        {
                                if (meth == -1)
                                        set.erase(x);
                                else if (meth == 1)
                                        set.insert(x);
                        } else
                                break;

                        it++;
                }

                if (set.begin() == set.end())
                        cout << -1 << endl;
                else
                        cout << *set.begin() << endl;
        }
}


Measured memory_bytes: 16876
a = list(map(int, input().split()))
for i in range(len(a)):
    j = len(a) - 1
    while i < j:
        if a[j] < a[j-1]:
            t = a[j]
            a[j] = a[j-1]
            a[j-1] = t
        j -= 1

for i in range(len(a)):
    if i == len(a) - 1:
        print(a[i])
    else:
        print(a[i], end=" ")
        

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

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

    int n;
    int p = 0, w = 0, g = 0, y = 0;
    
    cin >> n;

    char s[n];
    rep(i, n){
        cin >> s[n];
        if(s[n] == 'P' && p != 1) p++;
        if(s[n] == 'W' && w != 1) w++;
        if(s[n] == 'G' && g != 1) g++;
        if(s[n] == 'Y' && y != 1) y++;
    }

    if(p + w + g + y == 3) cout << "Three\n";
    else cout << "Four\n";

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
    int N, M, d, v;
    while(1) {
        scanf("%d%d", &N, &M);
        if(!N) break;
        int A[101] = {0};
        while(N--) {
            scanf("%d%d", &d, &v);
            if(v > A[d-1]) A[d-1] = v;
        }
        int sum = 0;
        while(M--) sum += A[M];
        printf("%d\n", sum);
    }
}



Measured memory_bytes: 2024
N = int(input())
W = list(map(int, input().split()))
min = 9999
for i in range(N):
    s1 = 0
    s2 = 0
    for j in range(N):
        if i<=j:
            s1 += W[j]
        else:
            s2 += W[j]
    if min>abs(s1-s2):
        min = abs(s1-s2)
print(min)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main(){
    int N;
    cin >> N;
    map<int, int> count;
    for(int i = 0; i < N; i++){
        ll A;
        cin >> A;
        if(A % 4 == 0) count[4]++;
        else if(A % 2 == 0) count[2]++;
        else count[1]++;
    }
    if((count[4] + 1 >= count[1] and count[2] % 2 == 0) or (count[4] >= count[1])) puts("Yes");
    else puts("No");

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int c[3][3],p,q,r;
  for(int i=0;i<3;i++)for(int j=0;j<3;j++)cin>>c[i][j];
  p=c[0][0]-c[0][1];
  q=c[1][0]-c[1][1];
  r=c[2][0]-c[2][1];
  if(!(p==q&&q==r)){cout<<"No";return 0;}
  p=c[0][1]-c[0][2];
  q=c[1][1]-c[1][2];
  r=c[2][1]-c[2][2];
  if(!(p==q&&q==r)){cout<<"No";return 0;}
  p=c[0][0]-c[1][0];
  q=c[0][1]-c[1][1];
  r=c[0][2]-c[1][2];
  if(!(p==q&&q==r)){cout<<"No";return 0;}
  p=c[1][0]-c[2][0];
  q=c[1][1]-c[2][1];
  r=c[1][2]-c[2][2];
  if(!(p==q&&q==r)){cout<<"No";return 0;}
  cout<<"Yes";return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

template<class T>inline void fr(T &a) {
    T s=0,w=1;char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=w*s;
}
template<class T>inline T fr() {T a;fr(a);return a;}
#define R() fr<int>()

signed main() {
    int x=R(),y=x/100,z=x/y;
    if(y==0)return !printf("0\n");
    else z=x/y;
    if(z*y==x&&z<=105)puts("1");
    else if(z==105&&y==1)puts("1");
    else if(z>=105)puts("0");
    else {
        int a=105-z,b=x-y*z,c=b/a;
        if(c*a==b) {
            if(c<=y)puts("1");
            else puts("0");
        } else {
            c++;
            if(c<=y)puts("1");
            else puts("0");
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,readline().split())
UVST = list(map(int,read().split()))
S,T = UVST[-2:]
UV = UVST[:-2]; U = UV[::2]; V = UV[1::2]

graph = [[] for _ in range(1+N+N+N)]
for x,y in zip(U,V):
    x1=x+N; x2=x1+N
    y1=y+N; y2=y1+N
    graph[x].append(y1)
    graph[x1].append(y2)
    graph[x2].append(y)   

INF = 10**15
dist = [INF] * (N+N+N+1)
dist[S] = 0
q = [S]
while q:
    qq = []
    for x in q:
        for y in graph[x]:
            if dist[y] != INF:
                continue
            qq.append(y)
            dist[y] = dist[x] + 1
    q = qq

d = dist[T]

answer = -1 if d == INF else d//3
print(answer)

Measured memory_bytes: 67696
N,M=map(int,input().split())
AC=[0]*(N+1)
WA=[0]*(N+1)
for i in range(M):
    p,S=input().split()
    p=int(p)
    if S=='WA' and AC[p]==0:
        WA[p]+=1
    if S=='AC' and AC[p]==0:
        AC[p]+=1
        
#結局正解できなかった場合はWA=0になる
for j in range(N+1):
    WA[j] = WA[j]*AC[j]
    
print(sum(AC),sum(WA))

Measured memory_bytes: 45656
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	int a, b;
	int ans = 0;
	CI a >> b;

	if (a <=b) {
		ans += b;
		b--;
	}
	else {
		ans += a;
		a--;
	}

	ans += max(a, b);

	CO ans EN;

	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(), W = sc.nextInt();
		int item[][] = new int[N][2];
		for(int i=0;i<N;i++) {
			item[i][0]= sc.nextInt(); //w
			item[i][1]= sc.nextInt(); //v
		}
		sc.close();
		
		int w0 = item[0][0];
		
		Integer weight0[]= new Integer[100];
		Integer weight1[]= new Integer[100];
		Integer weight2[]= new Integer[100];
		Integer weight3[]= new Integer[100];
		Arrays.fill(weight0, 0);
		Arrays.fill(weight1, 0);
		Arrays.fill(weight2, 0);
		Arrays.fill(weight3, 0);
		
		int pointer[] = new int[4];
		for(int i=0;i<N;i++) {
			int weight = item[i][0] - w0;
			int value = item[i][1];
			
			if(weight==0) {
				weight0[pointer[weight]]=value;
				pointer[weight]++;
			}
			if(weight==1) {
				weight1[pointer[weight]]=value;
				pointer[weight]++;
			}
			if(weight==2) {
				weight2[pointer[weight]]=value;
				pointer[weight]++;
			}
			if(weight==3) {
				weight3[pointer[weight]]=value;
				pointer[weight]++;
			}
		}
		Arrays.sort(weight0, (w1,w2)->w2-w1);
		Arrays.sort(weight1, (w1,w2)->w2-w1);
		Arrays.sort(weight2, (w1,w2)->w2-w1);
		Arrays.sort(weight3, (w1,w2)->w2-w1);
		
		//累積和を用意しておく
		long cumSum0[] = new long[N+1]; 
		long cumSum1[] = new long[N+1];
		long cumSum2[] = new long[N+1];
		long cumSum3[] = new long[N+1];
		
		
		for(int i=0;i<N;i++) {
			cumSum0[i+1] = cumSum0[i]+weight0[i];
			cumSum1[i+1] = cumSum1[i]+weight1[i];
			cumSum2[i+1] = cumSum2[i]+weight2[i];
			cumSum3[i+1] = cumSum3[i]+weight3[i];
		}
		
		int upper = 0;
		
		//荷物の数
		int minP = Math.min(W/(w0+3),N);
		int maxP = Math.min(W/w0,N);
		long ans = 0;
		for(int p=minP;p<=maxP;p++) {
			upper = W - w0*p;
			for(int i=0;i<=p;i++) {
				for(int j=0;i+j<=p;j++) {
					for(int k=0;i+j+k<=p;k++){	
							int l  = p -(i+j+k);
							//w1をi個, w1+1:j w1+2:k w1+3:l
							if(j+2*k+3*l > upper)continue;
							long sum = cumSum0[i]+cumSum1[j]+cumSum2[k]+cumSum3[l];
							ans = Math.max(ans, sum);
					}
				}
			}
			
			
		}
		System.out.println(ans);
	}
}

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

#define all(x) (x).begin(),(x).end()
#define init() \
  ios::sync_with_stdio(false); \
  cin.tie(0)

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) {
  return a == 0 ? b
    : b == 0 ? a
    : gcd(b, a % b);
}

template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

int sd(int n){
  int res=0;
  for(;n!=0;n/=10){
    res+=n%10;
  }
  return res;
}

int main() {
  init();

  int n,a,b;
  cin >> n >> a >> b;

  int res=0;
  for(int i=1;i<=n;i++){
    int s = sd(i);
    if(a <=s && s <= b){
      res+=i;
    }
  }
  cout << res << '\n';

  return 0;
}


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

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	int cnt=0;
	while(A>=B){
		++cnt;
		B *= 2;
	}
	while(B>=C){
		++cnt;
		C *= 2;
	}
	if(cnt<=K) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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


signed main(){
    int N,M;
    cin>>N>>M;
    vector<int>vec(M,N);
    REP(i,N){
        int K;
        cin>>K;
        REP(j,K){
            int a;
            cin>>a;
            vec[a-1]--;
        }
    }
    int ans=0;
    REP(i,M){
        if(vec[i]==0)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn bfs(r: usize, g: &Vec<Vec<usize>>, d: &mut Vec<usize>) -> bool {
    d[r] = 0;
    let mut q = std::collections::VecDeque::new();
    q.push_back(r);
    while let Some(v) = q.pop_front() {
        let l = d[v] + 1;
        for &u in g[v].iter() {
            if d[u] > l {
                d[u] = l;
                q.push_back(u);
            } else if d[u] % 2 == d[v] % 2 {
                return false;
            }
        }
    }
    true
}

fn run() {
    input! {
        n: usize,
        m: usize,
        e: [(usize1, usize1); m],
    }
    let mut g = vec![vec![]; n];
    for &(a, b) in e.iter() {
        g[a].push(b);
        g[b].push(a);
    }
    let mut d = vec![n; n];
    let ans = if bfs(0, &g, &mut d) {
        let mut cnt = [0; 2];
        for &d in d.iter() {
            cnt[d & 1] += 1;
        }
        let mut sum = cnt[0] * cnt[1];
        for &(a, b) in e.iter() {
            if d[a] % 2 != d[b] {
                sum -= 1;
            }
        }
        sum
    } else {
        n * (n - 1) / 2 - m
    };
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 16636
// https://atcoder.jp/contests/abc121/tasks/abc121_c

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int M_MAX = 1e5;
const int A_I_MAX = 1e9;
const int B_I_MAX = 1e5;

int N, M;
int A[N_MAX];
int B[N_MAX];

pair<ll, int> vs[N_MAX];

void solve() {
  REP(i, N) vs[i] = { A[i], B[i] };
  sort(vs, vs + N);
  ll ans = 0;
  REP(i, N) {
    ll a = vs[i].first;
    int b = min(M, vs[i].second);
    ans += a * b;
    M -= b;
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, N) scanf("%d%d", A + i, B + i);
}

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


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

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> t(N),v(N);
	int T = 0;
	rep(i,N){
		cin >> t[i];
		T += t[i];
	}
	rep(i,N)cin >> v[i];
	vector<double> maxv(T*2+5,(double)1e9);//maxv[i] := 時刻i/2 での出せる最高速度
	int cur = 1;
	for(int i=0;i<N;i++){//各v[i]について
		for(int j=0;j<t[i]*2;j++){
			maxv[cur] = v[i];
			if(j==t[i]*2-1&&i+1<N)maxv[cur] = min((double)v[i+1],maxv[cur]);
			cur++;
		}
	}
	//for(int i=0;i<=2*T;i++)cout << "i= " << i << "のとき " <<  maxv[i] << endl;
	maxv[2*T] = 0;
	maxv[0] = 0;
	for(int i=1;i<=2*T;i++){
		maxv[i] = min(maxv[i],maxv[i-1] + (double)0.5);
	}
	
	for(int i=2*T-1;i>=0;i--){
		maxv[i] = min(maxv[i],maxv[i+1] + (double)0.5);
	}
	
	//for(int i=0;i<=2*T;i++)cout << "i= " << i << "のとき " <<  maxv[i] << endl;
	double ans = 0;
	for(int i=1;i<=2*T;i++){
		//高さ0.5
		//上底:maxv[i]
		//下底:maxv[i+1];
		ans += (maxv[i]+maxv[i-1])*0.5*0.5;
	}
	cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 640
class UnionFind():
    n=1
    par=[0]
    rnk=[0]
    def __init__(self,size):
        self.n=size
        self.par=[i for i in range(self.n)]
        self.rnk=[0 for i in range(self.n)]
    def find(self,vertex1):
        if self.par[vertex1]==vertex1:
            return vertex1
        else:
            self.par[vertex1]=self.find(self.par[vertex1])
            return self.par[vertex1]
    def unite(self,vertex1,vertex2):
        vertex1=self.find(vertex1)
        vertex2=self.find(vertex2)
        if vertex1==vertex2:
            return
        if (self.rnk[vertex1]<self.rnk[vertex2]):
            self.par[vertex1]=vertex2
        else:
            self.par[vertex2]=vertex1
            if(self.rnk[vertex1]==self.rnk[vertex2]):
                self.rnk[vertex1]+=1
    def same(self,vetrex1,vertex2):
        return self.find(vetrex1)==self.find(vertex2)

N,Q=map(int,input().split())
G=UnionFind(N)
for i in range(Q):
    t,u,v=map(int,input().split())
    if t==0:
        G.unite(u,v)
    else:
        if G.same(u,v):
            print(1)
        else:
            print(0)


Measured memory_bytes: 93956
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a; cin >> a;
    int b; cin >> b;

    int ans = 0;
    if (0 == (b - 1) % (a - 1)) {
        ans = (b - 1) / (a - 1);
    } else {
        ans = (b - 1) / (a - 1) + 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int n;
    cin >> n;
    int sum = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        sum += a;
    }
    cout << sum-n << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] f = new int[m]; // foods
		
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				f[sc.nextInt() - 1]++;
			}
		}
		
		int ans = 0;
		for (int i = 0; i < f.length; i++) {
			if (f[i] == n) {
				ans++;
			}
		}
		
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 22100
n=gets.to_i
pi=gets.split.map(&:to_f)

arr = (0..n).map{|i|[0]*(i+1)}
arr[0][0]=1

pi.each.with_index{|pii,i|
  ari,arii = arr[i,2]
  ari.each.with_index{|ai,j|
    arii[j] += ai * (1-pii)
    arii[j+1] += ai * pii
  }
}
p arr[n][-n/2..-1].inject(:+)

Measured memory_bytes: 157308
#include <cstdio>
#include <iostream>

using namespace std;

int main(void)
{
	string s;

	cin >> s;
	int l = s.length();

	int ans = 0;
	for(int i = 0; i < l / 2; ++i){
		if(s[i] != s[l - i - 1]){
			++ans;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll n,a,b;

int main()
{
	cin>>n>>a>>b;
    ll p1=n/(a+b),p2=n%(a+b);
    p2=min(p2,a);
    cout<<p1*a+p2<<endl;
	return 0;
}

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

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;

//==============================================

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

	int n;
	cin >> n;

	vi A(n), L(n), R(n);

	REP(i, n) {
		L[i] = R[i] = i;
		cin >> A[i];
	}

	stack<int>st;
	REP(i, n) {
		while (!st.empty() && A[i] < A[st.top()]) {
			L[i] = L[st.top()]; st.pop();
		}
		st.push(i);
	}

	stack<int>st2;
	RREP(i, n) {
		while (!st2.empty() && A[i] < A[st2.top()]) {
			R[i] = R[st2.top()]; st2.pop();
		}

		st2.push(i);
	}

	LL ans = 0;
	REP(i, n) ans += (LL)A[i] * (R[i] - i + 1) * (i - L[i] + 1);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<b>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j);a×b行列の入力
 
int main() {
  ll a;
  ci(a);
  ll c=1;
  for(i,1,a)
    for(j,2,a){
      ll d=pow(i,j);
      if(d>a)
        break;
      else
        c=max(c,d);
    }
  co(c);
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
	val n = readLine()!!.toInt();
	val a = n/1000;
	val b = (n%1000)/100;
	val c = (n%100)/10;
	val d = (n%10);

	println("${if ((a == b && b == c) || (b == c && c == d)) {"Yes"} else {"No"}}");
}



Measured memory_bytes: 33684
#include <iostream>
#include <string>

using namespace std;

int main(){

	string S;

	cin >> S;

	char prev = S.at(0);
	bool flg = true;
	for(int i = 1; i < 4; ++i){
		if(prev == S.at(i)){
			flg = false;
			break;
		}
		prev = S.at(i);
	}

	if(flg) cout << "Good" << endl;
	else 	cout << "Bad"  << endl;

	return 0;
}

Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 1e6 + 111;
        
using namespace std;          

int n, m, a[maxn], sum, ans[maxn];

void solve(){             
	string s;

	cin >> s;

	int a = 0, b = 0;

	for (int i = 0; i < 3; i++){
		a += s[i] == 'A';
		b += s[i] == 'B';
	}

	if (a > 0 && b > 0 && a + b == 3)
		cout << "Yes";
	else
		cout << "No";
}                              
      
main(){
    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repi(i, a, b) for(int i=(a); i>(b); i--)
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define iceil(n, x) ((n + x - 1) / x)
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define fi first
#define se second
#define umap unordered_map
#define uset unordered_set
#define pqueue priority_queue
#define si(a) scanf("%d", &a)
#define sll(a) scanf("%lld", &a)
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
#define MOD 1000000007
#define N 100005
#define M 105
using namespace std;

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;

//All indexing is 0-based
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
			 tree_order_statistics_node_update> ordered_set;
//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.


main()
{	
	#ifdef CP
		freopen("/home/tarun/Desktop/input.txt", "r", stdin);
		//freopen("/home/tarun/Desktop/output.txt", "w", stdout);
	#endif
	sync;
	clock_t clk = clock();
	cerr << "I will return...\n";
	
	int n, k;
	cin >> n >> k;
	cout << !!(n % k) << '\n';

	cerr << "...don't you ever hang your head.\n";
	cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << '\n';
}

//Compile using:
//g++ -o filename.exe --std=c++11 filename.cpp
//Use -D CP for defining a macro CP in the local environment






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
int main(void){
    // Your code here!
    string s,g;
    cin>>s>>g;
    sort(s.begin(),s.end());
    sort(g.begin(),g.end(),greater<int>());
    if(s<g)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
from itertools import product as p
n,k=map(int,input().split())
*d,=map(int,input().split())

cd={i for i in range(10)}-set(d)

*a,=filter(lambda x:x>=n,sorted([int("".join(map(str,i))) for i in p(cd,repeat=1)]))
*b,=filter(lambda x:x>=n,sorted([int("".join(map(str,i))) for i in p(cd,repeat=2)]))
*c,=filter(lambda x:x>=n,sorted([int("".join(map(str,i))) for i in p(cd,repeat=3)]))
*d,=filter(lambda x:x>=n,sorted([int("".join(map(str,i))) for i in p(cd,repeat=4)]))
*e,=filter(lambda x:x>=n,sorted([int("".join(map(str,i))) for i in p(cd,repeat=5)]))

print((a+b+c+d+e)[0])


Measured memory_bytes: 6004
#include<iostream>
#include<utility>
#include<vector>
#include<cmath>

const double PI = std::acos(-1);

int main() {
	int A, B, H, M;
	std::cin >> A >> B >> H >> M;
	double x = A * std::sin(PI * H / 6 + PI * M / 360) - B * std::sin(PI * M / 30);
	double y = A * std::cos(PI * H / 6 + PI * M / 360) - B * std::cos(PI * M / 30);
	double answer = sqrt(x * x + y * y);
	printf("%.10f\n", answer);
	return 0;
}

Measured memory_bytes: 4016