akhauriyash/Code-Regression huggingface dataset:
import itertools

n = int(input())
L = list(map(int, input().split()))

comb = itertools.combinations(L, 3)

ans = 0

for i in comb:
    i = list(i)
    i.sort()
    
    if i[0] + i[1] > i[2] and (i[0] != i[1] and i[1] != i[2] and i[2] != i[0]):
        ans += 1
    
print(ans)

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

int main(void){
    int i = 0,total = 0;
    char number[1000] = {0};
    
    while(1){
        scanf("%s",number);
        
        if(number[0] == '0') break;
        
        for(i = 0;number[i] != '\0'; i++){
            total += (number[i]-'0');
        }
        printf("%d\n",total);
        total = 0;
    }
}

Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    lint H[N];
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }
    H[0]--;
    for(int i = 1; i < N; i++){
        if(H[i - 1] < H[i]){
            H[i]--;
        }else if(H[i - 1] > H[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    if(N == M) {
        cout << "Yes" << endl;

    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000001
void Heep(int);
int n,A[MAX];

void Heep(int i) {
  int l,r,large,ala;

  l = 2 * i;
  r = 2 * i + 1;

  if(l <= n && A[l] > A[i])
    large = l;
  else large = i;
  if(r <= n && A[r] > A[large])
    large = r;
  if (large != i) {
    ala = A[i];
    A[i] = A[large];
    A[large] = ala;
    Heep(large);
  }
}
int main() {
  int i;

  scanf("%d",&n);
  for(i = 1 ; i <= n ; i++) {
    scanf("%d",&A[i]);
  }
  
  for(i = n / 2 ; i >= 1 ; i--) {
    Heep(i);
  }
  
  for(i = 1 ; i <= n ; i++) {
    printf(" %d", A[i]);
  }
  
  printf("\n");
  
  return 0;
}




Measured memory_bytes: 3652
import bisect

n = int(input())
l = sorted(list(map(int, input().split())))
count = 0
for b in range(n-2):
  for c in range(b+1, n-1):
    count += max(0, bisect.bisect_left(l, l[b]+l[c])-c-1)

print(count)

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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    int x,y;
    vector<int> count(N+1,1);
    vector<int> possible(N+1,0);
    possible[1] = 1;
    for(int i = 0; i < M; ++i) {
        cin >> x >> y;
        count[x] -= 1;
        count[y] += 1;
        if(possible[x] == 1) {
            possible[y] = 1;
            if(count[x] == 0)
                possible[x] = 0;
        }
    }
    int ans = 0;
    for(int i = 1; i <= N; ++i)
        if(possible[i] == 1)
            ans += 1;
    cout << ans << endl;
    return 0;
}


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

int main(){
 	int n;
  	cin>>n;
  	if(n%10==2 || n%10==4 ||n%10==5 ||n%10==7 ||n%10==9 )
		cout<<"hon"<<endl;
  	else if(n%10==3)
      	cout<<"bon"<<endl;
  	else
      	cout<<"pon"<<endl;

}

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

adj_list = [[] for _ in range(n + 1)]

for i in range(n):
    tmp = list(map(int, input().split()))
    u = tmp[0]
    k = tmp[1]
    for v in range(2, 2 + k):
        adj_list[u].append(tmp[v])

d = [-1] * (n + 1)
q = []
q.append(1)
d[1] = 0

while len(q) > 0:
    u = q.pop(0)
    for v in adj_list[u]:
        if d[v] == -1:
            d[v] = d[u] + 1
            q.append(v)

for idx, d in enumerate(d):
    if idx != 0:
        print("%d %d" % (idx, d))




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

int main(){
	int a, b, c,max=0;
	cin >> a >> b >> c;
	if (max < a){
		max = a;
	}
	if (max < b){
		max = b;
	}
	if (max < c){
		max = c;
	}
	cout << a + b + c - max << endl;
	return 0;
	
}

Measured memory_bytes: 256
import itertools

n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]

li = [0,1,2,3]

ans = 10**9
for elm in  itertools.product(li,repeat=n):
    #1か2か3がなければ次へ
    if not(1 in elm) or not(2 in elm) or not(3 in elm):
        continue

    whch = [[],[],[]]
    ans_mm = 0
    for j in range(len(elm)):
        if elm[j] == 1:
            whch[0].append(l[j])
        elif elm[j] == 2:
            whch[1].append(l[j])
        elif elm[j] == 3:
            whch[2].append(l[j])

    ans_mm += ((len(whch[0])-1) + (len(whch[1])-1) + (len(whch[2])-1)) * 10
    ans_mm += abs(sum(whch[0])-a)
    ans_mm += abs(sum(whch[1])-b)
    ans_mm += abs(sum(whch[2])-c)

    ans = min(ans,ans_mm)

print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-100
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
//	file();
	fast();
	string str; cin >> str;
	if (str == "ABC")
		RT("ARC");
	else RT("ABC");
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000

/*
bool resuelveCaso() {
	int n = 0;

	set<int> res;
	for (int i = 2; i < 200; ++i) {
		int contDiv = 0;
		for (int j = 1; j <= i; ++j) {
			if (i % j == 0) ++contDiv;
		}
		if (contDiv == 8 && i % 2 == 1) res.insert(i);
	}

	cout << "HELO\n";

	return true;
}
*/

bool resuelveCaso() {
	int n;

	cin >> n;
	if (!cin) return false;

	if (n < 105) cout << "0\n";
	else if (n < 135) cout << "1\n";
	else if (n < 165) cout << "2\n";
	else if (n < 189) cout << "3\n";
	else if (n < 195) cout << "4\n";
	else cout << "5\n";

	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define ll long long

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<ll unsigned int> a(n);
    bool zeroflag = false;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(a[i] == 0){
            zeroflag = true;
        }
    }

    if(zeroflag){
        cout << 0 << endl;
        return 0;
    }
    ll unsigned int mul = 1;
    for(int i = 0;i < n;i++){
        ll unsigned int tmul = mul * a[i];
        if(tmul < mul || tmul < a[i]){
            cout << -1 << endl;
            return 0;
        } else if(tmul > (ll unsigned int)1000000000000000000) {
            cout << -1 << endl;
            return 0;
        }

        mul = tmul;
    }

    cout << mul;
    return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<set>
#define inf 0x3f3f3f3f
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define mst(x) memset(x,0,sizeof(x))
#define mstinf(x) memset(x,0x3f,sizeof(x))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
char ao[100];
int main(){
    for(int i = 0 ; i < 26; ++i){
        ao[i] = 'A' + i;
    }
    int n;
    cin>>n;
    string a;
    cin>>a;
    int len = a.length();
    for(int i = 0 ; i < len ;++i){
        cout<<ao[(a[i]-'A'+n)%26];
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <map>

using namespace std;

typedef long long LL;
map<LL, LL> tab;
int N;


int main()
{

	cin >> N;
	LL su = 0, t= 0;
	for (int i = 0; i < N; i++) {
		cin >> t;
		su += t;
		tab[su]++;
	}

	LL ans = 0;
	for (map<LL, LL>::iterator it = tab.begin(); it != tab.end(); it++) {
		if (it->first == 0) {
			ans += it->second;
		}
		if (it->second >= 2) {
			t = it->second;
			ans += t * (t - 1) / 2;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 12800
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    n,a,b = map(int,input().split())
    print(min(n*a,b))
    return

if __name__=='__main__':
    main()


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

using namespace std;

int main(){
    int d,n;

    cin >> d >> n;

    if(d == 0){
        if(n == 100) n++;
        cout << n << endl;
    }else if(d == 1){
        if(n == 100) n++;
        cout <<  n * (100) << endl;
    }else if(d == 2){
        if(n == 100) n++;
        cout << n * (10000) << endl;
    }

    return 0;
}

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

using namespace std;

int main(int argc, const char * argv[]) {
    int K;
    cin >> K;

    string input;
    cin >> input;
    cout << input.substr(0, K);
    if(input.length() <= K) {
        cout << endl;
    } else {
        cout << "..." << endl;
    }
    return 0;
}

/**
cheat sheet

vector<int> v{ 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
sort(v.begin(), v.end());
=> 0 1 2 3 4 5 6 7 8 9

vector<int> v{ 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
sort(v.begin(), v.end(), greater<int>());
=> 9 8 7 6 5 4 3 2 1 0

struct A { int x, y; };
bool comp(A i1, A i2) { return (i1.y < i2.y); }
vector<A> v { { 6, 8 }, { 1, 9 }, { 2, 4 }, { 4, 7 } };
sort(v.begin(), v.end(), comp);
=> [1, 9] [2, 4] [4, 7] [6, 8]

*/


Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define FOR(i,a,b) for (ll i = (a) ; i <= (b); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい


void Main(){
	ll a, b, c, ans;
	cin >> a >> b >> c;

	ans = c-(a-b);
	if(ans < 0) cout << 0 << endl;
	else cout << ans << endl;






}

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

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
ll mx(ll a,ll b){if(a>=b) return a;return b;}
ll mn(ll a,ll b){if(a<b) return a;return b;}
#define pb push_back
#define mp make_pair
//#define M (ll) (1e9+7)
#define INF (3e18)

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
//    freopen("xorr.gir","r",stdin);
//    freopen("xorr.cik","w",stdout);
    ll n;cin>>n;
    ll arr[n];double carp=1;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
        carp*=arr[i];
    }
    double sum=0;
    for(ll i=0;i<n;i++)
        sum+=carp/(arr[i]);
    double x=carp/sum;
    cout<<x;
    cout<<endl;
    return 0;
}













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

int main(){
    // We are Looking for a Contiguos String ( or SubString) where more than Half the Characters are Same
	// If no such thing exists print -1 -1 
	// If such Sub String do exists then print its starting and end positions {If more than one Solution exists then print any one of them}
    string s;
	ll b=-1,e=-1;
	cin>>s;
	for(size_t i=0;i<s.size()-1;i++){
          if(s[i]==s[i+1]){
              b=i+1;       // I is Index, I+1 is Pos
			  e=i+1+1;
			  break;
		  }else if(i <s.size()-2 && s[i]==s[i+2]){
              b=i+1;
			  e=i+2+1;
			  break;
		  }
	}
	cout<<b<<" "<<e;
    return 0;
}

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

int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i]; 
  }
  int max = 0;
  int max2 = 0;
  for(int i = 0; i < N; i++) {
    if(max < A[i]) max = A[i];
    else if(max2 < A[i]) max2 = A[i];
   // cout << max << " " << max2 << endl;
  }
  
  for(int i = 0; i < N; i++) {
    if(max == A[i]) {
      cout << max2 << endl; 
    }
    else {
      cout << max << endl; 
    }
  }
  
  return 0; 
}

Measured memory_bytes: 2432
unittest
{
	assert( [ "3 8 7 1" ].parse.expand.solve == "Left" );
	assert( [ "3 4 5 2" ].parse.expand.solve == "Balanced" );
	assert( [ "1 7 6 4" ].parse.expand.solve == "Right" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abcd = input.front.split.to!( long[] );
	return tuple( abcd[ 0 ], abcd[ 1 ], abcd[ 2 ], abcd[ 3 ] );
}

auto solve( long a, long b, long c, long d )
{
	auto l = a + b;
	auto r = c + d;
	
	if( r < l ) return "Left";
	if( l < r ) return "Right";
	return "Balanced";
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] ABK = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            List<long> check = new List<long>();
            //AからB
            for(long j = ABK[0]; j <= ABK[1]; j++)
            {
                if(j < ABK[0] + ABK[2] || ABK[1] - ABK[2] < j)
                {
                    Console.WriteLine(j);
                }

                //check.Add(j);
            }
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


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


#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[220000],b[220000];
map<ll,ll> c;
main(){
    ll n,ans=0;
    cin>>n;
    rep(i,0,n)cin>>a[i];
    b[0]=0;
    rep(i,0,n)b[i+1]=b[i]+a[i];
    rep(i,0,n+1)c[b[i]]++;
    for(auto i:c){
    ll ff=i.second;
    ans+=ff*(ff-1)/2;
    }
    cout<<ans;
}

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

using namespace std;

#define ll long long
int main(){
       int n;
       cin>>n;
       ll arr[n];
       ll sum=0;
       ll max1=INT_MIN;
       ll min1=INT_MAX;
       for(int i=0;i<n;i++){
           cin>>arr[i];
           max1=max(max1,arr[i]);
           min1=min(min1,arr[i]);
           sum=sum+arr[i];
       }
       sum=round((double)sum/(double)n);
       ll sum2=(max1+min1)/2;
       
       ll ans=0;
       ll ans2=0;
       for(int i=0;i<n;i++){
           ll a2=abs(sum2-arr[i]);
           a2=a2*a2;
           ans2=ans2+a2;
           ll a1=abs(sum-arr[i]);
           a1=a1*a1;
           ans=ans+a1;
       }
       
       cout<<ans;
       
}
    


Measured memory_bytes: 256
from fractions import gcd
T = int(input())
for i in range(T):
    A, B, C, D = map(int, input().split())

    # 初日でケーキが買えない
    if B > A:
        print("No")
        continue

    # 毎日補充できても足りなくなる
    if B > D:
        print("No")
        continue

    # 買切る前に必ず入荷が発生する
    if C >= B:
        print("Yes")
        continue
        
    if B - gcd(B, D) + (A % gcd(B, D)) <= C:
        print("Yes")
    else:
        print("No")


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

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

	if (a == b && b == c) cout << 1 << endl;
	else if (a == b || b == c || c == a) cout << 2 << endl;
	else cout << 3 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	
	int x, y;

	while (1) {
		scanf("%d %d", &x, &y);

		if (x == 0 && y == 0) {
			break;
		}

		if (x > y) {
			printf("%d %d\n", y, x);
		}
		else {
			printf("%d %d\n", x, y);
		}
	}

	return 0;
}



Measured memory_bytes: 2040
import java.util.Scanner;


public class Main {
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		int input= scanner.nextInt();
		int hour=input/(60*60);
		int minute= (input%(60*60))/60;
		int second= (input%(60*60))%60;
		System.out.println(Integer.toString(hour)+":"+Integer.toString(minute)+":"+Integer.toString(second));
		scanner.close();
	}
}

Measured memory_bytes: 17164
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) #x << "=" << x << "  " <<
#define prev oiertjaosrei
using namespace std;
using ll = long long;

const int MXN = 2e5 + 5;
const int MOD = 1e9 + 7;
int add(int x, int y) { return (x += y) < MOD ? x : x - MOD; }
int sub(int x, int y) { return (x -= y) >= 00 ? x : x + MOD; }
int mul(int x, int y) { return (ll) x * y % MOD; }

int dp[MXN];
int prev[MXN];
int last[MXN];

int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  dp[0] = 1;
  for (int i = 1; i <= n; ++i) {
    int num;
    cin >> num;
    prev[i] = last[num];
    last[num] = i;
    dp[i] = dp[i - 1];
    if (prev[i] && i - prev[i] > 1) {
      dp[i] = add(dp[i], dp[prev[i]]);
    }
  }
  cout << dp[n] << '\n';
}


