akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
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; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto e : s) os << e; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

vector<pii> runlength(vector<int> v) {
  vector<pii> ret;
  int cnt = 1;
  int n = sz(v);
  rep3(i, 1, n) {
    if (v[i] == v[i - 1]) {
      cnt++;
    } else {
      ret.eb(v[i - 1], cnt);
      cnt = 1;
    }
  }
  ret.eb(v[n - 1], cnt);
  return ret;
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  sort(all(a));

  auto v = runlength(a);
  a.clear();
  rep(i, sz(v)) a.eb(v[i].S);
  sort(all(a));

  vector<ll> b(sz(v) + 1);
  rep(i, sz(v)) b[i + 1] = b[i] + a[i];
  cerr << a << endl << b << endl;

  rep3(i, 1, n + 1) { // 何枚組でとるか
    auto binary_search = [&](int ok, int ng) {
      auto check = [&](int x) { // 最大何組とれるか
        int it = lb(a, x);
        ll sum = (it >= 0 ? b[it] : 0);
        sum += (sz(v) - it) * 1LL * x;
        if (sum >= x * 1LL * i) return 1;
        return 0;
      };
      int d = 1;
      while (abs(ng - ok) > d) {
        int mid = (ng + ok) / 2;
        (check(mid) ? ok : ng) = mid;
      }
      cout << ok << endl;
    };
    binary_search(0, n + 1);
  }

}


Measured memory_bytes: 9668
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);int b = int.Parse(s[1]);
            int ans = a+b;

            Console.WriteLine(ans>=24 ? ans-24:ans);
        }
    }
}


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

string a, ans;

int main() {
  cin >> a;

  if (a[0] == a[1] || a[1] == a[2] || a[2] == a[3]) {
    ans = "Bad";
  } else {
    ans = "Good";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
pair<int,int> a[100010];
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x,l;
        cin>>x>>l;
        a[i].first=x+l-1;
        a[i].second=x-l;
    }
    // end start
    sort(a,a+n);
    /*
    for(int i=0;i<n;i++)
        cout<<a[i].first<<' '<<a[i].second<<'\n';*/
    int cnt=0;
    for(int i=0;i<n;i++){
        int j= i;
        cnt++;
        while(i+1<n&&a[j].first>=a[i+1].second)
            i++;
    }
    cout<<cnt;

}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  map<char,int>m;
  rep(i,n){
      m[s[i]]++;
  }
  string S;
  rep(i,m['R']) S.push_back('R');
  rep(i,m['W']) S.push_back('W');
int R=0,W=0,ans = 0;
int a=0;
rep(i,m['R']){
if(s[i] != S[i]) R++;
}
for(int i = m['R']; i < n ;i++){
    if(s[i] != S[i]) W++;
}
cout<<min(R,W) + abs(R-W)<<endl;

  return 0;
}

Measured memory_bytes: 3920
n = int(input().strip())
arry = list(map(int,input().strip().split()))

min = arry[1]
max = arry[1]


for i in range(len(arry)):
  if arry[i] < min:
    min = arry[i]
  if arry[i] > max:
    max = arry[i]

print (max-min)


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

int a[200],n,i,nn,ln;
int main()
{
  
    scanf("%d\n",&n);
    nn=2000;
    ln=-1;
    for (i=1;i<=n;i++)
    {
        scanf("%d ",&a[i]);
        ln=max(ln,a[i]);
        nn=min(nn,a[i]);
    }
    printf("%d",ln-nn);
}


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

res = 0
right = 0
s = 0
for left in range(N):
    while right < N and s^A[right] == s+A[right]:
        s += A[right]
        right += 1
    res += right-left
    if right == left: right += 1
    else: s -= A[left]
print(res)

Measured memory_bytes: 24840
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;

const int N=10005;
const int M=10000005;

int n1,n2,n,cnt,now,m,ans;
int lk[N],p1[N],p2[N],pri[M],p[N],c[M],b[M],tag[N];
bool vis[M];
vector<int> lev[N];

void getpri(int n){
	int i,j;
	for (i=2;i<=n;i++){
		if (!vis[i]) pri[++cnt]=i;
		for (j=1;j<=cnt&&pri[j]*i<=n;j++){
			vis[i*pri[j]]=1;
			if (i%pri[j]==0) break;
		}
	}
	vis[1]=vis[2]=1;
}

