akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N, M, V, P;
  cin >>N >>M >>V >>P;
  vector<long long>Z(N,0), A(N,0);
  for(int i=0; i<N; i++){
    long long a;
    cin >>a;
    Z[i]=a;
  }
  stable_sort(Z.begin(), Z.end(), greater<long long>());
  A=Z;
  for(int i=0; i<N-1; i++){
    A[i+1]+=A[i];
  }
  long long h=N-1, l=0, mid=(h+l)/2;
  while(h-l>1){
    if(Z[mid]+M<Z[P-1]){
      h=mid;
      mid=(h+l)/2;      
      continue;
    }
    long long b=((N-mid)+P-1)*M;//いくらでも足していいやつ
    long long c=max((Z[mid]+M)*(N-b/M)-(A[mid-1]-A[P-2]), 0LL);//指定の値+V以下まで加えられるやつ
//    cout<<"mid:"<<mid<<" b:"<<b<<" c:"<<c<<" MV:"<<M*V<<endl;
    if(b+c>=M*V) l=mid;
    else h=mid;
    mid=(h+l)/2;
  }
//  cout<<"h"<<h<<endl;
  if(Z[h]+M<Z[P-1]) h--;  
  else{
  long long b=((N-h)+P-1)*M;//いくらでも足していいやつ
  long long c=max((Z[h]+M)*(N-b/M)-(A[h-1]-A[P-2]),0LL);//指定の値+V以下まで加えられるやつ
  if(b+c<M*V) h--;
  }
  h++;
//  cout<<"b:"<<b<<" c:"<<c<<" MV:"<<M*V<<endl;  
  cout << h << endl;
}


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

int main(){
    string s;
    cin >> s;
    int tmp = s.size();
    for (int i = 0; i < s.size(); i++){
        if (s[i] != '1') {
            tmp = i;
            break;
        }
    }
    int k;
    cin >> k;

    if (k <= tmp || tmp == s.size()) cout << 1 << endl;
    else cout << s[tmp] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N;
	cin >> N;
	vector <int> P( N ), Q( N ), A( N );
	rep( i, 1, N + 1 ){
		A[ i - 1 ] = i;
	}
	rep( i, 0, N ){
		cin >> P[ i ];
	}
	rep( i, 0, N ){
		cin >> Q[ i ];
	}
	int cnt = 0, cnt_A;
	bool is = false;
	do {
		cnt++;
		if (A == Q){
			if (is){
				cout << cnt - cnt_A << endl;
				return 0;
			}
			cnt_A = cnt;
			is = true;
		}
		if (A == P){
			if (is){
				cout << cnt - cnt_A << endl;
				return 0;
			}
			cnt_A = cnt;
			is = true;
		}
	} while( next_permutation( A.begin(), A.end()));

}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


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

