akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    ll n,x,t;
    cin >> n >> x >> t;

    cout << ((n + x - 1) / x) * t << endl;
    return 0;
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P	  = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
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; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2) cnt++;
	}
	dumpf((ld)cnt / n, 10);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
    a = input()
    A.append(a)

cnt1 = 0
cnt2 = 0
cnt3 = 0
cnt4 = 0

print('AC x {}'.format(A.count('AC')))
print('WA x {}'.format(A.count('WA')))
print('TLE x {}'.format(A.count('TLE')))
print('RE x {}'.format(A.count('RE')))

Measured memory_bytes: 16204
#include <iostream>

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

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

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

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> a(60);
  for(int i=0;i<N;i++) cin >> a.at(i);
  sort(a.begin(),a.end(),greater<int>());
  int sum=0;
  for(int i=0;i<K;i++){
    sum+=a.at(i);
  }
  cout << sum << endl;
}


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

class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        int ans = 0;
        for (int i = 0; i < 3; i++)
        {
            if (s[i] == '1') ans++;
        }
        Console.WriteLine(ans);
    }
}

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

#define LL long long

int main(){
    LL t;
    cin>>t;
    LL c=0;
    map<string,LL>m;
    for(LL i=0;i<t;i++){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        m[s]++;
    }
    for(map<string,LL>::iterator it=m.begin();it!=m.end();it++){
        LL h=it->second;
        c+=(h*(h-1))/2l;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
typedef long long ll;
const int MOD = (int)(1e9+7);
const int INF = (int)(1e9+1e7);
const ll INFL = (ll)(1e17);
const double EPS = 1e-8;
using namespace std;
int main()
{
  ll A,B,C;
  cin >> A >> B >> C;
  cout << B + min(C,B+A+1) << endl;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
A=[2,3,4,5,6,7,8,9,10,11,12,13,1]
if A.index(a)>A.index(b):
  print("Alice")
elif A.index(a)==A.index(b):
  print("Draw")
else:
  print("Bob")

Measured memory_bytes: 3060
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int right =0, left =0;
    for (int i=0; i<M; i++) {
      int A = sc.nextInt();
      if (A < X ) left++;
      if (A > X ) right++;
    }
    System.out.println(Math.min(right,left)); 
  }
}

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

struct Dice{
        vector<int>A;
        int t;
        void North(vector<int>&A){
            t=A[1],A[1]=A[2],A[2]=A[6],A[6]=A[5],A[5]=t;
        }
        void South(vector<int>&A){
            t=A[1],A[1]=A[5],A[5]=A[6],A[6]=A[2],A[2]=t;
        }
        void East(vector<int>&A){
            t=A[1],A[1]=A[4],A[4]=A[6],A[6]=A[3],A[3]=t;
        }
        void West(vector<int>&A){
            t=A[1],A[1]=A[3],A[3]=A[6],A[6]=A[4],A[4]=t;
        }
        void Spin(vector<int>&A){
            t=A[2],A[2]=A[3],A[3]=A[5],A[5]=A[4],A[4]=t;
        }
};
    
int main(){
    vector<int>N(7);
    for(int i=1;i<7;i++) cin>>N[i];
    vector<int>M(7);
    for(int i=1;i<7;i++) cin>>M[i];
    Dice d;
    
    int p=1;
    while(M[1]!=N[1] && p<4){
        d.North(M);
        if(M[1]!=N[1]) d.East(M);
        p++;
    }
    int q=1;
    while(M[2]!=N[2] && q<4) d.Spin(M),q++;
    
    int r=1;
    while(M[5]!=N[5] && r<4){
        d.North(M);
        if(M[5]!=N[5]) d.East(M);
        r++;
    }
    int s=1;
    while(M[6]!=N[6] && s<4) d.East(M),s++;
    
    bool ans = 1;
    for(int i=1;i<7;i++)if(N[i]!=M[i]) ans=0;
    
    if(ans) cout<< "Yes" <<endl;
    else cout<< "No" <<endl;
}


Measured memory_bytes: 3116
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s.length()==6&&s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
	else cout<<"No"; 
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

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


ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// テーブルを作る前処理
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;
}