bool dfs(int k){
	int u,j;
	for (j=0;j<lev[k].size();j++){
		u=lev[k][j];
		if (tag[u]!=now){
			tag[u]=now;
			if (!lk[u]||dfs(lk[u])){
				lk[u]=k;
				return 1;
			}
		}
	}
	return 0;
}

int main(){
	int i,j;
	getpri(M-1);
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&p[i]);
	sort(p+1,p+1+n); m=p[n]+1;
	for (i=1;i<=n;i++) b[p[i]]^=1;
	for (i=1;i<=m;i++) c[i]=b[i]!=b[i-1];
	for (i=1;i<=m;i++)
		if (c[i]){
			if (i&1) p1[++n1]=i;
			else p2[++n2]=i;
		}
	for (i=1;i<=n1;i++)
		for (j=1;j<=n2;j++)
			if (!vis[abs(p1[i]-p2[j])]) lev[i].push_back(j);
	for (i=1;i<=n1;i++){
		now++;
		ans+=dfs(i);
	}
	printf("%d\n",ans+(n1-ans)/2*2+(n2-ans)/2*2+(n1-ans)%2*3);
	return 0;
}

Measured memory_bytes: 92416
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
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; }
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

map<ll,ll> prime_factor(ll n){
    map<ll,ll> mp;
    for(ll i=2; i*i<=n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}
int main(){
    string s;
    cin >> s;
    for (ll bit=0;bit<(1LL<<3);bit++){
        bool x[3];
        fill(x,x+3,false);
        for (ll i = 0; i < 3; ++i) {
            if (bit & (1<<i)) {
                x[i]=true;
            }
        }
        ll a[4];
        for (ll i=0;i<4;i++){
            a[i]=s[i]-'0';
        }
        ll count=a[0];
        for (ll i=0;i<3;i++){
            if (x[i])count+=a[i+1];
            else count-=a[i+1];
        }
        if (count==7){
            cout << a[0];
            for (ll i=0;i<3;i++){
                if (x[i])cout << "+";
                else cout << "-";
                cout << a[i+1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

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

	Int N;
	cin >> N;

	map<string, Int> cnt;

	string temp1;
	cin >> temp1;
	cnt[temp1]++;

	Int len1, len2;
	string temp2;
	Int flag = 1;
	for (Int i = 0; i < N-1; i++) {
		cin >> temp2;

		cnt[temp2]++;
		if (cnt[temp2]>=2) {
			flag = 0;
			break;
		}

		len1 = temp1.size();
		len2 = temp2.size();

		if (temp1[len1-1]!=temp2[0]) {
			flag = 0;
			break;
		}
		else {
			temp1 = temp2;
		}
	}

	if (flag) cout << "Yes" << "\n";
	else cout << "No" << "\n";

}


Measured memory_bytes: 256
#include <stdio.h>
#define max(a, b) ((a)>(b)?(a):(b))
int n, m, la, lb;
char S[55][55];
int d[52][52][52][52];
int ax[26][11], ay[26][11], an[26];
inline bool match(char A, char B) {
    la = 'a' <= A && A <= 'z';
    lb = 'a' <= B && B <= 'z';
    if (la && !lb && A - 'a' == B - 'A') return 1;
    return 0;
}
int f(int ux, int uy, int dx, int dy) {
    if (ux > dx || uy > dy) return -1;
    if (d[ux][uy][dx][dy] != -2) return d[ux][uy][dx][dy];
    d[ux][uy][dx][dy] = -1;
    if (S[ux][uy] != '#' && S[dx][dy] != '#') {
        if (ux == dx && uy == dy) return d[ux][uy][dx][dy] = 0;
        if (S[ux][uy] == '.' || ('A' <= S[ux][uy] && S[ux][uy] <= 'Z')) d[ux][uy][dx][dy] = max(f(ux + 1, uy, dx, dy), f(ux, uy + 1, dx, dy));
        else {
            d[ux][uy][dx][dy] = max(f(ux + 1, uy, dx, dy), f(ux, uy + 1, dx, dy));
            int p = S[ux][uy] - 'a', v, nx, ny, ff;
            for (int i = 1; i <= an[p]; i++) {
                v = -1;
                nx = ax[p][i];
                ny = ay[p][i];
                if ((ux == nx && uy + 1 == ny) || (uy == ny && ux + 1 == nx)) {
                    ff = f(nx, ny, dx, dy);
                    if (match(S[ux][uy], S[nx][ny]) && ff != -1) d[ux][uy][dx][dy] = max(d[ux][uy][dx][dy], 1 + ff);
                }
                else {
                    if (ux <= nx && nx <= dx && uy <= ny && ny <= dy) {
                        v = max(v, f(ux + 1, uy, nx - 1, ny));
                        v = max(v, f(ux + 1, uy, nx, ny - 1));
                        v = max(v, f(ux, uy + 1, nx - 1, ny));
                        v = max(v, f(ux, uy + 1, nx, ny - 1));
                        ff = f(nx, ny, dx, dy);
                        if (v != -1 && ff != -1) d[ux][uy][dx][dy] = max(d[ux][uy][dx][dy], v + 1 + ff);
                    }
                }
            }
        }
    }
    return d[ux][uy][dx][dy];
}
int main() {
    while (scanf("%d%d", &n, &m), n&&m) {
        for (int i = 1; i <= n; i++) scanf("%s", S[i] + 1);
        for (int i = 0; i < 26; i++) an[i] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if ('A' <= S[i][j] && S[i][j] <= 'Z') {
                    int p = S[i][j] - 'A';
                    an[p]++;
                    ax[p][an[p]] = i;
                    ay[p][an[p]] = j;
                }
            }
        }
        for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) for (int k = 1; k <= n; k++) for (int l = 1; l <= m; l++) d[i][j][k][l] = -2;
        printf("%d\n", f(1, 1, n, m));
    }
}

Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
 
  
  if(b!=1){
  int num=1;
  int sum=a;
  while(sum<b){
    num++;
    sum+=a-1;
  }
  cout << num << endl;
  }
  else{
    cout << 0 << endl;
  }
  
}

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

#define ff first
#define ss second
#define maxn 2000006
#define pb push_back
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)

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

