akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<time.h>
#include<cstdlib>
#include<cmath>
#include<list>
using namespace std;
#define MAXN 10000006
#define eps 1e-10
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define cr clear()
#define sz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false)
#define fr freopen
#define pi acos(-1.0)
#define Vector Point
#define fir first
#define sec second
#define it_s_too_hard main
#define I_can_t_solve_it solve
//const long long inf=1LL<<62;
const double inf=1e9+9;
const int Mod=1e9+7;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef double ld;
inline int dcmp(ld x){ if(fabs(x)<=eps) return 0; return x<0?-1:1;}
inline int scan(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
inline ll scan(ll x){
	int f=1;char ch=getchar();x=0;
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
struct Point{
	double x,y;
	Point(double x=0,double y=0):x(x),y(y) {}
	Point operator - (const Point &a)const { return Point(x-a.x,y-a.y);}
	Point operator * (const double &a)const{return Point(x*a,y*a);  }
	bool operator != (const Point &a)const{ return dcmp(x-a.x)!=0 || dcmp(y-a.y)!=0; }
	bool operator == (const Point &a)const{ return dcmp(x-a.x)==0 && dcmp(y-a.y)==0; }
	void read(){scanf("%lf%lf",&x,&y);}
};
double Dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}
double dis(Vector a){
	return sqrt(Dot(a,a));
}
double Cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}
char s[2300];
void I_can_t_solve_it(){
	scanf("%s",s);
	int l=strlen(s),mk=1,ct=0;
	if(l<=3) mk=0;
	if(s[0]!='A') mk=0;
	For(i,2,l-2) {
		if(s[i]=='C') ct++;	
	}
	if(ct!=1) mk=0;
	For(i,1,l-1){
		if(s[i]!='C' && s[i]>='A' && s[i]<='Z') mk=0;
	}
	if(mk) cout<<"AC"<<endl;
	else cout<<"WA"<<endl;
}
int it_s_too_hard(){
	int t=1;
	For(i,1,t){
		I_can_t_solve_it();
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0; i <(n); i++)
int main(){
  int a,b,c,k;
  scanf("%d%d%d",&a,&b,&c);
  scanf("%d",&k);
  int total=0;
  total = a+b+c;
  int max=a;
  if(a<b){
    max=b;
  }else if(a<c){
    max=c;
  }
  if(b<c){
    max=c;
  }
  total=total-max;
  rep(i,k){
    max=max*2;
  }
  printf("%d\n",total+max);
  return 0;
}


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

void solve() {
    int a, b;
    cin >> a >> b;
    int ans = 1, cnt = 0;
    while (ans < b) {
        cnt++;
        ans--;
        ans += a;
    }
    cout << cnt;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
const ld pi = 3.14159265358979323846;
//ll MOD = 1e9 + 7;
ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
void solve(){
    
    for(ll i = 1;i<=5;i++){
        ll x;
        cin>>x;
        if(x==0){
            cout<<i<<nl;
            return;
        }
    }
    
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";


}


Measured memory_bytes: 3804
#!/usr/bin/env python
"""東京海上日動　プログラミングコンテスト2020: A - Tag
https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_b
"""


def run(a, vt, b, wt):
    if a < b:
        if b + wt <= a + vt:
            return 'YES'
        else:
            return 'NO'
    else:
        if a - vt <= b - wt:
            return 'YES'
        else:
            return 'NO'


def main():
    A, V = list(map(int, input().split()))
    B, W = list(map(int, input().split()))
    T = int(input())

    print(run(A, V*T, B, W*T))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
n = int(input())
h = list(map(int, input().split()))
h.append(0)
max_num = max(h)

count = 0
for i in range(max_num+1):
    is_mountain= False
    mountain = 0
    for index, value in enumerate(h):
        if value <= 0:
            if is_mountain:
                mountain += 1
            is_mountain = False
        else:
            is_mountain = True
        h[index] -= 1
    count += mountain
print(count)

Measured memory_bytes: 3064
main(n,i,I){
  for(;scanf("%d",&n),n;){
    double m=999,h,w,z;
    for(;n--;){
      scanf("%d%lf%lf",&i,&h,&w);
      z=fabs(w*10000/h/h-22);
      if(m>z)m=z,I=i;
      else if(m==z&&i<I)I=i;
    }
    printf("%d\n",I);
  }
  return 0;
}

Measured memory_bytes: 628
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ans = 0
buf = ""
for i in range(N):
    t = T[i]

    if t == "r":
        if i >= K:
            if buf[i - K] == "p":
                buf = buf + " "
                continue
        ans += P
        buf = buf + "p"
    elif t == "p":
        if i >= K:
            if buf[i - K] == "s":
                buf = buf + " "
                continue
        ans += S
        buf = buf + "s"
    elif t == "s":
        if i >= K:
            if buf[i - K] == "r":
                buf = buf + " "
                continue
        ans += R
        buf = buf + "r"

print(ans)

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

int main() {
  ll n;
  long double d;
  cin >> n >> d;
  long double tmp;
  ll x,y;
  int c = 0;
  for(int i = 0;i<n;i++){
    cin >> x >> y;
    tmp = sqrt(x*x + y*y);
    if(tmp <= d ){c++;}
  }
  cout << c;
}

Measured memory_bytes: 3776
// AOJ DPL_4_B Coin Combination Problem II
// 2018.5.10 bal4u
 
#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
 
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}

long long inLL()
{
    long long n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}

#define MAX  ((1<<20)+5)

long long a[42]; int w;
long long s1[42][MAX]; int w1[42];
long long s2[42][MAX]; int w2[42];

int binarysearch_upper(long long *a, long long x, int r)
{
	int m, l = 0;

    while (l < r) {
        m = (l+r) >> 1;
		if (a[m] == x) return m+1;
		if (a[m] < x) l = m + 1; else r = m;
    }
	return l;
}

int binarysearch_lower(long long *a, long long x, int r)
{
	int m, l = 0;

    while (l < r) {
        m = (l+r) >> 1;
        if (a[m] < x) l = m + 1; else r = m;
    }
	return l;
}

int cmp(long long *a, long long *b)
{
	if (*a < *b) return -1;
	return (*a != *b);
}

long long combi(int n, int k)
{
	long long ans;

	if (s1[n][k]) return s1[n][k];
	if ((k << 1) > n) k = n-k;
	if (k == 0) ans = 1;
	else if (k == 1) ans = n;
	else ans = combi(n-1, k) + combi(n-1, k-1);
	return s1[n][k] = ans;
}

int main()
{
	int N, K, i, j, k, m1, m2, n, lim;
	long long L, R, x, y, ans;

	N = in(), K = in(), L = inLL(), R = inLL();

	w = 0;
	y = inLL(); if (y + K-1 <= R) a[w++] = y;
	for (i = 1; i < N; i++) {
		x = inLL();
		if (x != y) y = 0;
		if (x + K-1 <= R) a[w++] = x;
	}

	// identical a[i]
	if (x == y) {
		if (w >= K && (y = x*K) >= L && y <= R) printf("%lld\n", combi(w, K));
		else puts("0");
		return 0;
	}

	m1 = w/2, lim = 1 << m1;
	for (i = 0; i < lim; i++) {
		x = 0, n = 0;
		for (j = 0; ; j++) {
			if (j == m1) { s1[n][w1[n]++] = x; break; }
			if ((i >> j) & 1) {
				x += a[j];
				if (++n > K) break;
			}
		}
	}

	m2 = w - m1;
	lim = 1 << m2;
		for (i = 0; i < lim; i++) {
		x = 0, n = 0;
		for (j = 0; ; j++) {
			if (j == m2) { s2[n][w2[n]++] = x; break; }
			if ((i >> j) & 1) {
				x += a[j+m1];
				if (++n > K) break;
			}
		}
	}

	for (i = 0; i <= K; i++) qsort(s2[i], w2[i], sizeof(long long), cmp);

	ans = 0;
	for (i = 0; i <= K; i++) {
		k = K-i;
		for (j = 0; j < w1[i]; j++) {
			x = L-s1[i][j], y = R-s1[i][j];
			if (y < 0) continue;
			ans += (long long)binarysearch_upper(s2[k], y, w2[k]);
			if (x > 0) ans -= (long long)binarysearch_lower(s2[k], x, w2[k]);
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 19604
n, k = map(int, input().split())
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append([a, b])
ab.sort()
cnt = 0
for i, v in ab:
    cnt += v
    if cnt < k:
        pass
    else:
        print(i)
        break

Measured memory_bytes: 20104
import java.util.*;

class Main{
	public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int five=0,seven=0;
    for(int i=0;i<3;i++){
    int n = Integer.parseInt(sc.next());
    if(n==5)five++;
    else if(n==7)seven++;
  }
  if(five==2 && seven==1)System.out.println("YES");
  else System.out.println("NO");
}
}


Measured memory_bytes: 21460
#include <iostream>
#include <vector>
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<P>>;

void dfs(Graph& g, vector<int>& d, int v) {
    for (P p : g[v]) {
        if (d[p.first] >= 0) continue;
        d[p.first] = d[v] + p.second;
        dfs(g, d, p.first);
    }
}

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

    int N; cin >> N;
    Graph g(N);
    for (int i = 0; i < N-1; i++) {
        int u, v, w; cin >> u >> v >> w; u--; v--;
        g[u].push_back(P(v, w));
        g[v].push_back(P(u, w));
    }

    vector<int> d(N, -1);
    d[0] = 0;
    dfs(g, d, 0);

    for (int i = 0; i < N; i++)
        cout << (d[i] % 2 ? 0 : 1) << "\n";
}

Measured memory_bytes: 17024
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
void printArr(int *a, int len){for(int i=0; i<len; i++){if(i)cout << " ";cout << a[i];}cout << endl;}
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;

//--global--//



//----------//

vector<pair<char, int> > Ranlength(string str){
    vector<pair<char, int> > ranlength;

    pair<char, int> f;
    char lastChar;
    int cnt = 0;
    rep(i, str.size()){
        if(lastChar != str[i] || i == str.size()){
            if(i!=0){
                f = make_pair(lastChar, cnt);
                ranlength.push_back(f);
            }
            lastChar = str[i];
            cnt=1;
        }
        else{
            cnt++;
        }
    }
    f = make_pair(lastChar, cnt);
    ranlength.push_back(f);

    // rep(i, ranlength.size()){ // for debug
    //     cout << ranlength[i].first << ranlength[i].second << endl;
    // }
    return ranlength;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    string str;
    cin >> str;
    vector<pair<char, int> > vv = Ranlength(str);
    int arr[MAX];
    fill(arr, arr+MAX, 0);

    int now = 0;
    rep(i, vv.size()){
        int dir = vv[i].first;
        int value = vv[i].second;
        
        int leftNow = now + value-1;
        int rightNow = now + value;
        if(dir == 'L'){
            int left = value / 2;
            int right = value - value / 2;
            arr[now-1] += left;
            arr[now] += right;
        }
        else{
            int left = value - value / 2;
            int right = value / 2;
            arr[leftNow] += left;
            arr[rightNow] += right;
        }
        now += value;
    }

    rep(i, str.size()){
        if(i)cout << " ";
        cout << arr[i];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 1908
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        System.out.println(x < a ? 0 : 10);
    }
    
    public static void printArr(int[][] arr, int h, int w){
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                System.out.print(arr[i][j] + " ");
            }
            System.out.println();
        }
        return;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25020
def main():
    n = int(input()) 
    a = list(map(int,input().split()))
    a.sort()
    o , e = 0 , 0 
    for i in range(n):
        if i % 2 == 0 :
            e += a[i] 
        else:
            o += a[i]
    print(abs(e-o))
main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
 
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000000000
#define MAXN        10000005
#define mod         998244353  
#define pi          3.1415926535897932384626433
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll l,r,d;
    cin>>l>>r>>d;
    ll count=0;
    for(ll i=l;i<=r;i++){
        if(i%d==0){
            count++;
        }
    }
    cout<<count;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+50;
int a[maxn];
int n,q;
int main()
{
	cin>>n;
	memset(a,0,sizeof a);
	ll sum=0;
	for(int i=0;i<n;++i)
	{
		int x;
		cin>>x;
		a[x]++;
		sum+=x;
	}
	cin>>q;	
	while(q--)
	{
		int b,c;
		cin>>b>>c;
		sum+=(c-b)*a[b];
		a[c]+=a[b];
		a[b]=0;
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 4000
def make_prime_factors_distinct(n: int) -> list:
    """自然数nの素因数(重複なし)を列挙したリストを出力する
    計算量: O(sqrt(N))
    入出力例: 156 -> [2, 3, 13]
    """
    prime_factors = []
    for k in range(2, int(n**0.5) + 1):
        if n % k == 0:
            prime_factors.append(k)
            while n % k == 0:
                n = n // k
    if n != 1:
        prime_factors.append(n)
    return prime_factors


def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor: GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


a, b = map(int, input().split()) 
res = gcd(a, b)
print(len(make_prime_factors_distinct(res)) + 1)

Measured memory_bytes: 38640
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
long long a,b,n;
long long c,d;
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out1.txt","w",stdout);
	cin>>a>>b>>n;
	if(n>=b){
		n=b-1;
	}
	c=floor(a*n/b);
	d=a*floor(n/b);
	cout<<c-d;
//fclose(stdout);
//fclose(stdin);
}

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

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

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int q;
  cin >> q;
  int com, b, e;
  rep(i,q) {
    cin >> com >> b >> e;
    if (com == 0) {
      cout << *min_element(a.begin()+b, a.begin()+e) << endl;
    } else {
      cout << *max_element(a.begin()+b, a.begin()+e) << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3088
import math
N,D = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]

cnt = 0
for i in range(N):
    MathDistance = math.sqrt(L[i][0] ** 2 + L[i][1] ** 2)
    if MathDistance <= D:
        cnt += 1
print(cnt)

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

const int mod = 1e9 + 7;

template <typename T> inline bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> inline bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    ll n, s;
    cin >> n >> s;
    if(n < s) {
        cout << -1 << endl;
        return 0;
    }
    if(n == s) {
        cout << n + 1 << endl;
        return 0;
    }
    for(ll b = 2; b * b <= n; b++) {
        ll num = n, sum = 0;
        while(num) {
            sum += num % b;
            num /= b;
        }
        if(sum == s) {
            cout << b << endl;
            return 0;
        }
    }
    for(ll a = sqrt(n - s); a; a--) {
        if((n - s) % a) continue;
        ll b = (n - s) / a + 1;
        if(a + n % b == s) {
            cout << b << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 384
# include <bits/stdc++.h>
# define int long long
# define fi first
# define se second

using namespace std ;

const int N = 1e5 + 1 ;
int v[N][3] ;

int32_t main() {
    //freopen("haybales.in", "r", stdin ) ;
    //freopen("haybales.out", "w", stdout ) ;
    int t ;
    cin >> t ;
    for( int i = 1 ; i <= t ; i ++ ) {
        cin >> v[i][1] >> v[i][2] >> v[i][3] ;
        if( i > 1 ) {
            v[i][1] += max( v[i-1][2], v[i-1][3] ) ;
            v[i][2] += max( v[i-1][1], v[i-1][3] ) ;
            v[i][3] += max( v[i-1][1], v[i-1][2] ) ;
        }
    }
    cout << max({v[t][1], v[t][2], v[t][3] } ) ;

}



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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)
#else
#define show(...) 42
#endif


#define f first
#define s second
#define endl "\n"
#define pb push_back
#define  oo 0x3f3f3f3f
#define limit 1000000007
#define int long long int
#define mod(x,m) ((x%m+m)%m)
#define ll long long
#define all(v) v.begin(),v.end()
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repb(i,a,b) for(int i=(a);i>=(b);i--)
#define fastio std::ios::sync_with_stdio(false)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define input_from_file  freopen("input.txt", "r", stdin);

signed main(){
  //input_from_file;
  int n; cin>>n;
  int dp[n+1][n+1];
  memset(dp,0,sizeof dp);
  // dp[i][j] represents upto i and the last no is j;
  for(int i=1;i<=n;i++) dp[1][i] = 1;
  string str; cin>>str;
  for(int i=2;i<=n;i++){
   for(int j=1;j<=i;j++)
    if(str[i-2] == '>') dp[i][j] = (dp[i-1][n]%limit-dp[i-1][j-1]%limit+limit)%limit;
    else dp[i][j] = dp[i-1][j-1];
   for(int j=1;j<=n;j++) dp[i][j] = (dp[i][j]+dp[i][j-1])%limit;
  }
  cout<<dp[n][n]<<endl;
}


Measured memory_bytes: 70656
from itertools import combinations
from collections import Counter
n = int(input())
s = []
ans = 0

for i in range(n):
    name = input()
    if name[0] in 'MARCH':
        s.append(name[0])

count = Counter(s)
for i, j, k in combinations(count, 3):
    ans += count[i] * count[j] * count[k]
print(ans)


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

int main(){
  int N;
  cin >> N;
  vector<pair<int64_t, int64_t>> BA(N);
  for(int i=0; i<N; i++){
    cin >> BA.at(i).second >> BA.at(i).first;
  }
  
  sort(BA.begin(), BA.end());

  int64_t timesum = 0;
  bool ans = true;
  for(pair<int64_t, int64_t> bai : BA){
    timesum += bai.second;
    if(timesum > bai.first){
      ans = false;
      break;
    }
  }
  
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

int main(){
    string s;
    int count=0;
    cin >> s;
    rep(i,s.length()){
        if(s[i]=='1'){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){
	char data[100]={'\0'},a,b;
	int i=0,c=0;
	scanf("%s",data);
	
	while(data[i]!='\0'){
		if(i==0){
			a=data[i];	
		}else if(data[i+1]=='\0'){
			b=data[i];	
		}else{
			c++;	
		}
		i++;
	}
	
	printf("%c%d%c\n",a,c,b);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define fi first
#define se second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define RFor(i,b,a) for(ll i = b;i>=a;i--)
#define sz size()
#define PQ priority_queue
#define len length()
#define mll map<ll,ll>
#define mpll map<pll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pair<ll,ll> >
#define mp(x,y)  make_pair(x,y)
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define ALL(v) v.begin(),v.end()
#define LAPAK ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

const ll MOD = 2*(1e9 + 7);
const ll INF = 2e18;
const ll MAX = 405;

ll binpow(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main() {
    LAPAK
    
    ll n;
    cin>>n;
    ll a[n];
    For(i,0,n)cin>>a[i];
    ll s1 = 0,s2 = 0;
    For(i,0,n){
        s1 += a[i];
        s2 += binpow(a[i],2,MOD);
        s1 %= MOD;
        s2 %= MOD;
        //cout<<s1<<" "<<s2<<endl;
    }
    
    ll s3 = binpow(s1,2,MOD);
    //cout<<s3<<" "<<s2<<endl;
    ll ans = (s3-s2 + MOD)/2;
    cout<<(ans+MOD)%(MOD/2);
    
    return 0;
}

Measured memory_bytes: 5172
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s =Console.ReadLine().Split(' ');

            int tate = int.Parse(s[0]);
            int yoko = int.Parse(s[1]);

            int menseki = tate * yoko;
            int syuui = 2 * (tate + yoko);

            Console.WriteLine(menseki+" "+syuui);

        }
    }
}

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30

int main()
{
	int N, M;
	vector<mii> v;
	vector<pii> py;
	int P, Y;

	cin >> N >> M;
	v.resize(N+1);
	py.resize(M);
	rep(i,M){
		cin >> P >> Y;
		py[i] = mp(P, Y);
		v[P][Y] = 0;
	}
	rep(i,N+1){
		int cnt = 1;
		for(auto &iter : v[i]){
			iter.second = cnt;
			cnt++;
		}
	}

	rep(i,M){
		P = py[i].first;
		Y = py[i].second;
		printf("%06d%06d\n", P, v[P][Y]);
	}

	return 0;
}


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

int main()
{
  int a, b;
  int k;
  cin >> a >> b >> k;
  int cnt = 0;
  for (int i = 100; i > 0; i--)
  {
    if (a % i != 0) continue;
    if (b % i != 0) continue;
    cnt++;
    if (cnt == k)
    {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


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

int main(void) {
	long long a, b, k;
	cin >> a >> b >> k;
	if (a >= k) {
		a -= k;
	} else {
		k -= a;
		a = 0;
		if (b >= k) {
			b -= k;
		} else {
			b = 0;
		}
	}
	cout << a << ' ' << b;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	System.out.println(c + " " + a + " " + b);
    }
}

Measured memory_bytes: 39488
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll A, B, C, K;
  cin >> A >> B >> C >> K;

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



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

int a[200000];

signed main(){

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

  int cnt = 0;
  int flag = 1;
  for(int i = 0; i < n; i++){
    flag = 0;
    int minj = i;
    for(int j = i; j < n; j++){
      if(a[j] < a[minj]){
        minj = j;
        flag = 1;
      }
    }
    swap(a[i],a[minj]);
    if(flag) cnt++;
  }

  for(int i = 0; i < n; i++){
    if(i) cout << " ";
    cout << a[i];
  }
  cout << endl;
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
using namespace std;
 
int main(){
  int n; cin >> n;
  vector<long long int> x(n),y(n);
  for(int i=0;i<n;i++) cin >> x[i] >> y[i];
  vector<pair<long long int,int> > xi(n),yi(n);
  vector<int> xid(n),yid(n);
  for(int i=0;i<n;i++){
    xi[i] = make_pair(x[i],i);
    yi[i] = make_pair(y[i],i);
  }
  sort(xi.begin(),xi.end());
  sort(yi.begin(),yi.end());
  for(int i=0;i<n;i++){
    xid[xi[i].second] = i;
    yid[yi[i].second] = i;
  }
 
  vector<bool> c(n);
  for(int i=0;i<n;i++) c[i] = false;
  priority_queue<pair<long long int,int>, vector<pair<long long int,int>>, greater<pair<long long int, int> > > q;
  c[xi[0].second] = true;
  q.push(make_pair(xi[1].first -xi[0].first, xi[1].second));
  if(yid[xi[0].second]>0) q.push(make_pair(yi[yid[xi[0].second]].first -yi[yid[xi[0].second]-1].first, yi[yid[xi[0].second]-1].second));
  if(yid[xi[0].second]<n-1) q.push(make_pair(yi[yid[xi[0].second]+1].first -yi[yid[xi[0].second]].first, yi[yid[xi[0].second]+1].second));
  int count = 1;
  long long int ans = 0;
  while(count!=n&&!q.empty()){
    while(c[q.top().second]) q.pop();
    int id = q.top().second;
    int ix = xid[id], iy = yid[id];
    //cout << q.top().first << ":" << id << endl;
    
    ans = ans + q.top().first;
    c[id] = true;
    count++;
    q.pop();
    
    if(ix>0&&!c[xi[ix-1].second]) 	q.push(make_pair(xi[ix].first-xi[ix-1].first, xi[ix-1].second));
    if(ix<n-1&&!c[xi[ix+1].second]) q.push(make_pair(xi[ix+1].first-xi[ix].first, xi[ix+1].second));
    if(iy>0&&!c[yi[iy-1].second]) 	q.push(make_pair(yi[iy].first-yi[iy-1].first, yi[iy-1].second));
    if(iy<n-1&&!c[yi[iy+1].second]) q.push(make_pair(yi[iy+1].first-yi[iy].first, yi[iy+1].second));
  }
  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Test int T;cin>>T;while(T--)
#define ls lower_bound
#define up upper_bound
#define bs binary_search
#define S second
#define F first
#define vi vector<int>  
#define pii pair<int,int>
#define vpi vector<pii>
#define vvi vector<vi>
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define m_n(v) *min_element(all(v))
#define m_x(v) *max_element(all(v))
#define ___(a) for(auto &i:a) cin>>i
#define __(a)  for(auto i:a) cout<<i<<" "
#define nl cout<<"\n";
#define momo(k) memset(k,0,sizeof(k))
#define momi(k) memset(k,-1,sizeof(k))
/* 
#include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
*/
int power(int x, int y,int mod){
    int res = 1;
    while (y)
    {
        if (y & 1)
        res = (res*x)%mod;
        y = y>>1;
        x = (x*x)%mod;
    }
    return res;
}
int modInverse(int a, int m){
    int m0 = m;
    int y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
int binomial(int n,int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}

// vector<int> prime;
// void sieve(){
//     bool arr[300000]={0};
//     prime.pb(2);
//     for(int i=3;i<300000;i+=2){
//         if(arr[i])continue;
//         for(int j=i*i;j<300000;j+=i) arr[j]=1;
//         prime.pb(i);
//     }
// }
// const int N=1e18+2;
const int mod = 1e9+7;
const int N = 1e5+2;
vi v[N];
int dp[N] = {0};

void dfs(int pre){
    dp[pre] = 0;
    for(auto i:v[pre]){
        if(dp[i] == -1) dfs(i);
        dp[pre] = max(dp[pre],1+dp[i]);
    }
}

int32_t main() {
    IOS;
    momi(dp);
    int n,m;
    cin>>n>>m;
    int x,y;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        v[x].pb(y);
    }
    int ans = 0;
    for(int i=0;i<=n;i++){
        if(dp[i] == -1){
            dfs(i);
        }
    }
    for(int i=1;i<=n;i++) ans = max(ans,dp[i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 11772
#include <iostream>
#include <vector>
using namespace std;
int gcd(int x, int y) {
    if (x == 0) return y;
    if (y == 0) return x;
    return gcd(y, x%y);
}

int main(void){
  int N,K;
  cin >> N >> K;
  
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  
  int g = a[0];
  int max = a[0];
  for(int i=1;i<N;i++){
    g = gcd(g,a[i]);
    if(a[i] > max) max = a[i];
  }
  
  if(max < K) cout << "IMPOSSIBLE" << endl;
  else{
    if(K % g == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define p(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1<<25

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef long long ll;

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}
int n,m,l,r;
string S;
void input(){
	cin>>S;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	rep(i,S.size()){
		if(i<=S.size()-2){
			if(S[i]==S[i+1]){
				p(i+1)P(i+2);
				return 0;
			}
		}
		if(i<=S.size()-2){
			if(S[i]==S[i+2]){
				p(i+1)P(i+3);
				return 0;
			}
		}
	}
	p("-1")P("-1")
	return 0;
}



Measured memory_bytes: 512
import math
n=int(input())
x = list(map(float, input().split()))
y = list(map(float, input().split()))
Dp = [0,0,0,0]

def Dp(x,y,n,p):
    i = 0
    ans = 0
    for i in range(n):
        ans += (math.fabs(x[i]-y[i]))**p
        i+=1
    return ans**(1/p)

def Dp_inf(x,y,n):
    i = 0
    ans = 0
    for i in range(n):
        if ans < math.fabs(x[i]-y[i]):
            ans = math.fabs(x[i]-y[i])
    return ans

for j in range(3):
    print(Dp(x,y,n,j+1))

print(Dp_inf(x,y,n))



Measured memory_bytes: 5724
import java.util.function.BiFunction;

public class Main {

	private static final int MAX_NUM = 9;

	public static void main(String[] args)
	{
		BiFunction<Integer, Integer, String> qq = (Integer num1, Integer num2) ->
			{return num1 +"x" + num2 + "=" + (num1 * num2);};

		for(int i = 1; i <= MAX_NUM; i++){
			for(int j = 1; j <= MAX_NUM; j++){
				System.out.println(qq.apply(i,j));
			}
		}
	}

}

Measured memory_bytes: 30476
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

fn main() {
    input! {
        n: usize,
        aa: [u64;n]
    }
    let mut c1 = 0;
    let mut c2 = 0;
    let mut c4 = 0;
    for a in aa {
        if a % 4 == 0 {
            c4 += 1;
        } else if a % 2 == 0 {
            c2 += 1;
        } else {
            c1 += 1;
        }
    }
    println!("{}",
        if (c1 + if c2 % 2 == 0 {0} else {1}) <= c4 + 1
        {"Yes"} else {"No"});
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


/// array globaly declare korbo, kokhon a[n+2] evabe korbona
/// loop check korbo koto porjunto choltese
///n & m thakle duitai ki n & n nki porer ta m likhsi cheak korbo
int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int n,k;
    cin >> n >> k;
    deque<int>DQ;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        DQ.push_back(x);
        //cerr << DQ.front() << " "<<DQ.back()<<endl;
    }
    int mn = min(n,k);
    int ans = 0;
    for(int x = 0; x <= mn; x++)
    {
        for(int y = 0; y <= mn; y++)
        {
            if(x+y <= mn)
            {
                int cnt = 0, tm;
                deque<int> dq = DQ;
                priority_queue<int> PQ;

                for(int i = 0; i < x; i++)
                {
                    if(dq.empty()) break;
                    tm = dq.front();
                    dq.pop_front();
                    cnt += tm;
                    if(tm < 0) PQ.push(tm * (-1));
                   // cerr << tm << " "<<cnt <<endl;
                }
                //cerr << "-----------------\n";

                for(int i = 0; i < y; i++)
                {
                    if(dq.empty()) break;
                    tm = dq.back();
                    dq.pop_back();
                    cnt += tm;
                    if(tm < 0) PQ.push(tm * (-1));
                }

                for(int l = 0; l < (k - x - y); l++)
                {
                    if(PQ.empty()) break;
                    cnt += PQ.top();
                    PQ.pop();
                }
                ans = max(ans, cnt);
            }
        }
    }
    cout << ans << endl;

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int MOD = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,m;
        cin>>n>>m;
        int h[n+1];
        for(int i=1;i<=n;i++)cin>>h[i];
        vector<int> a[n+1];
        while(m--)
        {
            int x,y;
            cin>>x>>y;
            a[y].pb(x);
            a[x].pb(y);
        }
        int ans = 0;
        for(int i=1;i<=n;i++)
        {
            int ok = 1;
            for(auto ne:a[i])
            {
                if(h[i]<=h[ne])ok=0;
            }
            ans+=ok;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 10256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define MAX 1000005

int cal(int n){
	int ans = 0, tot = 0;
	for(int i = 1; ; i++){
		if( tot + i <= n )
			tot += i, ans++;
		else
			break;
	}
	return ans;
}

int32_t main(){
	vector<bool> prm(MAX, true);
	prm[1] = false;
	for(int i = 2; i < MAX; i++)
		if( prm[i] == false ){
			for(int j = 2*i; j < MAX; j+=i)
				prm[j] = false;
		}

	int n, ans = 0;
	cin >> n;
	for(int i = 2; i < MAX && n > 1; i++){
		if( prm[i] && n%i == 0 ){
			int tot = 0;
			while( n%i == 0 ){
				tot++;
				n = n/i;
			}
			ans += cal(tot);
		}
	}
	if( n != 1 ){
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
bitset<50050> alv[50050];
int n,m,u[100050],v[100050],vis[50050];
char ans[100050];
void solve1(){
	for(int i=1;i<=n;i++){
		alv[i].reset();
		alv[i][i] = 1;
	}
	for(int i=m;i>=1;i--){
		alv[u[i]]|=alv[v[i]];
		alv[v[i]]|=alv[u[i]];
	}
	bitset<50050> cc;
	cc.set();
	for(int i=1;i<=n;i++){
		cc&=alv[i];
	}
	int cho = 0;
	for(int i=1;i<=n;i++) if(cc[i] && !cho)cho = i;
	if(!cho){
		cout<<-1<<endl;
		return;
	}
	vis[cho] = 1;
	for(int i=m;i>=1;i--){
		ans[i] = vis[u[i]]?'^':'v';
		vis[u[i]]|=vis[v[i]];
		vis[v[i]]|=vis[u[i]];
	}
	cout<<(ans+1)<<endl;
}
int cp[50050],cnt[50050];
void solve2(){
	if(n<=2){
		cout<<-1<<endl;
		return;
	}
	for(int i=1;i<=n;i++){
		cp[i] = i;
		cnt[i] = 1;
	}
	for(int i=m;i>=1;i--){
		if(cnt[cp[u[i]]]>cnt[cp[v[i]]]){
			ans[i] = 'v';
			cnt[cp[u[i]]]--;
			cnt[cp[v[i]]]++;
			cp[u[i]] = cp[v[i]];
		}else{
			ans[i] = '^';
			cnt[cp[v[i]]]--;
			cnt[cp[u[i]]]++;
			cp[v[i]] = cp[u[i]];
		}
	}
	cout<<(ans+1)<<endl;
}
int t;
int main() {
	read(n);read(m);read(t);
	for(int i=1;i<=m;i++){
		read(u[i]);
		read(v[i]);
	}
	if(t == 1){
		solve1();
	}
	if(t == 2){
		solve2();
	}
	return 0;
}


Measured memory_bytes: 307328
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
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(){
	ll n; cin>>n;
	vector<ll> a(100100,0);
	rep(i,1,100){
		rep(j,1,100){
			rep(k,1,100){
				ll sum = i*i + j*j + k*k + i*j + j*k + k*i;
				a[sum]++;
			}
		}
	}
	rep(i,1,n+1) cout<<a[i]<<endl;
}

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


int main(){
  int R,G,B,N; cin >> R >> G >> B >> N;
  
  long long result=0;
  for(int i=0; i<=N/R; i++){
    for(int j=0; j<=(N-i*R)/G; j++){
      if((N-i*R-j*G)%B==0) result++;
    }
  }
  cout << result << endl;
}

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

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

  int min_a = 1000000000;
  int max_a = 1;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;

    min_a = min(min_a, a);
    max_a = max(max_a, a);
  }

  cout << max_a - min_a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 100005
#define inf 1000000000001
using namespace std;

int main (){
	
	//freopen("t.txt","r",stdin);
	int n;
	cin>>n;
	int a[22],b[22],c[22];
	long long sum=0;
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=1;i<=n;i++) cin>>b[i];
	for (int i=1;i<=n-1;i++) cin>>c[i];
	
	
	for (int i=1;i<=n;i++){
		sum+=b[a[i]];
		if (i>1){
			if (a[i]==a[i-1]+1){
				sum+=c[a[i-1]];
			}
		}
	}
	cout<<sum;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        ll num = a[i];

        while (num % 2 == 0)
        {
            num /= 2;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;
 
public class Main {
    static int cntRectangle=0;
    static int cntDia=0;
    public static void main(String[] args) {
        try{
        Scanner scanline = new Scanner (System.in);
        while(scanline.hasNext()){
            String lines = scanline.nextLine();
            Scanner scan = new Scanner(lines);
            scan.useDelimiter(",");
            int a = scan.nextInt();
            int b = scan.nextInt();
            int c = scan.nextInt();
            if(a*a+b*b==c*c){
                cntRectangle+=1;
            }if(a==b){
                cntDia+=1;
            }
        }
        System.out.printf("%d\n",cntRectangle);
        System.out.printf("%d\n",cntDia);
    }
    catch(java.util.NoSuchElementException f){
        System.out.println("Input Valid Values");
    }
    }
 
}

Measured memory_bytes: 19376
def main():
    import sys
    my_input = sys.stdin.readline
    H, W, K = map(int, my_input().split())
    V = [[0] * W for _ in range(H)]
    for i in range(K):
        h, w, v = map(int, my_input().split())
        h, w = h - 1, w - 1
        V[h][w] = v

    # dp1 ~ 4[h][w][x] := h行w列にいて、h行からn個アイテムを拾っている時の価値の総和の最大値
    dp0 = [[0] * (W + 1) for _ in range(H + 1)]
    dp1 = [[0] * (W + 1) for _ in range(H + 1)]
    dp2 = [[0] * (W + 1) for _ in range(H + 1)]
    dp3 = [[0] * (W + 1) for _ in range(H + 1)]

    for h in range(1, H + 1):
        for w in range(1, W + 1):
            dp1[h][w] = max(
                dp1[h][w],
                dp3[h - 1][w] + V[h - 1][w - 1],
                dp1[h][w - 1],
                dp0[h][w - 1] + V[h - 1][w - 1]
            )

            dp2[h][w] = max(
                dp2[h][w],
                dp3[h - 1][w] + V[h - 1][w - 1],
                dp2[h][w - 1],
                dp1[h][w - 1] + V[h - 1][w - 1]
            )

            dp3[h][w] = max(
                dp3[h][w],
                dp3[h - 1][w] + V[h - 1][w - 1],
                dp3[h][w - 1],
                dp2[h][w - 1] + V[h - 1][w - 1]
            )

    print(dp3[-1][-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 433756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    string s;

    cin >> n >> s;

    int res = 1;

    for (int i = 1; i < n; i++)
    {
        res += s[i] != s[i - 1];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 512