template <typename T> bool next_combination(const T first, const T last, int k) {
    const T subset = first + k;
    // empty container | k = 0 | k == n 
    if (first == last || first == subset || last == subset) {
        return false;
    }
    T src = subset;
    while (first != src) {
        src--;
        if (*src < *(last - 1)) {
            T dest = subset;
            while (*src >= *dest) {
                dest++;
            }
            iter_swap(src, dest);
            rotate(src + 1, dest + 1, last);
            rotate(subset, subset + (last - dest) - 1, last);
            return true;
        }
    }
    // restore
    rotate(first, subset, last);
    return false;
}

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

    vector<ll> a(N+1), b(N+1), c(N+1);
    a[0] = b[0] = c[0] = 0;
    for(ll i = 1; i <= N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    vector<vector<ll>> dp(N+1, vector<ll>(3, 0));
    dp[0][0] = dp[0][1] = dp[0][2] = 0;

    for(ll i = 1; i <= N; i++) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }

    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;

    return 0;


    
}



Measured memory_bytes: 8064
N = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(N[K-1])

Measured memory_bytes: 3060
#include <map>
#include <unordered_map>
#include <set>
#include <vector>
#include <cstring>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <algorithm>
#include <time.h>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <random>
#include <iterator>
#include <cassert>
#include <cstdint>
#include <string>
#pragma comment(linker, "/STACK:10000000000")

using namespace std;

#define LLD "%I64d"

void print_str(const char* s)
{
	while (*s != 0)
	{
		putchar(*s);
		s++;
	}
}

template<typename T> void scan(T &t)
{
	cin >> t;
}

template<> void scan<int>(int &t)
{
	scanf("%d", &t);
}

template<> void scan<long long>(long long &t)
{
	scanf(LLD, &t);
}

template<> void scan<string>(string &t)
{
	cin >> t;
}

template<> void scan<char*>(char* &t)
{
	scanf("%s", t);
}

template<> void scan<char>(char &t)
{
	t = getchar();
	while (t <= 32)
		t = getchar();
}

template<typename T> void scan(vector<T> &t)
{
	for (int i = 0; i < t.size(); i++)
	{
		scan(t[i]);
	}
}


template<typename T, typename... Ts> void scan(T& t, Ts&... ts)
{
	scan(t);
	scan(ts...);
}

template<typename T> void print(T t)
{
	cout << t;
}

template<> void print<string>(string s)
{
	print_str(s.c_str());
}

template<> void print<int>(int t)
{
	printf("%d", t);
}

template<> void print<long long>(long long t)
{
	printf(LLD, t);
}

template<> void print<char>(char t)
{
	putchar(t);
}

template<> void print<const char*>(const char* t)
{
	print_str(t);
}

template<typename T, typename V> void print(pair<T, V> t)
{
	printf("(");
	print(t.first);
	printf(", ");
	print(t.second);
	printf(")");
}

template<typename T, typename... Ts> void print(T t, Ts... ts)
{
	print(t);
	print(ts...);
}

#define TASK "nocross"
#define X first
#define Y second

const int INF = 1e9;
const long long LINF = 3e18;
const int maxN = 1e5 + 100;
const int maxM = 58;
const int K = 10000;
const int SIZE = (1 << 18);
const int mb = 30;
const long long MOD = 1e9 + 7;
const long long P = 127;
const double EPS = 1e-8;

mt19937_64 random_generator;

long long random(long long l, long long r)
{
	uniform_int_distribution<long long> dist(l, r);
	long long res = dist(random_generator);
	return res;
}

namespace solution
{
}

namespace bruteforce
{
}

void init(bool testing = false)
{

}

void gen(int seed)
{
}

int a[maxN];

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen(TASK".in", "r", stdin);
	//freopen(TASK".out", "w", stdout);