using namespace std;

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

	ll n; cin >> n;

	ll v[n];
	f(i, 0, n - 1) cin >> v[i];

	sort(v, v + n);

	ll s = v[0];
	ll coeff = 1;

	f(i, 1, n - 1) {
		s += (coeff * v[i]);
		coeff = coeff << 1;
	}

	double ans = (double)s / pow(2ll, n - 1);

	cout << ans;


	return 0;
}

Measured memory_bytes: 512
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 

#define F(type, i, a, b) for(type i = a; i <= b; i ++)
const int MAX = 1000001; 

// structure to store queries 
struct Query 
{ 
	int l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 

// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 

// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
	int sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
	// initialising bit array 
	int bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 

	// holds the rightmost index of any number 
	// as numbers of a[i] are less than or equal to 10^6 
	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	// answer for each query 
	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		// If last visit is not -1 update -1 at the 
		// idx equal to last_visit[arr[i]] 
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		// Setting last_visit[arr[i]] as i and updating 
		// the bit array accordingly 
		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 

		// If i is equal to r of any query store answer 
		// for that query in ans[] 
		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 

	// print answer for each query 
	for (int i=0; i<q; i++) 
		cout << ans[i] << '\n'; 
} 

// driver code 
int main() 
{ 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,q;
    cin>>n>>q;
    int a[n];
    F(int, i, 0, n - 1) cin>>a[i];
	Query queries[q];
    F(int, i, 0, q - 1){
        cin>>queries[i].l>>queries[i].r;
        queries[i].l--;queries[i].r--;
        queries[i].idx = i;
    } 
	sort(queries, queries + q, cmp); 
	answeringQueries(a, n, queries, q); 
	return 0; 
} 


Measured memory_bytes: 19396
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ll long long int
using namespace std;
int main(){
	io;
	char s[105];
	cin >> s;
	int l = strlen(s);
	for(int i = 0;i < l;++i){
		cout << 'x';
	} 
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
As = list(map(int, input().split()))
ones = [1 for _ in range(N)]
Bs = []
Cs = []
both = list(zip(As, ones))
for _ in range(M):
  b, c = map(int, input().split())
  both.append((c, b))
both.sort()
a, b = zip(*both)
cnt = 0
out = 0
for k in reversed(range(N+M)):
  if N - cnt > b[k]:
    out += a[k] * b[k]
    cnt += b[k]
  else:
    out += a[k] * (N - cnt)
    break
print(out)

Measured memory_bytes: 47608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s, b;
        String c;
        int count = 0;
        int j = 0;
        try {
            s = br.readLine();
            b = br.readLine();
            c = s + s;
            for (int i = 0; i < c.length() - b.length(); i++) {
                if (b.equals(c.substring(i, i + b.length()))) {
                    System.out.println("Yes");
                    return;
                }
            }
            System.out.println("No");

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 24428
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int N;
    int f;
  cin >> N;
  for (int i = 0; i < 10; i++) {
    int a;
    int b;
    int c;
    int d;
    double e;
    e = pow(10, i);
    d = e;
    a = N % d;
    b = N % (10*d);
    c = (b-a)/d;
    f += c;
 }
  if(N%f==0){cout << "Yes" << endl;}
       else{cout << "No" << endl;}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main(){
  double L;
  cin >> L;
  double ans = L*L*L/27;
  printf("%.12f", ans);
  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);
        String b = sc.next();
        
        switch (b) {
        case "A":
        	System.out.println("T");
        	break;
        case "T":
        	System.out.println("A");
        	break;
        case "C":
        	System.out.println("G");
        	break;
        case "G":
        	System.out.println("C");
        	break;
        }
	}	
}