int main() {
  
  int N;
  cin >> N;
    vector<int> input(N);
     for (int i = 0 ;i < N;i++){
       cin >> input.at(i);
     }
  int a; a = 1;
  int b; b = 0;
  int l;
  for (int i = 0 ; i < N ; i++ ){
    l = input.at(a - 1);
    a = l;
    if (l == 2){
      cout << (i + 1);break;
    }
  }
  if (l == 2){}
  else { cout << -1;}      
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
int n,mod,i,j,ans,c[3005][3005],s[3005][3005],pw[10000005];
long long pw2[10005];
int qp(int x,long long y)
{
	int z=1;
	while(y){
		if(y&1){
			z=1ll*z*x%mod;
		}
		x=1ll*x*x%mod;
		y/=2; 
	}
	return z;
}
int solve(int x)
{
	int i,ans=0;
	fz1(i,x){
		inc(ans,1ll*s[x][i]*pw[(n+1-x)*(i-1)]%mod)
	}
	return 1ll*ans*qp(2,pw2[n+1-x])%mod;
}
int main()
{
	scanf("%d%d",&n,&mod);
	pw[0]=pw2[0]=1;
	fz1(i,10000000){
		pw[i]=pw[i-1]+pw[i-1];
		if(pw[i]>=mod) pw[i]-=mod;
	}
	fz1(i,10000){
		long long t=0ll+pw2[i-1]+pw2[i-1];
		if(t>=mod-1) t-=mod-1;
		pw2[i]=t;
	}
	c[0][0]=s[0][0]=1;
	fz1(i,n+2){
		c[i][0]=1;
		fz1(j,i){
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
			s[i][j]=(1ll*s[i-1][j]*j+s[i-1][j-1])%mod;
		}
	}
	fz0g(i,n){
		int t=1ll*solve(i+1)*c[n][i]%mod;
		if(i&1) dec(ans,t) else inc(ans,t) 
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 109952
N = int(input())
dic = {}
ans = 0
for _ in range(N):
    si = input()
    sortedSi = "".join(sorted(si))
    if sortedSi in dic:
        dic[sortedSi] += 1
    else:
        dic[sortedSi] = 1

for val in dic.values():
    ans += val * (val - 1) // 2

print(ans)


Measured memory_bytes: 17892
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int H, W; string s[11];
int main() {
	while (cin >> H >> W, H | W) {
		for (int i = 0; i < H; i++) cin >> s[i];
		vector<string> res;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				for (int dy = -1; dy <= 1; dy++) {
					for (int dx = -1; dx <= 1; dx++) {
						if (dx == 0 && dy == 0) continue;
						string now;
						int tx = (j + dx + W) % W, ty = (i + dy + H) % H;
						now += s[ty][tx];
						while (tx != j || ty != i) {
							tx = (tx + dx + W) % W, ty = (ty + dy + H) % H;
							now += s[ty][tx];
							res.push_back(now);
						}
					}
				}
			}
		}
		sort(res.begin(), res.end());
		string ret;
		int pre = 0;
		for (int i = 1; i <= res.size(); i++) {
			if (i == res.size() || res[i - 1] != res[i]) {
				if (i - pre > 1) {
					if (ret.size() < res[pre].size() || (ret.size() == res[pre].size() && ret > res[pre])) {
						ret = res[pre];
					}
				}
				pre = i;
			}
		}
		if(ret.size() > 1) cout << ret << endl;
		else cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 31068
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

int main(void)
{
    int a[5],k;
    rep(i,5)
    {
        cin >> a[i];
    }
    cin >> k;

    rep(i,5)
    {
        rep(j,5)
        {
            int d = abs(a[i]-a[j]);
            if(d > k)
            {
                cout << ":(" << endl;
                return 0;
            }

        }
    }

    cout << "Yay!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  int k,i,t;
  char s[101];
  scanf("%d\n%s",&k,s);
  i=strlen(s);
  if(i<=k)
	  puts(s);
  else
  {
	  for(t=0;t<k;t++)
		  printf("%c",s[t]);
	  printf("...");
  }
  return 0;
}

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

int main(){
    string s,t;cin >> s >> t;
    int n=s.length(),m=t.length();
    vector<vector<string>> dp(n+1,vector<string>(m+1,""));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            string p=dp[i][j-1],q=dp[i-1][j],r=dp[i-1][j-1];
            if(p.length()>q.length()) dp[i][j]=p;
            else dp[i][j]=q;
            if(s[i-1]==t[j-1]){
                if(r.length()+1>dp[i][j].length()) dp[i][j]=r+s[i-1];
            }
            dp[i-1][j-1]="";
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}



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

void getWord(const char* str, char* word, int n)
{
	int i;
	int j;
	int index;
	
	for( i = 0, j = 0; i < n - 1; i++ )
	{
		for(; str[j] != ' ' && str[j] != '\0' && str[j] != '.' && str[j] != '\n'; j++ )
		{
		}
		if( str[j] == ' ' )
		{
			j++;
		}
		else if( str[j] == '\n' )
		{
			j++;
		}
		else if( str[j] == '.' )
		{
			j++;
		}
		else if( str[j] == '\0' )
		{
			//printf( "%d\n", j );
			word[0] = '\0';
			return;
		}
	}
	
	for( index = 0; str[j] != ' ' && str[j] != '\0' && str[j] != '.' && str[j] != '\n'; index++, j++ )
	{
		//printf( "index:%d j:%d\n", index, j );
		word[index] = str[j];
	}
	word[index] = '\0';
}

void ceaser(char* word, int n)
{
	int i;
	for( i = 0; word[i] != '\0'; i++ )
	{
		if( word[i] != ' ' && word[i] != '.' && word[i] != '\n' )
		{
			word[i] = ((word[i] - 'a') + n) % 26 + 'a';
		}
	}
}

int main(void)
{
	char word[80];
	char string[256];
	int i;
	int j;
	
	//scanf( "%s", string );
	
	while( 1 )
	{
		if( fgets( string, 256, stdin ) == 0 )break;
		
		for( i = 0; i < 80; i++ )
		{
			for( j = 0;; j++ )
			{
				getWord( string, word, j + 1 );
				if( word[0] == '\0' )break;
				
				ceaser( word, i );
				
				if( strcmp( word, "the" ) == 0 || strcmp( word, "this" ) == 0 || strcmp( word, "that" ) == 0 )
				{
					ceaser( string, i );
					printf( "%s", string );
					i = 80;
					break;
				}
			}
		}
	}
	
	return (0);
}

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

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

	int ans = 0;
	int i = 1;
	while (true) {

		if ((double)(i * a) > (double)(t + 0.5)) {
			break;
		}
		ans += b;
		i++;
	}

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

Measured memory_bytes: 256
class Array
  def gcd
    inject(:gcd)
  end
end

k = gets.to_i
answer = 0
ans = [10174780,10290813,10493367,10611772,10813692]

if k < 196 then

for a in 1..k
  for b in 1..k
    for c in 1..k
      answer = answer + [a,b,c].gcd
    end
  end
end
  
else
  answer = ans[k-196]
end

print answer
#196 -> 10174780
#197 -> 10290813
#198 -> 10493367
#199 -> 10611772
#200 -> 10813692

Measured memory_bytes: 14352
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
// string s;
  ll n,m,k,x=0,y=0,c=1,q,ans=0;
  cin>>n>>k;
  std::vector<pii> v;

     x = ((n-1)*(n-2))/2;
  if(k>x)
  {
    c(-1);
    return;
  }

for (int i = 2; i <= n; ++i)
{
   v.pb({1,i});
}
for (int i = 2; i <= n; ++i)
{
       if(x==k)
        break;
      for(ll j=i+1;j<=n;j++)
      {
          v.pb({i,j});
          x--;
          if(x==k)
            break;

      }
       if(x==k)
         break;
}
c(v.size());
for (int i = 0; i < v.size(); ++i)
{
  cout<<v[i].F<<" "<<v[i].S<<"\n";
}

}

signed main(){

      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


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

using namespace std;

int A[3];

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

	cin >> A[0] >> A[1] >> A[2];
	sort(A, A+3);
	for(int i = 0; i < 3 ;++i) {
		cout << A[i];
		if(i != 2) cout << " ";
	}
	cout << '\n';	

	return 0;
} // br1



Measured memory_bytes: 3188
using System;
class c
{
    static void Main()
    {
        int i = 1;
        int n = int.Parse(Console.ReadLine());
        while ((i + 1) * i / 2 < n)
        {
            i++;
        }
        while (n > 0)
        {
            if (i > 0 && n - i >= 0)
            {
                Console.WriteLine(i);
                n = n - i;
            }
            i--;
        }
    }
}


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

void strInit(char str[]);//str[]を0で初期化
void extIntStr(char str[],int data[]);//str[]から数値(int)を抽出しdata[]に順次格納
void incsort(int data[],int len);//data[]を昇順ソート
void decsort(int data[],int len);//data[]を降順ソート
void printIntArray(int data[],int len);//data[]をprint
int* inputArray(int n);//文字列を受け取り数値を抽出、n個の数値(int)を格納した配列のポインタをreturn
int* cpyArray(int data[],int len);//配列(int)を複製した配列のポインタをreturn

//don't forget free(data);

int main(){
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    int ans = n * a;
    if(ans>b)ans=b;
    printf("%d",ans);
    return 0;
}

//temp##############################################

void strInit(char str[]){
    int len=strlen(str);
    for(int i=0;i<len;i++){
        str[i]=0;
    }
}

void extIntStr(char str[],int data[]){
    int length=strlen(str);
    str[length-1]=' ';
    char buff[12];
    int j,index;
    index=j=0;
    for(int i=0;i<length;i++){
        if(str[i]!=' '){
            buff[j++]=str[i];
        }else{
            data[index++]=atoi(buff);
            strInit(buff);
            j=0;
        }
    }
}

void incsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]>data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void decsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]<data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void printIntArray(int data[],int len){
    for(int i=0;i<len;i++){
        printf("%d\n",data[i]);
    }
}