#endif

	long long n;
	scan(n);
	print(n * 800 - n / 15 * 200);

	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  vi v(n);
  rep(i,n){
    cin>>v[i];
  }
  sort(all(v));
  int s=0;
  rep(i,n-1){
    s+=v[i];
  }

  Yes(v[n-1]<s);


}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let M: usize = read();
    let mut vec: Vec<usize> = vec![];
    let mut total = 0;
    for _ in 0..N {
        let v = read();
        vec.push(v);
        total += v;
    }
    vec.sort();
    vec.reverse();
    if vec[M - 1] as f64 >= total as f64 / (4.0 * M as f64) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
using namespace std;

const vector<long long> B={1000000000000000003LL,1000000000000000009LL};
const long long P=1000000000000000031LL;

long long pow_binary_mod(long long x,long long y,long long mod){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=(__int128_t)z*x%mod;
		x=(__int128_t)x*x%mod;
	}
	return z;
}

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

	int T;
	string s;
	cin>>T>>T>>s;
	vector<long long> Brev(2);
	for(int i=0;i<2;i++){
		Brev[i]=pow_binary_mod(B[i],P-2,P);
	}
	set<vector<long long> > se;

	int l=0,r=0;
	vector<long long> c={s[0],s[0]};
	for(;T--;){
		string q;
		cin>>q;
		if(q=="L--"){
			l--;
			for(int i=0;i<2;i++)c[i]=(s[l]*(__int128_t)pow_binary_mod(B[i],r-l,P)+c[i])%P;
		}else if(q=="L++"){
			for(int i=0;i<2;i++)c[i]=((c[i]-s[l]*(__int128_t)pow_binary_mod(B[i],r-l,P))%P+P)%P;
			l++;
		}else if(q=="R--"){
			for(int i=0;i<2;i++)c[i]=((c[i]-s[r])%P+P)%P*(__int128_t)Brev[i]%P;
			r--;
		}else if(q=="R++"){
			r++;
			for(int i=0;i<2;i++)c[i]=(c[i]*(__int128_t)B[i]+s[r])%P;
		}
		se.insert(c);
	}
	printf("%d\n",se.size());
}



Measured memory_bytes: 31464
p=2019
s=input()
l=len(s)
amari=[0]*l
count=[0]*p

ruijo=1

for i in range(l):
    suji=int(s[l-i-1])
    amari[i]=(suji*ruijo)%p
    ruijo*=10
    ruijo%=p

gen=0
count[0]+=1
for i in range(l):
    gen+=amari[i]
    gen%=p
    count[gen]+=1
    #print(gen)

ans=0

for c in count:
    if(c>1):
        ans+=c*(c-1)//2

print(ans)

Measured memory_bytes: 16420
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    LL N;
    R(N);
    if(N&1)W(0);
    else{
        N/=2;
        LL v=0;
        while(N){
            v+=N/5;
            N/=5;
        }
        W(v);
    }
    return 0;
}


Measured memory_bytes: 256
def delta_t(t):
    return abs(t[1] - t[0])

def mh_distance(x, y):
    return abs(x[1] - x[0]) + abs(y[1] - y[0])

def yes_no():
    for i in range(N):
        d_t = delta_t(t[i:i+2])
        mh_d = mh_distance(x[i:i+2], y[i:i+2])
        if (d_t < mh_d or d_t % 2 != mh_d % 2):
            return "No"
    return "Yes"

N, = map(int, input().split())
t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)
for i in range(1, N+1):
    t[i], x[i], y[i] = map(int, input().split())
print(yes_no())

Measured memory_bytes: 11636
rectangles, lozenges = 0, 0
while 1:
    try:
        a, b, c = map(int, input().split(','))
        if a ** 2 + b ** 2 == c ** 2:
            rectangles += 1
            if a == b:
                lozenges += 1
        elif a == b:
            lozenges += 1
    except:
        break

print(rectangles)
print(lozenges)



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

