akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

const ll md = 998244353;

int ren(int c){
	return c=='R' ? 0 : c=='G' ? 1 : 2;
}

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	string s;
	cin >> s;

	vi l1(3), l2(3);
	ll ans = 1;
	trav(c, s){
		int i = ren(c);
		int j = (i+1)%3;
		int k = (i+2)%3;
		if(l2[i]){
			ans = ans * l2[i] % md,
			--l2[i];
		} else if(l1[j]){
			ans = ans * l1[j] % md;
			--l1[j];
			++l2[k];
		} else if(l1[k]){
			ans = ans * l1[k] % md;
			--l1[k];
			++l2[j];
		} else {
			++l1[i];
		}
	}
	rep(i,2,n+1) ans = ans * i % md;
	cout << ans << endl;
}


Measured memory_bytes: 720
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    int sum=0;
    vector<int> d(n);
    for(int i=0;i<n;i++)    cin >> d[i];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum+=d[i]*d[j];
        }
    }
    cout << sum;
}   

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

using namespace std;

int main(){
    int n,m,l;
    cin >> n >> m >> l;
    
    vector<vector<int>>a(n,vector<int>(m));
    for(int fn=0;fn<n;fn++){
        for(int fm=0;fm<m;fm++){
            cin >> a.at(fn).at(fm);
        }
    }
    
    vector<vector<int>>b(m,vector<int>(l));
    for(int fm=0;fm<m;fm++){
        for(int fl=0;fl<l;fl++){
            cin >> b.at(fm).at(fl);
        }
    }
   
    vector<vector<long long int>>c(n,vector<long long int>(l));
    for(int fn=0;fn<n;fn++){
        for(int fl=0;fl<l;fl++){
            for(int fm=0;fm<m;fm++){
                c.at(fn).at(fl) += a.at(fn).at(fm) * b.at(fm).at(fl);
            }
        }
    }
    
    for(int fn=0;fn<n;fn++){
        for(int fl=0;fl<l;fl++){
            cout << c.at(fn).at(fl);
            if(fl != l-1){
                cout <<' ';
            }
        }
        
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3260
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int x = sqrt(N);
    int ans = x * x;
    if ((x + 1) * (x + 1) <= N) { ans = x + 1; }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll X,Y;
  cin>>X>>Y;
  if(Y%2!=0) {
cout<<"No"<<endl;
  return 0;
  }
  else if(Y>=2*X&&Y<=4*X) {
cout<<"Yes"<<endl;
  }
  else {
cout<<"No"<<endl;
  }
}


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

int main(){

  int N;
  int A[3][110];
  int max=0;
  int sum=0;

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

  for(int i=1; i<=N; i++){
    sum=0;
    for(int j=1;j<=i;j++){
      sum+=A[1][j];
    }
    for(int j=i;j<=N;j++){
      sum+=A[2][j];
    }
    if(max < sum)
      max = sum;
  }

  cout << max << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> p(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}

	int ans = 0;
	for (int i = 2; i < n; i++) {
		if ((p[i-2] < p[i-1] && p[i-1] < p[i]) ||
			(p[i-2] > p[i-1] && p[i-1] > p[i])
		) {
			ans++;
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# import sys
from itertools import compress
# from random import shuffle, seed, random
from time import perf_counter


def is_right_order(B, C):
    """ B, C????????§??????????????????????????????(??????)????????§???????????? """
    max_val = 0
    for b in B:
        if b < max_val:
            return False
        max_val = b

    max_val = 0
    for c in C:
        if c < max_val:
            return False
        max_val = c
    return True


def solve_bf(d):
    """ ??????????????§?§£???(??????) """
    for i in range(1024):  # ????????§??????????????????????????????????????????????????????B?????????C????????????????????????
        bin_i = '{0:010b}'.format(i)
        bin_i = [int(x) for x in bin_i]
        comp = compress(d, bin_i)
        B = list(comp)
        C = d[:]
        for b in B:
            C.remove(b)
        if is_right_order(B, C):  # ???????????????????????????????????§?????¶???????????????????????????????¨???????
            return True
    return False


def solve_greed(d):
    """ ????¬????????????????
    ????????¨?????????????????????????????\????????????C?????\?????????????????\?????????B?????\?????????
    ??? ???????????????????????????????????°????????¨???????????????????????¨????????????????????????????????´?????????
    """
    used = [False] * 11  # ???????????????????????????????????????????????°?????????????????????index??????????????????used[1]?????????????????????????????§????????????+1????????????

    B = []  # ?????\????????????????????\?????????
    C = []  # ????????\???????????????????????????????????\?????????
    for b in d:
        cb = 0
        for i in range(1, 11):
            if used[i] == False:
                cb = i  # ?????????????????????????????????????????\????????????cb??¨?????¶
                break
        if b == cb:
            C.append(b)
        else:
            B.append(b)
        used[b] = True  # ????????????????????????????????????B?????????C???????????????????????????????????§????????¨?????????
    return is_right_order(B, C)


if __name__ == '__main__':
    # ??????????????\???
    num = int(input())
    data = []
    for _ in range(num):
        data.append(list(map(int, input().split(' '))))

    # ???????????¨??????????????????????????????
#    for i in range(100):
#        t = list(range(1, 11))
#        shuffle(t)
#        data.append(t)

    # start_time = perf_counter()
    # ????????????
    for d in data:
        # print('trying: {0}'.format(d))
        #result = solve_bf(d)
        result = solve_greed(d)

        if result:
            print('YES')
        else:
            print('NO')

    # end_time = perf_counter()
    # print('elapsed: {0}'.format(end_time - start_time))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n-1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < n; ++i)
#define FORR(i, s, n) for (int i = n-1; i >= s; --i)
#define ALL(c) (c).begin(), (c).end()
#define CLEAR(v) memset(v, 0, sizeof(v))
#define F first
#define S second

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (a + b > c + d ? "Left" : a + b < c + d ? "Right" : "Balanced") << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <deque>
#include <numeric>
#include <set>
using namespace std;

typedef long long ll;

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

    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    // 入力の総和を保持しておく(総和は変わらない)
    ll Sum = accumulate(a.begin(), a.end(), 0);
    // Sumの約数列挙
    set<ll> divisor;
    for(int i = 1; (ll)i * i <= Sum; ++i){
        if(Sum % i == 0){
            divisor.insert(i);
            divisor.insert(Sum / i);
        }
    }

    ll ans = 1;
    for(auto it = divisor.begin(); it != divisor.end(); ++it){
        vector<ll> temp(n);
        for(int i = 0; i < n; ++i){
            temp[i] = a[i] % *it;
        }
        sort(temp.begin(), temp.end());
        ll rSum = 0;
        for(int i = 0; i < n; ++i){
            rSum += *it - temp[i];
        }
        ll need = rSum;
        ll lSum = 0;
        for(int i = 0; i < n; ++i){
            lSum += temp[i];
            rSum -= *it - temp[i];
            need = min(need, max(lSum, rSum));
        }
        if(need <= k){
            ans = max(ans, *it);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=(int)b;++i)
#define per(i,a,b) for(int i=a;i>=(int)b;--i)
#define ll long long

bitset<2000*2000+5>bs;
int main()
{
    IOS
    int n,sum=0;cin>>n; bs[0]=1;
    rep(i,1,n)
    {
        int x;cin>>x;
        sum+=x;
        bs|=bs<<x;
    }
    rep(i,(sum+1)/2,sum)
    {
        if(bs[i])
        {
            cout<<i<<"\n";
            return 0;
        }
    }
}


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

using namespace std;

int n , i , x , t;

int main()
{

//freopen("test.in" , "r" , stdin);
//freopen("test.out" , "w" , stdout);

scanf("%d" , &n);
for (i = 1 ; i <= n ; ++i)
{
    scanf("%d" , &x);
    if (x % 2 == 1) t ^= 1;
}

if (t) printf("NO\n");
else printf("YES\n");

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define poly vector<ll>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
inline ll read(){
	ll x=0;char ch=getchar();bool d=1;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') d=0;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return d?x:-x;
}
inline void write(ll x){
	if(x<0) x=-x,putchar('-');
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=205;
int head[N],opt;
struct info{
	int to,nxt;
}e[N*N*2];
void add(int x,int y){
	e[++opt]=(info){y,head[x]};head[x]=opt;
	e[++opt]=(info){x,head[y]};head[y]=opt;
}
bool check(int x){
	if(x<=2) return 0;
	for(int i=2;i*i<=x;i++){
		if(x%i==0) return 0;
	}
	return 1;
}
int ma[N];
bool used[N];
bool dfs(int u){
	for(int i=head[u];i;i=e[i].nxt){
		int k=e[i].to;
		if(used[k]) continue;
		used[k]=1;
		if(!ma[k]||dfs(ma[k])) return ma[k]=u,1;
	}
	return 0;
}
int a[N],pos[N];
int main(){
	// freopen("ssw.in","r",stdin);
	int n=read(),m=0,cnt=0;
	For(i,1,n){
		a[i]=read();
		if(i==1||a[i-1]<a[i]-1) pos[++m]=a[i];
		if(i>1&&a[i-1]+1<a[i]) pos[++m]=a[i-1]+1;
	}
	pos[++m]=a[n]+1;
	sort(pos+1,pos+m+1);
	For(i,1,m) cerr<<pos[i]<<endl;
	For(i,1,m) if(pos[i]&1) cnt++;
	For(i,1,m) For(j,i+1,m){
		if(check(pos[j]-pos[i])) add(i,j);
	}
	int ssw=0;
	For(i,1,m) if(pos[i]%2==0){
		memset(used,0,sizeof(used));
		ssw+=dfs(i);
	}
	cout<<ssw+(m-ssw*2)+(cnt-ssw)%2;
}

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

vector<int> next_r(100010, -1);
queue<int> q;

void dfs(vector<vector<int>>& G) {
  while (!q.empty()) {
    int par = q.front();
    q.pop();
    for (auto&& v : G.at(par)) {
      if (next_r.at(v) == -1) {
        q.push(v);
        next_r.at(v) = par;
      }
    }
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> G(n + 1, vector<int>(0));

  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  q.push(1);
  dfs(G);

  bool ok = true;
  for (int i = 2; i <= n; ++i) {
    if (next_r[i] == -1) {
      ok = false;
      break;
    }
  }

  if (ok) {
    cout << "Yes" << endl;
    for (int i = 2; i <= n; ++i) {
      cout << next_r[i] << endl;
    }
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 10172
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
using namespace std;
const ll maxn = 1e6 + 7;
const ll mod = 1e9 + 7;
const ll mod1 = 123456789;
const int maxx = 1005;
ll q, t, n, m, T, k, ans, a[maxn], b[maxn], f[maxx][maxx];
priority_queue<ll> pr;
string s, str;
char ss[maxx][maxx];

struct dang
{
    ll val, sl;
};
dang st[maxn];
bool lt(const dang &x, const dang &y)
{
    return x.val < y.val;
}


void test()
{
    //ll c[maxn], d[maxn];
    cin >> n;
    for(ll i = 1; i <= 1000; i++)
    {
        for(ll j = -1000; j <= 1000; j ++)
        {
            if(i * i * i * i * i == n + j * j * j * j * j)
            {
                cout << i <<" "<<j;
                return;
            }
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    test();
}


Measured memory_bytes: 3560
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
void solve()
{
	int r;
	cin >> r;
	cout << r * r;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
constexpr int  INF = 1000000007;
typedef long long ll;
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; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	int n; int K;
	cin >> n >> K;
	vector<int>dp(100009,INF);
	vector<int>a(100001,0);
	rep0(i, n)cin >> a[i];
	dp[0] = 0;
	rep0(j, n) {
		rep1(k, K + 1) {
			chmin(dp[j + k], dp[j] + abs(a[j] - a[j + k]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
n,m = map(int,input().split())
x_lst = list(map(int,input().split()))
x_lst.sort()

if n>=m:
    answer = 0
else:
    remainder_lst = []
    for i in range(m-1):
        x1 = x_lst[i]
        x2 = x_lst[i+1]

        remainder = x2 - x1
        remainder_lst.append(remainder)

    remainder1_lst = sorted(remainder_lst, reverse=True)
    delete = 0

    for i in range(n-1):
        remainder1 = remainder1_lst[i]
        delete += remainder1
    answer =  sum(remainder_lst) - delete

print(answer)

Measured memory_bytes: 13968
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define mxn 12
#define mxm 26
using namespace std;
char s[mxn][mxn];
int n,m,p[mxn],a[mxn];
string t[mxn|1];
bool mirror(int l,int r) {
	for(int i=0;i<n;i++)
		if(s[i][l]!=s[p[i]][r])
			return 0;
	return 1;
}
void dfscol(int d,bool b) {
	if(d==m) {	puts("YES");	exit(0);	}
	if(~a[d]) {	dfscol(d+1,b);	return;	}
	for(int i=d+1;i<m;i++)
		if(a[i]==-1&&mirror(d,i)) {
			a[d]=i,a[i]=d;
			dfscol(d+1,b);
			a[d]=-1,a[i]=-1;
		}
	if(b&&mirror(d,d))	a[d]=d,dfscol(d+1,0),a[d]=0;
}
void dfsrow(int d,bool b) {
	if(d==n) {	dfscol(0,m&1);	return;	}
	if(~p[d]) {	dfsrow(d+1,b);	return;	}
	for(int i=d+1;i<n;i++)
		if(p[i]==-1&&t[d]==t[i]) {
			p[d]=i,p[i]=d;
			dfsrow(d+1,b);
			p[d]=-1,p[i]=-1;
		}
	if(b)	p[d]=d,dfsrow(d+1,0),p[d]=0;
}
int main() {
	memset(p,-1,sizeof(p));
	memset(a,-1,sizeof(a));
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) {
		scanf("%s",s[i]);
		for(int j=0;j<m;j++)
			t[i]+=s[i][j];
		sort(t[i].begin(),t[i].end());
	}
	dfsrow(0,n&1);
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

ll dp[1111111][4];
void Main() {
  ll n;
  R n;
  mem(dp);
  dp[0][0]=1;
  rep(i,n) {
    dp[i+1][0]+=dp[i][0]*8;
    dp[i+1][0]%=MAX;
    
    dp[i+1][1]+=dp[i][0];
    dp[i+1][1]%=MAX;
    dp[i+1][1]+=dp[i][1]*9;
    dp[i+1][1]%=MAX;
    
    dp[i+1][2]+=dp[i][0];
    dp[i+1][2]%=MAX;
    dp[i+1][2]+=dp[i][2]*9;
    dp[i+1][2]%=MAX;
    
    dp[i+1][3]+=dp[i][1];
    dp[i+1][3]%=MAX;
    dp[i+1][3]+=dp[i][2];
    dp[i+1][3]%=MAX;
    dp[i+1][3]+=dp[i][3]*10;
    dp[i+1][3]%=MAX;
  }
  pr(dp[n][3]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 38356
using System;

public class Sum
{
    private static void Main()
    {
        string[] ab = Console.ReadLine().Split(' ');
        int a = int.Parse(ab[0]);
        int b = int.Parse(ab[1]);

        if (a < b)
            Console.WriteLine("a < b");
        else if (a > b)
            Console.WriteLine("a > b");
        else
            Console.WriteLine("a == b");
    }
}

Measured memory_bytes: 8848
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt=0;
  int a[200]={};
  bool f=true;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  while(f){
    for(int i=0;i<n;i++){
      if(a[i]%2==1){
        f=false;
        break;
      }
      else a[i]/=2;
    }
    if(f)
      cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int x;
    cin >> x;
    if (x == 7 || x == 5 || x == 3)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

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

int main() {
  int x,y;
  cin >> x >> y;
  bool can = false;
  for (int i = 0; i < x+1; i++) {
    for (int j = 0; j < x+1; j++) {
      if (i * 2 + j * 4 == y && i + j == x) {
        can = true;
      }
    }
  }
  if (can) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)



int main (){
  vector<ll> v(100001,0);
  ll n,k;
  cin>>n>>k;
  int a,b;
  r(i,n){
    cin>>a>>b;
    v.at(a)+=b;
  }

  for(int i=1;i<=100000;i++){
    if(k<=v.at(i)){
      cout<<i<<endl;
      break;
    }
    else k-=v.at(i);
  }


  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
using namespace std;
const int SIZE=2005;
const LL INF=1LL<<60;
//int N=3,K=2;
//int N=1333,K=37;
int N=1407,K=38;
//int N=13,K=4;
bool linked[SIZE][SIZE];
int used[SIZE];
VI nums[SIZE];
VI uses[SIZE];

int group(int x){
	return x/(K-1);

}
void write(LL n,LL tar){

}
void add(LL a,LL b){
	nums[a].PB(b);
	uses[b].PB(a);
}
LL solve(){
	cout <<N << " "<< K << endl;
	FOR(i,1,K+1) add(i,N);
	FOR(i,1,N) add(group(i-1)+1,i);
	int number=K+1;
	FOR(i,0,K-1){
		int start=i+1;
		REP(ini,K-1){
			int now=1;
			add(number,start);
			int mod=ini;
			REP(j,K-1){
				now+=K-1;
				add(number,now+mod);
				mod+=i;
				mod%=K-1;
			}
			number++;
		}
		
	}
	FOR(i,1,N+1){
		REP(j,uses[i].size()){
			if(j) cout << " ";
			cout << uses[i][j];
		}
		cout << endl;
	}
	return 0;
}
int check(){
	int ans=0;
	FOR(i,1,N+1){
		REP(j,nums[i].size())
			REP(k,j){
				if(linked[nums[i][j]][nums[i][k]]) ans++;
				linked[nums[i][j]][nums[i][k]]=true;
			}
	}
	return ans;
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>

int main(){
  int n;
  int i;
  while(scanf("%d", &n)!=EOF){
    for(i=0;i<10;i++){
      if(n&1){
        printf("%d", 1<<i);
        if(n>>1) printf(" ");
      }
      n >>= 1;
    }
    printf("\n");
  }
  return 0;
}
    

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
        a[i]--;
    }

    vector<int> vis(n, -1);
    int t = 1;
    int idx = 0;
    vis[0] = 0;
    while(vis[a[idx]] == -1){
        idx = a[idx];
        vis[idx] = t;
        t++;
    }
    int dist = vis[a[idx]];
    int T = t - vis[a[idx]];
    idx = 0;
    if(k < dist){
        rep(i, k)idx = a[idx];
    }else{
        k -= dist;
        k %= T;
        rep(i, dist+k)idx = a[idx];
    }
    cout << idx + 1 << endl;
}

Measured memory_bytes: 4776
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
int l[100000], r[100000];
pi x[100000];
priority_queue<int, vector<int>, greater<int>> que;
map<int, int> huga;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int L = 0, R = inf;
    rep(i,n) {
        cin >> l[i] >> r[i];
        r[i]++;
        L = max(L, l[i]);
        R = min(R, r[i]);
    }
    int ans = 0;
    rep(i,n) {
        ans = max(ans, max(0,R-L)+r[i]-l[i]);
    }
    rep(i,n) x[i] = pi(R-l[i], r[i]-L);
    sort(x, x+n, greater<pi>());
    rep(i,n) que.push(r[i]-L);
    rep(i,n-1) {
        huga[x[i].second]++;
        while (huga[que.top()]) {
            huga[que.top()]--;
            que.pop();
        }
        ans = max(ans, x[i].first+que.top());
    }
    cout << ans << endl;
}

Measured memory_bytes: 7032
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a) - 1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i -  1) * 10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}
 
struct IoSetup {
  	IoSetup() {
    	cin.tie(nullptr);
    	ios::sync_with_stdio(false);
    	cout << fixed << setprecision(15);
  	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

string N;

int main() {
	cin >> N;

	int now = 0; 
	rep (i, N.size()) {
		now += (N[i] - '0');
		now %= 9;
	}

	if (now % 9 == 0) yn
	
	return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
ll f[1<<17];
int G[20],num[1<<17];
int read()
{
	int x=0;char c=getchar(),flag='+';
	while(!isdigit(c)) flag=c,c=getchar();
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	return flag=='-'?-x:x;
}
int main()
{
	int n=read(),m=read();
	for(int i=1;i<=(1<<n);i++) num[i]=num[i>>1]+(i&1);
	//for(int i=1;i<=10;i++) cout<<num[i]<<' ';
	for(int i=1;i<=m;i++)
	{
		int u=read(),v=read();
		G[u]|=1<<v-1;
	}
	f[0]=1;
	for(int s=1;s<(1<<n);s++)
	{
		if((s&1)==((s>>1)&1))
		{
			for(int u=s;u;u=(u-1)&s)
			{
				if((u&1)==((u>>1)&1))
				{
					ll tmp=1;
					int t=s^u;
					for(int j=1;j<=n;j++)
					{
						if(s&(1<<j-1))
						{
							if(u&(1<<j-1)) tmp=tmp*(1<<num[G[j]&t])%mod;
							else tmp=tmp*((1<<(num[G[j]&u]))-1)%mod;
						}
					}
					f[s]=(f[s]+tmp*f[t])%mod;
				}
			}
		}
	}
	ll ans=1;
	for(int i=1;i<=m;i++) ans=ans*2%mod;
	cout<<(ans-f[(1<<n)-1]+mod)%mod;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long i,j;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	long long t,k,c=0;
	string s;
	cin >> t>>s;
	for(i=0;i<t-2;i++){
		if(s.substr(i,3)=="ABC") c++;
	}
	cout << c;
	
}

Measured memory_bytes: 256
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e5+1;
 
typedef long long ll;
typedef long double ld;

int main()
{
    IOS();
    
   	ll n,m,i,j;
   	cin>>n;
   	ll p[n];
   		f(i,0,n)
   		cin>>p[i];
   	ll ans=0,mi=p[0];
   	f(i,0,n)
   	{

   		if(mi>=p[i])
   			ans++;
   		mi=min(p[i],mi);
   	}
   	cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long[] A;
        long[] B;
        long[] C;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            A = new long[N];
            B = new long[N];
            C = new long[N];
            for(int i = 0;i < N;i++){
                A[i] = sc.nextLong();
            }
            for(int i = 0;i < N;i++){
                B[i] = sc.nextLong();
            }
            for(int i = 0;i < N - 1;i++){
                C[i] = sc.nextLong();
            }
        }
        long result = 0;
        for(int i = 0;i < N - 1;i++){
            if(A[i] +1 == A[i+1]){
                result += C[(int)A[i]-1];
            }
        }
        for(int i = 0;i < N;i++){
            result += B[i];
        }
        System.out.println(result);
    }

}


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

int f(int n){
    if(n == 1) return 1;
    if(n == 2) return 2;
    if(n == 3) return 4;
    
    return f(n-1)+f(n-2)+f(n-3);
}

int main(void){
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        cout << (f(n) / 3650)+1 << endl;
    }
}


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

int main() {
  int A, B, N, n, sum = 0;
  cin >> A >> B;
  N = B - A;
  n = A;
  
  for (int i = 0; i <= N; i++) {
    if (n / 10000 == n % 10 && (n % 10000) / 1000 == (n % 100) / 10) {
      sum += 1;
    }
    else {
      sum += 0;
    }
    n += 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    int n; cin >> n;
    bool ans = true;
    map<string,int> index; 
    vector<string> lang(n);
    string pre;

    rep(i,n) { cin >> lang[i]; index[lang[i]]++; }
    
    for(auto l : index) { if(l.second > 1) { ans = false; } }

    rep(i,n-1) {
        if(lang[i][lang[i].size()-1] != lang[i+1][0]) { ans = false; }
    }
    
    if(ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



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

int main()
{
    long long int a, b, x, l, r;
    cin >> a >> b >> x;
    r = (b / x);
    l = max(a - 1, 0LL) / x;
    if (a == 0) r++;
    cout << (r - l) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  while (true) {
    int n; cin >> n;
    if (n == 0) break;
    VV<> a(30);
    for (int i = 0; i < n; ++i) {
      int f; cin >> f;
      while (f--) {
        int d; cin >> d, --d;
        a[d].push_back(i);
      }
    }
    V<lint> b(n);
    for (int i = 0; i < n; ++i) {
      b[i] = 1LL << i;
    }
    for (int d = 0; d < 30; ++d) {
      lint c = 0;
      for (int i : a[d]) {
        c |= b[i];
      }
      if (c == (1LL << n) - 1) {
        cout << d + 1 << '\n';
        break;
      }
      for (int i : a[d]) {
        b[i] = c;
      }
      if (d == 29) {
        cout << "-1\n";
      }
    }
  }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  for (auto it = vc.begin(); it != vc.end(); ++it)
  {
    if (std::next(it) == vc.end())
      os << *it;
    else
      os << *it << '\n';
  }
  return os;
}

template<class T1, class T2>
inline
std::ostream & operator<<(std::ostream & os, const std::pair<T1, T2> & p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  using std::cout;
  
  ui N{}, Q{}; std::cin >> N >> Q;
  string S{}; std::cin >> S;

  vector<ui> res(S.size(), 0);
  rep(0, S.size() - 1)
  {
    res[i + 1] = res[i] + (S[i] == 'A' && S[i + 1] == 'C' ? 1 : 0);
  }

  vector<ui> ans(Q);
  rep(0, Q)
  {
    ui l{}, r{}; cin >> l >> r;

    ans[i] = res[r - 1] - res[l - 1];
  }

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

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

  solve();

  return 0;
}


Measured memory_bytes: 1872
#include<stdio.h>
int main(){
    
    int a,b,c;

    while(1){
        
        //点数読み取り,値が全て-1だったときbreak
        scanf("%d %d %d", &a, &b, &c);
        if( a == -1 && b == -1 && c == -1 )break;
        
        //F評価
        if( a == -1 || b == -1 || a+b < 30 )printf("F\n");

        //A～Cの評価
        if( 80 <= a+b )printf("A\n");
        if( 65 <= a+b  && a+b < 80 )printf("B\n");
        if( (50 <= a+b && a+b < 65) || 50 <= c )printf("C\n");
        
        //Dの評価
        if( (30 <= a+b && a+b < 50 && c < 50) && ( a != -1 && b != -1 ) )printf("D\n");
    }

    return 0;
}


Measured memory_bytes: 2024
#include<bits/stdc++.h>
using namespace std;
int a[200010], f[200010];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	long long k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; ++i) {
		cin >> f[i];
	}
	sort(a + 1, a + 1 + n);
	sort(f + 1, f + 1 + n, greater<int>());
	long long l = 0, r = 1e12, answer = 0;
	while (l <= r) {
		long long mid = (l + r) / 2;
		long long ch = 0;
		for (int i = 1; i <= n; ++i) {
			if (1LL * a[i] * f[i] > mid) {
				ch += ceil(((1.0L * a[i] * f[i]) - mid) / f[i]); 
			}
		}
		if (ch <= k) {
			answer = mid;
			r = mid - 1;
		} else {
			l = mid + 1;
		}
	}
	cout << answer;
}

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

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

const long long MOD = 1000000007;

int main(){
  vector<int> num={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};
  int k;
  cin >> k;
  k--;
  cout << num.at(k) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
#define SQ 320
//#define N 1000005
typedef long long ll;
using namespace std;
ll n,i,j,k,x,y,z,q,r,timer,mx;

ll a[100500], dp[100500];
int main() {
    //freopen("input.txt","r",stdin);
    string s;
    cin >> s;
    ll sz = s.size();
    cout << s.substr(0, sz-8) << endl;
    return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
c = []
for _ in range(h):
    c.append(input())
for i in range(h):
    for j in range(w):
        if c[i][j] == '.':
            continue
        if i == 0:
            if j == 0:
                if c[i][j+1] == '.' and c[i+1][j] == '.':
                    print('No')
                    exit(0)
            elif j == w-1:
                if c[i][j-1] == '.' and c[i+1][j] == '.':
                    print('No')
                    exit(0)
            else:
                if c[i][j-1] == '.' and c[i+1][j] == '.' and c[i][j+1] == '.':
                    print('No')
                    exit(0)
        elif i == h-1:
            if j == 0:
                if c[i][j+1] == '.' and c[i-1][j] == '.':
                    print('No')
                    exit(0)
            elif j == w-1:
                if c[i][j-1] == '.' and c[i-1][j] == '.':
                    print('No')
                    exit(0)
            else:
                if c[i][j-1] == '.' and c[i-1][j] == '.' and c[i][j+1] == '.':
                    print('No')
                    exit(0)
        else:
            if j == 0:
                if c[i][j+1] == '.' and c[i-1][j] == '.' and c[i+1][j] == '.':
                    print('No')
                    exit(0)
            elif j == w-1:
                if c[i][j-1] == '.' and c[i-1][j] == '.' and c[i+1][j] == '.':
                    print('No')
                    exit(0)
            else:
                if c[i][j-1] == '.' and c[i-1][j] == '.' and c[i][j+1] == '.' and c[i+1][j] == '.':
                    print('No')
                    exit(0)
print('Yes')


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,a,b) for(int i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
void send(int a,int b,int c,int d){
  printf("%d %d %d %d\n",a,b,c,d);
}
int main(){
  int n;  cin >> n;
  map<int,int> ma;
  rep(i,0,n){
    int x;  cin >> x;
    ma[x]++;
  }
  priority_queue<int> que;
  for(auto ite=begin(ma) ; ite!=end(ma) ; ite++){
    que.push(ite->se);
  }
  while(que.size()>1){
    if(que.top()==1) break;
    int x=que.top();  que.pop();
    int y=que.top();  que.pop();
    if(x-1>0) que.push(x-1);
    if(y-1>0) que.push(y-1);
  }
  int ans = que.size();
  cout << ans << endl;
  return 0;
}


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

int main() { 
  string s;
  cin >> s;
  int a[s.size()+1] = {0};
  int c = 1;
  long long int sum = 0;
  vector<int> me;
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] == '<') {
      a[i+1] = c;
      c++;
    } else {
      c = 1;
    }
  }
  c = 1;
  for(int i = s.size()-1; i >= 0; --i) {
    if(s[i] == '>') {
      if(a[i] < c) a[i] = c;
      c++;
    } else {
      c = 1;
    }
  }
  for(int i = 0; i <= s.size(); ++i) {
    //cout << a[i] << '\n'; 
    sum += a[i];
  }
  cout << sum << '\n';
}


Measured memory_bytes: 2820
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e15)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)

const int mxn = 1*(1e6) + 5;
ll n;

int solve(){
	cin>>n;
	ll t;
	set<ll>a;
	map<int, int>m;
	for(int i=0; i<n; i++) {
		cin >> t;
		m[t]++;
		a.insert(t);
	}		
	// if(a.size() == 1) {
	// 	cout<<"0";
	// 	return 0;
	// }
	bool vis[mxn] =  {};
	ll ans=0;
	for(auto el : a) {
		if(!vis[el]) {
			ans++;
			if(m[el] > 1) ans--;
			for(int i=el; i<mxn; i += el) {
				vis[i] = 1;
			}
		}
	}
	cout<<ans;
	return 0;
}
 
int main(){
	fast;
	// tt
		solve();
}


Measured memory_bytes: 23300
import java.util.*;
import java.lang.*;
import java.math.*;

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

	class E {
		int sum;
		int start;
		int end;

		E(int s, int end, int sum) {
			this.start = s;
			this.end = end;
			this.sum = sum;
		}
	}

	class list {
		LinkedList<E> list;

		public list() {
			list = new LinkedList<E>();
		}
	}

	void run() {
		for (;;) {
			int N, M;
			N = sc.nextInt();
			M = sc.nextInt();
			if ((N | M) == 0) {
				break;
			}

			list[] data = new list[M];
			int[] start = new int[M];
			int[] sum = new int[M];
			for (int i = 0; i < M; i++) {
				data[i] = new list();
				data[i].list.add(new E(0, 0, 0));
			}
			int using[] = new int[M];
			int r = sc.nextInt();
			for (int i = 0; i < r; i++) {
				int t = sc.nextInt();
				int n = sc.nextInt() - 1;
				int m = sc.nextInt() - 1;
				int s = sc.nextInt();
				if (s == 1) {
					if (using[m] == 0) {
						start[m] = t;
					}
					using[m]++;
				} else {
					using[m]--;
					if (using[m] == 0) {
						data[m].list.add(new E(start[m], t, sum[m]));
						sum[m] += t - start[m];
					}
				}
			}
			for(int i = 0; i < M; i++){
				data[i].list.add(new E(10000,10000,sum[i]));
			}
			int q = sc.nextInt();
			for (int i = 0; i < q; i++) {
				int t = sc.nextInt();
				int t2 = sc.nextInt();
				int m = sc.nextInt() - 1;

				int ret;
				int left = 0;
				int right = data[m].list.size();
				int premid = -1;
				for (;;) {
					int mid = (left + right) / 2;
					E cand = data[m].list.get(mid);
					if (premid == mid) {
//						System.err.println(" - start from " + cand.start + " "
//								+ cand.end + " " + cand.sum);
						ret = -(cand.sum + cand.end - cand.start);
						break;
					}
					if (cand.start > t) {
						right = mid;
					} else if (cand.end < t) {
						left = mid;
					} else {
//						System.err.println("start from " + cand.start + " "
//								+ cand.end + " " + cand.sum);
						ret = -(cand.sum + t - cand.start);
						break;
					}
					premid = mid;
				}
				left = 0;
				right = data[m].list.size();
				premid = -1;
				for (;;) {
					int mid = (left + right) / 2 ;

					E cand = data[m].list.get(mid);
					if (premid == mid) {
//						System.err.println(" - end with " + cand.start + " "
//								+ cand.end + " " + cand.sum);
						ret += cand.sum + cand.end - cand.start;
						break;
					}

					if (cand.start > t2) {
						right = mid;
					} else if (cand.end < t2) {
						left = mid;
					} else {
//						System.err.println("end with " + cand.start + " "
//								+ cand.end + " " + cand.sum);
						ret += (cand.sum + t2 - cand.start);
						break;
					}
					premid = mid;
				}
				System.out.println(ret);
			}

		}
	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 17000
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        ab: [(usize, usize); n],
    }
    let mut ab = ab;
    ab.sort_by_key(|row| (row.1, row.0));
    let mut t = vec![0; n];
    t[0] = ab[0].0;
    for i in 1..n {
        t[i] = t[i - 1] + ab[i].0;
    }
    for i in 0..n {
        if t[i] > ab[i].1 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int x;
    cin >> x;
    int ans = 1;
    for (int i = 1; i <= 1000; i++)
    {
        for (int j = 2; j <= 10; j++)
        {
            if (pow(i, j) <= x)
                ans = max((int)pow(i, j), ans);
        }
    }
    OP(ans);
    return 0;
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>

using namespace std;

string str;
int t, n, m;


int main() {
    
    //int T; cin>>T;
    //while(T--) {
        
    //}
    
    
    string str; cin>>str;
    cout<<str.substr(0,4)<<" "<<str.substr(4,8)<<endl; 
    
    return 0;
}


Measured memory_bytes: 256
import collections
import itertools
import math

n,m = map(int,input().split())
ans = 0
if abs(n-m)>1:
    ans = 0
elif n - m == 0:
    tmp = math.factorial(n)
    ans = tmp**2*2
else:
    ans = math.factorial(m)*math.factorial(n)
print(ans%(10**9+7))

Measured memory_bytes: 5464
#include <cstdio>
#include <algorithm>

using namespace std;
const int N = 2e5 + 5;
const int LogN = 23;
const long long inf = 1e17;

int A[N], n;
long long D;

struct Edge {
    int u, v;
    long long w;
} e[N * LogN];
int etot = 0;

void buildGraph(int l, int r) {
    if (l == r) return;
    int mid = (l + r) >> 1;
    buildGraph(l, mid);
    buildGraph(mid + 1, r);

    int x, y;
    long long f = inf, g = inf;

    for (int i = l; i <= mid; i++)
        if (f > A[i] - i * D)
            f = A[i] - i * D, x = i;
    for (int i = mid + 1; i <= r; i++)
        if (g > A[i] + i * D)
            g = A[i] + i * D, y = i;
    
    for (int i = mid + 1; i <= r; i++)
        e[++etot] = Edge{x, i, f + A[i] + i * D};
    for (int i = l; i <= mid; i++)
        e[++etot] = Edge{y, i, g + A[i] - i * D};
    return;
}

int fa[N];
int find(int x) {
    return x == fa[x] ? x : fa[x] = find(fa[x]);
}
void init_ufs(int n) {
    for (int i = 1; i <= n; i++)
        fa[i] = i;
}
bool merge(int u, int v) {
    int fu = find(u), fv = find(v);
    if (fu == fv) return false;
    return fa[fu] = fv, true;
}

long long Kruskal_MST() {
    sort(e + 1, e + 1 + etot, [](Edge& a, Edge& b) {
        return a.w < b.w;
    });
    init_ufs(n);

    long long ans = 0ll;
    for (int i = 1, c = 0; c < n - 1; i++)
        if (merge(e[i].u, e[i].v))
            ans += e[i].w, ++c;
    
    return ans;
}

signed main() {
    scanf("%d%lld", &n, &D);
    for (int i = 1; i <= n; i++)
        scanf("%d", A + i);
    
    buildGraph(1, n);
    printf("%lld\n", Kruskal_MST());
    return 0;
}

Measured memory_bytes: 59336