Measured memory_bytes: 2560
n,m = gets.split.map &:to_i

root = Array.new(n + 1).map{ Array.new }

m.times{
	a, b = gets.split.map &:to_i
	root[a] << b
	root[b] << a
}

mark = Array.new(n + 1, 0)

mark[1] = 1
current = [1]

while current.size > 0
	nexts = []
	current.each{ |c|
		root[c].each { |r|
			if mark[r] == 0 then
				mark[r] = c
				nexts << r
			end
		}
	}
	
	current = nexts
end

puts 'Yes'

mark[2..-1].each{ |m|
	puts m
}


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

#define ll long long
#define pii pair<int, int>
using namespace std;
const ll mod = 1e9 + 9;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] != s[s.size() - i - 1])ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;


int main(void){
  ll n;
  cin >> n;
  
  ll ans = 100000000000000;
  for(ll i=1; i<=sqrt(n); i++){
	if(n%i == 0 && i-1+n/i-1 < ans){
	  ans = i-1+n/i-1;
	}
  }

  cout << ans << endl;
}


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

int n;
int a[MAX];

int main()
{
    cin >> n;
    int flag = 1;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(!(a[i]&1) && (a[i]%3 && a[i]%5)) flag = 0;
    }
    if(flag) puts("APPROVED");
    else puts("DENIED");

    return 0;
}