int main() {
	char vowel[6] = {'a', 'e', 'i', 'o', 'u'};
	char S[2];
	cin >> S;
	int flag = 0;
	for (int i = 0; i < 5; i++) {
		if (S[0] == vowel[i]) flag = 1;
	}
	if (flag == 1) cout << "vowel" << endl;
	else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

template <class Abel>
class BIT
{
public:
  using F=function<Abel(Abel,Abel)>;
  F f;
  ll l;
  vector<Abel> bit;
  Abel m0;
  BIT(ll maxidx,F fu,Abel m0):f(fu),l(maxidx),m0(m0)
  {
    bit.assign(l,m0);
  }
  void update(ll idx,ll val)
  {
    while(idx<=l)
    {
      bit[idx]=f(bit[idx],val);
      idx+=idx & -idx;
    }
  }
  ll query(ll idx)
  {
    ll res=m0;
    while(idx>0)
    {
      res=f(bit[idx],res);
      idx-=idx& -idx;
    }
    return res;
  }
};
ll mod=1e9+7;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll> s(n);
  rep(i,n)cin>>s[i];

  s.erase(unique(all(s)),s.end());

  ll l=s.size();
  map<ll,vector<ll>> cidx;
  vector<ll>tv;
  rep(i,l)
  {
    if(cidx.count(s[i])==0)
    {
      cidx[s[i]]=tv;
    }
    cidx[s[i]].push_back(i);
  }

  BIT<ll>bt(l+1,[](ll a,ll b){return (a+b)%mod;},0);
  rep(i,l)
  {
    auto nitr=upper_bound(all(cidx[s[i]]),i);
    if(nitr==cidx[s[i]].end())continue;
    bt.update(*nitr,bt.query(i)+1);
  }
  cout<<(bt.query(l)+1)%mod<<endl;



  return 0;

}


Measured memory_bytes: 25216
#include <iostream>
using namespace std;
char a[52][234];
int main(int argc, char** argv) {
    int n,m,i,j,t;
    cin >> n >> m;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cin >> a[i][j];
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            t=0;
            if(a[i][j]=='.')
            {
                if(a[i-1][j]=='#')
                  t++;
                if(a[i-1][j-1]=='#')
                  t++;
                if(a[i-1][j+1]=='#')
                  t++;
                if(a[i][j+1]=='#')
                  t++;
                if(a[i][j-1]=='#')
                  t++;
                if(a[i+1][j-1]=='#')
                  t++;
                if(a[i+1][j]=='#')
                  t++;
                if(a[i+1][j+1]=='#')
                  t++;
                a[i][j]=t+'0';
            }
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
  int x, y;
  while (1) {
    cin >> x >> y;
    if (x + y == 0)  break;
    cout << min(x, y) << " " << max(x, y) << "\n";
  }
  return 0;
}


Measured memory_bytes: 2980
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

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

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

    // input
    int N;
    cin >> N;

    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> C(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }
    FOR(i, 0, N){
        cin >> B.at(i);
    }
    FOR(i, 0, N){
        cin >> C.at(i);
    }

    sort(ALL(A));
    sort(ALL(B));
    sort(ALL(C));
    
    ll sum = 0;
    for(auto b : B){
        auto it_c = upper_bound(ALL(C), b);
        ll dist_c = distance(it_c, C.end());        

        auto it_a = lower_bound(ALL(A), b);
        ll dist_a = distance(A.begin(), it_a);

        sum += dist_a * dist_c;
    }

    p(sum);

    return 0;
}

Measured memory_bytes: 2560
ab1 = input().split(" ")
ab2 = input().split(" ")
ab3 = input().split(" ")
line = []
count = []

for i in range(2):
    line.append(int(ab1[i]))
    line.append(int(ab2[i]))
    line.append(int(ab3[i]))

count.append(line.count(1))
count.append(line.count(2))
count.append(line.count(3))
count.append(line.count(4))

if(count.count(1) == 2 and count.count(2) == 2):
    print("YES")
else:
    print("NO")


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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