int* inputArray(int n){
    int *data;
    data=(int*)malloc(sizeof(int)*n);
    char *get;
    get=(char*)malloc(sizeof(char)*11*n+1);
    fgets(get,11*n+1,stdin);
    extIntStr(get,data);
    free(get);
    return data;
}

int* cpyArray(int data[],int len){
    int *cp;
    cp=(int*)malloc(sizeof(int)*len);
    for(int i=0;i<len;i++){
        cp[i]=data[i];
    }
    return cp;
}

//temp##############################################


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll A,B,C;

int main(){
    cin>>A>>B>>C;

    if(A==B && B==C && ~A&1){
        cout<<-1<<endl;
        return 0;
    }

    int ans=0;
    while(~A&1 && ~B&1 && ~C&1){
        ll sum=A+B+C;
        A=(sum-A)/2;
        B=(sum-B)/2;
        C=(sum-C)/2;
        ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s;
    cin>>s;
    rep(0,i,s.length())if(s.substr(i,1)=="7"){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll x;
    cin >> x;

    ll res;
    if (x % 11 > 6) {
        res = 2* (x / 11) + 2;
    }
    else if (x % 11 == 0){
        res = 2 * (x / 11);
    }
    else {
        res = 2 * (x / 11) + 1;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int x,a,b;
    cin>>x>>a>>b;
    x-=a;
    x%=b;
    cout<<x;
    return 0;
}


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;
vector<ll> prime;
map<ll,ll> sqr;
const ll MAX_A = 1e10;

ll calc_pair(ll x)
{
	ll res = 1;
	map<ll,int> fact;
	for(int i = 0;i < prime.size() && prime [i] * prime [i] * prime [i] <= x;i++){
		while(x % prime [i] == 0){
			fact [prime [i]]++;
			x /= prime [i];
		}
	}
	if(sqr.count(x) && res <= MAX_A / sqr [x]){
		res *= sqr [x];
	}
	else if(sqr.count(x) == 0 && res <= MAX_A / x / x){
		res *= x * x;
	}
	else{
		return -1;
	}
	for(auto&& it : fact){
		if(it.second == 1 && res <= MAX_A / it.first / it.first){
			res *= it.first * it.first;
		}
		else if(it.second == 2 && res <= MAX_A / it.first){
			res *= it.first;
		}
		else{
			return -1;
		}
	}

	return res;
}

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

	cin >> N;
	vector<ll> A(N);
	FOR(i,0,N){
		cin >> A [i];
	}

	for(ll i = 2;i * i <= MAX_A;i++){
		bool flag = true;
		for(int j = 0;j < prime.size() && prime [j] * prime [j] <= i;j++){
			if(i % prime [j] == 0){
				flag = false;
				break;
			}
		}
		if(flag){
			prime.push_back(i);
			sqr [i * i] = i;
		}
	}

	map<ll,int> cnt;
	FOR(i,0,N){
		for(int j = 0;j < prime.size() && prime [j] * prime [j] * prime [j] <= A [i];j++){
			while(A [i] % (prime [j] * prime [j] * prime [j]) == 0){
				A [i] /= prime [j] * prime [j] * prime [j];
			}
		}
		cnt [A [i]]++;
	}

	ll ans = 0;
	for(auto&& it : cnt){
		if(it.first == 1){
			ans++;
			continue;
		}
		ll tmp = calc_pair(it.first);
		if(tmp == -1 || cnt.count(tmp) == 0){
			ans += it.second;
		}
		else if(tmp > it.first){
			ans += max(it.second,cnt [tmp]);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 7936
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

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

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)

vector<int> lst[1001];
vector<int> pos[1001];
int ind[1001];
int volt[1001][1001];
int main() {
	IO;
	int n;
	cin>>n;
	for(int i=1;i<=n;++i) {
		lst[i].resize(n-1);
		pos[i].resize(n+1);
		for(int j=0;j<n-1;++j) {
			cin>>lst[i][j];
			pos[i][lst[i][j]]=j;
		}
	}
	
	queue<pair<int,int>> q;
	for(int i=1;i<=n;++i) {
		q.push({i,0});
	}
	
	int pairs=0;
	int mx=0;
	while(!q.empty()) {
		auto fr=q.front();
		q.pop(); 
		//cerr<<fr.first<<" "<<fr.second<<"\n";
		mx=max(fr.second, mx);
		if(ind[fr.first]>=n-1) continue ;
		
		int masik=lst[fr.first][ind[fr.first]];
		volt[fr.first][masik]++;
		volt[masik][fr.first]++;
		
		if(volt[fr.first][masik]==2) {
			ind[fr.first]++;
			ind[masik]++;
			pairs++;

			q.push({fr.first, fr.second+1});
			q.push({masik, fr.second+1});
		}
	}
	
	if(pairs!=n*(n-1)/2) {
		cout<<"-1\n";
	}else {
		cout<<mx<<"\n";
	}
	
	return 0;
}


Measured memory_bytes: 12032
L,R = map(int,input().split())
mod_list = []
if R-L >= 2019:
	mod_list = [i for i in range(2020)]
else:
	for i in range(L,R+1):
		mod_list.append(i%2019)
mod_list.sort()
ans = (mod_list[0]*mod_list[1]) % 2019
len_modlist = len(mod_list)
for i in range(len_modlist-1):
	for j in range(i+1, len_modlist):
		tmp = (mod_list[i] * mod_list[j]) % 2019
		ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
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; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> V(N),C(N);
    for(auto& in:V) cin >> in;
    for(auto& in:C) cin >> in;
    for(int i = 0; i < N;i++){
        res += max(0LL,V[i]-C[i]);
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int Max(int a,int b,int c);

int main(void){
  int N,W;
  cin>>N>>W;
  int tables[N+1][W+1];
  for(int i=0;i<N+1;i++){
    for(int j=0;j<W+1;j++){
      tables[i][j]=0;
    }
  }
  int v[N+1];
  int w[N+1];
  v[0]=0;
  w[0]=0;
  for(int i=1;i<N+1;i++){
    cin>>v[i]>>w[i];
  }

  for(int i=1;i<N+1;i++){
    for(int j=0;j<W+1;j++){
      if(j>=w[i]){
        tables[i][j]=Max(tables[i-1][j],tables[i-1][j-w[i]]+v[i],tables[i][j-w[i]]+v[i]);
      }
      else{
        tables[i][j]=tables[i-1][j];
      }

    }
  }

  cout<<tables[N][W]<<endl;
  return 0;
}

int Max(int a,int b,int c){
  int retval=0;
  int values[3]={a,b,c};
  for(int i=0;i<3;i++){
    retval=max(retval,values[i]);
  }
  return retval;
}



Measured memory_bytes: 7036
#include <stdio.h>

int main (void){
    int i;
    int balls,collers;
    int patterns;
    scanf("%d %d",&balls ,&collers);
    for (i=0;i< balls;i++){
        if (i==0){patterns = collers;}
        else{
            patterns *= collers-1; 
        }
    }
    printf("%d\n",patterns);
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(n==i*j){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>

#define TRUE 1
#define FALSE 0
int A1[1000];
int A2[1000];
int n1,n2;

int solve(int i,int m){
    int res;
    //printf("m=%d\n",m);
    if(m==0){
        //printf("True\n");
        return TRUE;
    }
    
    if(i>=n1){
        //printf("False\n");
        return FALSE;
    }
    res=solve(i + 1, m)||solve(i + 1, m - A1[i]);
    //printf("solve(%d + 1, %d)||solve(%d + 1, %d - %d)\n",i,m,i,m,A1[i]);
    return res;
}

int main(){
    int i;
    for(i=0;i<1000;i++){
        A1[i]=0;
        A2[i]=0;
    }
    scanf("%d",&n1);
    
    for(i=0;i<n1;i++)
        scanf("%d",&A1[i]);
    
    scanf("%d",&n2);
    for(i=0;i<n2;i++){
        scanf("%d",&A2[i]);
    }
    
    
    for(i=0;i<n2;i++){
        if(solve(0,A2[i])==TRUE)printf("yes\n");
        else printf("no\n");
    }
    
    return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  vector<pair<double, int>> temp(N);
  for (int i = 0; i < N; i++) {
    int H;
    cin >> H;
    temp[i].first = abs(T - H*0.006 - A);
    temp[i].second = i+1;
  }
  sort(temp.begin(), temp.end());
  cout << temp[0].second << endl;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define pcnt __builtin_popcount
#define pcntll(x) __builtin_popcountll(x)
#define DMAX DBL_MAX;
#define IMIN INT_MIN;
#define IMAX INT_MAX;

//const ll MOD = 1e9+7;
//const ll MOD = 998244353;
//const ll MAX = 3e5+1;
//const ll INF = 1e18;
//const ld PI = acos(-1L);

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string T;
    in(T);
    int n = T.size();
    rep(i, n) {
        if (T[i] == '?') {
            T[i] = 'D';
        }
    }
    out(T);


    return 0;
}


Measured memory_bytes: 3744
#include <vector>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <sstream>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cassert>
#include <cstring>
#include <sys/time.h>
#include <stdlib.h>
using namespace std;

int main(int argc, char *argv[]){
  int a, b;
  cin >> a >> b;
  int c = a-2*b;
  if(c<0){
    c = 0;
  }
  cout << c << endl;
  return 0;
}


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

int main(){
	bool udah[110];
	int n, x, i, salah=0;
	cin>>n;
	for(i=0;i<105;i++){
		udah[i]=false;
	}
	for(i=0;i<n;i++){
		cin>>x;
		if(udah[x]){
			salah++;
		}
		udah[x]=true;
	}
	cout<<n-salah<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector <int> ve;
const int maxn = 1000010;
long long cnt = 0;
int num[maxn];

void InsertionSort(int n,int g)
{
    for(int i=g;i<n;i++)
    {
        int v = num[i];
        int j = i-g;
        while(j>=0 && num[j] > v)
        {
            num[j+g] = num[j];
            j -= g;
            cnt++;
        }
        num[j+g] = v;
    }
}

void ShellSort(int n)
{
    int h = 1;
    while(h <= n)
    {
        ve.push_back(h);
        h = h*3 + 1;
    }

    for(int i=ve.size()-1;i>=0;i--)
        InsertionSort(n,ve[i]);
}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&num[i]);
    ShellSort(n);
    printf("%d\n",ve.size());
    for(int i=ve.size()-1;i>=0;i--)
    {
        printf("%d",ve[i]);
        if(i != 0)
            printf(" ");
    }
    printf("\n");
    printf("%lld\n",cnt);
    for(int i=0;i<n;i++)
    {
        printf("%d",num[i]);
        if(i != n-1)
            printf("\n");
    }
    return 0;
}

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

int main() {

	int n; cin >> n;
	string p_s = " ";
	string q_s = " ";
	for (int i = 0; i < n; i++) {
		string p; cin >> p;
		p_s += p;
	}
	for (int i = 0; i < n; i++) {
		string q; cin >> q;
		q_s += q;
	}
	vector<int> c(n);
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		c[i] = i + 1;
	}
	int a, b;
	do {
		cnt++;
		// c[i] を使う
		string tmp = " ";
		for (int i = 0; i < c.size(); i++) {
			tmp += to_string(c[i]);
		}
		if (tmp == p_s) a = cnt;
		if (tmp == q_s) b = cnt;

	} while (next_permutation(c.begin(), c.end()));
	cout << abs(a - b) << endl;
    return 0;
}

Measured memory_bytes: 3720
h, w = map(int, input().split())
s = [input() for _ in range(h)]
 
hdots = [[0]*(w+1) for _ in range(h)]
for j in range(h):
    ndots = 0
    for i in range(1, w+1):
        if s[j][i-1] == '.':
            ndots += 1
        else:
            hdots[j][i-1] = ndots
            ndots = 0
    hdots[j][-1] = ndots if s[j][-1] == '.' else 0
    for i in range(w, 0, -1):
        if s[j][i-1] == '.':
            hdots[j][i] = ndots
        else:
            ndots = hdots[j][i-1]
vdots = [[0]*w for _ in range(h+1)]
for i in range(w):
    ndots = 0
    for j in range(1, h+1):
        if s[j-1][i] == '.':
            ndots += 1
        else:
            vdots[j-1][i] = ndots
            ndots = 0
    vdots[-1][i] = ndots if s[-1][i] == '.' else 0
    for j in range(h, 0, -1):
        if s[j-1][i] == '.':
            vdots[j][i] = ndots
        else:
            ndots = vdots[j-1][i]
 
ans = 0
for j in range(h):
    for i in range(w):
        nh, nv = hdots[j][i+1], vdots[j+1][i]
        if nh == 0 or nv == 0:
            continue
        ans = max(ans, nh+nv-1)
print(ans)

Measured memory_bytes: 126168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int sum = 0;
  for (int i = 0; i < 10; i++) {
    int a;
    cin >> a;
    sum += a;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3184
#include<iostream>

using namespace std;

const int coin[2] = {5,500};

int main(){
  int money,happy;
  cin >> money;
  int C[2] = {0,0};
  for(int i = 1;i >= 0;i--){
    C[i] = money / coin[i];
    money -= coin[i]*C[i];
  }
  happy = C[0]*5 + C[1]*1000;
  cout << happy << endl;
  return 0;
}

Measured memory_bytes: 3584
def f(a, b, c):
  a1 = a / 2
  a2 = a - a1
  return b * c * abs(a1 - a2)

def main():
  a, b, c = [int(s) for s in raw_input().split()]
  print min(f(a, b, c), f(b, a, c), f(c, a, b))

if __name__ == '__main__':
  main()

Measured memory_bytes: 2572
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	char s[257];
	int i, c;
	while (cin.getline(s, sizeof(s)))
	{
		if (!strcmp(s, "END OF INPUT"))
			break;
		for (i = c = 0; i < strlen(s); i++)
		{
			if (s[i] == ' ' && s[i+1] != '\0')
			{
				cout << c;
				c = 0;
			}
			else
				c++;
		}
		cout << c << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int lli;
const long long int MaxN=200005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	void solve(){
		lli N,legs,i,j,p,q;
		cin>>N>>legs;
		for(i=0;i<=N;i++){
			p=i*2;
			if((legs-p)%4==0){
				if(i+((legs-p)/4)!=N)continue;
				cout<<"Yes\n";
				return;
			}
		}
		cout<<"No\n";
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,j,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
	
}


Measured memory_bytes: 3152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> PL;

ll A;

void solve(){
	cin >> A;
	ll t = (A / 11)*2;
	A %= 11;
	if(1 <= A && A <= 6)t++;
	else if(A > 6)t += 2;
	cout << t << endl;
}

int main(){
	int Tc = 1; //scanf("%d", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

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

using namespace std;

int n, T;
int ans;
int a[200005];

int main()
{
    scanf("%d%d", &n, &T);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        if(a[i] - a[i - 1] > T) ans += T;
        else ans += a[i] - a[i - 1];
    }
    printf("%d", ans + T);
    return 0;
}


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

vector<int> AP;
vector<int> AQ;
vector<int> BP;
vector<int> BQ;

bool check(vector<int> AP, int ap, int r){
	if(AP.size() <= ap) return false;
	if(AP[ap] == r) return true;
	return false;
}

bool dfs(int p, int ap, int aq, int bp, int bq, int l, int r){
	if(p == 1){ // 先手
		if(ap >= AP.size() && aq >= AQ.size()) return true; // 先手の勝ち
	}else{
		if(bp >= BP.size() && bq >= BQ.size()) return false; // 先手の負け
	}
	
	int cnt = 0;
	
	if(p == 0){ // A 先手の番
		if(check(AP, ap, l - 1)){ // 小さいカードを出せる
			++cnt;
			if(dfs((p + 1) % 2, ap + 1, aq, bp, bq, l - 1, r)) return true;
		}
		if(check(AQ, aq, r + 1)){ // 大きいカードを出せる
			++cnt;
			if(dfs((p + 1) % 2, ap, aq + 1, bp, bq, l, r + 1)) return true;
		}
		
		if(cnt == 0){ // パス
			if(dfs((p + 1) % 2, ap, aq, bp, bq, l, r)) return true;
		}
		return false;
	}
	
	else{ //      B 後手の番
		bool possible = true;
		if(check(BP, bp, l - 1)){
			++cnt;
			if(!dfs((p + 1) % 2, ap, aq, bp + 1, bq, l - 1, r)) possible = false;
		}
		if(check(BQ, bq, r + 1)){
			++cnt;
			if(!dfs((p + 1) % 2, ap, aq, bp, bq + 1, l, r + 1)) possible = false;
		}
		
		if(cnt == 0){ // パス
			if(!dfs((p + 1) % 2, ap, aq, bp, bq, l, r)) possible = false;
		}
		return possible;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	
	for(int i = 0;i < n;++i){
		AP.clear();
		AQ.clear();
		BP.clear();
		BQ.clear();
		
		bool used[14] = {};
		int input;
		for(int j = 0;j < 6;++j){
			cin >> input;
			if(input < 7){
				AP.push_back(input);
				used[input] = true;
			}else if(7 < input){
				AQ.push_back(input);
				used[input] = true;
			}
		}
		sort(AQ.begin(), AQ.end());
		sort(AP.begin(), AP.end(), greater<int>());
		
		for(int j = 6;j >= 1;--j){
			if(used[j] == false){
				BP.push_back(j);
			}
		}
		for(int j = 8;j <= 13;++j){
			if(used[j] == false){
				BQ.push_back(j);
			}
		}
		
		/*
		for(int j = 0;j < AP.size();++j){
			cout << AP[j] << ' ';
		}
		cout << "|";
		for(int j = 0;j < AQ.size();++j){
			cout << AQ[j] << ' ';
		}
		cout << endl;
		
		for(int j = 0;j < BP.size();++j){
			cout << BP[j] << ' ';
		}
		cout << "|";
		for(int j = 0;j < BQ.size();++j){
			cout << BQ[j] << ' ';
		}
		cout << endl;
		*/
		
		if(dfs(0, 0, 0, 0, 0, 7, 7)) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	
	return 0;
}



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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: usize,
      aa: [usize; n],
    }
    let mut colors = [0; 9];
    for i in 0..n {
        let r = aa[i]/400;
        if r >= 8 {
            colors[8] += 1;
        } else {
            colors[r] += 1;
        }
    }
    let mut ans = 0;
    for i in 0..8 {
        if colors[i] > 0 {
            ans += 1;
        }
    }
    if ans == 0 {
        println!("{} {}", 1, colors[8]);
    } else {
        println!("{} {}", ans, ans+colors[8]);
    }
}


Measured memory_bytes: 4352
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    for v in a:
        if v % 2 == 0:
            if v % 3 != 0 and v % 5 != 0:
                print("DENIED")
                exit()
    print("APPROVED")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, M;
	cin >> N >> M;
	int S[2000], T[2000];
	rep(i, N) cin >> S[i];
	rep(i, M) cin >> T[i];

	ll mod = 1e9 + 7;
	ll dp[2001];
	ll dp2[2001] = {};

	rep(i, M + 1) dp[i] = 1;
	rep1(i, N) {
		rep1(j, M) {
			if (S[i - 1] == T[j - 1]) {
				dp2[j] = dp[j];
				dp[j] = dp[j - 1] + dp[j];
			}
			else {
				dp[j] = dp[j - 1] + dp2[j];
			}
			if ((i & 15) == 0 || (j & 15) == 0) {
				dp[j] %= mod;
				dp2[j] %= mod;
			}
		}
	}
	co(dp[M] % mod);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

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

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


int dx[5] = {1, 0, -1, 0};
int dy[5] = {0, 1, 0, -1};

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
ll euler_phi(ll n) {
    ll ret = n;
    for(ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            ret -= ret / i;
            while(n % i == 0) n /= i;
        }
    }
    if(n > 1) ret -= ret / n;
    return ret;
}
bool isPrime(int n){
    for(int i=2; i*i<=n; i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

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

    for(int i=x; i<=200000; i++){
        if(isPrime(i)){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	auto it = unique(a.begin(), a.end());
	if(it == a.end()) {
		cout << "YES";
	} else {
		cout << "NO";
	}

	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0;i <n;i++)
#define RFOR(i, n) for(int i = n;i >= 0;i--)
#define REP(i, m, n) for(int i = m;i < n;i++)
#define RREP(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
 
using namespace std;
int main(int argc, char const *argv[]) 
{
  int a,count[26] = {};
 string s;
 cin >>s;

 a = s.size();
 FOR(i,a)
 {
   count[s[i]-'a']++; 
 }
 FOR(i,25)
 {
   if(count[i]%2 != 0)
   {
     cout<<"No"<<endl;
     return 0;
   }
 }

 cout<<"Yes"<<endl;

return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 int main()
 { long i,j,ans,genz,riso,num,plus;
   string s;
  cin >> s ;
  long n;
  
  n=s.size();
  char t[n+2];
  t[0]='D';
  t[n+1]='D';
  for(i=1;i<n+1;i++)
  {
    t[i]=s.at(i-1);
  }
  
  j=0;
  num=0;
  ans=0;
  genz=0;
  plus=0;
  for(i=1;i<n+2;i++)
  {
    if(t[i]=='A')
    { j++;
      genz=genz+j;
      
      num++;
     //cout << 'A' ;
    }
    if(t[i]=='B'&&t[i+1]=='C')
    {
      j++;
     // cout << "BC";
    }
    if((t[i]=='B'&&t[i+1]!='C')||((t[i]=='C'&&t[i-1]!='B')||i==n+1))
    {
      plus=(2*j-num+1)*num/2-genz;
      ans=ans+plus;
      j=0;
      genz=0;
      num=0;
      //cout << "TSUKEMONOISHI";
      
    }
      

    
        
  }   
  cout << ans << endl;

  
    

            }
            
       

Measured memory_bytes: 772
require 'set'
require 'pp'

n, k = gets.chomp!.split(" ").map!(&:to_i)
v_n = gets.chomp!.split(" ").map!(&:to_i)

r = [k, n].min # < 50
max = 0

# i個とる
0.upto(r) do |i|
    # 左からからj個とる.右からi-j個とる
    0.upto(i) do |j|
        0.upto(i) do |l|
            if l + j > i
                break
            end
            
            #pp v_n[0, j]
            #pp v_n[v_n.size - l, l]
            jewelries = (v_n[0,j]+ v_n[v_n.size-l, l]).sort
            
            # 残った回数分負数を除く
            rem = k - (j + l)
            rem.times do |m|
                if jewelries[m] && jewelries[m] < 0
                    jewelries[m] = 0
                end
            end
            #pp jewelries
            sum = jewelries.inject(0) {|s, x| s += x }
            #puts "i=#{i}, j=#{j}, l=#{l}, sum=#{sum}"

            if sum > max
                max = sum
            end
        end
    end
end

puts max


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define first fst
#define second scd
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long


signed main(){
  int n,m;
  cin>>n>>m;
  int a=1;
  rep(i,m){
    a*=2;
  }
  cout<<((m*1900)+(n-m)*100)*a<<endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	void doIt() { 
		String str;
		try {
			str = in.readLine();
			String str1 = str.toUpperCase();
			System.out.println(str1);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
     }
    public static void main(String[] args) {
    	// TODO Auto-generated method stub
    	new Main().doIt();
    }
}

Measured memory_bytes: 17284
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
	vector<char> s;char buf,ast;
	int n,k;
	cin >> n;
	REP(i,n){
		cin >> buf;
		s.push_back(buf);
	}
	cin >> k;
	ast = s[k-1];
	REP(i,n){
		if(s[i]!=ast){
			s[i] = '*';
		}
	}
	REP(i,n){
		cout << s[i];
	}
	return(0);
}


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

int main()
{
  int k,s;
  cin >> k >> s;
  
  int ans = 0;
  for(int x = 0; x <= k; x++){
    for(int y = 0; y <= k; y++){
      int z = s - x - y;
      if( (z >= 0) && (z <= k) ){
        ans++;
      }//if
    }//for
  }//for
  
  cout << ans << endl;

}

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

int main(){
	int N,M;
	cin>>N>>M;
	int p2=1;
	REP(i,M)p2<<=1;
	cout<<p2*(1900*M+100*(N-M))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=105;
//i_am_noob
int a,b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b;
	print1(a*b/2);
	return 0;
}


Measured memory_bytes: 256