Measured memory_bytes: 256
# your code goes herefro
from collections import Counter
n=int(input())
s=input()
res=Counter(s)
ans=[]
if(n==1):
	print("No")
else:
	m=n//2
	s1=""
	s2=""
	for i in range(0,m):
		s1+=s[i]
	for j in range(m,n):
		s2+=s[j]
	if(s1==s2):
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  set<int> s;
  int q;
  cin >> q;
  int tmp, tmp2, tmp3;
  rep_i(i, q){
    cin >> tmp >> tmp2;
    if(tmp == 0){
      s.insert(tmp2);
      say(s.size());
    }else if(tmp == 1){
      set<int>::iterator itr = s.find(tmp2);
      if(itr == s.end()){
        say(0);
      }else{
        say(1);
      }
    }else if(tmp == 2){
      s.erase(tmp2);
    }else{
      cin >> tmp3;
      // set<int>::iterator lit = s.lower_bound(tmp2);
      // set<int>::iterator rit = s.lower_bound(tmp3);
      // size_t start = distance(s.begin(), lit);
      // size_t end = distance(s.begin(), rit);
      set<int>::iterator itr = s.lower_bound(tmp2);
      set<int>::iterator itr2 = s.find(tmp3);
      for (auto i = itr; i != s.end() && *i <= tmp3; i++){
        say(*i);
      }
      
      // r_rep_i(i, tmp2, tmp3 + 1){
      //   if(itr == s.end()){
      //     continue;
      //   }else{
      //     say(*itr);
      //   }
      // }
    }
  }
}


