akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int b[(int) 1e6+7]={};
int  main(){
    int n,ans=0;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    for(int i=0;i<n;i++){
        if(b[a[i]]!=0){
            b[a[i]]=2;
            continue;
        } 
        
        for(int j=a[i];j<=1e6;j+=a[i]) b[j]++;
    }
    rep(i,n){
        if(b[a[i]]==1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8320
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, M = list(map(int, sys.stdin.readline().split()))

# 1 回の時間は M*1900 + (N-M)*100
time = M * 1900 + (N - M) * 100
# AC になる確率
p_ac = 1 / 2 ** M

print(int(1 / p_ac * time))



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

using namespace std;

int main(){
  int n;
  cin >> n;
  int a[n];
  long long int sum = 0;
  for(int i = 0;i < n;i++)
    cin >> a[i];
  for(int i = 0;i < n;i++){
    for(int j = 0;j < i;j++){
      sum += (a[i] * a[j]);
    }
  }
  cout << sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	ll num_1,num_2;
};

Info delete_max(ll attack_num,ll num_1,ll num_2){

	Info ret;

	if(attack_num <= num_1){

		num_1 -= attack_num;
		ret.num_1 = num_1;
		ret.num_2 = num_2;

	}else{

		ret.num_1 = 0;
		attack_num -= num_1;

		if(attack_num/2 >= num_2){

			ret.num_2 = 0;
		}else{

			ret.num_2 = num_2 - attack_num/2;
			if(attack_num%2 == 1){
				ret.num_1 += 1;
				ret.num_2 -= 1;
			}
		}
	}

	return ret;
}

Info delete_min(ll attack_num,ll num_1,ll num_2){

	Info ret;

	if(attack_num < num_2){

		num_1 += attack_num;
		num_2 -= attack_num;
		ret.num_2 = num_2;
		ret.num_1 = num_1;

	}else{

		num_1 += num_2;
		attack_num -= num_2;
		num_2 = 0;

		num_1 -= attack_num;
		if(num_1 < 0){
			num_1 = 0;
		}
		ret.num_1 = num_1;
		ret.num_2 = 0;
	}

	return ret;
}

int main(){

	ll A,B;
	scanf("%lld %lld",&A,&B);

	ll ans_1 = 0;
	Info tmp_A,tmp_B;

	tmp_A.num_1 = 0;
	tmp_A.num_2 = A;

	tmp_B.num_1 = 0;
	tmp_B.num_2 = B;

	while(true){

		tmp_B = delete_max(tmp_A.num_1+tmp_A.num_2,tmp_B.num_1,tmp_B.num_2);

		if(tmp_B.num_1 == 0 && tmp_B.num_2 == 0){
			break;
		}
		ans_1++;

		tmp_A = delete_min(tmp_B.num_1+tmp_B.num_2,tmp_A.num_1,tmp_A.num_2);

		if(tmp_A.num_1 == 0 && tmp_A.num_2 == 0){
			break;
		}

		ans_1++;
	}


	ll ans_2 = 0;

	tmp_A.num_1 = 0;
	tmp_A.num_2 = A;

	tmp_B.num_1 = 0;
	tmp_B.num_2 = B;

	while(true){

		tmp_B = delete_min(tmp_A.num_1+tmp_A.num_2,tmp_B.num_1,tmp_B.num_2);

		if(tmp_B.num_1 == 0 && tmp_B.num_2 == 0){
			break;
		}
		ans_2++;

		tmp_A = delete_max(tmp_B.num_1+tmp_B.num_2,tmp_A.num_1,tmp_A.num_2);

		if(tmp_A.num_1 == 0 && tmp_A.num_2 == 0){
			break;
		}

		ans_2++;
	}

	printf("%lld\n",min(ans_1,ans_2));

	return 0;
}



Measured memory_bytes: 3236
import time
import itertools
import collections

N = int(input())
start = time.time()
def function(x,y,z):
    return pow(x,2) + pow(y,2) + pow(z,2) + (x * y) + (x * z ) + (y * z)

p = list(itertools.product(range(1,100),repeat=3))
a = []

for p_in in p:
    a.append(function(p_in[0],p_in[1],p_in[2]))

dict = collections.Counter(a)

for n in range(1,N + 1):
    print(dict[n])


Measured memory_bytes: 118524
#include<stdio.h>

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

Measured memory_bytes: 128
/*
  Contest 064
  C - Colorful Leaderboard
  Rakesh Kumar --> 31/08/2020
 */

#include <bits/stdc++.h>

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

    int n = 0;
    std::cin >> n;
    int b = 0;
    std::vector<bool> v(8, false);
    while (n--) {
        int r = 0;
        std::cin >> r;
        if (r < 3200)
            v[r / 400] = true;
        else
            ++b;
    }

    int a = 0;
    for (bool b : v)
        a += b;
    std::cout << std::max(1, a) << " " << a + b << std::endl;

    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<math.h>
#include<map>
#include<queue>
#include <iomanip>
#include<string.h>
using namespace std;
const int  N = 105;
int arr[N];



int main()
{
    int number ;
    cin>>number;
    int x,y,z;
    int count=0;
    for(int i =1;i<=number;i++)
    {
        count = 0;
        for(x=1;x<=i;x++)
        {
            if(x*x>i)
                break;
            for(y=1;y<=i;y++)
            {
                if((x*x+y*y+x*y)>i)
                    break;
                for(z=1;z<=i;z++)
                {
                    if(x*x+y*y+z*z+x*y+x*z+y*z>i)
                        break;
                    if((x*x+y*y+z*z+x*y+x*z+y*z)==i)
                        count++;
                }
            }
        }
         cout<<count<<endl;
    }
   
}


Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main () {
  int N, D;
  cin >> N >> D;
  if (N%(2*D+1)==0) {
    cout<<N/(2*D+1)<<endl;
  } else {
    cout<<N/(2*D+1)+1<<endl;
    
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#define db(x) cout <<#x <<"="<<(x)<<" "
#define el cout<<endl
using namespace std;
const int MXN = 100010, mol = 1000000007;

int n;
char s[2][MXN] = {};
int f[MXN] = {};
int main()
{
    scanf("%d", &n);
    scanf("%s", s[0] + 1);
    scanf("%s", s[1] + 1);
    for (int i = 1; i <= n; ++i)
        if (s[0][i] == s[1][i])
        {
            if (i == 1) f[i] = 3;
            else
            {
                if (s[0][i - 1] == s[1][i - 1])
                    f[i] = f[i - 1] * 2 % mol;
                else
                    f[i] = f[i - 1];
            }
        }
        else
            if (i > 1)
                if (s[0][i] == s[0][i - 1])
                    if (i == 2)
                        f[i] = 6;
                    else
                        if (s[0][i - 2] == s[1][i - 2])
                            f[i] = f[i - 2] * 2 % mol;
                        else
                            f[i] = ((f[i - 2] + f[i - 2]) % mol + f[i - 2]) % mol;
    printf("%d\n", f[n]);
    //for (int i = 1; i <= n; ++i)db(f[i]),el;
    return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
    string S;
    cin >> S;

    ll ans0 = 0;
    // 0101010101...
    for (int i = 0; i < S.size(); ++i) {
        int num = (S[i] == '0') ? 0 : 1;
        if (num != (i % 2)) {
            ++ans0;
        }
    }

    ll ans1 = 0;
    // 1010101010...
    for (int i = 0; i < S.size(); ++i) {
        int num = (S[i] == '0') ? 0 : 1;
        if (num != (i+1)%2) {
            ++ans1;
        }
    }

    ll ans = min(ans0, ans1);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
import qualified Data.ByteString.Char8 as B
import Data.Attoparsec.ByteString.Char8
import qualified Data.IntMap as M
import Data.List
import Data.Char

main :: IO ()
main = do
    Right m <- parseOnly (decimal *> space *> decimal) <$> B.getLine
    Right as <- parseOnly (decimal `sepBy` space) <$> B.getLine
    print $ solve m as

solve :: Int -> [Int] -> Int
solve m =  M.foldl' (+) 0
     . fmap (\x -> x * (x - 1) `div` 2)
     . foldr (\k mp -> M.insertWith (+) k 1 mp)  M.empty
     . map (`mod` m)
     . scanl' (+) 0


Measured memory_bytes: 29820
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[n];
    memset(arr,0,sizeof(arr));
	for(int i=0;i<n;i++)
	{
		int temp;
		cin>>temp;
		arr[temp]++;
	}
	long long int count=1;
	int flag=0;
	for(int i=0;i<n;i++)
	 {
	 	if((arr[i]==1 && i!=0) || arr[i]>2)
	 	 {
	 	 	flag=1;
	 	 	break;
		 }
      if(i==0 && arr[i]==2)
      {
        flag=1;
        break;
      }
		 if(arr[i]==2)
		  count=(count*2)%1000000007;
	 }
	 if(flag!=1)
	  cout<<count<<endl;
	 else
	  cout<<0<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define int long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define w(x) int x;cin>>x;while(t--)
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__);
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

const int POSITIVE_INFINITY = 9223372036854775807;
const int NEGATIVE_INFINITY = -9223372036854775807;
const int MOD = 1000000007;
const ld PI = acos(-1.0);
const int INF = 1e18;
const int MX = 1000001;

int pow(int a, int n , int m){
    int res = 1;
    while(n){
        if(n%2){
            res=(res*a)%m;
            n--;
        }
        a=(a*a)%m;
        n/=2;
    }
    return res;
}

int32_t main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    int total = pow(10,n,MOD);
    int wo9 = (2*pow(9,n,MOD))%MOD;
    int wob = pow(8,n,MOD);
    int res =( total -wo9+wob+MOD)%MOD;
    // res= (res+MOD)%MOD;
    cout<<res<<endl;
 
    
 
    return 0;
}


Measured memory_bytes: 3564
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t) {
	stringstream ss;
	ss << f;
	ss >> t;
}


#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

#define MOD 1000000009LL
#define EPS 1e-8


int a[7]={1,3,5,7,8,10,12},b[4]={4,6,9,11},c[1]={2};
int x,y;
int main(){
    cin>>x>>y;

    REP(i,7){
        if(a[i]==x){
            REP(j,7){
                if(a[j]==y){
                    cout<<"Yes"<<endl;
                    exit(0);
                }
            }
        }
    }

     REP(i,4){
        if(b[i]==x){
            REP(j,4){
                if(b[j]==y){
                    cout<<"Yes"<<endl;
                    exit(0);
                }
            }
        }
    }
    if(x==2&&y==2){
        cout<<"Yes"<<endl;
        exit(0);
    }
    
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
def init(lst):
    l = [lst[0]]
    r = [lst[0]]
    for i in range(1, len(lst)):
        if lst[i - 1] < lst[i]:
            l.append(lst[i])
            r.append(lst[i])
        else:
            l.append(1)
            r.append(lst[i])
    return l, r

n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))

l1, r1 = init(t)
a.reverse()
l2, r2 = init(a)
l2.reverse()
r2.reverse()

l3 = []
r3 = []
for i in range(n):
    if l2[i] <= r1[i] and l1[i] <= r2[i]:
        l = max(l1[i], l2[i])
        r = min(r1[i], r2[i])
        l3.append(l)
        r3.append(r)
    else:
        print(0)
        exit(0)

ans = 1
for i in range(n):
    ans *= r3[i] - l3[i] + 1
    ans %= 10 ** 9 + 7
print(ans)

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

int main(void)
{
    int A, B;
    cin >> A >> B;
    if(A==B)
        cout << "Draw" << endl;
    else if(A==1)
        cout << "Alice" << endl;
    else if(B==1)
        cout << "Bob" << endl;
    else if(A>B)
        cout << "Alice" << endl;
    else if(B>A)
        cout << "Bob" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
typedef long long int l1;
typedef vector <int> vi;
typedef vector <long long int> v1;
#define pb push_back
#define iter(i,a,b) for(i=a;i<b;i++)

int main()
{
    ios_base::sync_with_stdio(false);      //for fast cin and cout streams
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    while(test--)
{
char s;
cin>>s;
      if(s>=65&&s<=90)
        cout<<"A";
      else
        cout<<"a";
      



    
   

}

return 0;
}






Measured memory_bytes: 3648
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=1000000000;

ll n=-1; int nq;
bool query(ll x) {
	if(x==0) return true;
	if(x<=0||x>=1000000000000000000LL) printf("n=%lld, err\n",n);
	++nq;
	if(n==-1) {
		printf("? %lld\n",x); fflush(stdout);
		char res; scanf(" %c",&res); return res=='Y';
	} else {
		char a[20],b[20];
		sprintf(a,"%lld",n); sprintf(b,"%lld",x);
		bool xa=x<=n;
		bool xb=strcmp(b,a)<=0;
		bool ret=xa&&xb||!xa&&!xb;
		//printf("? %lld = %c (%d,%d)\n",x,ret?'Y':'N',x<=n?1:0,strcmp(b,a)<=0?1:0); fflush(stdout);
		return ret;
	}
}

ll solve() {
	ll l=1;
	while(l*10<=MAXN) l*=10;
	if(query(l)&&query(10*l)&&query(l-1)) {
		l=1;
		while(!query(l+1)) l*=10;
		return l;
	}
	while(true) {
		if(!query(l-1)) break;
		if(!query(l)) { l/=10; continue; }
		break;
	}
	ll r=min(10*l,(ll)MAXN+1);
	while(l+1<r) {
		ll m=l+(r-l)/2;
		if(!query(10*(m-1))) l=m; else r=m;
	}
	return l;
}

void run() {
	printf("! %lld\n",solve());
}

void test() {
	scanf("%lld",&n);
	printf("! %lld\n",solve());
}

void stress() {
	int mxq=0;
	for(n=1;n<=10000;++n) {
		nq=0;
		ll have=solve();
		if(have!=n) { printf("err %lld\n",n); }
		if(nq>mxq) mxq=nq;
	}
	for(ll bn=1;bn<=MAXN;bn*=10) {
		for(int j=-100;j<=+100;++j) {
			n=bn+j; if(n<1||n>MAXN) continue;
			nq=0;
			ll have=solve();
			if(have!=n) { printf("err %lld\n",n); }
			if(nq>mxq) mxq=nq;
		}
	}
	REP(i,1000) {
		ll bn=rand()%1000*1000000+rand()%1000*1000+1;
		REP(t,2) REP(j,100) {
			if(t==0) n=bn+j; else n=bn+1000-j-1; nq=0;
			ll have=solve();
			if(have!=n) { printf("err %lld\n",n); }
			if(nq>mxq) mxq=nq;
		}
	}
	printf("mxq=%d\n",mxq);
}

int main() {
	run();
	//test();
	//stress();
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++) cin >> X[i];

    int ans = 10000000;
    for (int i = 1; i <= 100; i++) {
        int total = 0;
        for (int j = 0; j < N; j++) {
            total += (X[j] - i) * (X[j] - i);
        }
        ans = min(ans, total);
    }

    cout << ans << endl;
}

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

int main()
{
  int n;

  cin >> n;

  vector<int> ans(n);

  int total = 0;

  for (int i = 1; i < sqrt(n); i++)
  {
    for (int j = 1; j < sqrt(n); j++)
    {
      for (int k = 1; k < sqrt(n); k++)
      {
        total = i * i + j * j + k * k + i * j + j * k + i * k;
        if (n >= total)
          ans.at(total-1)++;
      }
    }
  }
  rep(i, n) cout << ans.at(i) << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int a[200001];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a, a+n);
    long long ans = 1;
    if(k%2 == 1){
        if(a[n-1] == 0){
            printf("0\n");
            return 0;
        }
        else if(a[n-1] < 0){
            long long ans = 1;
            for(int i=n-1;i>=n-k;i--) ans = ans*1ll*(a[i]+mod)%mod;
            printf("%lld\n", ans);
            return 0;
        }
        else{
            ans = ans*1ll*a[n-1]%mod;
            k--;
            n--;
        }
    }
    int l = 0, r = n-1;
    while(k > 0){
        if(a[l]*1ll*a[l+1] > a[r]*1ll*a[r-1]){
            ans = ans*1ll*(a[l]+mod)%mod;
            ans = ans*1ll*(a[l+1]+mod)%mod;
            l+=2;
        }
        else{
            ans = ans*1ll*(a[r]+mod)%mod;
            ans = ans*1ll*(a[r-1]+mod)%mod;   
            r-=2;
        }
        k-=2;
    }
    printf("%lld\n", ans);
}

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

int main() { 
    int n;
    map<int, long long> mp;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        mp[a[i]]++;
    }
    long long sum = 0;
    auto begin = mp.begin(), end = mp.end();
    for (auto iter = begin; iter != end; iter++) {
        sum += iter->second*(iter->second-1)/2;
    }

    for(int i = 0; i < n; ++i) {
        cout << sum - mp[a[i]]*(mp[a[i]]-1)/2 + max(mp[a[i]]-2, 0ll)*(mp[a[i]]-1)/2 << "\n";
    }

    return 0;
}