Measured memory_bytes: 22868
import math
N,K=map(int,(input().split()))
ans=0
if N >= K :
    for i in range(K-1):
        L = int(math.log(K/(i+1) , 2))
        if L < math.log(K/(i+1) , 2)  :
            ans +=  (1/N) * 0.5**(L+1)
        else:
            ans += (1/N) * 0.5**L
    ans += (N-K+1) / N
else:
    for i in range(N):
        L = int(math.log(K/(i+1) , 2))
        if L - math.log(K/(i+1) , 2) == 0 :
            ans += (1/N) * 0.5**L
        else :
            ans += (1/N) * 0.5**(L+1)
print(ans)

Measured memory_bytes: 3316
#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() {
    int n;
    string s;
    cin >> n >> s;
    long long  RC=0,GC=0,BC=0;
    for(int i=0;i<n;++i){
        if(s[i] == 'R')RC++;
        else if(s[i] == 'G')GC++;
        else BC++;
    }
    long long sum = RC * GC * BC;
    for(int i=0;i<n;++i){
        for(int d=0;d<n;++d){
            int j = i + d;
            int k = j + d;
            if(k >= n)break;
            if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]){
                sum--;
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3620
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
lis = sorted(make_divisors(N))

ans = 10000
for i in range(len(lis)):
    a, b = lis[i], N // lis[i]
    f = max(len(str(a)), len(str(b)))
    ans = min(ans, f)
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    int n, k;
    cin >> n >> k;
    int ma = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ma = max(ma, a[i]);
    }

    int ok = ma, ng = 0;
    while (ok - ng > 1) {
        int mid = (ok + ng) / 2;

        ll count = 0;
        for (auto &x:a) count += (x - 1) / mid;

        if (count <= k)ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 3976
# サイコロ        初期状態
#    [1]           N
# [4][2][3][5]   W[1]E
#    [6]           S
#
# 上記の順番でラベルに対する整数が与えられる
# l1 l2 l3 l4 l5 l6
# 「上面[1] 前面[2]」が与えられて右側の面[3]を答える

class Dice:
    def __init__(self, l1, l2, l3, l4, l5, l6):
        self.l1 = l1
        self.l2 = l2
        self.l3 = l3
        self.l4 = l4
        self.l5 = l5
        self.l6 = l6
        self.tmp = 0
    def move_n(self):
        self.tmp = self.l5
        self.l5 = self.l1
        self.l1 = self.l2
        self.l2 = self.l6
        self.l6 = self.tmp
    def move_s(self):
        self.tmp = self.l2
        self.l2 = self.l1
        self.l1 = self.l5
        self.l5 = self.l6
        self.l6 = self.tmp
    def move_e(self):
        self.tmp = self.l3
        self.l3 = self.l1
        self.l1 = self.l4
        self.l4 = self.l6
        self.l6 = self.tmp
    def move_w(self):
        self.tmp = self.l4
        self.l4 = self.l1
        self.l1 = self.l3
        self.l3 = self.l6
        self.l6 = self.tmp
    def show(self):
        return self.l1, self.l2, self.l3, self.l4, self.l5, self.l6

d1 = Dice(*map(int, input().split()))
n = int(input())

for _ in range(n):
    ue, mae = map(int, input().split())
    ne_switch = 0
    while d1.l2 != mae:
        if ne_switch < 3:
            d1.move_n()
            ne_switch+=1
        elif 3 <= ne_switch :
            d1.move_e()
            ne_switch+=1
        if ne_switch == 6: ne_switch = 0
    while d1.l1 != ue:
        d1.move_e()
    print(d1.l3)


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    ll a,b,k;
    cin>>a>>b>>k;
    cout<<max(0LL,a-k)<<" "<<max(0LL,b+min(0LL,a-k));
    return 0;
}


