akhauriyash/Code-Regression huggingface dataset:
#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define ifor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define SIZE 200005
#define UF_MAX 100005
using namespace std;
typedef long double ld;
typedef long long int lli;
const double eps = 1e-11;
int vex[4] = {1, 0, -1, 0};
int vey[4] = {0, 1, 0, -1};
lli MOD = 1000000007;
#define UF_MAX 100005
struct UFind {
    int par[UF_MAX];
    int rank[UF_MAX];
    int count[UF_MAX];
    UFind(int n)
    {
        rep(i, n)
        {
            par[i] = i;
            rank[i] = 0;
            count[i] = 1;
        }
    }
    int find(int x)
    {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (rank[x] < rank[y]) {
            par[x] = y;
            count[y] += count[x];
        } else {
            par[y] = x;
            count[x] += count[y];
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

int main()
{
    lli n, m, k;
    cin >> n >> m;
    map<lli, vector<lli>> a;
    rep(i, n)
    {
        cin >> k;

        rep(j, k)
        {
            lli l;
            cin >> l;
            a[l].push_back(i);
        }
    }
    UFind t(n + 3);
    rep(i, m + 1)
    {
        vector<lli> now = a[i];
        if (now.size() <= 1)
            continue;
        int tmp = now[0];
        for (auto s : now) {
            t.unite(tmp, s);
        }
    }
    rep(i, n)
    {
        if (!t.same(0, i)) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 10368
import numpy as np
from numpy.fft import fft
from numpy.fft import ifft
class FFT:
  def exe(s, A, B):
    N, M = 1, len(A) + len(B) - 1
    while N < M: N <<= 1
    A, B = s.arrN(N, A), s.arrN(N, B)
    A = fft(A) * fft(B)
    A = ifft(A).real[:M] + 0.5
    return list(map(int, A))
  def arrN(s, N, L):
    return np.zeros(N) + (L + [0] * (N - len(L)))

N = int(input())
a = list(map(int, input().split()))
MOD = 200003

r = 2
EXP = [0] * MOD
LOG = [0] * MOD
EXP[0] = 1
# r ^ i % MOD = EXP[i]
# logr(i) = LOG[i]
for i in range(1, MOD):
  EXP[i] = EXP[i - 1] * r % MOD
  LOG[EXP[i]] = i

b = [0] * MOD
for n in a:
  # log0は無限、実際には不要なので無視
  if n == 0: continue 
  b[LOG[n]] += 1

# x * y = z => log(x * y) = log(z) => log(x) + log(y) = log(z)
# c[i] <- log(x) + log(y) が i となる個数
f = FFT()
c = f.exe(b, b)

ans = 0
t = 1
for n in c:
  # log(z)をzに戻しつつ個数を掛ける
  ans += n * t
  t = t * r % MOD

# i * i が含まれているので引く
for i in a:
  ans -= i * i % MOD

# i * j と j * i が両方含まれているので割る
ans //= 2

print(ans)


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

using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], count;
  cin >> count;

  for (int i = 0; i < count; i++) cin >> R[i];

  int maxv = -2000000000;
  int minv = R[0];
  for (int i = 1; i < count; i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }
  cout << maxv <<endl;
  return 0;
}


Measured memory_bytes: 3868
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
	int ans = 0;
	int N;
	cin >> N;
	vector<int> H(N);
	for(int i=0; i<N; ++i) cin >> H[i];
	int MAX = 0;
	for(int i=0; i<N; ++i){
		if(MAX<=H[i]) ++ans;
		MAX = max(MAX, H[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	string s;
	cin>>s;
	int maxPos = 0;
	int cnt = 0;
	set<char> st;
	st.insert('A');
	st.insert('C');
	st.insert('G');
	st.insert('T');
	for(int i=0; i<s.length(); i++)
	{
		if(st.count(s[i]))
			cnt++;
		else
		{
			maxPos = max(maxPos, cnt);
			cnt = 0;
		}
	}
	maxPos = max(maxPos, cnt);
	cout<<maxPos<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    vector<vi> adj(n);
    rep(i,m){
        int a,b; cin>>a>>b; a--; b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    rep(i,n){
        cout<<adj[i].size()<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
W, H, N = map(int, input().split())

x0, y0, x1, y1 = 0, 0, W, H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        if x0 < x:
            x0 = x
    elif a == 2:
        if x < x1:
            x1 = x
    elif a == 3:
        if y0 < y:
            y0 = y
    else:
        if y < y1:
            y1 = y

if x1-x0<0 or y1-y0<0:
    print(0)
else:
    print((x1-x0)*(y1-y0))




Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>

using namespace std;

int main(){
	int K;
	cin >> K;
	int seven = 7 % K;

	for (int i = 1; i <= K; i++) {
		if(seven == 0) {
			cout << i << endl;
			return 0;
		}
		seven = (seven*10 + 7) % K;
	}
	cout << -1 << endl;
	return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k; cin>>n>>k;
	if(k==1) cout<<0<<"\n";
	else cout<<abs(n-(k-1)-1)<<"\n";
	return 0;
}

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

int main(){
    long long K,ans=0;
    cin >> K;
    for(int i=0;i<K;i++){
        for(int j=0;j<K;j++){
            for(int k=0;k<K;k++){
                ans+=__gcd(__gcd(i+1,j+1),k+1);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
/// IN THE NAME OF METAL
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef pair<ll, ll> pll;
 
#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second

ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}
const ll MAXN = 1e5 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
ll Sz[MAXN], H[MAXN], n;
pll D[MAXN]; vector<ll> adj[MAXN]; map<ll, ll> pos;

void DFS(ll v, ll p = -1) {
    for (ll u : adj[v]) {
        H[u] = H[v] + 1;
        DFS(u, v);
    }
}

int main() {
    scanf("%lld", &n);
    for (ll i = 1; i <= n; i++) {
        scanf("%lld", &D[i].F);
        D[i].S = i;
        pos[D[i].F] = i;
    }
    sort(D + 1, D + n + 1, greater<pll>());
    for (ll i = 1; i <= n - 1; i++) {
        ll v = D[i].S;
        pos.erase(D[i].S);
        Sz[v] = 1;
        for (ll u : adj[v]) {
            Sz[v] += Sz[u];
        }
        if (pos.find(D[i].F - n + 2 * Sz[v]) == pos.end()) break;
        ll par = pos[D[i].F - n + 2 * Sz[v]];
        adj[par].push_back(v);
    }
    DFS(D[n].S);
    if (accumulate(H, H + MAXN, 0LL) != D[n].F) printf("-1\n");
    else {
        for (ll i = 1; i <= n; i++) {
            for (ll u : adj[i]) printf("%lld %lld\n", i, u);
        }
    }
    return 0;
}



Measured memory_bytes: 20944
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MOD (ll)1000000007

int a[1000001];
int b[1000001];

int main(void)
{
	ll n;
	scanf("%lld", &n);

	ll ans = 0;

	for (ll a = 1; a <= n - 1LL; a++)
	{
		ans += (n - 1LL) / a;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1732
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
A = A1 + A2 + A3
N = int(input())
B = []
for _ in range(N):
    B.append(int(input()))
ans =  [0]*9
for i in range(N):
    if B[i] in A:
        ans[A.index(B[i])] = 1

if (ans[0] == 1 and ans[1] == 1 and ans[2] == 1) or \
    (ans[3] == 1 and ans[4] == 1 and ans[5] == 1) or \
    (ans[6] == 1 and ans[7] == 1 and ans[8] == 1) or \
    (ans[0] == 1 and ans[3] == 1 and ans[6] == 1) or \
    (ans[1] == 1 and ans[4] == 1 and ans[7] == 1) or \
    (ans[2] == 1 and ans[5] == 1 and ans[8] == 1) or \
    (ans[0] == 1 and ans[4] == 1 and ans[8] == 1) or \
    (ans[2] == 1 and ans[4] == 1 and ans[6] == 1) :
    print("Yes")
else :
    print("No")


Measured memory_bytes: 38332
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin>>a;
    cin>>b;
    int i,count=0;

    for(i=0;i<a.size();i++)
    {
        if(a[i]!=b[i])
            count++;
    }

    cout<<count<<endl;

    return 0;
}


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

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		int j = i;
		int k = i%10;
		while (j >= 10) {
			j /= 10;
			k += j % 10;
		}
		if (k >= A && k <= B) ans += i;
	}
	cout << ans;
}

Measured memory_bytes: 256
type symbol =
  | Spade
  | Heart
  | Club
  | Diamond

type card = symbol * int

let iota ?(start=0) ?(step=1) count =
  let rec doit count acc =
    if count <= 0 then acc
    else
      let i = count - 1 in
      doit i (start + i * step :: acc)
  in
  doit count []

let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  List.rev (doit str [])

let read_cards n =
  let rec doit i acc =
    if i > n then acc
    else
      let l = read_line () in
      match split l ' ' with
      | [] | [_] -> exit 1
      | s :: n :: _ ->
          let n = int_of_string n in
          match s with
          | "S" -> doit (i + 1) ((Spade, n) :: acc)
          | "H" -> doit (i + 1) ((Heart, n) :: acc)
          | "C" -> doit (i + 1) ((Club, n) :: acc)
          | "D" -> doit (i + 1) ((Diamond, n) :: acc)
          | _ -> exit 1
  in
  doit 1 []

let print_card sym num =
  match sym with
  | Spade -> Printf.printf "S %d\n" num
  | Heart -> Printf.printf "H %d\n" num
  | Club -> Printf.printf "C %d\n" num
  | Diamond -> Printf.printf "D %d\n" num

let () =
  let n = read_int () in
  let all_sym = [Spade; Heart; Club; Diamond] in
  let all_num = iota 13 ~start:1 in
  let cards = read_cards n in
  List.iter (fun sym ->
    List.iter (fun num ->
      if not (List.mem (sym, num) cards) then print_card sym num
      ) all_num
    ) all_sym

Measured memory_bytes: 2300
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    char W[10], T[10];
    int count = 0, i;
    scanf("%s", W);
    while (scanf("%s", T) != EOF && strcmp(T, "END_OF_TEXT")) {
        for (i = 0; T[i]; i++) {
            T[i] = tolower(T[i]);
        }
        if (!strcmp(W, T)) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 552
n = int(input())

list_A = []
for i in range(n):
    list_A.append(int(input()))

#リスト内の最大の値を格納
max_val = max(list_A)

#リスト内の最大の値の位置を格納
for i in range(len(list_A)):
    if list_A[i] == max_val:
        max_val_position = i
        break

#リスト内のから最大の要素を除いた後の，最大の要素
max_val_2 = max(list_A[:max_val_position] + list_A[max_val_position+1:])

for i in range(len(list_A)):
    
    #リスト内の最大の数が除かれたときは二番目に大きい数を出力する
    if i == max_val_position:
        print(max_val_2)
    else:
        print(max_val)

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

using namespace std;

namespace {
    string s;
    bool input() {
        cin >> s;
        return s != "#";
    }

    int N;

    bool isVowel(char c) {
        string vs = "aiueo";
        return vs.find(c) != string::npos;
    }

    // 無声子音か？
    bool C(char c) {
        string ks = "ksthp";
        return ks.find(c) != string::npos;
    }

    int next(int i) {
        for (int j = i + 1; j < N; j++) {
            if (!isVowel(s[j])) return j;
        }
        return N;
    }

    void solve() {
        N = int(s.size());

        vector<bool> X(N, false);
        for (int i = 1; i < N; i++) {
            if (s[i] != 'i' && s[i] != 'u') continue;
            char c = s[i - 1];
            if (c == 'y') {
                if (i >= 2 && C(s[i - 2])) {
                    c = s[i - 2];
                }
            }
            if (C(c) && (i == N - 1 || C(s[i + 1]))) {
                X[i] = true;
            }
        }

        string t = s;

        for (int i = 0; i < N - 1; i++) {
            if (!isVowel(s[i]) && s[i] == s[i + 1]) {
                s[i] = 'x';
            }
        }

        string ks = "ao";
        for (int k = 0; k < 2; k++) {
            char c = ks[k];
            int last = -1;
            for (int i = 0; i < N; ) {
                if (!C(s[i])) {
                    i = next(i);
                    if (last >= 0) {
                        X[last] = false;
                        last = -1;
                    }
                } else {
                    i++;
                    if (i >= N) continue;
                    if (s[i] == 'y') i++;
                    if (i >= N) continue;
                    if (s[i] == c) {
                        X[i] = true;
                        last = i;
                    } else {
                        if (last >= 0) {
                            X[last] = false;
                            last = -1;
                        }
                    }
                    i++;
                }
            }
            if (last >= 0) {
                X[last] = false;
                last = -1;
            }
        }

        bool prev = false;
        for (int i = 0; i < N; i++) {
            if (isVowel(t[i])) {
                if (prev) {
                    X[i] = false;
                    prev = false;
                } else {
                    if (X[i]) {
                        prev = true;
                    }
                }
            }
        }

        for (int i = 0; i < N; i++) {
            if (X[i]) {
                cout << "(" << t[i] << ")";
            } else {
                cout << t[i];
            }
        }
        cout << endl;
    }
}

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

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int t = a *b;
  for(; t >= 0; t-=a) {
   	if(t % b == c) {
      	cout << "YES\n";
      	return 0;
    }
  }
  cout << "NO\n";
  
  
  
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline

def KMP(sentence,word):
  ret=[]
  
  def make_table(word):
    n=len(word)
    table=[0]*(n+1)
    table[0]=-1
    j=-1
    for i in range(n):
      while j>=0 and word[i]!=word[j]:
        j=table[j]
      j+=1
      table[i+1]=j
    return table
  
  table=make_table(word)
  sentence_size=len(sentence)
  word_size=len(word)
  m=0
  i=0
  while m+i<sentence_size:
    if word[i]==sentence[m+i]:
      i+=1
      if i==word_size:
        ret.append(m)
        m=m+i-table[i]
        i=table[i]
    else:
      m=m+i-table[i]
      if i>0:
        i=table[i]
  return ret

n=int(input())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
a=[]
b=[]
for i in range(n):
  a.append(arr1[i]^arr1[(i+1)%n])
  b.append(arr2[i]^arr2[(i+1)%n])
a=(a+a)[:-1]
ks=KMP(a,b)
if len(ks)==0:
  exit()
ans=[]
for k in ks:
  ans.append((k,arr2[0]^arr1[k%n]))
ans=sorted(ans,key=lambda x:x[1])
ans=sorted(ans,key=lambda x:x[0])
for k,x in ans:
  print(k,x)

Measured memory_bytes: 62728
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cout << #x << " = " << x << endl;
 
template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}
 
template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}
 
template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}
 
template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();    
    return 0;
}
 
const int MOD = 998244353, MAXN = 5e5 + 10, INF = 1e18 + 10, BASE = 37; 

void solve() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < $(s); ++i) {
        if (s[i] != t[i]) {
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3796
n, x = map(int, input().split())

t = [1]
p = [1]

for i in range(1, n+1):
    t.append(3+2*t[i-1])
    p.append(1+2*p[i-1])

def pathi(n, x):
    if n == 0:
        if x >= 1:
            return 1
        return 0
    elif x == 1:
        return 0
    elif x <= t[n-1] + 1:
        return pathi(n-1, x-1)
    elif x == t[n-1] + 2:
        return p[n-1] + 1
    else:
        return p[n-1] + 1 + pathi(n-1, x-t[n-1]-2)

print(pathi(n, x))

Measured memory_bytes: 61644
#import<iostream>
#import<atcoder/all>
int i,N,Q,w,e,r;long a;using namespace std;int main(){cin>>N>>Q;atcoder::fenwick_tree<long>b(N);for(;i<N;i++){cin>>a;b.add(i,a);}while(Q--){cin>>w>>e>>r;if(w)cout<<b.sum(e,r)<<'\n';else b.add(e,r);}}

Measured memory_bytes: 8236
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define ull unsigned ll
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP1(i,n) for (int i=1; i<=(n); i++)
#define f first
#define s second
#define pii pair<int,int>
#define SQ(x) (x)*(x);
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define endl '\n'
using namespace std;
main (){
	int n; cin>>n;
	vector<int> vc(n);
	REP(i,n) cin>>vc[i];
	sort(ALL(vc));
	vector<ll> prsum(n);
	prsum[0]=vc[0];
	REP1(i,n-1){
		prsum[i]=prsum[i-1]+vc[i];
	}
	int cnt=0;
	REP(i,n-1){
		if (prsum[i]*2<vc[i+1]) cnt=0;
		else cnt++;
	}
	cout<<cnt+1<<endl;
}

Measured memory_bytes: 1408
def test():
    g1 = [1,3,5,7,8,10,12]
    g2 = [4,6,9,11]
    g3 = [2]
    x,y = map(int,input().split())
    if x in g1 and y in g1:
        print("Yes")
    elif x in g2 and y in g2:
        print("Yes")
    elif x == 2 and y == 2:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    test()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define fi first
#define se second
#define All(x) (x).begin(),(x).end()
#define TYPE(x) typeid(x).name()
int main(){
	int n;
	cin>>n;
	unordered_map<int,int>node;
	int k;
	cin>>k;
	for(int i=1;i<=k;++i){
		int d;
		cin>>d;
		for(int _=1;_<=d;++_){
			int tt;
			cin>>tt;
			++node[tt];
		}
	}
	int ans=0;
	for(auto i:node){
		if(i.second>0)++ans;
	}
	cout<<n-ans;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>

int main(){
  int A, B;
  scanf("%d", &A);
  scanf("%d", &B);
  int H, M;
  scanf("%d", &H);
  scanf("%d", &M);
  double thetaA = 30.0*((double)H+M/60.0);
  double thetaB = 6.0*M;
  //std::cout << thetaA << std::endl;
  //std::cout << thetaB << std::endl;
  double xA = (double)A*cos(thetaA*3.14159265358979/180.0);
  double yA = (double)A*sin(thetaA*3.14159265358979/180.0);
  double xB = (double)B*cos(thetaB*3.14159265358979/180.0);
  double yB = (double)B*sin(thetaB*3.14159265358979/180.0);
  double ans = sqrt(pow(xA-xB, 2) + pow(yA-yB, 2));
  printf("%.15lf\n", ans);
  return 0;
}


Measured memory_bytes: 3616
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
//#define MOD 1000000007
#define Mod 998244353
//#define N 200001
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.first<b.first) return true;
	else if(a.first==b.first) return a.second<b.second;
	else return false;
}
int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int x = (j < a) ^ (i < b);
      cout << x;
    }
    cout << '\n';
  }
  	return 0;
}








Measured memory_bytes: 1280
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa
from collections import Counter


def input():
    return sys.stdin.readline().rstrip()


def main():
    H, W = map(int, input().split())
    A = []
    for _ in range(H):
        for c in input():
            A.append(c)

    A.sort()
    B = Counter(A).most_common()
    # print(A)
    # print(B)
    success = False
    if H % 2 == 0 and W % 2 == 0:
        if all([val[1] % 4 == 0 for val in B]):
            success = True
    elif H % 2 == 1 and W % 2 == 0:
        if all([val[1] % 2 == 0 for val in B]):
            four = 0
            two = 0
            for el in B:
                x = el[1]
                if x % 4 == 0:
                    four += 1
                elif x % 2 == 0:
                    two += 1
            if two <= W // 2 and (W // 2 - two) % 2 == 0:
                success = True
    elif H % 2 == 0 and W % 2 == 1:
        if all([val[1] % 2 == 0 for val in B]):
            four = 0
            two = 0
            for el in B:
                x = el[1]
                if x % 4 == 0:
                    four += 1
                elif x % 2 == 0:
                    two += 1
            if two <= H // 2 and (H // 2 - two) % 2 == 0:
                success = True
    else:
        odd = 0
        two = 0
        four = 0
        for el in B:
            x = el[1]
            if x % 2 == 1:
                odd += 1
                x -= 1
            if x % 4 == 0:
                four += 1
            elif x % 2 == 0:
                two += 1
        if odd == 1:
            if two <= H // 2 + W // 2 and (H // 2 + W // 2 - two) % 2 == 0:
                success = True
    if success:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 39532
import bisect
N,Q=map(int,input().split())
S=input()
l=[]
for i in range(N-1):
  if S[i:i+2]=="AC":
    l.append(i+1)
for i in range(Q):
  a,b=map(int,input().split())
  c=bisect.bisect_left(l,a)
  d=bisect.bisect_right(l,b-1)
  print(d-c)

Measured memory_bytes: 5724
h,w = map(int,input().split())

if h ==1 or w == 1:
    print(1)
    exit()

# (偶数、偶数) (奇数、偶数)の場合
if (h%2 == 0 and w%2 ==0) or (h%2 != 0 and w%2 == 0):
    ans = int(w/2) * h

# 奇数、奇数の場合
elif h%2 != 0 and w%2 !=0:
    f = int(w/2) + 1
    s = f-1
    ans = f * (int(h/2)+1) + s * int(h/2)

# 偶数、奇数の場合
elif h%2 == 0 and w%2 != 0:
    f = int(w/2) + 1
    s = int(w/2)
    ans = f * int(h/2) + s * int(h/2)

print(ans)

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

void Main() {
  int n, k;
  cin >> n >> k;
  double exp[n];
  for (int i = 0; i < n; i++) {
    double p;
    cin >> p;
    exp[i] = (1 + p) / 2;
  }
  double ans = 0;
  double res = 0;
  for (int i = 0; i < k; i++) {
    res += exp[i];
  }
  ans = res;
  for (int i = k; i < n; i++) {
    res -= exp[i - k];
    res += exp[i];
    ans = max(ans, res);
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

const int MAX = 510000;

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

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

ll calcLCS(ll a, ll b) {
    if(b > a)swap(a, b);
    return a * b / calcGCD(a, b);
}

int getMultipleOf2Num(ll x) {
    int ret = 0;
    while(x % 2 == 0) {
        ++ret;
        x /= 2;
    }
    return ret;
}

int main() {
    ll N, M; cin >> N >> M;
    int cnt2;
    ll a[N];
    ll LCS = 1;
    rep(i, N) {
        cin >> a[i];
        a[i] /= 2;
        if(i == 0)cnt2 = getMultipleOf2Num(a[i]);
        LCS = calcLCS(a[i], LCS);
        if(cnt2 != getMultipleOf2Num(a[i]) || LCS > M) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << M / LCS / 2 + ((M / LCS % 2 == 0) ? 0 : 1) << endl;
}


Measured memory_bytes: 1024
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    F = [0] * (N + 1)
    for x in range(1, 101):
        X = x ** 2
        for y in range(1, 101):
            Y = y ** 2
            for z in range(1, 101):
                a = X + Y + z ** 2 + x * y + y * z + z * x
                if a <= N: F[a] += 1
    print(*F[1:], sep="\n")
                

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 68476
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    int n,k;
    cin>>n>>k;
    vi v1;
    int a1;
    loop(i,0,n)
    {
        cin>>a1;
        v1.pb(a1);
    }
    SORT(v1);
    int sum = 0;
    loop(i,0,k)
    {
        sum+=v1[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3620
# coding: utf-8
import sys


class Player:

    def __init__(self, name):
        self.name = name
        self.cards = None

    def set_cards(self, cards):
        self.cards = cards

    def has_no_cards(self):
        return self.cards == []

    def play_card(self):
        return self.cards.pop(0)


def main(argv=sys.argv):

    a = Player('A')
    a.set_cards(list(input()))
    b = Player('B')
    b.set_cards(list(input()))
    c = Player('C')
    c.set_cards(list(input()))

    next_player = a
    while True:
        card = next_player.play_card()
        if card == 'a':
            next_player = a
        elif card == 'b':
            next_player = b
        elif card == 'c':
            next_player = c

        if next_player.has_no_cards():
            print(next_player.name)
            break

    return 0


if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 3064
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  def f(d, n):
    m = n // d
    return m * (m+1) * d // 2
  print(sum([f(d, n) for d in range(1, n+1)]))
  
if __name__=='__main__':
  main()


Measured memory_bytes: 404528
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func max(a int, b int) int {
	if a >= b {
		return a
	}
	return b
}

type Node struct {
	Index     int
	Value     int
	Neighbors []*Node
	Len       int
	IsSearched  bool
}

var nodes []*Node
var already map[int]bool

// dp[i]: 長さiの増加部分列において最後の値の最小値
func search(n *Node, dp []int) {
	if n.IsSearched {
		return
	}
	n.IsSearched = true

	idx := sort.SearchInts(dp, n.Value)
	befVal := dp[idx]
	dp[idx] = n.Value
	n.Len = sort.SearchInts(dp, MAX_INT)
	for _, to := range n.Neighbors {
		search(to, dp)
	}
	dp[idx] = befVal
}

var X int64
var N int

func main() {
	sc.Split(bufio.ScanWords)
	nextInt64(&X)
	N=200

	x := make([]int, 2*N + 1)
	y := make([]int64, 2*N + 1)
	for i := 0; i <= 2*N; i++ {
		x[i] = i-N
		y[i] = int64(math.Pow(float64(x[i]), 5))
		//fmt.Printf("x: %d, y: %d\n", x[i], y[i])
	}

	for i := 0; i <= 2*N; i++ {
		for j := i; j <= 2*N; j++ {
			if y[j] - y[i] == X {
				fmt.Printf("%d %d", x[j], x[i])
				return
			}
		}
	}
}




const MAX_INT int = 1_000_000_000
var sc = bufio.NewScanner(os.Stdin)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)

func nextLine() string {
	buffer := make([]byte, 0)
	for true {
		line, isPrefix, err := reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func nextInt(A ...*int) {
	L := strings.Split(nextLine(), " ")
	for i, a := range A {
		*a, _ = strconv.Atoi(L[i])
	}
}
func nextInts(A *[]int) {
	L := strings.Split(nextLine(), " ")
	(*A) = make([]int, len(L))
	for i, l := range L {
		(*A)[i], _ = strconv.Atoi(l)
	}
}

func nextInt64(A ...*int64) {
	L := strings.Split(nextLine(), " ")
	for i, a := range A {
		*a, _ = strconv.ParseInt(L[i], 0, 64)
	}
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define LIMIT 1000000007 //10^9+7
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}

int main(){
	int N;cin>>N;
  int max_p = 0;
  int ans = 0;
  rep(i,N){
    int p;cin>>p;
    max_p = max(max_p, p);
    ans += p;
  }
  ans -= (max_p/2);
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<string.h>

int main() {
	
	int N, A[20], B[20], C[20];
	int ans = 0;
	int ago_a = 0;
	int Ci = 0;

	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	for (int i = 0; i < N; i++) {
		scanf("%d", &B[i]);
	}
	for (int i = 0; i < N - 1; i++) {
		scanf("%d", &C[i]);
	}

	for (int i = 0; i < N; i++) {
		ans += B[A[i] - 1];
		if (ago_a + 1 == A[i] && ago_a - 1 >= 0) {
			Ci = ago_a - 1;
			ans += C[Ci];
		}
		ago_a = A[i];
		
	}

	printf("%d", ans);

	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long inf = 100000000000000;
typedef pair<int, int> P;
int main(){
	int h, w, x;
	cin >> h >> w >> x;
	int ans = 0;
	int now = 0;
	while (now < x) {
		now += max(h, w);
		ans++;
	}
	cout << ans;
	return(0);
}

Measured memory_bytes: 256
n = int(input())
card_list = list(map(int, input().split()))

alice_point = 0
bob_point = 0

def pick_card(card_list):
    # print(card_list)
    max = 0
    max_index = 0
    for i in range(card_list.__len__()):
        # print('-------', i)
        if card_list[i] > max:
            # print('@', i, ':', max, '<', card_list[i])
            max = card_list[i]
            max_index = i
    
    del card_list[max_index]

    # print('----', card_list)

    return max, card_list

def sort_card(card_list: list):
    return sorted(card_list, reverse=True)

turn = 0
sorted_list = sort_card(card_list)
while turn < n:
    # print('--', turn)
    if turn % 2 == 0:
        # alice_get, remain_list = pick_card(card_list)
        # alice_point += alice_get
        alice_point += sorted_list.pop(0)
    else:
        # bob_get, remain_list = pick_card(card_list)
        # bob_point += bob_get
        bob_point += sorted_list.pop(0)

    # card_list = remain_list
    # print(alice_point, bob_point, sorted_list)

    turn += 1

print(alice_point - bob_point)

Measured memory_bytes: 3064
import scala.io.StdIn
object Main extends App {
  val N = StdIn.readLine().toInt
  val B = StdIn.readLine().split(" ").map(_.toInt).toList
  val answer = for {
    i <- 0 to N-2
    a = if (i == 0) B(0) else B(i).min(B(i-1))
  } yield a
  println(answer.sum + B(N-2))
}


Measured memory_bytes: 27344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    set<string> st;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        st.emplace(s);
    }
    cout << st.size() << '\n';
    return 0;
}

Measured memory_bytes: 19288
local s = io.read("*n")
local t = {}
t[s] = 1
local cur_idx = 1
local cur_val = s
while true do
  cur_idx = cur_idx + 1
  if cur_val % 2 == 0 then
    cur_val = cur_val / 2
  else
    cur_val = 3 * cur_val + 1
  end
  if(t[cur_val] ~= nil) then
    print(cur_idx)
    break
  end
  t[cur_val] = cur_idx
end


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [int(input()) for m in range(M)]
A = set(A)
dp=[0]*(N+1)
dp[0]=1
if 1 in A:
  dp[1]=0
else:
  dp[1]=1
for i in range(2,N+1):
  if i in A:
    dp[i]=0
  else:
    dp[i]=dp[i-1]+dp[i-2]
print(dp[N]%1000000007)

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

int main() {
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  double ans=0;
  const double pai=3.141592653589;
  if(h>=12){
    h=h-12;
  }
  const double A=100000000000000/72*0.00000000000001;
  const double B=100000000000000/60*0.00000000000001;
  ans=sqrt( a*a+b*b-2*a*b*cos(2*pai*abs((A*(60000000*h+1000000*m)-10000000*m*B))*0.0000001));
  printf("%.20lf\n",ans);
  return 0;
}

Measured memory_bytes: 4192
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[i];
  ll res=0;
  ll sum=0,Xor=0;
  int right = 0;     
  for(int left=0;left<n;left++){
    while(right<n && sum+a[right]==(Xor^a[right])){
      sum += a[right];
      Xor^=a[right];
        right++;
    }
    res+=right-left;
    if(right==left)right++;
    else{
      sum-=a[left];
      Xor^=a[left];
    }
  }
  cout << res << endl;
return 0;}

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


int main() {
  long H,W;
  cin >> H>>W;
  long sa=1001001001;
  rep(i,H){
    long a=i*W;
    long b;
    long c;
    if((H-i)%2==0){
      b=(H-i)/2*W;
      c=H*W-a-b;
    }
    else{
      if(W%2==0){
        b=W/2*(H-i);
        c=H*W-a-b;
      }
      else{
        b=max(W,H-i)/2*min(W,H-i);
        c=H*W-a-b;
      }
    }
    sa=min(sa,abs(max(a,c)-min(a,b)));
  }
  rep(i,W){
    long a=i*H;
    long b;
    long c;
    if((W-i)%2==0){
      b=(W-i)/2*H;
      c=H*W-a-b;
    }
    else{
      if(H%2==0){
        b=H/2*(W-i);
        c=H*W-a-b;
      }
      else{
        b=max(H,W-i)/2*min(H,W-i);
        c=H*W-a-b;
      }
    }
    sa=min(sa,abs(max(a,c)-min(a,b)));
  }
 
    cout<<sa<<endl;
  
}






Measured memory_bytes: 256
n=int(input())
s=input()
ans=0
for i in range(10):
    if str(i) in s[:-2]:
        s1=s.index(str(i))

        for j in range(10):
            if str(j) in s[s1+1:-1]:
                s2=s[s1+1:].index(str(j))+s1+1

                for k in range(10):
                    if str(k) in s[s2+1:]:
                        ans+=1

print(ans)


Measured memory_bytes: 9272
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

const ll MOD = 1e18;

ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;

    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}


int main(){

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

    ll n, p; cin >> n >> p;

    if(n == 1){
        cout << p << endl;
        return 0;
    }

    // map<ll, ll> mp;
    // ll div = 2;
    // while(p > 1){
    //     if(p % div == 0){
    //         p /= div;
    //         mp[div]++;
    //     }
    //     else{
    //         div++;
    //     }
    // }

    // for(auto e : mp){
    //     cout << e.first << " " << e.second << endl;
    // }


    int divmax = floor(powf(p, 1.0/n));

    // cout << divmax << endl;

    ll ans = 1;
    ll i = 2;
    while(i <= divmax){
        ll divpowp = mod_pow(i, n, MOD);
        if(p % divpowp == 0){
            ans *= i;
            p /= divpowp;
        }
        else{
            i++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {
  int n;
  vector<int> a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  long long ans = 0;
  int maxA = a[0];

  for (int i = 1; i < n; i++) {
    ans += (maxA - a[i] > 0) ? maxA - a[i] : 0;
    maxA = max(maxA, a[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3876
import Control.Applicative
import Control.Monad

data BTree = BEmpty | BNode BTree BTree
instance Show BTree where
  show BEmpty = ""
  show (BNode l r) = '(' : show l ++ ',' : show r ++ ")"

parse ss = let (t,_) = psub ss in t
  where
    psub ('(':s1) = let (left, (',':s2)) = psub s1 in let (right, (')':s3)) = psub s2 in (BNode left right, s3)
    psub s = (BEmpty, s)

btintersection BEmpty _ = BEmpty
btintersection _ BEmpty = BEmpty
btintersection (BNode l1 r1) (BNode l2 r2) = BNode (btintersection l1 l2) (btintersection r1 r2)

btunion BEmpty r = r
btunion l BEmpty = l
btunion (BNode l1 r1) (BNode l2 r2) = BNode (btunion l1 l2) (btunion r1 r2)

solve ["i", lt, rt] = btintersection (parse lt) (parse rt)
solve ["u", lt, rt] = btunion (parse lt) (parse rt)

main = map (solve . words) . lines <$> getContents >>= mapM_ print


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

using namespace std;

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

int main(){
    string s; int k;
    cin >> s >> k;
    set<string> sub;
    for(int i = 0; i < s.size(); i++){
        for(int j = 1; (j <= k) && (i+j <= s.size()); j++){
            sub.insert(s.substr(i, j));
        }
    }
    auto itr = sub.begin();
    for(int i = 0; i < k-1; i++)itr++;
    cout << *itr << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int sod(int c){
     int sum = 0;
     while(c!=0){
          sum+=(c%10);
          c=c/10;
          
     }
     return sum;
}
int main() {
     long long int N;
     cin >> N;
     int digits = 0;
     int c = N;
     int mina = 9999;
     for(int i=1;i<N;i+=1){
          int A = i;
          int B = N-A;
          int ans = sod(A)+sod(B);
          if((ans)<mina){
               mina = ans;
          }
     }
     cout << mina;
}

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

int main(){
	int m=0, f=0, r=0, sum=0;
	char grade;

	do{
		sum = 0;
		cin >> m >> f >> r; 
		sum = m + f;

		if(m==-1 | f==-1) grade = 'F';
		if(sum >= 80) grade = 'A';
		if(sum >= 65 & sum < 80) grade='B';
		if(sum >= 50 & sum < 65) grade='C';
		if(sum >= 30 & sum < 50 & r < 50) grade='D';
		if(sum >= 30 & sum < 50 & r >= 50) grade='C';
		if(sum < 30) grade='F';
		if(m == -1 | f == -1) grade='F';
		if(m == -1 & f==-1 & r==-1) break;
		cout << grade << endl;
	}while(m!=-1 | f!=-1 | r!=-1);
	return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, K, a;
    cin >> N >> K;
    int ans = 0;
    rep(0, i, N)
    {
        cin >> a;
        ans += min(a, K - a);
    }
    cout << ans * 2 << endl;
}

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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MAX = 1e5 + 5;

int main()
{
	IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		int l, r, d;
		cin >> l >> r >> d;
		int ct = 0;
		for(int i = l; i <= r; i++)
		{
			if(i % d == 0)ct += 1;
		}
		cout << ct;
	}
	return 0;
}


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

using namespace std;
using LL = long long;

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

    int n;
    cin >> n;
    vector< int> A(n), B(n - 1);
    
	for (int i = 0; i < n - 1; i ++) {
		cin >> B[i];
	}

	A[0] = A[1] = B[0];
	for (int i = 1; i < n - 1; i ++) {
		if (A[i] > B[i]) A[i] = B[i];
		A[i + 1] = B[i];
	}

	int s = accumulate(begin(A), end(A), 0);
	cout << s << endl;
}

Measured memory_bytes: 256