akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var ans = new int[n];
        ans[0] = -1;
        var list = new List<Tuple<int, int, int>>();
        for (int i = 0; i < n - 1; i++)
        {
            var line = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            list.Add(new Tuple<int, int, int>(line[0], line[1], line[2]));
        }
        var tree = new List<Tuple<int, bool>>[n];
        for (int i = 0; i < n; i++)
        {
            tree[i] = new List<Tuple<int, bool>>();
        }
        for (int i = 0; i < n - 1; i++)
        {
            int u = list[i].Item1 - 1;
            int v = list[i].Item2 - 1;
            int w = list[i].Item3;
            bool b = (w % 2 == 0) ? true : false;
            tree[u].Add(new Tuple<int, bool>(v, b));
            tree[v].Add(new Tuple<int, bool>(u, b));
        }
        var next = new List<int>();
        next.Add(0);
        var searched = new bool[n];
        while (next.Count() != 0)
        {
            if (!searched[next[0]])
            {
                searched[next[0]] = true;
                for (int i = 0; i < tree[next[0]].Count(); i++)
                {
                    if (!searched[tree[next[0]][i].Item1]) next.Add(tree[next[0]][i].Item1);
                }
            }
            for (int j = 0; j < tree[next[0]].Count(); j++)
            {
                if (ans[tree[next[0]][j].Item1] != 0) continue;
                else
                {
                    if (tree[next[0]][j].Item2) ans[tree[next[0]][j].Item1] = ans[next[0]];
                    else if (ans[next[0]] == -1) ans[tree[next[0]][j].Item1] = -2;
                    else ans[tree[next[0]][j].Item1] = -1;
                }
            }
            next.RemoveAt(0);
        }
        foreach (var x in ans)
        {
            if (x == -1) Console.WriteLine(0);
            else Console.WriteLine(1);
        }
    }
}

Measured memory_bytes: 38516
#include <stdio.h> 
  #include <ctype.h> 
  
 
  int main(){ 
      char ch; 
      while(1){ 
          scanf("%c", &ch); 
          if(ch=='\n'){ 
              printf("\n"); 
              break; 
          }else if(islower(ch)){ 
              printf("%c", toupper(ch)); 
          }else if(isupper(ch)){ 
              printf("%c", tolower(ch)); 
          }else{ 
              printf("%c", ch); 
          } 
      } 
  
 
      return 0; 
  } 



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(auto i=0;i<n;i++)
#define s(c) static_cast<int>((c).size())

int64_t cnt = 0;

void merge(int A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int i, j, k, L[n1+1], R[n2+1];

    for(int i = 0; i < n1; i++)
    	L[i] = A[left + i];
    for(int i = 0; i < n2; i++)
    	R[i] = A[mid + i];
    L[n1] = R[n2] = INT_MAX;

    i = j = 0;
    for (k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
            cnt += (n1 - i);
        }
    }
}