Measured memory_bytes: 12372
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()
graph = defaultdict(list)

for _ in range(M):
	a, b = MAP()
	graph[a-1].append(b-1)
	graph[b-1].append(a-1)


for i in graph[0]:
	if N-1 in graph[i]:
		print("POSSIBLE")
		break
else:
	print("IMPOSSIBLE")


Measured memory_bytes: 58448
#include <stdio.h>

int main (){
    int n,i,A[100000],x,p,r,j,tmp;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    r=n-1;
    p=0;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(A[j]<=x){
            i++;
            tmp=A[i];
            A[i]=A[j];
            A[j]=tmp;
        }
    }
    tmp=A[i+1];
    A[i+1]=A[r];
    A[r]=tmp;
    for(j=0;j<n;j++){
        if(j)printf(" ");
        if(j==i+1){
            printf("[%d]",A[j]);
        }
        else printf("%d",A[j]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2192
#include<stdio.h>
int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  int a[m];
  int i;
  for(i=0;i<m;i++){
    scanf("%d",&a[i]);
  }
  int sum=0;
  for(i=0;i<m;i++){
    sum+=a[i];
  }
  if(n-sum>=0){
    printf("%d\n",n-sum);
  }else{
    printf("-1\n");
  }
  return 0;
}


Measured memory_bytes: 1756
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,m;cin>>n>>m;
	vector<int> c(500001,0);
	vector<int> dp(n + 1,INF);
	dp[0] = 0;
	for(int i = 0; i < m; i++) {
		cin>>c[i];
	}
	for(int i = 0; i < m; i++) {
		for(int j = c[i]; j <= n; j++) {
			dp[j] = min(dp[j],dp[j - c[i]] + 1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 4952
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int w,a,b;cin >> w >> a >> b;
    int ans=0;
    if(a<=b)ans=max(b-(a+w),0);
    else ans=max(a-(b+w),0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
using namespace std;

// Q1
int main()
{
	int nA,nB;
	cin >> nA;
	cin >> nB;

	if (1 > nA || nA > 9)
	{
		cout << -1;
		return 0;
	}
	if (1 > nB || nB > 9)
	{
		cout << -1;
		return 0;
	}

	cout << nA*nB;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;
using VEC = vector<vector<int>>;

void chmax(int& a, int b) { if (a < b) a = b; }

int N;
vector<int> memo;

void update(int id, VEC& a, VEC& d) {
	int next = memo[id] + 1;
	if (next >= N) { return; }
	int v = a[id][next];
	d[id][v] = d[id][a[id][memo[id]]] + 1;
	if (d[v][id] >= 0) {
		++memo[id];
		++memo[v];
		chmax(d[id][v], d[v][id]);
		chmax(d[v][id], d[id][v]);
		update(id, a, d);
		update(v, a, d);
	}
}

int main() {
	cin >> N;
	vector<vector<int>> a(N, vector<int>(N, 0));
	for (int i = 0; i < N; ++i) {
		for (int j = 1; j <= N - 1; ++j) {
			cin >> a[i][j];
			--a[i][j];
		}
	}

	// memo[i] := 選手i が何番目まで試合したか
	memo.assign(N, 0);
	// d[i][j] := 選手i と選手j の試合がいつ行われたか
	vector<vector<int>> d(N, vector<int>(N, -1));
	// for (int i = 0; i < N; ++i) { d[i][0] = 0; }
	int curr = 0;
	int cnt = 0;
	// 順番に選手curr について更新していく
	while (cnt < N) {
		++cnt;
		// next := 選手curr の次の試合のid
		int next = memo[curr] + 1;
		if (next >= N) {
			curr = (curr + 1) % N;
			continue;
		}
		// v := 選手curr の次の試合相手
		int v = a[curr][next];
		// 前の試合が行われた日 + 1 に更新
		d[curr][v] = d[curr][a[curr][memo[curr]]] + 1;
		if (d[v][curr] >= 0) {
			++memo[curr];
			++memo[v];
			chmax(d[curr][v], d[v][curr]);
			chmax(d[v][curr], d[curr][v]);
			update(curr, a, d);
			update(v, a, d);
			cnt = 0;
		}
		curr = (curr + 1) % N;
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (i == j) { continue; }
			if (d[i][j] < 0) {
				ans = -1;
			}
			if (ans >= 0) { chmax(ans, d[i][j]); }
		}
	}
	if (ans >= 0) { ++ans; }
	cout << ans << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;


int main()
{
    ll  n,m,k; std::cin >> n >> m >> k;
    ll  a[200001], b[200001];
    // std::vector<long long>  a(n+1), b(m+1);
    a[0]=0; b[0]=0;
    for (int i=1;i<n+1;i++)
        cin >> a[i];
    for (int i=1; i<m+1; i++)
        cin >> b[i];
    
    for (int i=1; i<n+1; i++)
        a[i]+=a[i-1];
    for (int i=1; i<m+1; i++)
        b[i]+=b[i-1];

    ll ans=0, r=m;
    for (int i=0; i<n+1; i++)
    {
        if(a[i]>k) break;
        while (a[i]+b[r]>k)
            r--;
        ans = std::max({ans, i+r});
    }
    
    std::cout << ans;

    return 0;
}

Measured memory_bytes: 6764
s = input()
k = int(input())
n = len(s)

substring = []

for i in range(min(n, k)):
    for j in range(n-i):
        substring.append(s[j:j+i+1])
        #print(s[j:j+i+1], j, j+i+1)

substring = list(set(substring))
substring.sort()
#print(substring)
#substring.pop(0)

print(substring[k-1])



Measured memory_bytes: 5068
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

ll comb(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mod, factr[i]=factr[i-1]*inv[i]%mod;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mod*factr[N_-C_]%mod;
}

int main(){
	ll n,m,k;cin>>n>>m>>k;
    ll ans = 1;
    ans = comb(m*n-2,k-2);
    ll num = 0;
    rep(i,1,n){
        num = (num+i*(n-i)%mod*m%mod*m%mod)%mod;
    }
    rep(i,1,m){
        num = (num+i*(m-i)%mod*n%mod*n%mod)%mod;
    }
    cout<<(ans*num%mod)%mod<<endl;
}

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

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

    vector<int> d(K);
    vector<vector<int>> A(K, vector<int> (N));
    for (int i = 0; i < K; i++) {
        cin >> d.at(i);
        for (int j = 0; j < d.at(i); j++) {
            cin >> A.at(i).at(j);
        }
    }

    vector<int> sunuke(N);
    int ans = N;

    for (int i = 0; i < N; i++) {
        sunuke.at(i) = 0;
    }

    for (int i = 0; i < K; i++) {
        for (int j = 0; j < d.at(i); j++) {
            for (int l = 0; l < N; l++) {
                if (l + 1 == A.at(i).at(j)) {
                    sunuke.at(l) = 1;
                }
            }
        }
    }

    for (int i = 0; i < N; i++) {
        ans -= sunuke.at(i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR (i,n) for(int i=n;i>0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1e9+7			// int 1000000007
const int inf{int(1e9)};	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;


int main(void) {
	
	string S, T;
	cin >> S >> T;
	
	// string -> vecotr<char>
	vector<char> s(begin(S),end(S)), t(begin(T), end(T));
	sort(s.begin(), s.end());	// 昇順
	sort(t.begin(), t.end(),greater<char>());	// 降順

	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

using namespace std;

int main() {
    int n, i, j;
    long c;
    cin >> n >> c;

    vector<array<long, 2>> xv;
    array<long, 2> buf;
    for(i = 0; i < n; i++) {
        cin >> buf[0] >> buf[1];
        xv.push_back(buf);
    }

    long ans = 0, sum;

    for(i = 0; i < 2; i++) {
        vector<long> v_sum = {xv[0][1]};
        for(j = 1; j < n; j++) v_sum.push_back(v_sum[j-1] + xv[j][1]);

        vector<long> f;
        for(j = 0; j < n; j++) f.push_back(v_sum[j] - xv[j][0]);

        vector<long> g = {f[0]};
        for(j = 1; j < n; j++) g.push_back(g[j-1] > f[j] ? g[j-1] : f[j]);

        if(ans < g[n-1]) ans = g[n-1];
        for(j = n-1; j > 0; j--) {
            sum = v_sum[n-1] - v_sum[j-1] - 2 * (c - xv[j][0]) + g[j-1];
            if(ans < sum) ans = sum; 
        }

        for(j = 0; j < n; j++) xv[j][0] = c - xv[j][0];
        reverse(xv.begin(), xv.end());
    }

    cout << ans << endl;
}

Measured memory_bytes: 7760
#include <bits/stdc++.h>  // ver2.2.2
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ

int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  vector<VPii> a(n,VPii(0));
  int qw,er,ty;
  
  rep(i,0,n-1){
    cin >> qw >> er >> ty;
    qw--,er--;
    a[qw].pb(mp(er,ty));
    a[er].pb(mp(qw,ty));
  }
  
  Vi dis(n,-1);
  dis[0]=0;
  queue<int> next;
  next.push(0);
  
  while(!next.empty()){
    qw = next.front();
    next.pop();
    rep(i,0,a[qw].size()){
      if(dis[a[qw][i].FI]==-1){
        next.push(a[qw][i].FI);
        dis[a[qw][i].FI] = dis[qw]+a[qw][i].SE;
      }
    }
  }
  //Vout(dis);
  rep(i,0,n){
    if(dis[i]%2==0) cout<<0<<endl;
    else cout<<1<<endl;
  }
  return 0;
}

Measured memory_bytes: 8704
#include <stdio.h>
#include <string.h>
#include <math.h>
#define rep(i,l,n) for(i=l;i<n;i++)

void print(char str[],int a,int b){
	int i;
	rep(i,a,b+1) printf("%c",str[i]);
	printf("\n");
}

void reverse(char str[],int a,int b){
	int i;
	char str2[1010];
	rep(i,0,b-a+1) str2[a+i]=str[b-i];
	rep(i,a,b+1) str[i]=str2[i];
}

void replace(char str[],int a,int b,char p[]){
	int i;
	rep(i,0,b-a+1) str[a+i]=p[i];
}

int main(void){
	char str[1010],od[10],p[1010];
	int q,i,a,b;
	
	scanf("%s",str);
	scanf("%d",&q);
	
	rep(i,0,q){
		scanf("%s",od);
		if(strcmp(od,"print")==0){
			scanf("%d %d",&a,&b);
			print(str,a,b);
		}else if(strcmp(od,"reverse")==0){
			scanf("%d %d",&a,&b);
			reverse(str,a,b);
		}else if(strcmp(od,"replace")==0){
			scanf("%d %d %s",&a,&b,p);
			replace(str,a,b,p);
		}
	}
	
	return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll n;
    cin>>n;
    mll m;
    ll i,j;
    ll nn=n;
    for(i=2;i*i<=nn;i++)
    {
        if(nn%i==0)
        {
            ll no=0;
            
            while(nn%i==0)
            {
                no++;
                nn/=i;
            }
            m[i]=no;
        }
    }
    if(nn>1)
    {
        m[nn]=1;
    }
    ll res=0;

    for(auto it:m)
    {
        ll xx=it.second;
        for(i=1;i<50;i++)
        {
           ll no =(i*(i+1))/2;
           if(xx<no)
           {
               break;
           }
        }
        i--;
        res+=i;
    }
    cout<<res<<"\n";


}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3636
n,m = map(int, input().split())
good=n-m
ok = 1/(2**m)
now_ok=ok
ans=0
x=1
nokori=1
while x<1000:
    tmp=(good*100+m*1900)*x
    now_ok = nokori * ok
    nokori -= now_ok
    tmp *= now_ok
    ans+=tmp
    x+=1

print(round(ans))

Measured memory_bytes: 38384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
    char a[10], mozi[100];
    int n, x, y;
    scanf("%s %d", &a, &n);
    y=0;
    for(x=0; x<n; x++)
    {
        scanf("%s", mozi);
        strncat(mozi,mozi,10);
        if((strstr(mozi,a))!=NULL)
        {
            y++;
        }
    }
    printf("%d\n", y);
     
    return 0;
}


Measured memory_bytes: 2104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		DFS("", 'a', n);
	}
	
	static void DFS(string str, char mx, int max)
	{
		if(str.Length == max)
		{
			Console.WriteLine(str);
			return;
		}
		
		for(char c ='a'; c <= mx; c++)
		{
			DFS(str+c.ToString(), c==mx?(char)(mx+1):mx,max);
		}
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 16456
#include<bits/stdc++.h>
using namespace std;
const int N = (int)1e5+5;

long long int arr[N];
int main()
{
    int t,a,b,n,i,j=0,m1,m2,d1,d2;
  cin>>m1>>d1;
   cin>>m2>>d2;
if(m1==1||m1==3||m1==5||m1==7||m1==8||m1==10||m1==12)
{
    if(d1==31)
    {
        cout<<"1"<<endl;
    }

    else
        cout<<"0"<<endl;

}
else
{
    if(m1==2&&(d1==28||d1==29)&&d2!=29)
    {
        cout<<"1"<<endl;

    }
    else if(d1==30)
    {
        cout<<"1"<<endl;
    }

    else
        cout<<"0"<<endl;

}





    return 0;
}



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

int main(){
    int m, f, r;
    while(1){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        int s = m + f;
        if(m == -1 || f == -1) cout << "F" << endl;
        else if(s >= 80) cout << "A" << endl;
        else if(s >= 65 && s < 80) cout << "B" << endl;
        else if((s >= 50 && s < 65) || r >= 50) cout << "C" << endl;
        else if(s >= 30 && s < 50) cout << "D" << endl;
        else if(s < 30) cout << "F" << endl;
    }
    return 0;
}



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

using namespace std;

typedef unsigned long long ull;

int main(){
	ull a, b, n;
	cin>>a>>b>>n;
	if(n>=b-1){
		cout<<(a*(b-1))/b;
	}
	else{
		cout<<(a*(n))/b;
	}
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
using namespace std;
int n;
int a,b;

int main() {
    cin>>n>>a>>b;
    int answer=0;
    for(int i=0;i<=n;i++)
    {
        string temp= to_string(i);
        int count=0;
        for(int t=0;t<temp.length();t++)
        {
            count+=temp[t]-'0';
        }
        if(count>=a&&count<=b)
        answer+=i;
    }
    cout<<answer;
}


Measured memory_bytes: 3148
//Alhamdulillah for everything you gave

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#include <cmath>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

namespace _template
{
using namespace std;
using namespace __gnu_pbds;
template <typename T>  using ordered_set =
   tree<T, null_type, less<T>,
   rb_tree_tag, tree_order_statistics_node_update>;
typedef long long Long;

#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define bal pair<int, int>

#define FOR(a, n) for(int i=a;i<n;i++)
#define mm(a, n) memset(a, n, sizeof(a))
#define printCase cout<<"Case "<<i<<": "
#define DIC() ({int a; cin>>a; a;})

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {return out<<"("<<a.FF<<", "<<a.SS<<")"; }
template <class A> ostream& operator << (ostream& out, const vector<A> &v) { out<<"["; for(int i=0; i<(int)v.size(); i++) { if(i) out<<", "; out<<v[i]; } return out << "]"; }
#define chka(a) cout<<endl<<"values of:  "<<(#a)<<endl;for(int i=0, n=sizeof(a)/sizeof(a[0]); i<n; i++) cout<<a[i]<<" "; cout<<endl;
#define chk(a) cout<<(#a)<<" = "<<a<<endl;
#define mara cout<<"mara"<<endl;

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define MOD 729644203597
#define pi 3.141592653589793
} using namespace _template;
//unordered_map<int, int> dp, _next;
void solve()
{

    int n=4;
    Long a[4]; FOR(0, n) cin>>a[i];
    Long ans=-LLONG_MAX;
    for(int i=0; i<2; i++)
    {
        for(int j=2; j<4; j++)
        {
            ans=max(a[i]*a[j], ans);
        }
    }
    cout<<ans<<endl;
}
int ETC=0;  //check here if test case is enabled
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else
    #endif
/* *******Bismillahir Rahmanir Rahim **** */
    FastIO;
    for(int i=1, t=(ETC?DIC():1); i<=t; i++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;
 
public class Main {

  public static class edge {
    int from;
    int to;
    edge (int _from, int _to) {
      from = _from;
      to   = _to;
    }
  }

  static final int V = 100;
  static int n, t;
  static int d[], f[];
  static edge es[][];

  public static void dfs(int v) {  
    int i;
    d[v] = ++t;
    for (i=0; i<es[v].length; i++) {
      int to = es[v][i].to;
      if (d[to] == -1) dfs(to);
    }
    f[v] = ++t;
  }

  public static void main(String[] args) {
    int i, j;

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    es = new edge[n][];
    d = new int[n];
    f = new int[n];
    Arrays.fill(d, -1);
    Arrays.fill(f,  0);

    for (i=0; i<n; i++) {
      int u = Integer.parseInt(sc.next());
      int k = Integer.parseInt(sc.next());
      es[i] = new edge[k];
      for (j=0; j<k; j++) {
        int v = Integer.parseInt(sc.next());
        es[i][j] = new edge(u-1, v-1);
      }
    }

    t = 0;
    for (i=0; i<n; i++)
      if (d[i] == -1) dfs(i);

    for (i=0; i<n; i++) {
      System.out.print(String.valueOf(i+1) + ' ');
      System.out.print(String.valueOf(d[i]) + ' ');
      System.out.println(f[i]);
    }
  }
}

Measured memory_bytes: 20316