Measured memory_bytes: 10240
#[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")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

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

#[allow(unused)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

#[allow(unused)]
fn lcm(x: i64, y: i64) -> i64 {
    x * y / gcd(x, y)
}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        n: usize,
        a: [f64; n],
    }

    let mut tmp: f64 = 0.0;

    for i in 0..n {
        tmp += 1.0 / a[i];
    }

    println!("{}", 1.0 / tmp);
}


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

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


void solve(long long X, long long K, long long D){
    ll ans = 0;
    X = abs(X);

    if(X/K >= D){
        ans = X - (K*D);
        cout << ans << endl;
        return;
    }

    ll d = X / D;
    X = X-(D*d);
    K = K - d;
    if(K % 2 == 0) ans = X;
    else ans = abs(X-D);
    cout << ans << endl;
    return;

}
int main(){
    long long X;
    scanf("%lld",&X);
    long long K;
    scanf("%lld",&K);
    long long D;
    scanf("%lld",&D);
    solve(X, K, D);
    return 0;
}


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

const int INF = 1e9;

int main() {
	int V, E;
	cin >> V >> E;
	vector<vector<int>> G(V, vector<int>(V, INF));
	for (int i=0;i<E;i++) {
		int s, t, d;
		cin >> s >> t >> d;
		G[s][t] = d;
	}

	int ans = INF;
	for (int s=0;s<V;s++) {
		vector<vector<int>> dp((1<<V), vector<int>(V, INF));
		dp[(1<<s)][s] = 0;
		for (int i=0;i<(1<<V);i++) {
			for (int j=0;j<V;j++) {
				for (int k=0;k<V;k++) {
					if (dp[i][j] != INF && G[j][k] != INF && (i&(1<<k)) == 0) {
						dp[i+(1<<k)][k] = min(dp[i+(1<<k)][k], dp[i][j]+G[j][k]);
					}
				}
			}
		}
		for (int i=0;i<V;i++) {
			if (G[i][s] != INF) {
				ans = min(ans, dp[(1<<V)-1][i]+G[i][s]);
			}
		}
	}
	if (ans == INF) cout << -1 << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 6260
#include<bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll
#define np next_permutation
#define PI acos(-1)
#define deb(x) cout<<#x<<" "<<x<<endl;


int main() {
    auto start = chrono::high_resolution_clock::now();
    fio;
    ll t=1; 
   // cin>>t;
    while(t--)
    {
		
		ll n; cin>>n;
		ll sum=0;
		for(ll i=1;i<=n;i++)
		{
			for(ll j=1;j<=n;j++)
			{
				for(ll k=1;k<=n;k++)
				{
					ll x=__gcd(i,j);
					sum+=__gcd(k,x);
				}
			}
		}
		
		
		
		
	cout<<sum<<"\n";

		
    }



    auto finish = chrono::high_resolution_clock::now();
    cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
    return 0;
        
}


Measured memory_bytes: 3804
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		long N = sc.nextLong();
		long K = sc.nextLong();

		long ans = Math.min(N % K, Math.abs(N % K - K));

		System.out.println(ans);
	}

}



Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b)
    {
        cout<<"a > b"<<endl;
    }
    else if(a<b)
    {
        cout<<"a < b"<<endl;
    }
    else
    {
        cout<<"a == b"<<endl;
    }
}



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