signed main(void){
  int n;cin >> n;
  vector<double> v(n);
  rep(i,n) cin >> v[i];
  vsort(v);
  double res = accumulate(all(v),v[0],[](double x, double y) -> double {
      return (x+y)/2;
      });
  cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long int n,a,b;
	cin>>n>>a>>b;
	if(n==1){
		if(a!=b){
			cout<<0<<endl;
		}else{
			cout<<1<<endl;
		}
		return 0;
	}
	if(a>b){
		cout<<0<<endl;
		return 0;
	}
	cout<<(n-2)*(b-a)+1<<endl;
	return 0;
}


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

int main() {
int N;
string a ="Three";
cin >> N;

 vector<char> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }

for (int i = 0; i < N; i++){
  if(S.at(i) == 'Y'){
a = "Four";
break;
  }
}
cout << a << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		String s = sc.next();

		char[] c = s.toCharArray();

		int count = 0;
		for(int i=0;i<c.length/2;i++) {
			if(c[i] != c[c.length-i-1]) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, d;
  cin >> n >> d;
  vector<ll> x(n), y(n);
  rep(i, n) {
    cin >> x[i] >> y[i];
  }

  ll ans = 0;

  rep(i, n) {
    if (x[i] * x[i] + y[i] * y[i] <= d * d) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6420
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,k,q;
    vector<int> a(100000);
    cin >> n >> k >> q;
    vector<int> b(n,0);
    for(int i=0; i<q; i++){
        cin >> a[i];
    }
    
    for(int j=0; j<q; j++){
        b[a[j]-1]++;
    }
    
    for(int l=0; l<n; l++){
        if((q-b[l])>=k){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }
}

Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio> 
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rangeRep(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
struct Node
{
	int x, y, turn;
};
class Solve {
public:
	Solve() {};
	~Solve() {};

	void solver() {
		std::vector<int> results;
		std::array<std::array<bool, 121>, 121> field;
		while (1) {
			int t, n;
			int startX, startY;
			field = { {0} };
			std::cin >> t >> n;
			if (!t && !n) break;

			//Setting obstacles
			rep(i, n) {
				int x, y;
				std::cin >> x >> y;
				field[y + 60][x + 60] = true;
			}
			std::cin >> startX >> startY;
			field[startY + 60][startX + 60] = true;

			//Breadth-first search
			std::queue<Node> q; //Remember coordinates
			int discoverdCount = 1;
			q.push(Node{ startX+60, startY+60, 0 });
			int dx[] = {1, 0, -1, -1, 0, 1};
			int dy[] = {0, -1, -1, 0, 1, 1};
			while (!q.empty()) {
				auto now = q.front(); q.pop();

				rep(i, 6) {
					auto next = now;
					next.x += dx[i]; next.y += dy[i]; next.turn++;

					//out of range
					if (next.x < 0 || next.x > 120 || next.y < 0 || next.y > 120) {
						continue;
					}
					//obstacle or discovered
					if (field[next.y][next.x]) {
						continue;
					}
					//OK
					discoverdCount++;
					field[next.y][next.x] = true;
					//turn is over
					if (next.turn >= t) continue;
					q.push(next);
				}
			}
			results.push_back(discoverdCount);
		}

		for (auto& x : results) {
			std::cout << x << std::endl;
		}
	}
private:

};

int main() {
	Solve solve;
	solve.solver();
	return 0;
}

Measured memory_bytes: 3032
// Multiple of 2 and N

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int n;

int gcd(long long m, long long n) {

	if ((0 == m) || (0 == n))
		return 0;

	// ユークリッドの方法
	while(m != n) {
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}

int lcm(long long m, long long n) {
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;

	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

int main() {
    cin >> n;
    long long res = lcm(n, 2);

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    println(problem136_b(a))
}

fun problem136_b(a: Long): Int {
    var count = 0
    for (i in 1..a) {
        if (i.toString().length % 2 == 1) {
            count++
        }
    }
    return count
}



Measured memory_bytes: 34224
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
  ll N, X;
  cin >> N >> X;
  
  vector<ll> A(N);
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  
  ll ans = 0;
  while (true){
    if (X >= A.at(ans)){
      X -= A.at(ans);
      ans++;
      if (ans == N){
        if (X > 0){
          ans--;
        }
        break;
      }
    }
    else{
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ffor for(;;)
#define ub upper_bound
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
 
typedef long long ll;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
//const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
int main(){
    ffor{
        int n,x;
        int ans=0;
        std::cin >> n>>x;
        if(x==0&&n==0)exit(0);
        rrep(i,1,n+1){
            rrep(j,i+1,n+1){
                rrep(k,j+1,n+1)if(i+j+k==x)ans++;
            }
        }
        std::cout << ans << std::endl;
    }
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    long long x, y;
    cin >> x >> y;
    for(int i = 0; i < 70; i++){
    if(x > y){
        cout << i << endl;
        return 0; 
    }
    x = x * 2;
    }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ans = 0

def cal(x):
    cnt = 1
    for i in range(1, x + 1):
        cnt *= i
        cnt %= (10**9 + 7)
    return cnt


if abs(N - M) >= 2:
    ans = 0
elif abs(N - M ) == 1:
    ans = (cal(N) * cal(M))  % (10**9 + 7)
else:
    ans = (cal(N) * cal(M) * 2) % (10 ** 9 + 7)

print(ans)

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  ll p,q;
  vector<vector<ll>> a(n);
  for(i=0;i<m;i++){
    cin>>p>>q;
    a[p-1].push_back(q-1);
    a[q-1].push_back(p-1);
  }
  for(i=0;i<a[0].size()&&judge;i++){
    buf=a[0][i];
    for(j=0;j<a[buf].size();j++){
      if(a[buf][j]==n-1){
        judge=false;
        break;
      }
    }
  }
  anss(judge,"IMPOSSIBLE","POSSIBLE");

  return 0;
}

Measured memory_bytes: 12776
a = gets.chomp.chars
b = gets.chomp.chars
if a.size > b.size
  puts 'GREATER'
elsif a.size < b.size
  puts 'LESS'
else
  while a.size != 0
    if a[0] > b[0]
      puts 'GREATER'
      exit
    elsif a[0] < b[0]
      puts 'LESS'
      exit
    elsif
      a.delete_at(0)
      b.delete_at(0)
    end
    if a.size == 0
      puts 'EQUAL'
    end
  end
end


Measured memory_bytes: 14376
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

ld n;
double threes, twos, ones;
vector<vector<vector<ld>>> dp;
vector<vector<vector<bool>>> vis;

ld cnt(int o, int tw, int th)
{
    if (o == 0 && tw == 0 && th == 0)
        return 0;
    if (vis[o][tw][th])
        return dp[o][tw][th];
    vis[o][tw][th] = true;
    ld x = 0, y = 0, z = 0;
    if (o - 1 >= 0)
        x = cnt(o - 1, tw, th);
    if (tw - 1 >= 0)
        y = cnt(o + 1, tw - 1, th);
    if (th - 1 >= 0)
        z = cnt(o, tw + 1, th - 1);
    //cout << "ch\n";
    dp[o][tw][th] = (n + o * x + tw * y + th * z) / ld(o + tw + th);
    // cerr << o << ' ' << tw << ' ' << th << ' ' << x << ' ' << y << ' ' << z << ' ';
    // cerr << dp[o][tw][th] << '\n';
    return dp[o][tw][th];
}

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

    cin >> n;
    dp = vector<vector<vector<ld>>>(n + 1, vector<vector<ld>>(n + 1, vector<ld>(n + 1)));
    vis = vector<vector<vector<bool>>>(n + 1, vector<vector<bool>>(n + 1, vector<bool>(n + 1)));
    for (size_t i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        if (temp == 1)
            ones++;
        else if (temp == 2)
            twos++;
        else
            threes++;
    }

    cout << fixed << setprecision(12) << cnt(ones, twos, threes);
    return 0;
}


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

map<int,int> dp;

int solve(int x) {
  if ( dp.count(x) ) {
    return dp[x];
  }
  if ( x == 0 || x == 100 || x == 101 || x == 102 || x == 103 || x == 104 || x == 105 ) {
    dp[x] = 1;
    return dp[x];
  }
  if ( x < 100 ) {
    dp[x] = 0;
    return dp[x];
  }
  if ( solve(x-100) ) {
    dp[x] = 1;
    return dp[x];
  }
  if ( solve(x-101) ) {
    dp[x] = 1;
    return dp[x];
  }
  if ( solve(x-102) ) {
    dp[x] = 1;
    return dp[x];
  }
  if ( solve(x-103) ) {
    dp[x] = 1;
    return dp[x];
  }
  if ( solve(x-104) ) {
    dp[x] = 1;
    return dp[x];
  }
  if ( solve(x-105) ) {
    dp[x] = 1;
    return dp[x];
  }
  dp[x] = 0;
  return dp[x];
}

int main() {
  //input
  int X;
  cin >> X;
  //calc
  int answer = solve(X);
  //output
  cout << answer << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
    char s[100002];
    scanf("%s", s);
    int x = 0, p = 0;
    while(s[x] != '\0'){
        if(s[x] == 'g'){
            p++;
        }else{
            p--;
        }
        x++;
    }
    printf("%d", p/2);

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
l = []
for i in range(200001):
  l.append([])

for i in range(m):
  a, b = map(int, input().split())
  l[a].append(b)
def f():
  for i in l[1]:
    if n in l[i]:
      return 'POSSIBLE'
  
  return 'IMPOSSIBLE'
print(f())

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

int main() {
  ll n,k;
  cin >> n >> k;
  ll a = n%k;
  ll ans = min(a, k-a);
  cout << ans << endl;
};

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  string s;cin>>s;

  vector<ll> a(s.size()+2,0);
  vector<ll> b(s.size()+2,0);
  
  ll p = 0,m = 0;
  rep(i,s.size()){
    if(s[i] == '<')p++;
    else p = 0;
    a[i+1] = p;
  }
  for(int i = s.size()+1;i >= 0;--i){
    if(s[i] == '>')m++;
    else m = 0;
    b[i] = m;
  }
  
  ll ans = 0;
  rep(i,s.size()+2){
    
    ans += max(a[i],b[i]);
    //cout<<s[i]<<max(a[i],b[i])<<' ';
  }
  //cout<<endl;
  print(ans);
  return 0;
}



Measured memory_bytes: 8708
// package com.company;

import java.util.Scanner;
import java.util.Stack;

public class Main {
    static Scanner input = new Scanner(System.in);

    private static void solve() {
        
        int n = input.nextInt();

        int[] p = arrayInput(n);
        input.close();
        
        // Map<Integer, Integer> map = new HashMap<>();
        Stack<Integer> stack = new Stack<>();
        char[] ans = new char[n*2];
        int indexAns = 0;
        int indexStack = 0;

        for (int i=0; i<n; i++) {
            while (stack.isEmpty() || stack.peek()<p[i]) {
                ans[indexAns++] = '(';
                stack.push(++indexStack);
            }
            if (stack.peek() != p[i]) {
                System.out.println(":(");
                return;
            }
            stack.pop();
            ans[indexAns++] = ')';
        }

        if(stack.size() >=1) {
            System.out.println(":(");
            return;
        } else {
            System.out.println(ans);
        }
        
    }

    public static void main(String[] args) {
        solve();
    }
    

    private static int[] arrayInput(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
        a[i] = input.nextInt();
        return a;
    }
}


Measured memory_bytes: 70712
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	
    public static void main(String[] args) {
    	FastScanner sc = new FastScanner();
    	
    	int c11 = sc.nextInt();
    	int c12 = sc.nextInt();
    	int c13 = sc.nextInt();
    	int c21 = sc.nextInt();
    	int c22 = sc.nextInt();
    	int c23 = sc.nextInt();
    	int c31 = sc.nextInt();
    	int c32 = sc.nextInt();
    	int c33 = sc.nextInt();
    	
    	int b1 = c11;
    	int b2 = c12;
    	int b3 = c13;
    	int a2 = c21 - b1;
    	int a3 = c31 - b1;
    	
    	boolean can = true;
    	
    	if(c22!=a2+b2 || c23!= a2+b3 || c32!= a3+b2 || c33!= a3+b3){
    		can = false;
    	}
    	
    	if(can){
        	System.out.println("Yes");
    	}
    	else{
        	System.out.println("No");
    	}
    }
    
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 22484
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		int n[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
		
		
		if(n[x] == n[y]) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int calcNumOfCombination(int n, int r){
    int num = 1;
    for(int i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}
int main() {
    int n,m;
    cin>>n>>m;
    int a=0;
    int b=0;
    a = calcNumOfCombination(n,2);
    b = calcNumOfCombination(m,2);
    printf("%d\n",a+b);
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[list(map(int,input().split())) for i in range(n)][::-1]
b=0
for i in range(n):
    if (b+a[i][0])%a[i][1]==0:
        continue
    b+=a[i][1]-(b+a[i][0])%a[i][1]
print(b)

Measured memory_bytes: 27956
#include <stdio.h>
#define MAX_V 1000000
int prime[MAX_V+1];
int main(){
    int i, k, n;
    
    for(i = 2; i <= MAX_V; i++){
        prime[i] = 1;
    }
    for(i = 2; i * i <= MAX_V; i++){
        if(prime[i]){
            for(k = 2*i;k <= MAX_V; k += i){
                prime[k] = 0;
            }
        }
    }
    while(scanf("%d", &n) != EOF){
        if(n==0) break;
        for(i = n; i >=2; i--){
            if(prime[i - 2]&& prime[i]/*&&p1<i*/){
                printf("%d %d\n", i - 2, i);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 5660
#include <bits/stdc++.h>
#define maxN 802
#define inf 1000000000
using namespace std;

//FILE *fin = freopen("c.in", "r", stdin);

int h, w, k;
char a[maxN][maxN];

struct Coord
{
    int x, y;
} st;
int dist[maxN][maxN];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
queue < Coord > q;

int ans;


int Manhattan(int x, int y)
{
    if (x == 1 || x == h || y == 1 || y == w)
        return 0;
    int ret = min(x - 2, y - 2) / k + 1;
    ret = min(ret, min(h - x - 1, w - y - 1) / k + 1);
    return ret;
}

void Bfs()
{
    q.push(st);
    while (!q.empty())
    {
        Coord nod = q.front();
        q.pop();
        ans = min(ans, 1 + Manhattan(nod.x, nod.y));
        if (dist[nod.x][nod.y] >= k)
            continue;
        for (int d = 0; d < 4; ++ d)
            if (a[nod.x + dx[d]][nod.y + dy[d]] == '.' &&
                    (!dist[nod.x + dx[d]][nod.y + dy[d]] || dist[nod.x + dx[d]][nod.y + dy[d]] > dist[nod.x][nod.y] + 1))
            {
                dist[nod.x + dx[d]][nod.y + dy[d]] = dist[nod.x][nod.y] + 1;
                q.push({nod.x + dx[d], nod.y + dy[d]});
            }
    }
}

int main()
{
    scanf("%d %d %d", &h, &w, &k);
    for (int i = 1; i <= h; ++ i)
    {
        scanf("%s", a[i] + 1);
        for (int j = 1; j <= w; ++ j)
            if (a[i][j] == 'S')
                st = {i, j};
    }
    ans = inf;
    Bfs();
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

int n, a[100001], b[100001], c[100001];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a+n);
	for(int i = 0; i < n; i++){
		cin >> b[i];
	}
	sort(b, b+n);
	for(int i = 0; i < n; i++){
		cin >> c[i];
	}
	sort(c, c+n);
	
	Int ans = 0;
	
	for(int i = 0; i < n; i++){
		ans += (lower_bound(a, a+n, b[i]) - (a)) * ((c+n) - upper_bound(c, c+n, b[i]));
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1408