Measured memory_bytes: 256
/*
ex4_1
tomatokan
*/
#include<stdio.h>

int main(void){
    int apple,sight;
    scanf("%d",&apple);
    scanf("%d",&sight);
    if(apple%(2*sight+1)==0){
        /*監視員の視野をちょうど使い切る場合*/
        printf("%d\n",apple/(2*sight+1));
    }else{
        /*その他*/
        printf("%d\n",1+apple/(2*sight+1));
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

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

    String TAILES = sc.next();
    int sum = 0;

    char anxis = TAILES.charAt(0);
    char next;
    if(anxis == '0'){
      next = '1';
    }else{
      next = '0';
    }

    for(int i=1;i<TAILES.length();i++){
      if(TAILES.charAt(i) != next){
        sum+=1;
      }
      if(next == '0'){
        next = '1';
      }else{
        next ='0';
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 24364
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
issafe = [1] * (n + 1)
for i in range(m):
    issafe[a[i]] = 0
mod = 10**9 + 7
dp = [0] * (n + 1)
dp[0] = 1
if issafe[1]:
    dp[1] = 1
for i in range(2, n + 1):
    if issafe[i - 1]:
        dp[i] += dp[i - 1]
    if issafe[i - 2]:
        dp[i] += dp[i - 2]
    dp[i] %= mod
print(dp[n])


Measured memory_bytes: 9608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		sc.close();
		
		String [] St = S.split("");
		
		int [] Left = new int [N+2];
		int[] Right = new int [N+2];
		
		int count =0;
		for (int i=0; i<N; i++){
			if (St [i].equals("W"))
				count++;
			Left [i+1]=count;
		}
		Left[0]=0;
		Left[N+1]=count;
		
		count = 0;
		for (int i=N; i>0; i--){
			if (St[i-1].equals("E"))
				count++;
			Right [i]=count;
		}
		Right[0]=count;
		Right[N+1]=0;
		
		int min = 1_000_000_007;
		for (int i=1; i<N+1; i++){
			min = Math.min(min, Left[i-1]+Right[i+1]);
		}
	
		System.out.println(min);

	}

}

Measured memory_bytes: 55040
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N,M,sum=0;
    cin>>N>>M;
    vector<int>vote(N);
    for(int i=0;i<N;i++){
    	cin>>vote.at(i);
        sum+=vote.at(i);
    }
    sort(vote.begin(),vote.end());
   
    if(vote.at(N-M)*4*M>=sum){
    	cout<<"Yes"<<endl;
    }else{
    	cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect

setrecursionlimit(10**7)

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

k = "keyence"
m = len(k)

S = input()
N = len(S)

if N < m:
  print("NO")
  exit()

a = next(i for i in range(N, -1, -1) if S[:i] == k[:i])
b = next(i for i in range(N, -1, -1) if S[N-i:] == k[m-i:])

print("YES" if a + b >= m else "NO")

Measured memory_bytes: 38384
// :)
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <sstream>
#include <stack>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <vector>

typedef long long LL;

using namespace std;

std::random_device rd_device;
std::mt19937 rng(rd_device());

int main() {
    ios::sync_with_stdio(false);
    cin.exceptions(ios_base::failbit);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(10);
    cout<<fixed;
    
    vector<int> dishes(5);
    for (int i=0;i<5;i++) cin>>dishes[i];

    int diff = 0;
    int s = 0;
    int additional = 0;
    for (int i=0;i<5;i++) {
        int r = (10 -  dishes[i] % 10) % 10;
        s += dishes[i];
        additional += r;
        diff = max(diff, r);
    }

    cout<<s + additional - diff<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	int n,k;
	char a[55];
	cin>>n>>k;
	scanf("%s",&a);
	if(a[k-1]=='A'){
		a[k-1]='a';
	}
	if(a[k-1]=='B'){
		a[k-1]='b';
	}
	if(a[k-1]=='C'){
		a[k-1]='c';
	}
	for(int i=0;i<n;i++){
		cout<<a[i];
	}
	return 0;
}


Measured memory_bytes: 256
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
li = [0] * M
for i in range(M):
    B,C = [int(j) for j in input().split()]
    li[i] = [C,B]
li.sort()
li.reverse()
A.sort()
Ba = [0] * M
for i in range(M):
    Ba[i] = li[i][1]
from numpy import cumsum
from bisect import bisect_left
B_sum = list(cumsum(Ba))
count = B_sum[-1]
N = min(N,count)
for i in range(N):
    indexa = bisect_left(B_sum,i+1)
    if A[i] >= li[indexa][0]:
        break
    if A[i] < li[indexa][0]:
        A[i] = li[indexa][0]
print(sum(A))

Measured memory_bytes: 38984
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

int a[3];

int main(){

	scanf("%d %d %d",&a[0],&a[1],&a[2]);

	sort(a,a+3);

	if(a[2]==a[0]+a[1]){printf("Yes\n");}
	else{printf("No\n");}

	return 0;
}

Measured memory_bytes: 256
#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(){
    int k, a, b;
    cin >> k;
    cin >> a >> b;
    string ans = "NG";
    for(int i = a; i <= b; i++){
        if(i % k ==0){
            ans = "OK";
            break;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main() {
	string s;
	cin >> s;
 
	if (s[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}
 
	int cnt = 0;
	for (int i = 1; i < s.size(); i++) {
		if (((i >= 2) && (i < s.size() - 1)) && (s[i] == 'C')) cnt++;
		else if ((s[i] >= 'A') && (s[i] <= 'Z')) {
			cout << "WA" << endl;
			return 0;
		}
	}
 
	if (cnt == 1) {
		cout << "AC" << endl;
	} else {
		cout << "WA" << endl;
	}
 
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        map.put("AC", 0);
        map.put("WA", 0);
        map.put("TLE", 0);
        map.put("RE", 0);
        while (N-- > 0) {
            String s = sc.next();
            map.put(s, map.get(s) + 1);
        }

        System.out.println("AC x " + map.get("AC"));
        System.out.println("WA x " + map.get("WA"));
        System.out.println("TLE x " + map.get("TLE"));
        System.out.println("RE x " + map.get("RE"));
    }
}


Measured memory_bytes: 58316
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s_: Vec<char> = iterator.next().unwrap().chars().collect();
    let t: Vec<char> = iterator.next().unwrap().chars().collect();

    if t.len() > s_.len() {
        return "UNRESTORABLE".to_string();
    }

    let mut candidates: Vec<String> = Vec::new();
    for i in 0..(s_.len() - t.len() + 1) {
        let mut can_replace = true;
        let mut candidate = s_.clone();
        for j in 0..t.len() {
            if candidate[i + j] != '?' && candidate[i + j] != t[j] {
                can_replace = false;
                break;
            } else {
                candidate[i + j] = t[j];
            }
        }
        if can_replace {
            let s: String = candidate.into_iter().collect::<String>();
            candidates.push(s.replace('?', "a"));
        }
    }

    if candidates.is_empty() {
        return "UNRESTORABLE".to_string();
    }

    candidates.sort();

    return candidates[0].clone();
}


Measured memory_bytes: 4476
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];

void Solve() {
	int n;
	cin >> n;
	int ma = 0;
	int sum = 0;
	for (size_t i = 0; i < n; i++)
	{
		int v;
		cin >> v;
		ma = max(ma, v);
		sum += v;
	}
	if ((sum - ma) > ma) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}


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



Measured memory_bytes: 6400
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===

def disLR(a, idx):
    small = a[max(0, idx - 1)]
    large = a[min(len(a) - 1, idx)]
    return [small, large]


def main():
    a, b, q = ns()
    s = [ni() for _ in range(a)]
    t = [ni() for _ in range(b)]

    for _ in range(q):
        ans = INF

        x = ni()

        idxs = bisect.bisect_left(s, x)
        a1 = disLR(s, idxs)

        idxt = bisect.bisect_left(t, x)
        a2 = disLR(t, idxt)

        for ta1 in a1:
            for ta2 in a2:
                tmp1 = abs(x - ta1) + abs(ta2 - ta1)
                tmp2 = abs(x - ta2) + abs(ta1 - ta2)
                ans = min(ans, tmp1, tmp2)

        print(ans)


if __name__ == '__main__':
    main()


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

int main(){
  int k,slen;
  string s;
  cin>>s>>k;
  slen=s.size();
  for(int i=0;i<slen;i++){
    if(!k)break;
    if(i!=slen-1){
      if(s[i]!='a'&&'z'-s[i]+1<=k)k-='z'-s[i]+1,s[i]='a';
    }else{
      k=k%26;
      if(s[i]+k>'z'){
	k-='z'-s[i];
	s[i]='a'+k-1;
      }else{
	s[i]=s[i]+k;
      }
    }
  }
  cout<<s<<endl;
  return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

struct edge{
	lli to,cost;
};
lli distA[100100];
lli distB[100100];

vector<vector<edge>> g;

void func1(lli now,lli from){
	for(auto e:g[now]){
		if(e.to==from)continue;
		distA[e.to] = distA[now]+e.cost;
		func1(e.to,now);
	}
}

void func2(lli now,lli from){
	for(auto e:g[now]){
		if(e.to==from)continue;
		distB[e.to] = distB[now]+e.cost;
		func2(e.to,now);
	}
}

signed main(){

	lli n,u,v;
	cin>>n>>u>>v;
	u--,v--;
	g.resize(n);

	REP(i,0,n-1){
		lli u,v;
		cin>>u>>v;
		u--,v--;
		g[u].push_back({v,1});
		g[v].push_back({u,1});
	}

	distA[u]=0,distB[v]=0;
	func1(u,-1);
	func2(v,-1);

	lli maxAns = 0;
	REP(i,0,n){
		if(distA[i]<distB[i]){
			maxAns = max(maxAns,distB[i]-1);
		}
	}
	cout<<maxAns<<endl;
	return 0;
}

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

int A[55];

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

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

    long long int ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            ans += A[i] * A[j];
        }
    }

    cout << ans << '\n';
    return 0;
}


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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string n; cin>>n;
	if (n[0]=='9'||n[1]=='9') cout<<"Yes\n";
	else cout<<"No\n"<<endl;
	return 0;
}