int main(){
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if(i%2==0 && s[i]=='L' || i%2==1 && s[i]=='R')
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
lst = []

for i in range(n):
    lst.append(abs(a-(t-h[i]*0.006)))

for i in range(n):
    if lst[i]==min(lst):
        print(i+1)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	int i;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	long long int min = 1000000;
	long long int sum = 0;

	for (i = -100; i <= 100; i++)
	{
		sum = 0;
		for (int t = 0; t < n; t++)
		{
			sum += pow(i - a[t], 2);
		}
		if (min > sum)
		{
			min = sum;
		}
	}

	cout << min<<endl;
	return 0;
}

Measured memory_bytes: 256
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 405;
vc < vc <ll> > dp (mxn, vc <ll> (mxn));
// dp[i][j] -> the min cost of combining (i, j) into one vertex

int32_t main(){
    FastIO;
    int n; cin >> n;
    vc <ll> a(n);
    for(int i=0; i<n; i++) cin >> a[i];

    auto sum = [&](int l, int r) {
        ll s=0;
        for(int i=l; i<=r; i++) {
            s += a[i];
        }
        return s;
    };

    // iterate through small intervals
    for(int l=n-1; l>=0; l--) {
        for(int r=l; r<n; r++) {
            if(l == r) dp[l][r] = 0;
            else {
                dp[l][r] = inf;
                auto s = sum(l, r);
                for(int i=l; i<= r-1; i++) {
                    dp[l][r] = min(dp[l][r], dp[l][i] + dp[i+1][r] + s);
                }
            }
        }
    }
    cout << dp[0][n-1] << endl;
    return 0;
}