void mergeSort(int A[], int left, int right) {
	if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

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

	mergeSort(a, 0, n);
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 4656
#include<iostream>

int main(){
    int n;

    std::cin >> n;

    for(int i = 1; i <= 9; i++){
        for(int j = i; j <= 9; j++){
            if(n == i * j){
                std::cout << "Yes" << std::endl;
                return 0;
            }
            if(n != i * j && i == 9 && j == 9){
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    long M = 1_000_000_007;
    int N = scanner.nextInt();
    int[][] a = new int[N + 1][N];
    for (int i = 1; i <= N; i++) for (int j = 0; j < N; j++) a[i][j] = scanner.nextInt();

    long[] dp = new long[1 << N];
    dp[0] = 1;

    for (int i = 1; i < 1 << N; i++) {
      int n = i;
      int j = 0;
      while (n > 0) {
        if (n % 2 == 1) j++;
        n >>= 1;
      }

      for (int k = 0; k < N; k++) {
        if ((i & (1 << k)) != 0) {
          dp[i] += dp[i ^ (1 << k)] * a[j][k];
          if (dp[i] > M) dp[i] -= M;
        }
      }
    }
    System.out.println(dp[(1 << N) - 1]);
  }
}


Measured memory_bytes: 40788
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int cmp_str(const char *s1, const char *s2)
{
    while(*s1==*s2){
        if(*s1=='\0') return 0;
        s1++;
        s2++;
    }
    return (*s1 - *s2);
}

int main()
{
    string s;
    int K;
    cin >> s >> K;
    vector<string> substrs;
    for(int i=0;i<s.length();i++){
        for(int len=1;len<6;len++){
            if(i+len>s.length()) break;
            string subs = s.substr(i,len);
            bool isunique = true;
            for(int j=0;j<substrs.size();j++){
                if(subs == substrs[j]) isunique = false;
            }
            if(isunique){
                substrs.push_back(subs);
            }
        }
    }
    sort(substrs.begin(), substrs.end());
    cout << substrs[K-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    int n;
    cin >> n;
    int a[200];
    int count[200] = {};
    int ans = 100;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        while(a[i]%2==0){
            a[i] /= 2;
            count[i]++;
        }
        ans = min(ans,count[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    vector<long long> tot(n,0);
    long long mod = 1e9 + 7;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(i == 0) tot[i] = a[i];
        else{
            tot[i] += (tot[i-1] + a[i]) % mod;
            tot[i] %= mod;
        }
    }
    long long ans = 0;
    for(int i=1; i<n; i++){
        ans += (a[i] * tot[i-1]) % mod;
        ans %= mod;
    }
    cout << ans << endl;
}

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

#define ll long long
#define mod 1000000007
#define pb push_back


int main()
{
  ll a;
  cin>>a;
  map<string,ll> mp;
  while(a--)
  {
    string s;
    cin>>s;

    mp[s]++;
  }
  ll maxm=INT_MIN;
  for(auto x:mp)
  {
    maxm=max(maxm,x.second);
  }
  for(auto x:mp)
  {
    if(x.second==maxm)
    cout<<x.first<<endl;
  }
}


Measured memory_bytes: 25216
import numpy as np

n = int(input())
a = np.array(list(map(int,input().split())))
b = np.array(list(map(int,input().split())))

d = a - b
s = np.sum(d)


if(s < 0):
    print(-1)
else:
    d = np.sort(d)
    d = d[d != 0]
    d2 = np.copy(d)
    i = -1
    for j in range(len(d2)):
        if(d2[j] >= 0):break
        while(d2[j] < 0):
            t = min(-d2[j],d2[i])
            d2[j] += t
            d2[i] -= t
            if(d2[i] == 0):i -= 1
    c = 0
    for i in range(len(d2)):
        if(d[i] != d2[i]):c += 1
    print(c)

Measured memory_bytes: 32792
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define  fill(st,et,val,arr) for(int i=st;i<=et;i++)arr[i]=val;
#define all(v) v.begin(),v.end()
template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}
 
const int M=1e9 + 7;
const int MAX=1e5+7;
using namespace std;
bool comp(int a,int b)
{	
	return a>b;
}
void printQ(vector<int> q)
{   
    cout<<"v->  ";
	for(int i=0;i<q.size();i++)
	{
		cout<<q[i]<<" ";
	}
	cout<<endl;
}
int solve(int h,int* a,int*  c,int n,vector<vector<int>>& dp)
{
	if(h<=0)
	{
		return 0;
	}
	if(n==0)
	{
		return INT_MAX;
	}
	if(dp[h][n]!=-1)
	{
		return dp[h][n];
	}
	//int ans=c[0]+solve(h-a[0],a+1,c+1);
	int ans=solve(h,a+1,c+1,n-1,dp);
	ans=min(ans,c[0]+solve(h-a[0],a,c,n,dp));
	ans=min(ans,c[0]+solve(h-a[0],a+1,c+1,n-1,dp));
	dp[h][n]=ans;
	return ans;
}
int32_t main() 
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
    	int a;
    	cin>>a;
    	if(a%2==0)
    	{
    		if(a%3==0 || a%5==0)
    		{
    			
			}else{
				cout<<"DENIED"<<endl;
				return 0;
			}
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}













Measured memory_bytes: 256
w,h,n=map(int,input().split())
s=[0,w,0,h]
for i in range(n):
    p=list(map(int,input().split()))
    if p[2]==1 or p[2]==3:
        s[p[2]-1]=max(p[p[2]//2],s[p[2]-1])
    else:
        s[p[2]-1]=min(p[p[2]//2-1],s[p[2]-1])
print(max(s[1]-s[0],0)*max(s[3]-s[2],0))

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	string s, t;
	cin >> s >> t;
	long long n = s.length(), m = t.length();
	vector< vector<long long> > nxt(26, vector<long long>(s.length(), -1));
	for (long long i = 0; i < n - 1; ++i)
		if (nxt[s[i] - 'a'][n - 1] == -1)
			nxt[s[i] - 'a'][n - 1] = i;
	for (long long i = n - 2; i >= 0; --i)
	{
		for (long long ch = 0; ch < 26; ++ch)
		{
			nxt[ch][i] = nxt[ch][i + 1];
			if (nxt[ch][i] == i)
				nxt[ch][i] = -1;
		}
		nxt[s[i + 1] - 'a'][i] = i + 1;
	}
	long long ans = 0;
	long long i = 0;
	if (s[0] != t[0])
	{
		if (nxt[t[0] - 'a'][0] == -1)
		{
			cout << "-1\n";
			return 0;
		}
		i = nxt[t[0] - 'a'][0];
	}
	ans += i + 1;
	for (long long j = 1; j < t.length(); ++j)
	{
		if (nxt[t[j] - 'a'][i] == -1)
		{
			if (s[i] == t[j])
			{
				ans += n;
				continue;
			}
			else
			{
				cout << "-1\n";
				return 0;
			}
		}
		if (nxt[t[j] - 'a'][i] < i)
			ans += n - 1 - i + nxt[t[j] - 'a'][i] + 1;
		else
			ans += nxt[t[j] - 'a'][i] - i;
		i = nxt[t[j] - 'a'][i];
	}
	cout << ans << endl;

	char I;
	cin >> I;
}

Measured memory_bytes: 21712
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i = s ; i < t ; ++i)
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define UNIQ(a) a.erase(unique(ALL(a)),a.end())
#define debug(a) cerr<<#a":="<<a<<endl
using LL = long long; template<class T> using V = vector<T>; template<class T> using VV = V<V<T>>;

int Euler_Phi(int n) {
	int res = n;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			res = res / i * (i - 1); // n (1 - 1/pk) = n - n/pk
			while (n /= i, n % i == 0); //n を素因数分解
		}
	}
	if (n != 1) res = res / n * (n - 1);
	return res;
}

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

	int N; cin >> N;
	cout << Euler_Phi(N) << endl;

	return 0;
}


Measured memory_bytes: 3200
(function(input) {
  var p = input.replace(/\n$/, '').split('\n').map(Number);
  var n = p.length;
  var G = 9.8;
  for (var i = 0; i < n; i++) {
    var mv = p.shift();
    var t = mv / G;
    var N = (G / 2 * t * t + 5) / 5;
    console.log(Math.ceil(N));
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7644
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 4");
            WillReturn.Add("2 1 3");
            WillReturn.Add("3 1 2 3");
            WillReturn.Add("2 3 2");
            //1
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("5 5");
            WillReturn.Add("4 2 3 4 5");
            WillReturn.Add("4 1 3 4 5");
            WillReturn.Add("4 1 2 4 5");
            WillReturn.Add("4 1 2 3 5");
            WillReturn.Add("4 1 2 3 4");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1 30");
            WillReturn.Add("3 5 10 30");
            //3
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        var ListArr = new List<int[]>();
        foreach (string EachStr in InputList.Skip(1)) {
            int[] wkArr = { };
            Action<string> SplitAct = pStr =>
                wkArr = pStr.Split(' ').Select(X => int.Parse(X)).Skip(1).ToArray();
            SplitAct(EachStr);
            ListArr.Add(wkArr);
        }

        int[] InterSectArr = ListArr[0];
        for (int I = 1; I <= ListArr.Count - 1; I++) {
            InterSectArr = InterSectArr.Intersect(ListArr[I]).ToArray();
        }
        Console.WriteLine(InterSectArr.Length);
    }
}


Measured memory_bytes: 13408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    int n,k,sum=0,i;
    scanf("%d %d",&n,&k);
    char *s=(char*)malloc(sizeof(char)*(n+1));
    scanf("%s",s);
    for(i=0;i<n-1;i++)
    {
        if(s[i]==s[i+1]) sum++;
    }
    sum=(sum+2*k)>=n-1?n-1:sum+2*k;
    printf("%d",sum);
    return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define maxn 105
using namespace std;
int dp[maxn][maxn];
char s[maxn][maxn];
int main(){
	int h,w,i,j;
	scanf("%d%d",&h,&w);
	for(i=1;i<=h;i++)scanf("%s",s[i]+1);
	for(i=1;i<=h;i++)
		for(j=1;j<=w;j++)
			dp[i][j]=210;
	dp[1][1]=(s[1][1]=='#');
	for(i=1;i<=h;i++)
		for(j=1;j<=w;j++){
			dp[i][j+1]=min(dp[i][j+1],dp[i][j]+(s[i][j]!=s[i][j+1]));
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]+(s[i][j]!=s[i+1][j]));
		}
	printf("%d\n",(dp[h][w]+(s[h][w]=='#'))/2);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define DEBUG(X) cerr<<__LINE__<<" "<<#X<<": "<<X<<endl;
#define sci(x) int x;scanf("%d",&x);
#define scii(x, y) int x,y;scanf("%d%d",&x,&y);
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
int main() {
  scii(H,W);
  REP(i,W+2) {
    cout << "#";
  }
  cout << endl;
  REP(i,H)
  {
    string s;
    cin >> s;
    cout << "#" << s << "#" << endl;
  }
  REP(i,W+2) {
    cout << "#";
  }
  cout << endl;
}

Measured memory_bytes: 256
/* author:hellojim */
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
string s,t;
ll res,ans;
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	ans=1e9;
	cin>>s>>t;
	rep(i,s.size())
	{
		if(i+t.size()>s.size())break;
		res=0;
		rep(j,t.size())
			if(s[i+j]!=t[j])res++;
		ans=min(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
        #include<functional>
       #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------
int n,m;

signed main(){
int a[8];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	
	if(a[0]==5 && a[1]==5 && a[2]==7) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;


	return 0;
        }


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

using namespace std;
using pii = pair<int, int>;

int main(){
	ios_base::sync_with_stdio(false);
	const int k = 100000;
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	vector<pii> h1(k + 1), h2(k + 1);
	for(int i = 0; i <= k; ++i){
		h1[i].second = i;
		h2[i].second = i;
	}
	for(int i = 0; i < n; i += 2){
		++h1[a[i + 0]].first;
		++h2[a[i + 1]].first;
	}
	sort(h1.begin(), h1.end(), greater<pii>());
	sort(h2.begin(), h2.end(), greater<pii>());
	int answer = n;
	if(h1[0].second != h2[0].second){
		answer = n - h1[0].first - h2[0].first;
	}else if(h1[1].first < h2[1].first){
		answer = n - h1[0].first - h2[1].first;
	}else{
		answer = n - h1[1].first - h2[0].first;
	}
	cout << answer << endl;
	return 0;
}



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

int main() {
	string s;
	cin >> s;
	deque<char> a(s.begin(), s.end());
	int ans = 0;
	while (1 < a.size()) {
		if (a.front() != a.back()) {
			ans++;
			if (a.front() != 'x') {
				a.push_front('x');
				if (a.back() != 'x') {
					cout << -1;
					return 0;
				}
			}
			else a.push_back('x');
		}
		else {
			a.pop_front();
			a.pop_back();
		}
	}
	cout << ans;
}

Measured memory_bytes: 512
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)

    return arr

def main():
    N = int(input())
    #xxx = list(map(int, input().split()))

    if N == 1:
        print(0)
        return

    e_num = []
    for i in range(0, 40):
        for k in range(0, i+1):
            e_num.append(i)
    #print(e_num)

    e_list = factorization(N)

    ans = 0
    for e in e_list:
        ans += e_num[e]
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

// Header files, namespaces,
// macros as defined above
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define f first
#define s second
#define db long double
#define pb push_back
#define sz(c) (c).size()
#define all(c) (c).begin(),(c).end()

typedef long long ll;
typedef pair <int , int> ii;
typedef pair <ii , int> iii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <iii> viii;
typedef vector <vi> vvi;
typedef vector <vii> vvii;

const ll mod = 1e9+7;
const int MAX = 1e6+5;
const db eps = 1e-13;

vector <ll> v;
int n , k;

ll dp[MAX][2];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    cout<<setprecision(11)<<fixed;

    cin>>n>>k;
    bool tmp = false;
    dp[0][0] = 1;
    for( int i = 1; i <= n ; i++ ) {
        ll x;cin>>x;
        for( int j = 0 ; j <= k ; j++ ) {
            dp[j][!tmp] += dp[j][tmp];
            dp[j][!tmp] %= mod;

            dp[j+x+1][!tmp] -= dp[j][tmp];
            dp[j+x+1][!tmp] += mod;
            dp[j][!tmp] %= mod;
        }

        for( int j = 1 ; j <= k ; j++ )
            dp[j][!tmp] = ( dp[j][!tmp] + dp[j-1][!tmp] + mod ) % mod;
        for( int j = 0 ; j <= k ; j++ )
            dp[j][tmp] = 0;
        tmp = !tmp;
    }

    cout<<dp[k][tmp]<<"\n";

}
/*
1 100000
1
*/


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] a=new long[N];
		for(int i=0;i<N;i++) a[i]=sc.nextLong();
		
		int sol=0;
		for(long v:a){
			while((v&1)==0){
				v>>=1;sol++;
			}
		}
		System.out.println(sol);
	}

}


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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<vector<int>> A(N+1,vector<int> (M));
  for(int i = 0; i < N+1; i++){
    for(int j = 0; j < M; j++){
      cin >> A[i][j];
    }
  }
  int sum = 0, count = 0;
  for(int j = 1; j < N+1; j++){
    for(int i = 0; i < M; i++){
      sum += A[0][i]*A[j][i];
    }
    if(sum+C > 0){count++;}
    sum = 0;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

type Count []int

func (c Count) Len() int {
	return len(c)
}

func (c Count) Less(i, j int) bool {
	return c[i] < c[j]
}

func (c Count) Swap(i, j int) {
	c[i], c[j] = c[j], c[i]
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()
	// balls[i] = i+1が書かれたボールの個数
	balls := make(Count, n)
	kind := 0
	for i := 0; i < n; i++ {
		a := nextInt()
		if balls[a-1] == 0 {
			kind++
		}
		balls[a-1]++
	}
	sort.Sort(balls)

	ans := 0
	for i := 0; kind > k; i++ {
		if balls[i] > 0 {
			ans += balls[i]
			kind--
		}
	}
	fmt.Println(ans)
}


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

int main () {
	int n[3], i;
	
	for(i=0; i<3; i++) {
		cin>>n[i];
	}
	
	sort(n,n+3);
	
	int sum=0;
	for(i=1; i<3; i++) {
		if(n[i] != n[i-1]) {
			sum++;
			
		}
	}
	
	cout<<sum+1<<endl;
	
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func blackjack(one, two, three int) string {
	sum := one + two + three
	if sum >= 22 {
		return "bust"
	}
	return "win"
}

func main() {
	var one, two, three int
	fmt.Scan(&one, &two, &three)
	fmt.Println(blackjack(one, two, three))
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if (a >= 13) {
        cout << b << endl;
    } else if (6 <= a && a <= 12) {
        cout << b / 2 << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define pi M_PI

typedef struct xy{
double x;
double y;
}P;

P koch(P pre,P nex,int n){
P PREV,MID,NEXT,DIS;
if(n == 0)printf("%f %f\n",pre.x,pre.y);
else{
DIS.x = nex.x - pre.x;
DIS.y = nex.y - pre.y;
PREV.x = pre.x + DIS.x/3.0;
NEXT.x = pre.x + DIS.x*2.0/3.0;
PREV.y = pre.y + DIS.y/3.0;
NEXT.y = pre.y + DIS.y*2.0/3.0;
MID.x = PREV.x + (DIS.x/3.0)*cos(pi/3.0) - (DIS.y/3.0)*sin(pi/3.0);
MID.y = PREV.y + (DIS.x/3.0)*sin(pi/3.0) + (DIS.y/3.0)*cos(pi/3.0);

koch(pre,PREV,n - 1);
koch(PREV,MID,n - 1);
koch(MID,NEXT,n - 1);
koch(NEXT,nex,n - 1);
}
}

int main(int argc,char argv[]){
P pre={0,0},nex={100,0};
int n;
scanf("%d",&n);
koch(pre,nex,n);
printf("%f %f\n",nex.x,nex.y);
return 0;
}

Measured memory_bytes: 636
n, k = map(int, input().split())
d = list(map(int, input().split()))

def solve():
  for i in range(10*n+2):
    if i >= n:
      s = str(i)
      for j in range(len(s)):
        if int(s[j]) in d:
          break
      else:
        print(i)
        return 0

solve()


Measured memory_bytes: 3060
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vi v(n);
  cin >> v;
  sort(rall(v));
  int maxi = c / a;
  rep(k, n) {
    int w = c;
    rep(i, k + 1) w += v[i];
    cmax(maxi, w / (a + (k + 1) * b));
  }
  cout << maxi << endl;
}

Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
using ll = int64_t;
using v = vector<int>;

int main() {
  int N;
  cin >> N;
  v ans(N);
  rep(i,N-1) {
    int num;
    cin >> num;
    num--;
    ans.at(num)++;
  }
  rep(i,N) {
    cout << ans.at(i) << endl;
  }
}

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

int main(){
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    constexpr unsigned long B{30};
    vector P(B, vector<unsigned long>(N));
    for(auto&& i : P[0]){
        cin >> i;
        --i;
    }
    for(unsigned long i{1}; i < B; ++i)for(unsigned long j{0}; j < N; ++j)P[i][j] = P[i - 1][P[i - 1][j]];
    vector C(B, vector<long>(N));
    for(auto&& i : C[0])cin >> i;
    for(unsigned long i{1}; i < B; ++i)for(unsigned long j{0}; j < N; ++j)C[i][j] = C[i - 1][j] + C[i - 1][P[i - 1][j]];
    vector ans(2, vector<long>(N));
    --K;
    copy(begin(C[0]), end(C[0]), begin(ans[0]));
    fill(begin(ans[1]), end(ans[1]), numeric_limits<long>::min() / 2);
    for(unsigned long i{B}; i--; ){
        if((K >> i) & 1){
            vector tmp(ans);
            for(unsigned long j{0}; j < N; ++j)ans[0][j] = C[i][j] + tmp[0][P[i][j]];
            for(unsigned long j{0}; j < N; ++j)ans[1][j] = max({tmp[0][j], tmp[1][j], C[i][j] + tmp[1][P[i][j]]});
        }else if(K >> i){
            vector tmp(ans);
            for(unsigned long j{0}; j < N; ++j)ans[1][j] = max(tmp[1][j], C[i][j] + tmp[1][P[i][j]]);
        }
    }
    cout << max(*max_element(begin(ans[0]), end(ans[0])), *max_element(begin(ans[1]), end(ans[1]))) << endl;
    return 0;
}

Measured memory_bytes: 6136
#define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

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

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    n %= 10;
    string ans;
    if( n == 3){
        ans = "bon";
    }
    else if(n == 0 || n == 1 || n == 6 || n == 8){
        ans = "pon";
    }
    else{
        ans = "hon";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}
const int mod = 1000000007;

int main() {
    string s;
    cin >> s;
    bool ok = false;

    rep(i,s.size()) {
        if(s[i] == 'R') ok = true;
    }
    if(!ok) {
        cout << 0 << endl;
        return 0;
    }
    if(s=="RRR") cout << 3 << endl;
    else if(s=="RRS") cout << 2 << endl;
    else if(s=="SRR") cout << 2 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int v[100];

int main(){
  int n;
  cin>>n;
  rep(i,n){
    cin>>v[i+1];
  }
  sort(v,v+n+1);
  FOR(i,1,n+1){
    if(i%2==0)
      v[i]=24-v[i];
  }
  sort(v,v+n+1);

 
  int ans=24;
  FOR(i,1,n+1){
    ans=min(ans,v[i]-v[i-1]);
  }

  cout<<ans<<endl;
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	string s, t; cin >> s >> t;
	ll N = s.size();
	ll M = t.size();

	vector<ll> cnts(26, 0), cntt(26, 0);
	for (auto &c : s)
	{
		++cnts[c-'a'];
	}
	for (auto &c : t)
	{
		++cntt[c-'a'];
	}


	ll res{-1};
	REP(i, 26)
	{
		if (cntt[i])
		{
			if (cnts[i] == 0)
			{
				std::cout << res << std::endl;
				return 0;
			}
		}
	}

	map<char, vector<ll>> V;
	REP(i, N)
	{
		V[s[i]].push_back(i);
	}

	ll times{0};
	ll k;
	for (ll i = 0; i < M;)
	{
		char c = t[i];
		k = V[c].front();
		ll j = i + 1;
		while (j < M)
		{
			if (V[t[j]].back() <= k)
				break;

			k = *upper_bound(V[t[j]].begin(), V[t[j]].end(), k);
			++j;
		}

		if (j >= M)
		{
			res = k;
			break;
		}
		else
			++times;

		i = j;
	}


	std::cout << N*times + res + 1<< std::endl;
	// std::cout << "times : " << times << std::endl;
	// std::cout << "res : " << res << std::endl;
}

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

using namespace std;

using int64 = long long;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

vector<vector<Edge>> ReadUndirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge(v1, v2));
    graph[v2].push_back(Edge(v2, v1));
  }
  return graph;
}

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}
template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int n, k;
  cin >> n >> k;

  auto graph = ReadUndirectedGraph(n, n - 1, true);

  vector<int> visited(n, 0);
  function<void(int, int, int)> dfs = [&](int v, int p, int d) {
    visited[v] = 1;
    if (d == 0) return;
    for (const auto& e : graph[v]) {
      if (e.to == p) continue;
      dfs(e.to, v, d - 1);
    }
  };

  int ans = n;

  if (k % 2 == 1) {
    for (int v1 = 0; v1 < n; v1++) {
      for (const Edge& e : graph[v1]) {
        int v2 = e.to;

        fill(visited.begin(), visited.end(), 0);
        dfs(v1, v2, (k - 1) / 2);
        dfs(v2, v1, (k - 1) / 2);

        int count = 0;
        for (int i = 0; i < n; i++) if (!visited[i]) count++;
        UpdateMin(ans, count);
      }
    }
  } else {
    for (int v = 0; v < n; v++) {
      fill(visited.begin(), visited.end(), 0);
      dfs(v, -1, k / 2);
      int count = 0;
      for (int i = 0; i < n; i++) if (!visited[i]) count++;
      UpdateMin(ans, count);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
from fractions import gcd


MOD = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

lcm = A[0]

for a in A:
    lcm = (lcm * a) // gcd(lcm, a)

ans = 0
for a in A:
    ans += (lcm % MOD) * pow(a, MOD - 2, MOD)
    ans %= MOD

print(ans)


Measured memory_bytes: 6200
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int INT_MAX_SQRT = sqrt(INT_MAX);
int pwi(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    int tmp = pwi(x, p / 2);
    if (tmp > INT_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

long LONG_MAX_SQRT = sqrt(LONG_MAX);
long pwl(long x, long p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    long tmp = pwl(x, p / 2);
    if (tmp > LONG_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

map<long, long> factorization(long N) {
    map<long, long> res;
    long SQRT_N = ceil(sqrt(N));
    for (long i = 2; i < SQRT_N; i++) {
        while (N % i == 0) {
            if (res.find(i) == res.end()) {
                res[i] = 1;
            } else {
                res[i] += 1;
            }
            N /= i;
        }
    }
    if (N > SQRT_N) res[N] = 1;
    return res;
}

void debug_vec(string name, vector<long> vec) {
    cout << name << endl;
    for (auto e: vec) cout << e << endl;
}

void debug_mat(string name, vector<vector<long>> mat) {
    cout << name << endl;
    for (auto vec: mat) {
        for (auto e: vec) cout << e << "   ";
        cout << endl;
    }
}

int main() {
    char a;
    cin >> a;

    if (a > 'Z') {
        cout << "a" << endl;
    } else {
        cout << "A" << endl;
    }

    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    string s;
    getline(cin,s);
    for(int i=0;i<s.size();i++)
        if(s[i]>='a' && s[i]<='z')
            s[i]=toupper(s[i]);
        else if(s[i]>='A' && s[i]<='z')
            s[i]=tolower(s[i]);
    cout<<s<<endl;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T>inline int bs(int g,int k,T c){while(abs(k-g)>1){int m=(g+k)/2;(c(m)?k:g)=m;}return k;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> cntr(n+1, 0);
    vector<int> cntg(n+1, 0);
    vector<int> cntb(n+1, 0);
    for(int i = 0; i < n; ++i){
        cntr[i+1] = cntr[i]+(s[i] == 'R');
        cntg[i+1] = cntg[i]+(s[i] == 'G');
        cntb[i+1] = cntb[i]+(s[i] == 'B');
    }

    ll cnt = 0;
    for(int a = 0; a < n-2; ++a){
        for(int c = a+2; c < n; ++c){
            char A = s[a], C = s[c];
            if(A == C) continue;
            switch(A^C){
                case 5:
                    cnt += cntr[c]-cntr[a+1];
                    if((a+c)%2 == 0 and s[(a+c)/2] == 'R') --cnt;
                    break;
                case 16:
                    cnt += cntg[c]-cntg[a+1];
                    if((a+c)%2 == 0 and s[(a+c)/2] == 'G') --cnt;
                    break;
                case 21:
                    cnt += cntb[c]-cntb[a+1];
                    if((a+c)%2 == 0 and s[(a+c)/2] == 'B') --cnt;
                    break;
            }
        }
    }
    cout << cnt << '\n';

    
    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>

int main(void)
{
	int k, x, a, b;
	
	scanf("%d %d", &k, &x);
	
	a = x - (k - 1);
	b = x + (k - 1);
  
  	while(a <= b){
    	printf("%d\n", a);
    	a++;
  	}	
  	return 0;
}

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

#define first  fs
#define second se
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, char s = '\n') { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int x = in();
	lint sum = 0;
	for (int i = 1; ; ++i) {
		sum += i;
		if (sum >= x) {
			cout << i << endl;
			return 0;
		}
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int x;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> x;
	cout << ((x == 7 || x == 5 || x == 3) ? "YES\n" : "NO\n");
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter

@JvmField val _writer = PrintWriter(System.out, false)
fun main(args: Array<String>) { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    val (s, w) = readLine()!!.split(' ').map { it.toInt() }
    if (s > w) {
        println("safe")
    } else {
        println("unsafe")
    }
}


Measured memory_bytes: 36352
import sys

s = input()

if s[0] == "A" and s.count("C") == 1 and "C" in s[2:-1]:
    ss = set(s)
    ss.remove("A")
    ss.remove("C")
    SS = set([i.upper() for i in ss])
    if len(ss & SS) == 0:
        print("AC")
        sys.exit()

print("WA")




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

int main(){
    int count = 0;
    string S;
    cin >> S;

    for(int i=0; i<S.size(); i++){
        if(S[i] != (i%2) + '0') count++;
    }

    if(count > S.size()/2)
        cout << S.size() - count << endl;
    else
        cout << count << endl;
    
    return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int count(vector<int> &v){
    int n = v.size();
    vector<int> x(n);
    REP(i,n){x[i]=i+1;}
    int itr = 0;
    do{
        if(x==v)break;
        itr++;
    }while(next_permutation(x.begin(),x.end()));
    
    return itr;
}

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    REP(i,n){cin>>p[i];}
    REP(i,n){cin>>q[i];}
    cout << abs(count(p)-count(q)) << endl;
    return 0;
} 

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////


int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K; cin >> N >> K;
    
    double ans = 0;
    for (int i = 1; i <= N; i++) {
        double p = 1.0/N;
        int a = i;
        while (a < K) {
            a *= 2;
            p /= 2;
        }
        ans  += p;
    }

    cout << fixed << setprecision(10) << ans << ln;
}

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

using namespace std;

const long long INF = (1LL << 60);

int main(){
	int N;
	while(cin >> N){
		vector<pair<int,int>> vp(N);
		for(auto& t : vp) cin >> t.first >> t.second;
		sort(vp.begin(), vp.end(),
		     [](const pair<int,int>& a, const pair<int, int>& b){
				return a.first + a.second < b.first + b.second;
		     }
		);
		vector<long long> dp(N+1, INF);
		dp[0] = 0;
		for(int i=0;i<N;i++){
			for(int j=i;j>=0;j--){
				if(dp[j] <= vp[i].first){
					dp[j+1] = min(dp[j+1], dp[j] + vp[i].second);
				}
			}
		}
		for(int i=N;i>=0;i--){
			if(dp[i] != INF){
				cout << i << endl;
				break;
			}
		}
	}
}


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(void){
    int n; cin >> n;
    int a[n+1]; 
    ll maxEdge = 0;
    rep(i,0,n+1){
        cin >> a[i];
        maxEdge += a[i];
    }
    bool f = true;
    if(a[0] > 0) f = false;

    ll ans = 1;
    ll num = 1;

    rep(i,1,n+1){
        if(num <= 0) f = false;

        ll maxNum = min(num*2, maxEdge);
        if(a[i] > maxNum) f=false;
        ans += maxNum;
        num = maxNum-a[i];

        
        maxEdge -= a[i];
    }

    if(f) cout << ans << "\n";
    else if(n == 0 && a[0] == 1) cout << 1 << "\n";
    else cout << -1 << "\n";
} 

Measured memory_bytes: 3932
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>

#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
    int N;
    cin >> N;
    vector<unsigned long long> A(N);
    rep(i, N) {
        cin >> A[i];
        if(A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    unsigned long long ret = 1; 
    unsigned long long tmp;
    rep(i, N) {
        tmp = A[i];
        if(tmp == 0) {
            cout << 0 << endl;
            return 0;
        }
        if(tmp > 1000000000000000000 / ret) {
            cout << -1 << endl;
            return 0;
        }
        ret *= tmp;
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 4052