Measured memory_bytes: 256
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
typedef long long ll;typedef pair<int,int> PII;const ll mod=1e9+7;const int N = 1e6+10;ll a[N];
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int main() {
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;
	int k;
	cin>>s>>k;
	if(k==1){
		ll n = s.size();
		ll dig = s[0]-'0';
		cout<<(n-1)*9+dig;
	}else if(k==2){
		ll n = s.size();
		ll dig = s[0]-'0',ans=0;
		for(ll i=2;i<n;i++)
		ans+=81*(i-1);
		ans+=(dig-1)*(n-1)*9;
		ll i=1;
		while(i<n&&s[i]=='0')i++;
		if(i==n){
			cout<<ans;
		}else{
			cout<<ans+s[i]-'0'+(n-i-1)*9; 
		} 
	}else{
		ll n = s.size();
		if(n<3){
			cout<<0;
			return 0;
		}
		ll dig = s[0]-'0',ans=0;
		for(ll i=3;i<n;i++){
			ans+=9*9*9*(i-2)*(i-1)/2;
		}
		ans+=(dig-1)*(n-2)*(n-1)/2*81;
		ll i=1;
		while(i<n&&s[i]=='0')i++;
		if(i>=n-1){
			cout<<ans;
		}else{
			ans+=(s[i]-'0'-1)*(n-i-1)*9;
			ll j = i+1;
			while(j<n&&s[j]=='0')j++;
			if(j==n){
				;
			}else{
				ans+=s[j]-'0'+(n-j-1)*9;
			}
			if(n-i-1>=2){
				ans+=81*(n-i-1-1)*(n-i-1)/2;
			}
			cout<<ans;
		}
	}
  	return 0;
}