Measured memory_bytes: 1536
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
from fractions import gcd
# import itertools

# from operator import attrgetter, itemgetter
# import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, x = list(map(int,readline().split()))
    city = list(map(int,readline().split()))

    diff = [abs(city[i] - x) for i in range(n)]

    ans = diff[0]
    for i in range(1, n):
        ans = gcd(ans,diff[i])
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 85012
/*** I came, I saw, I conquered. ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;typedef unsigned long long ull;
#define sc(a) cin >> a
#define pf(a) cout << a << endl
#define forIn(arr, num) for(ll i = 0; i < num; i++) cin >> arr[i];
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define mod 1000000007
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define GET_SET_BITS(a) (__builtin_popcount(a))
#define GET_SET_BITSLL(a) ( __builtin_popcountll(a))
#define GET_TRAIL_ZERO(a) (__builtin_ctz(a))
#define GET_LEAD_ZERO(a) (__builtin_clz(a))
#define GET_PARITY(a) (__builtin_parity(a))
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
void go() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
/*----------------------------------------------------------------*/
void solve() {
    int x;
    cin >> x;
    pf(!x);
}

int main() {
    go();
    solve();
    return 0;
}

Measured memory_bytes: 3648
require 'pp'

def gets; ARGF.gets; end

class Solver
  def main
    a, b = gets.split.map(&:to_i)
    # puts a, b

    # 2進数で1の桁から順に論理和を計算していく
    # 10^12 = 2^40

    ans = 0
    0.upto(40) do |i|
      # i桁目について:
      # A-1 までに1がいくつ立っているか->偶数？奇数？がわかれば良い
      isEvenA = isEvenBits(a-1, i)
      isEvenB = isEvenBits(b, i)

      if isEvenA != isEvenB
        ans += (1 << i)
      end
    end
    puts ans
  end

  # i桁目について、n以下の整数でいくつbitが立っているか？
  # というか偶数か奇数か？
  def isEvenBits(n, i)
    if n <= 0
      true
    elsif i == 0
      r = n % 4
      (r == 0 || r == 3)
    elsif n[i] == 0
      true
    else
      n.odd?
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
#define debug 1