Measured memory_bytes: 256
import math
import collections
def main():

    N = int(input())
    A = list(map(int, input().split()))

    d = dict()
    def prime_factor(n):
        if n % 2 == 0: d[2] = d.get(2, 0) + 1
        while n % 2 == 0:
            n //= 2

        i = 3
        while i * i <= n:
            if n % i == 0:
                d[i] = d.get(i, 0) + 1
            while n % i == 0:
                n //= i
            i += 2
        if n > 1:
            d[n] = d.get(n, 0) + 1
        return

    ispair = True
    isset = True

    d = dict()
    for v in A: prime_factor(v)
    # print(d)

    if any(d[p] > 1 for p in d):
        ispair = False
    if any(d[p] == N for p in d):
        isset = False

    if ispair:
        return "pairwise coprime"
    if isset:
        return "setwise coprime"

    return "not coprime"

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 194024
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 z = sc.nextInt();
		x = x - z;
		System.out.println(x / (y + z));
	}
}


Measured memory_bytes: 23892
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int n;
    cin >> n;
    vi count(3,0);
    rep(i, n)
    {
        int a;
        cin >> a;
        if(a%4==0){
            count[2]++;
        }else if(a%2==0){
            count[1]++;
        }else{
            count[0]++;
        }
    }
    if(!count[1]){
        if(count[0]<=count[2]+1){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    else{
        if(count[0]<=count[2]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int n = 0;

      for(int i=0;i<4;i++){
        if(a.charAt(i)=='+'){
          n++;
        }else{
          n--;
        }
        
      }
            System.out.println(n);
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long mod = 1000000007;

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

	string s;
	cin >> s;
	ll* l, *r;
	l = new ll[s.length() + 1];
	r = new ll[s.length() + 1];

	ll left = 0, right = 0;
	l[0] = 0;
	r[s.length()] = 0;
	rep(i, s.length()) {
		if (s[i] == '<') ++left;
		else left = 0;

		if (s[s.length() - 1 - i] == '>') ++right;
		else right = 0;

		l[i + 1] = left;
		r[s.length() - 1 - i] = right;
	}

	ll ans = 0;
	rep(i, s.length() + 1) {
		ans += max(l[i], r[i]);
	}

	cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 8732
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

struct UnionFind{
  vi r;
  UnionFind(int n){
    r=vi(n,-1);
  }
  int root(int x){
    if(r[x]<0) return x;
    return r[x]=root(r[x]);
  }
  bool unite(int x, int y){
    x=root(x); y=root(y);
    if(x==y) return false;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    r[y]=x;
    return true;
  }
  int size(int x){
    return -r[root(x)];
  }
  int same(int x, int y){
    if(root(x)==root(y)) return true;
    else return false;
  }
};

int main(){
  int n,m; cin>>n>>m;
  int ans=0;
  vi p(n); rep(i,n) cin>>p[i];
  rep(i,n) p[i]--;
  UnionFind UF(n+1);
  rep(i,m){
    int x,y; cin>>x>>y; x--; y--;
    UF.unite(x,y);
  }
  rep(i,n){
    if(UF.same(i,p[i])) ans++;
  }
  cout<<ans<<endl;
}


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


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

struct UnionFind {
    vector<int> size, parents;
    UnionFind() {}
    UnionFind(int n) {  // make n trees.
        size.resize(n, 0);
        parents.resize(n, 0);
        for (int i = 0; i < n; i++) {
            makeTree(i);
        }
    }
    void makeTree(int x) {
        parents[x] = x;  // the parent of x is x
        size[x] = 1;
    }
    bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
    bool unite(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) return false;
        if (size[x] > size[y]) {
            parents[y] = x;
            size[x] += size[y];
        } else {
            parents[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    int findRoot(int x) {
        if (x != parents[x]) {
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    int treeSize(int x) { return size[findRoot(x)]; }
};

int main() {
    ll N,M;
    cin >> N>>M;
    
    vector<ll> A(M);
    vector<ll> B(M);
    rep(i,M){
        ll a,b;
        cin >>A[i]>>B[i];
        A[i]--;
        B[i]--;
    }
    reverse(all(A));
    reverse(all(B));
    UnionFind tree(N);
    vector<ll> ans(M);
    ans[0] = N*(N-1)/2;

    rep(i,M-1){
        
        if(!tree.isSame(A[i],B[i])){
            ans[i+1] = ans[i] - tree.treeSize(A[i])*tree.treeSize(B[i]);
            tree.unite(A[i],B[i]);
        }else{
            ans[i+1] = ans[i];
        }
        
    }
    reverse(all(ans));

    rep(i,M){
        cout <<ans[i]<<endl;
    }
    //cout << ans<<endl;
    return 0;
    

}


Measured memory_bytes: 6420
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    a,b,x=MI()
    print(b//x-(a-1)//x)

main()

Measured memory_bytes: 3064
while True:
    n, m = map(int, input().split())
    if n == 0 and m == 0:
        break

    taro = [int(input()) for i in range(n)]
    hanako = [int(input()) for i in range(m)]

    taro.sort()
    hanako.sort()

    diff = sum(taro) - sum(hanako)

    if diff % 2 != 0:
        print(-1)
        continue

    diff /= 2

    ti = 0
    hi = 0

    flag = False
    while ti < n and hi < m:
        if taro[ti] - hanako[hi] == diff:
            print(taro[ti], hanako[hi])
            flag = True
            break
        else:
            if taro[ti] - hanako[hi] < diff:
                ti += 1
            else:
                hi += 1

    if not flag:
        print(-1)


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  string s;
  cin>>s;
  if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
  }else if(s=="Cloudy"){
    cout<<"Rainy"<<endl;
  }else{
    cout<<"Sunny"<<endl;
  }
}


Measured memory_bytes: 256