int main() {
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n;
	cin>>n;
	int fir=0,sec=0;
	int a[n];
	
	for(int i=0;i<n;i++) {
		cin>>a[i];
		if(a[i]>fir) fir=a[i];
		else if(a[i]>sec) sec=a[i];
	}
	for(int i=0;i<n;i++) {
		if(a[i]==fir) cout<<sec<<endl;
		else cout<<fir<<endl;
	}
	return 0;
}


Measured memory_bytes: 2432
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int32_t main()
{
	int n;
	cin >> n;
	int a[n+1];
	bool ok = false;
	for(int i = 1 ; i <= n ; i++ ){
		cin >> a[i];
		if(a[i]==1){
			ok = true;
		}
	}
	if(!ok){
		cout<<"-1";
		return 0;
	}
	int ans = 0;
	int pos = 1;
	for(int i = 1 ; i<= n ; i++ ){
		if(a[i]==pos){
			ans++;
			pos++;
		}
	}
	cout<<n-ans;
}


Measured memory_bytes: 1792
import itertools
def solve():
    N = int(input())
    p = list(map(int, input().split()))

    one_cnt = 0
    swap_cnt = 0
    for i in range(N):
        if p[i] == i + 1:
            one_cnt += 1
        else:
            if one_cnt % 2 == 0:
                swap_cnt += one_cnt / 2
            else:
                swap_cnt += one_cnt // 2 + 1
            one_cnt = 0
    
    else:
        if one_cnt % 2 == 0:
            swap_cnt += one_cnt / 2
        else:
            swap_cnt += one_cnt // 2 + 1

    print(int(swap_cnt))

if __name__ == '__main__':
    solve()


Measured memory_bytes: 52332
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  int len  = n + 1;
  int maxi = 0;
  rep (i, len) {
    int l = i;
    while (i < len && s[i] == '1') ++i;
    maxi = max(maxi, i - l);
  }
  if (m <= maxi) {
    cout << -1 << endl;
    return 0;
  }
  int now = n;
  vector<int> ans;
  while (now) {
    int prev = now;
    now -= m;
    while (now < 0 || s[now] == '1') ++now;
    ans.push_back(prev - now);
  }
  reverse(all(ans));
  rep (i, ans.size()) cout << ans[i] << (i < ans.size() - 1 ? " " : "\n");
  return 0;
}

Measured memory_bytes: 1096
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int POW[20];

int main(){

	POW[0] = 1;
	for(int i = 1; i < 20; i++){

		POW[i] = POW[i-1]*2;
	}

	int M,K;
	scanf("%d %d",&M,&K);

	if(M == 1){

		if(K == 0){

			printf("0 0 1 1\n");

		}else{

			printf("-1\n");
		}

		return 0;
	}

	if(K >= POW[M]){

		printf("-1\n");
		return 0;
	}

	vector<int> A,B;
	for(int i = 0; i < POW[M]; i++){
		if(i == K)continue;

		A.push_back(i);
		B.push_back(i);
	}
	A.push_back(K);
	for(int i = B.size()-1; i >= 0; i--){

		A.push_back(B[i]);
	}
	A.push_back(K);

	printf("%d",A[0]);

	for(int i = 1; i < A.size(); i++){

		printf(" %d",A[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 3568
n = int(input())
s = input()
ans = 0

def my_index(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default
      
for i in range(1000):
  ss = str(i)
  if len(ss) == 1:
    ss = "00" + ss
  elif len(ss) == 2:
    ss = "0" + ss
  k = my_index(s, ss[0])
  if k < 0:
    continue
  else:
    kk = my_index(s[k+1:], ss[1])
    if kk < 0:
      continue
    else:
      kkk = my_index(s[k+1:][kk+1:], ss[2])
      if kkk < 0:
        continue
      else:
        ans += 1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{

    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    vector<int> fact(n + 1, 1);
    rep(i, n)
    {
        fact[i + 1] = (i + 1) * fact[i];
    }

    rep(i, n)
    {
        cin >> p[i];
    }
    rep(i, n)
    {
        cin >> q[i];
    }

    int np = 1, nq = 1;
    rep(i, n)
    {
        auto unused = vector<int>(p.begin() + i, p.end());
        sort(unused.begin(), unused.end());
        int order = distance(unused.begin(), find(unused.begin(), unused.end(), p[i]));
        np += fact[n - i - 1] * (order);

        auto uq = vector<int>(q.begin() + i, q.end());
        sort(uq.begin(), uq.end());
        int oq = distance(uq.begin(), find(uq.begin(), uq.end(), q[i]));
        nq += fact[n - i - 1] * oq;
    }

    cout << abs(np - nq) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for (int64_t i = (a); i <= (b); i++)
#define REP(i,n) rep(i,0,n)
#define be(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};

bool f(int x)
{
    rep(i,2,sqrt(x))if(x/i*i==x)return false;
    return true;
}

int main()
{
    int x;
    while(cin>>x)
    {
        if(x==0)return 0;
        int ans=0;
        rep(i,x+1,2*x)
        {
            if(f(i))ans++;
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3100
module ABC125

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_C
  private :: calculate_gcd

  ! variables for this <module>
  integer(INT32), private              :: num_integers
  integer(INT32), private, allocatable :: list_integer (:)
  integer(INT32), private, allocatable :: list_gcd_fore(:)
  integer(INT32), private, allocatable :: list_gcd_rear(:)
  integer(INT32), private, allocatable :: list_gcd_max (:)

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_C

    ! support variables for this <subroutine>
    integer(INT32) :: itr

    ! STEP.01
    ! read out the number of given integers
    read(unit=INPUT_UNIT, fmt=*) num_integers

    ! STEP.02
    ! allocate the array to store the given integers
    allocate( list_integer (1:num_integers  ) )
    allocate( list_gcd_fore(0:num_integers+1) )
    allocate( list_gcd_rear(1:num_integers+1) )
    allocate( list_gcd_max (1:num_integers  ) )

    ! STEP.03
    ! read out the given integers
    read(unit=INPUT_UNIT, fmt=*) list_integer(1:num_integers)

    ! STEP.04
    ! calculate the greatesst common divisors
    list_gcd_fore(0               ) = 0_INT32
    list_gcd_rear(num_integers + 1) = 0_INT32

    do itr = 0_INT32, num_integers, 1_INT32
      list_gcd_fore(itr+1) = calculate_gcd( list_gcd_fore(itr), list_integer(itr) )
    end do

    do itr = num_integers, 1_INT32, -1_INT32
      list_gcd_rear(itr) = calculate_gcd( list_gcd_rear(itr+1), list_integer(itr) )
    end do

    do itr = 1_INT32, num_integers, 1_INT32
      list_gcd_max(itr) = calculate_gcd( list_gcd_fore(itr), list_gcd_rear(itr+1) )
    end do

    ! STEP.05
    ! output the maximum greatest common divisor
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') maxval( list_gcd_max(:), dim=1 )

    ! STEP.06
    ! deallocate the array to store the given integers
    deallocate( list_integer  )
    deallocate( list_gcd_fore )
    deallocate( list_gcd_rear )
    deallocate( list_gcd_max  )

    ! STEP.END
    return

  end subroutine task_C

  recursive function calculate_gcd (x, y) result(gcd)

    ! arguments for this <function>
    integer(INT32), intent(in) :: x, y

    ! return value of this <function>
    integer(INT32) :: gcd

    if (y .eq. 0_INT32) then
      gcd = x
    else
      gcd = calculate_gcd(y, mod(x, y))
    end if

    return

  end function calculate_gcd

end module ABC125


program main

  ! <module>s to import
  use, non_intrinsic :: ABC125

  ! require all variables to be explicitly declared
  implicit none

  call task_C

end program main

Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
#include<cmath>
#include <iomanip> 
using namespace std;




int main(void){
    double L=0.0;
    cin >> L;
    double res = 0.0;

    cout << fixed << setprecision(20) << pow(L,3)/27.0 << endl;




    return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int a[50];
int ans=0;
int main()
{
	int n,m;	cin>>n>>m;
	for(int i=1;i<=n;i++){
		int l;	cin>>l;
		for(int j=1;j<=l;j++){
			int k;	cin>>k;
			a[k]+=1;
		}
	}
	for(int i=1;i<=m;i++)
		if(a[i]==n)
			ans++;
	cout<<ans<<endl;
}


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

#define F first
#define S second
#define int long long
#define inf 1000000000
#define mod 1000000007

using namespace std;

signed main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int> > g(n);
    for (int i = 0; i < m; i++){
        int v, u;
        cin >> v >> u;
        g[--u].push_back(--v);
        g[v].push_back(u);
    }
    vector<int> ans(n, -1);
    queue<int> q;
    q.push(0);
    while (!q.empty()){
        int cur = q.front();
        q.pop();
        for (int i = 0; i < (int)g[cur].size(); i++){
            int nxt = g[cur][i];
            if (ans[nxt] == -1){
                ans[nxt] = cur+1;
                q.push(nxt);
            }
        }
    }
    for (int i = 1; i < n; i++){
        if (ans[i] == -1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 12868
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
	int n;
	cin >> n;
	map<int, int> mp;
	rep(i, n) {
		int a;
		cin >> a;
		mp[a]++;
	}
	ll w = 0, h = 0;
	for (auto a : mp) {
		if (a.second >= 4) {
			if (w < a.first) {
				w = h = a.first;
			}
			else if (h < a.first) h = a.first;
		}
		else if (a.second >= 2) {
			if (w < a.first) {
				h = w;
				w = a.first;
			}
			else if (h < a.first) h = a.first;
		}
	}
	cout << w * h << endl;
	return 0;
}


Measured memory_bytes: 8264
using System.Collections.Generic;
using System.Linq;
using System;
class Program
{
    static void Main()
    {
        string input = Console.ReadLine();
        int num = int.Parse(input);

        var root = Math.Sqrt(num);
        int rootInt = (int)root;
        int result = rootInt * rootInt;
        Console.WriteLine(result.ToString());
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

#define INF 1e17

class Graph {
    private:
        int _num_v;
        vector<pair<int, long long>> *_adj;

    public:
        Graph(int num_v);
        void addEdge(int u, int v, long long w);
        vector<long long> shortestPath(int s); 
};

Graph::Graph(int num_v) {
    _num_v = num_v;
    _adj = new vector<pair<int, long long>> [num_v];
}

void Graph::addEdge(int u, int v, long long w) {
    _adj[u].push_back({v, w});
    _adj[v].push_back({u, w});
}

vector<long long> Graph::shortestPath(int s) {
    priority_queue<pair<int, long long>, vector<pair<int, long long>>, greater<pair<int, long long>>> q;
    vector<long long> dist(_num_v, INF);

    q.push({0, s});
    dist[s] = 0;

    while (!q.empty()) {
        int u = q.top().second;
        q.pop();

        for (auto &p: _adj[u]) {
            int v = p.first;
            long long w = p.second;

            if (dist[v] > dist[u] + w) {
                dist[v] = dist[u] + w;
                q.push({dist[v], v});
            }
        }
    }

    return dist;
}


int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--, t--;

    int u, v;
    long long a, b;
    Graph ga(n), gb(n);
    for (int i = 0; i < m; i++) {
        cin >> u >> v >> a >> b;
        u--, v--;
        ga.addEdge(u, v, a);
        gb.addEdge(u, v, b);
    }

    vector<long long> dista = ga.shortestPath(s);
    vector<long long> distb = gb.shortestPath(t);

    vector<long long> ans(n+1, INF);
    for (int i = n-1; i >= 0; i--) {
        ans[i] = min(ans[i+1], dista[i] + distb[i]);
    }

    long long tmp = 1e15;
    for (int i = 0; i < n; i++) {
        cout << tmp - ans[i] << endl;
    }
}


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

using namespace std;

int main (){

  int n,k;
  int ans=0;
  cin>>n>>k;
  vector <int> h(n);
  
  for(int i=0; i<n;i++){
  	cin>>h.at(i);
  }
  
  for(int j=0; j<n; j++){
  	if(h.at(j)>=k) ans++;
  }
   cout<<ans<<endl;
  
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int x, y;
  x = (s[0] - '0') * 10 + (s[1] - '0');
  y = (s[2] - '0') * 10 + (s[3] - '0');
  int mask = 0;
  if (x >= 1 && x <= 12) mask |= 1;
  if (y >= 1 && y <= 12) mask |= 2;
  if (mask == 3) {
    cout << "AMBIGUOUS" << endl;
  } else if (mask == 1) {
    cout << "MMYY" << endl;
  } else if (mask == 2) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
  return 0;
}


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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;

ll sum;
map<ll, int>m;

int main(){
	setIO();
	int n; cin >> n;
	for (int i = 0; i < n; i++){
		int x; cin >> x;
		sum += x;
		m[x]++;
	}
	int q; cin >> q;
	for (int i = 0; i < q; i++){
		ll a, b; cin >> a >> b;
		sum += (m[a]*b);
		sum -= (m[a]*a);
		m[b] += m[a];
		m[a] = 0;
		cout << sum << endl;
	}
}

Measured memory_bytes: 9432
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    go_back_home = True
    if "N" in S:
        if "S" not in S:
            go_back_home = False
    if "S" in S:
        if "N" not in S:
            go_back_home = False
    if "W" in S:
        if "E" not in S:
            go_back_home = False
    if "E" in S:
        if "W" not in S:
            go_back_home = False

    ans = "Yes" if go_back_home else "No"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3068