akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

vint x;
double n,dis[20][20];
int m;
string str;
double dp[5000][15];

void input(){
	int c;
	x.clear();
	m=0;
	bool first=true;
	int num=0;
	int i;
	for(i=0;i<str.size();i++){
		c=str[i];
		if(c==' '){
			if(first){
				n=num;
				num=0;
				first=false;
			}else{
				x.push_back(num);
				m++;
				num=0;
			}
		}else{
			num=num*10+c-'0';
		}
	}
	if(num!=0){x.push_back(num);m++;}
	return;
}

void hoge(int i,int j){
//cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
	int k;
	double res=-2;
	if(dp[i][j]!=-1)return;
	if(i&1<<j){
		int ii=i^1<<j;
		for(k=0;k<m;k++){
			hoge(ii,k);
//cout<<" "<<ii<<" "<<k<<" "<<dp[ii][k]<<" "<<x[j]<<" "<<x[k]<<endl;
			if(dp[ii][k]==-2)continue;
			else if(res==-2)res=dp[ii][k]+dis[x[j]][x[k]];
			else chmin(res,dp[ii][k]+dis[x[j]][x[k]]);
		}
	}
	dp[i][j]=res;
//cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
}

int main() {
	int i,j;
	for(i=0;i<20;i++){
		for(j=0;j<20;j++){
			dis[i][j]=sqrt(double((i+j)*(i+j)-(i-j)*(i-j)));
		}
	}
	while(getline(cin,str)){
		input();
		int i;
//for(i=0;i<m;i++)cout<<x[i]<<endl;
		for(i=0;i<5000;i++){
			for(j=0;j<15;j++){
				dp[i][j]=-1;
			}
		}
		for(i=0;i<m;i++)dp[1<<i][i]=x[i];
		for(i=0;i<m;i++){
			hoge((1<<m)-1,i);
			dp[(1<<m)-1][i]+=x[i];
		}
		double res=100100100;
		for(i=0;i<m;i++)chmin(res,dp[(1<<m)-1][i]);
		cout<<(n>=res?"OK":"NA")<<endl;
	}
	return 0;
}

Measured memory_bytes: 1488
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        Integer r = Integer.parseInt(sc.next());
        Integer r2 =  r * r * 314;
        Integer result = r2 / 314;
        System.out.println(result);
    }
}

Measured memory_bytes: 21844
import Control.Monad
import Data.Bool
import Data.List

readInt = readLn :: IO Int
readInts = map read . words <$> getLine :: IO [Int]
readNInts = flip replicateM readInts

main :: IO ()
main = do
    [a,b] <- readInts
    print $ if b `mod` a == 0
                  then a + b
                  else b - a


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

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;



int main(){
  int n, k;
  cin >> n >> k;

  //    cout << "a";
  vector<ll> a(n);
  
  rep(i,n)    cin >> a.at(i);

  int flag = 0;
  ll tmp_min = *min_element(a.begin(), a.end());
  ll tmp_max = *max_element(a.begin(), a.end());

  if (k>tmp_max) {
      cout << "IMPOSSIBLE" << endl;
      return 0;      
  }

  ll tmp = a.at(0);
  rep(i, n) {
    tmp = __gcd(tmp, a.at(i));
  }
  
  
  if (k%tmp==0) {
    cout << "POSSIBLE" << endl;
    return 0;
  }
  else {
      cout << "IMPOSSIBLE" << endl;
      return 0;
  }
  
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
  long long x;
  cin >> x;
  if(x % 11 == 0) cout << x / 11 * 2 << endl;
  else if(x % 11 <= 6) cout << x / 11 * 2 + 1<< endl;
  else cout << x / 11 * 2 + 2 << endl;

  return 0;
}


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

int main() {
  int X;
  cin>>X;
  int A=1;
    cin>>A;
  if(X==2){
    cout<<2<<endl;
  }
  else
  {for (int i = 0; i < X; i++) {
    
    
    for (int j = 2; j <sqrt(X+i) ; j++) {
      if(__gcd(j, X+i)!=1){
        break;
      }
      else if(
        j>sqrt(X+i)-1)
      {cout<<X+i<<endl;
       A=0;
      }
      else {
        continue;
      }
    }
      if (A==0){
        break;}
 
}
  }   
 


}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[][] a = new int[n][m];
        int[] count = new int[m];
        int ans = 0;
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[a[i][j] - 1]++;
            }
        }
        for (int i = 0; i < m; i++) {
            if (count[i] == n)
                ans++;
        }
        System.out.println(ans);
    }
}

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

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

    vector<int> a(3);
    for(int i=0;i<3;i++)cin>>a[i];

    sort(a.begin(),a.end(),greater<int>());

    int ans=0;
    ans+=a[0]-a[1];
    ans+=(a[1]-a[2])/2;
    ans+=((a[1]-a[2])%2)*2;

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3664
#include "iostream"
#include "string"


int main()
{
	int tempX = 1;
	int tempY = 1;
	short int x[3000], y[3000];
	int i = 0;

	while (tempX != 0 || tempY != 0) {
		std::cin >> tempX >> tempY;
		x[i] = tempX;
		y[i] = tempY;
		i++;
	}

	i = 0;
	while (x[i] != 0 || y[i] != 0){
		if (x[i] >= y[i]){
			tempX = x[i];
			x[i] = y[i];
			y[i] = tempX;
		}
		i++;
	}

	i = 0;
	while (x[i] != 0 || y[i] != 0) {
		std::cout << x[i] << " " << y[i] << std::endl;
		i++;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second
 
const int MOD = 1e9 + 7;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0}; 
const char dir[] = {'R', 'L', 'D', 'U'};
 
int add(int a, int b){
    a += b;
    if(a >= MOD){
        a -= MOD;
    }
    return a;
}
 
int sub(int a, int b){
    a -= b;
    if(a < 0) a += MOD;
    return a;
}
 
int mult(int a, int b){
    return ((ll) a * b) % MOD;
}
 
void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    freopen((s+".in").c_str(),"r",stdin);
//    freopen((s+".text").c_str(),"w",stdout);
}
 
//ctrl q is comment
//ctrl b is run
//ctrl s is compile
//alt r is search & replace
//alt d is delete a line
 
int main(){
    setIO();
    string s; cin >> s;
    int n = s.length();
    int sz = 0;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] != 'R'){
            ans = max(ans, sz);
            sz = 0;
        }
        else ++sz;
    }
    cout << max(sz, ans) << "\n";
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;
int n, p;
ll dp[55][55555];
int a[111];

int main(void) {
  scanf("%d%d", &n, &p);
  for (int i = 0; i < n; i++) scanf("%d", a+i);
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 50000; j >= 0; j--) {
      dp[i+1][j] += dp[i][j];
      if (j+a[i] <= 50000) dp[i+1][j+a[i]] += dp[i][j];
    }
  }
  ll res = 0;
  for (int i = 0; i < 55555; i++) {
    if (i%2 == p) res += dp[n][i];
  }
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 22144
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

#define MP       make_pair
#define PB       push_back
#define ALL(x)   (x).begin(),(x).end()

const int INF = 1<<29;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

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


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);

  int N, M, L, K, A, H;
  while( cin>>N>>M>>L>>K>>A>>H, N ){

    bool isRei[N+1];
    memset( isRei, 0, sizeof(isRei) );
    REP(_t,L){
      int rei;
      cin >> rei;
      isRei[rei] = true;
    }
    isRei[A] = isRei[H] = true;

    int cost[N+1][N+1];
    REP(_t,N+1){
      fill( cost[_t], cost[_t]+N+1, INF );
      cost[_t][_t] = 0;
    }
    REP(_t,K){
      int X,Y,T;
      cin >> X >> Y >> T;
      cost[X][Y] = cost[Y][X] = T;
    }

    REP(k,N+1)
      REP(i,N+1)
      REP(j,N+1)
      cost[i][j] = min( cost[i][j], cost[i][k] + cost[k][j] );

    REP(i,N+1){
      REP(j,N+1) {
	if( cost[i][j] > M )
	  cost[i][j] = INF;
	else if( isRei[i] != isRei[j] )
	  cost[i][j] = INF;
      }
    }

    REP(k,N+1)
      REP(i,N+1)
      REP(j,N+1)
      cost[i][j] = min( cost[i][j], cost[i][k] + cost[k][j] );   

    if( cost[A][H] == INF )
      cout << "Help!" << endl;
    else{
      int res = cost[A][H] + max(0,cost[A][H]-M);
      cout << res << endl;
    }
  }


  return 0;
}

Measured memory_bytes: 1212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Competition
{
    public class Program
    {
        
        static void Main(string[] args)
        {
            var r = int.Parse(Console.ReadLine());
            Console.WriteLine(r * r);
        }

    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int m , n ,f[200005] , l ,sum, x,y,book[200005];
int df(int u)
{
	 if(f[u] ==u ) return u;
	 else 
	 {
	 	 f[u] = df(f[u]);
	 	 return f[u];
	 }
}
void getf(int t1 ,int t2)
{
	int k1 = df(t1) ;
	int k2 = df(t2) ;
	
    f[k2] = k1 ;

}
int main()
{   
    cin >> n >> m ;
	for(int i = 1 ; i <= n; i++) f[i] = i ;
	for(int i = 1; i <= m; i++)
	{ 
	   cin >> x >> y ;
	   getf(x,y);
	}
	
	for(int i = 1 ; i <= n; i++) df(i);
	
	for(int i = 1 ; i <= n; i++)  book[f[i]]++;
	
	for(int i = 1 ; i <= n; i++)
	sum = max(sum,book[i]);
	
	cout << sum ;
	return 0 ; 
}

Measured memory_bytes: 4704
k = input()
d = int(input())
n = len(k)
mod = 10**9 + 7

MOD = [[0] * 10 for i in range(n)]
# for i in range(1, 10):
#     MOD[0][i] = (MOD[0][i-1] + 1) % d
# for i in range(1, n):
#     for j in range(10):
#         MOD[i][j] = (MOD[i-1][j] * 10) % d

for i in range(n):
    for j in range(10):
        MOD[i][j] = j % d

D = [0] * d
h = 0
for i in range(int(k[0])):
    D[MOD[n-1][i]] += 1
h = MOD[n-1][int(k[0])]

for i in range(1, n):
    # print(D)
    DN = [0] * d
    for j in range(10):
        for l in range(d):
            DN[(l + MOD[n-1-i][j]) % d] = (DN[(l + MOD[n-1-i][j]) % d] + D[l]) % mod
    for j in range(int(k[i])):
        DN[(h + MOD[n-1-i][j]) % d] = (DN[(h + MOD[n-1-i][j]) % d] + 1) % mod
    h = (h + MOD[n-1-i][int(k[i])]) % d
    D = DN[:]
# print(D)

D[h] += 1
# print(D)
print((D[0] - 1) % mod)

Measured memory_bytes: 70136
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <iomanip>
#include <sstream>

using namespace std;

int sum_digit(int n){
  if( n == 0 ) return 0;
  else return n%10 + sum_digit(n/10);
}
int absolute(int a){
  if(a < 0) return -a;
  else return a;
}
int main()
{
  int i,N; cin >> N;
  vector<int> n(4);
  for(i = 3; i >= 0; i--){
    n.at(i) = N % 10;
    N /= 10;
  }
  vector<char> op(3);
  
  for(int bit = 0; bit < (1<<3); bit++){
    int sum = n.at(0);
    //cout << bitset<3>(bit) << endl;
    
  	for(i = 0; i < 3; i++){
      if(bit & (1<<i)){
      	sum += n.at(i+1);
        op.at(i) = '+';
      }else{
      	sum -= n.at(i+1);
        op.at(i) = '-';
      }
    }
    //cout << sum << endl;
    if(sum == 7) break; 
  }
  for(i = 0; i < 4; i++){
      cout << n.at(i);
    if(i < 3) cout << op.at(i);
  }
  cout << "=7" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mid (tl+tr)/2
#define mod 1000000007
#define fain(arr) for(int i=0;i<n;i++)cin>>arr[i];
#define all(x) x.begin(),x.end()
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bugv(n1) if(DEBUG)cout<<#n1<<" is "<<n1<<'\n';
#define buga(A) cout<<#A<<" is :"<<endl ; for(auto x:A)cout<<x<<" "; cout<<endl;
#define FILE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ll long long 
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define pi acos(-1)
#define sz(x) ((int)x.size())
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define DEBUG true
using namespace std;





int main() {
  // FILE;
  SPEED;
  
  string s,t;
  cin>>s>>t;
  if(s.length()>t.length())swap(s,t);
  int memo[s.length()+1][t.length()+1];

  for(int i=0;i<=t.length();i++){
    memo[s.length()][i]=0;
  }

  for(int i=0;i<=s.length();i++){
    memo[i][t.length()]=0;
  }

  for(int i=s.length()-1;i>=0;i--){
    for(int j=t.length()-1;j>=0;j--){
      int ans=0;
      if(s[i]==t[j]){
        ans=max(ans,1+memo[i+1][j+1]);
      }
      ans=max(ans,memo[i+1][j]);
      ans=max(ans,memo[i][j+1]);
      memo[i][j]=ans;
    }
  }

  // cout<<memo[0][0]<<endl;

  string common="";

  int i=0;
  int j=0;

  while(i<s.length()&&j<t.length()){
    if(s[i]==t[j]){

      int maxi=max({memo[i+1][j],memo[i][j+1],memo[i+1][j+1]});
      if(memo[i+1][j+1]==maxi){
        common.push_back(s[i]);
        i++;
        j++;
      }
      else if(maxi==memo[i+1][j]){
          i++;
        }
      
      else{
        j++;
      }
    }
    else{
      
      if(memo[i][j+1]>memo[i+1][j]){
        j++;
      }
      else{
        i++;
      }
    }
  }

  cout<<common<<endl;

}

Measured memory_bytes: 35456
#include <stdio.h>          // printf(), scanf()

#define MAX_N 100
#define swap(x, y) {int t = x; x = y; y = t;}

int
main(int argc, char** argv)
{
	int a[MAX_N];
	int n;
	int i, j;

	scanf("%d", &n);
	for (i = 0; i < n; ++i)
		scanf("%d", &a[i]);

	int count = 0;
	for (i = 0; i < n; ++i)
	{
		int minj = i;
		for (j = i; j < n; ++j)
		{
			if (a[j] < a[minj])
				minj = j;
		}

		if (i != minj)
		{
			swap(a[i], a[minj]);
			count++;
		}
	}

	for (i = 0; i < n; ++i)
		printf("%d%c", a[i], (i != n - 1) ? ' ' : '\n');

	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef double ld;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=100005;
int fa[N],d[N],a[N],cur[N],c[N],tmp[N],ans[N];
int num,pos,cnt,s,t,n,m,u,v;
vi e[N];

void dfs(int u){
	for(auto v:e[u])
		if(v!=fa[u]){
			d[v]=d[u]+1;
			fa[v]=u,dfs(v);
		}
}

int cmp(int *a,int *b){
	rep(i,1,cnt)
		if(a[i]!=b[i])return a[i]<b[i];
	return 0;
}

int main(){
	read(n);
	rep(i,1,n-1){
		read(u),read(v);
		e[u].pb(v),e[v].pb(u);
	}
	fa[1]=0,d[1]=1,dfs(1);
	s=max_element(d+1,d+n+1)-d;
	fa[s]=0,d[s]=1,dfs(s);
	t=max_element(d+1,d+n+1)-d;
	a[++cnt]=t;
	while(a[cnt]!=s){
		int t=fa[a[cnt]];
		a[++cnt]=t;
	}
	rep(i,1,cnt)cur[a[i]]=i;
	rep(i,1,n)
		if(!cur[i]){
			if(a[cur[fa[i]]]!=fa[i])
				return puts("-1"),0;
			cur[i]=cur[fa[i]];
			++c[cur[i]];
		}
	memcpy(tmp,c,sizeof c);
	reverse(tmp+1,tmp+cnt+1);
	if(cmp(tmp,c))memcpy(c,tmp,sizeof tmp);
	rep(i,1,cnt){
		int tmp=++num;
		rep(j,1,c[i])
			ans[pos+j]=++num;
		pos+=c[i]+1;
		ans[pos]=tmp;
	}
	rep(i,1,n)printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 13696
#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef map<ll,ll> mpll;
typedef set<ll> setll;
typedef multiset<ll> msetll;
 
#define F first
#define S second
#define pb push_back
#define mp make_pair 

const ll inf = ll(1e18);
const ll MOD = (1e9 + 7);

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef DEBUG_
		freopen("input.txt","r",stdin);
	#endif
	cout.setf(ios::fixed), cout.precision(20);
    ll n;
    cin >> n;
    ll arr[n];
    for(int i=0;i<n;i++)
    {
        cin >> arr[i];
    }

    ll cnt = 0;
    for(int i=0;i<n;i++){
        if(arr[i]==cnt+1){
            cnt++;
        }
    }
    if(cnt==0)
        cout<<-1<<"\n";
    else
        cout<<n-cnt<<"\n";
        
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
char s[20];int n;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	int sum=0,ans=0;
	for(int i=1;i<=n;++i){
		if(s[i]=='0')continue;
		sum+=s[i]-'0';
		ans=max(ans,sum-1+9*(n-i));
	}
	ans=max(ans,sum);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c;
	cin >> a >> b >> c;
	if(a==b+c || b==a+c || c==a+b) cout << "Yes";
	else
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, T;
int a[100010];
signed main() {
    cin >> N >> T;
    rep(i,0,N) cin >> a[i];
    sort(a, a+N);

    int ans = 1;
    rep(i,0,N) {
        int bad = lower_bound(a, a+N, a[i] - T) - a;
        int good = i - bad;
        (ans *= (good + 1)) %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int n,i;cin>>n;
  static double x[100],a,y,p,q,r,s;

  for(i=0;i<n;i++)cin>>x[i];
  for(i=0;i<n;i++)cin>>y,p+=a=abs(x[i]-y),q+=a*a,r+=a*a*a,s=s<a?a:s;
  cout<<fixed<<p<<endl<<sqrt(q)<<endl<<cbrt(r)<<endl<<s<<endl;
  return 0;
}

Measured memory_bytes: 3408
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int[][] A = new int[3][3];
        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < 3; j++) {
                A[i][j] = scanner.nextInt();
            }
        }
        int N = scanner.nextInt();
        Set<Integer> b = new HashSet<>();
        for(int i = 0; i < N; i++) {
            b.add(scanner.nextInt());
        }
        boolean flag = false;
        if(b.contains(A[0][0]) && b.contains(A[0][1]) && b.contains(A[0][2])) {
            flag = true;
        }
        if(b.contains(A[1][0]) && b.contains(A[1][1]) && b.contains(A[1][2])) {
            flag = true;
        }
        if(b.contains(A[2][0]) && b.contains(A[2][1]) && b.contains(A[2][2])) {
            flag = true;
        }

        if(b.contains(A[0][0]) && b.contains(A[1][0]) && b.contains(A[2][0])) {
            flag = true;
        }
        if(b.contains(A[0][1]) && b.contains(A[1][1]) && b.contains(A[2][1])) {
            flag = true;
        }
        if(b.contains(A[0][2]) && b.contains(A[1][2]) && b.contains(A[2][2])) {
            flag = true;
        }

        if(b.contains(A[0][0]) && b.contains(A[1][1]) && b.contains(A[2][2])) {
            flag = true;
        }
        if(b.contains(A[0][2]) && b.contains(A[1][1]) && b.contains(A[2][0])) {
            flag = true;
        }

        if(flag) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e18;
const LL MX = 1e9;
const LL INF = 1e9;

LL n, x, m;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin>>n>>x>>m;
    ULL m_val[m];
    loop(i,0,m) m_val[i] = INF;

    ULL ans = x;
    --n;
    VL vec;

    while(n)
    {
        //watch(x);
        if(m_val[x] == INF)
        {
            --n;
            m_val[x] = (x * x) % m;
            ans += m_val[x];
            vec.PB(x);
            //watch(m_val[x]);
            x = m_val[x];
        }
        else
        {
            int id = -1, sz = vec.size();
            ULL sum = 0;

            loop(i,0,sz)
            {
                if(vec[i] == x) {id = i;}
                if(id != -1) sum += m_val[vec[i]];
            }

            //watch(sum);

            int l = sz - id;
            LL n1 = n / l, m1 = n % l;
            //watch(n1); watch(m1);

            ans += (sum * n1);
            while(m1--)
            {
                ans += m_val[vec[id]]; ++id;
            }

            break;
        }
    }

    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 4656
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    vector<vector<bool>> v(n, vector<bool>(m + 1, false));
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int t;
            cin >> t;
            v[i][t] = true;
        }
    }

    int count = 0;
    for (int i = 1; i < m + 1; ++i) {
        bool flag = true;
        for (int j = 0; j < n; ++j) {
            if (!v[j][i]) {  // look from the first food
                flag = false;
                break;
            }
        }
        if (flag)
            ++count;
    }
    cout << count << '\n';
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 2e9;


/*
!) 0-indexed
!) [a, b)に対する演算
!) m0 / l0 : 初期化する値
!) merge, updateNode, propagateを書く
*/
template <typename Monoid>
struct LazySegtree {
    int n;
    vector<Monoid> dat, lazy;
    Monoid M0, L0;

    void init(int sz, Monoid m0, Monoid l0) {
        n = 1;
        M0 = m0;
        L0 = l0;
        while (n < sz) n *= 2;
        dat.assign(2*n-1, M0);
        lazy.assign(2*n-1, L0);
    }

    LazySegtree(int sz, Monoid m0, Monoid l0){
        init(sz, m0, l0);
    }

    LazySegtree(int sz, Monoid m0) {
        init(sz, m0, m0);
    }

    Monoid merge(Monoid a, Monoid b){
        // ##### WRITE HERE #####
        // 区間をマージする二項演算
        return min(a, b);
    }

    void updateNode(int k, Monoid x){
        // ##### WRITE HERE #####
        // 区間を更新する二項演算
        lazy[k] = x;
    }

    void propagate(int k){
        // ##### WRITE HERE #####
        // 遅延配列の伝搬のさせ方
        dat[k] = lazy[k];
    }

    void eval(int k, int l, int r) {
        if(lazy[k] == L0) return;
        propagate(k);
        if(r-l > 1) {
            updateNode(2*k+1, lazy[k]);
            updateNode(2*k+2, lazy[k]);
        }
        lazy[k] = L0;
    }

    void update(int a, int b, Monoid x, int k, int l, int r) {
        eval(k, l, r);
        // 範囲外
        if (r <= a || b <= l) return;
        // [a, b)が[l, r)を被覆
        if (a <= l && r <= b) {
            updateNode(k, x);
            eval(k, l, r);
        }else{
            update(a, b, x, k*2+1, l, (l+r)/2);
            update(a, b, x, k*2+2, (l+r)/2, r);
            dat[k] = merge(dat[2*k+1], dat[2*k+2]);
        }
    }

    void update(int a, int b, Monoid x) {
        update(a, b, x, 0, 0, n);
    }

    Monoid query(int a, int b, int k, int l, int r) {
        eval(k, l, r);
        // 範囲外
        if (r <= a || b <= l) return M0;
        // [a, b)が[l, r)を被覆
        if (a <= l && r <= b) return dat[k];
        else {
            Monoid L = query(a, b, k*2+1, l, (l+r)/2);
            Monoid R = query(a, b, k*2+2, (l+r)/2, r);
            return merge(L, R);
        }
    }

    Monoid query(int a, int b){
        return query(a, b, 0, 0, n);
    }

    Monoid operator[](const int &k){ return dat[k + n - 1]; }
};

int main(){
    int n, q;
    cin >> n >> q;
    LazySegtree<int> seg(n, numeric_limits<int>::max());

    rep(i, q){
        int p;
        cin >> p;
        if(p == 0){
            int s, t, x;
            cin >> s >> t >> x;
            seg.update(s, t+1, x);
        }else{
            int x;
            cin >> x;
            cout << seg.query(x, x+1) << endl;
        }
    }
}


Measured memory_bytes: 4964
(declaim (optimize (speed 3) (debug 0) (safety 0)))

;;cyclone-loop
(defun cyclone-reader (stream char)
  (declare (ignore char))
  `(loop ,@(read stream t nil t) do ,(read stream t nil t)))
(set-macro-character #\CYCLONE #'cyclone-reader)
;;

;;compiling-main
(defun main-reader (stream char)
  (declare (ignore char))
  `(funcall (compile nil (lambda () ,(read stream t nil t)))))
(set-macro-character #\HOUSE_BUILDING #'main-reader)
;;

🏠
(let ((a (* (read) 100))
      (b (* (read) 100))
      (c (read))
      (d (read))
      (e (read))
      (f (read)))
  (declare (fixnum a) 
           (fixnum b)
           (fixnum c)
           (fixnum d)
           (fixnum e)
           (fixnum f))
  🌀 (for an to (truncate f a)
             :with max rational  = -1
             :with amax fixnum = -1
             :with smax fixnum = 0
             :finally (format t "~A ~A~%" amax smax)) 
  🌀 (for bn to (truncate (- f (* an a)) b))
  🌀 (for cn to (truncate (- f (+ (* an a) (* bn b))) c))
  🌀 (for dn to (truncate (- f (+ (* an a) (* bn b) (* cn c))) d)
             :for s fixnum = (+ (* cn c) (* dn d))
             :for w fixnum = (+ (* an a) (* bn b))
             :for all fixnum = (+ w s))
  (when (and (not (zerop all))
             (> (/ s all) max)
             (<= all f)
             (<= (* s 100) (* e w)))
    (setf max (/ s all))
    (setf amax all)
    (setf smax s)))

Measured memory_bytes: 55652
def abc128c_switches():
    import itertools
    n, m = map(int, input().split())
    s = []
    for _ in range(m):
        v = list(map(int, input().split()))
        v = v[1:]
        s.append(v)
    p = list(map(int, input().split()))
    pattern = itertools.product([0,1], repeat=n)
    result = 0
    for pat in pattern:
        cnt = 0
        for i in range(m):
            total = 0
            for j in s[i]:
                if pat[j-1] == 1:
                    total += 1
            if total %2==p[i]:
                cnt +=1
        if cnt == m:
            result += 1
    print(result)

abc128c_switches()

Measured memory_bytes: 9084
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

ll binary_search(function<bool(ll)> func, ll start, ll end) {
    /*      func:int ->bool
            returns smallest int x where func(x) evaluates to true, searches in [start,end), it is assumed the values are false, .. , false, true ...
             */
    if (end <= start) {   return end;  }   // has to be here, otherwise func(end-1) in next line could be a problem
    if (!func(end-1)) {  return end;  }
    while (end-start>1) {
        ll mid = (start+end)/2;
        if (func(mid)) {  end = mid;  } else { start = mid;   }
    }
    if (func(start)) {  return start;  } else {  return end;   }
}; 

long long gcd(long long a, long long b) { 
    if (a == 0)  {   return b;  }
    return gcd(b % a, a); 
};


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(n); readll(m);
        vector<int> keys, price;
        forr(i,0,m) {
            readint(pp); readint(bb);
            price.push_back(pp);
            int key = 0;
            forr(i,0,bb) {
                readint(rr);
                key += (1 << (rr-1));
            }
            keys.push_back(key);
        }
        ll infty = 10000000000000LL;
        vector<ll> min_price(1 << n, infty);
        min_price[0] = 0;
        forr(i,0,keys.size()) {
            for(int j=min_price.size()-1; j>=0;--j) {
                min_price[j | keys[i]] = min(min_price[j | keys[i]], min_price[j]+price[i]);
            }
        }
        if (min_price[(1<<n)-1]==infty) {
            cout << -1 << endl;
        } else {
            cout << min_price[(1<<n)-1] << endl;
        }

    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;
 
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

vector<ll> inv,fact,invfact;
void mod_build(int n=101010){  
  fact.resize(n+1);
  inv.resize(n+1);
  invfact.resize(n+1);
  fact[0]=inv[0]=invfact[0]=1;
  inv[1]=1;
  rep(i,n){
    fact[i+1]=fact[i]*(i+1)%mod;
    if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
    invfact[i+1]=invfact[i]*inv[i+1]%mod;
  }
}
ll perm(int n,int k){
  if(n<0||k<0||k>n)return 0;
  return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
  if(n<0||k<0||k>n)return 0;
  return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
  k%=mod-1;
  if(k<0)k+=mod-1;
  ll ret=1;
  while(k){
    if(k&1)ret=ret*n%mod;
    n=n*n%mod;
    k>>=1;
  }
  return ret;
}
 
int main(){  
  int n;
  cin>>n;
  mod_build();
    
  ll ans = 0;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  ll s = 0;
  rep(i,n-1){
    s += inv[i+1];
    s %= mod;
    ans += (a[i+1]-a[i])*s%mod;
  }
  ans %= mod;
  cout<<ans*fact[n-1]%mod<<endl;
  return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    cout << (500*in() >= in() ? "Yes" : "No")<< "\n";
}

Measured memory_bytes: 256
program irreversible_operation
  implicit none
  character(len=200000) :: s
  integer               :: i, j, n
  integer(8)            :: a, b
  read(*,*) s
  n = len_trim(s)
  a = 0
  b = 0
  j = 0
  do i = 1, n
     if (s(i:i) .eq. 'B') then
        a = a + n - j
        b = b + i
        j = j + 1
     end if
  end do
  write(*,'(i0)') a - b
  stop
end program irreversible_operation

Measured memory_bytes: 1468
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        _n: usize,
        m: usize,
        x: u32,
        a: [u32;m]
    }
    let mut l = 0;
    let mut r = 0;
    for i in a {
        if i < x {
            l+=1;
        }
        if i > x {
            r+=1;
        }
    }
    println!("{}", std::cmp::min(l,r));
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;
typedef vector<vi> mat;

inline ll read(){
	ll Hashimoto=0,Kanna=1;
	char I_Love=getchar();
	while(I_Love<'0'||I_Love>'9'){
		if(I_Love=='-')Kanna=-1;
		I_Love=getchar();
	}
	while(I_Love>='0'&&I_Love<='9'){
		Hashimoto=Hashimoto*10+I_Love-'0';
		I_Love=getchar();
	}
	return Hashimoto*Kanna;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<Kanna;I_Love++)cout<<Hashimoto[I_Love]<<(I_Love==Kanna-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<Kanna;I_Love++)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define inf (int)1e9
#define linf (ll)1e18
#define mod (inf+7)

int n,d,m;

int I_Love_Hashimoto_Kanna() {
  fastio;
  cin>>n>>m>>d;
  double k=(n-d)*(d==0?1:2);
  k/=n;
  k/=n;
  printf("%.10lf\n",k*(m-1));
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;



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

	cin >> N >> M;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	vector<vector<long long int>>w(N, vector<long long int>(N, MOD*MOD));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			w[j][i] = v[j];
			if (i) {
				w[j][i] = w[j][i - 1];
				w[j][i] = min(w[j][i], w[(j + N - 1) % N][i - 1]);
			}
		}
	}
	long long int ans = MOD * MOD;
	for (int i = 0; i < N; i++) {
		long long int box = M * i;
		for (int j = 0; j < N; j++) {
			box += w[j][i];
		}
		//cout << i << " " << box << endl;
		ans = min(ans, box);
	}
	cout << ans << endl;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  
  ll n;
  cin>>n;
  
  ll as,bs,cs,ds;
  as=a*4*n;
  bs=b*2*n;
  cs=c*n;
  ds=d*(n/2);
  
  if(n%2==0){
    cout<<min({as,bs,cs,ds})<<endl;
    return 0;}
  
  if(a*8>d&&b*4>d&&c*2>d){
    ll sum=0;
    sum+=ds;
    sum+=min({a*4,b*2,c});
    cout<<sum<<endl;}
  
  else{
    cout<<min({as,bs,cs})<<endl;
  }
  
  return 0;

 
}

Measured memory_bytes: 256
// Problem : D - Div Game
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define all(x) (x).begin() , (x).end()
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    ll n;
    cin >> n;
    
    map<ll , ll> m;
    for(ll i = 2 ; i * i <= n ; i++){
    	if(n % i == 0){
    		ll cnt = 0;
    		while(n % i == 0){
    			n /= i;
    			cnt++;
    		}
    		m[i] = cnt;
    	}
    }
    if(n > 1){
    	m[n] = 1;
    }
    
    ll sum = 0;
    for(auto it : m){
    	ll beg = 0 , last = it.ss , mid , ans = 0;
    	while(beg <= last){
    		mid = (beg + last) >> 1;
    		if(mid * (mid + 1) / 2 <= it.ss){
    			ans = mid;
    			beg = mid + 1;
    		}
    		else last = mid - 1;
    	}
    	
    	sum += ans;
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
int main() {
int a, b = 0, c = 0, y = 0, i, j;
int x[100];
scanf("%d", &a);
for (i = 0;i < a;i++) {
scanf("%d", &x[i]);
} 
for (i = 0;i < a - 1;i++) {
    for (j = a - 1;j > i;j--) {
    if (x[j - 1] < x[j]) {
    int t = x[j];
    x[j] = x[j - 1];
    x[j - 1] = t;
    }
} }
if (a % 2 == 0) {
for (i = 0;i < a - 1;i = i + 2) {
b = b + x[i];
} for (i = 1;i < a;i = i + 2) {
c = c + x[i];
} printf("%d\n", b - c);
} 
else if (a % 2 == 1) {
for (i = 0;i < a;i = i + 2) {
b = b + x[i];
} for (i = 1;i < a - 1;i = i + 2) {
c = c + x[i];
} printf("%d\n", b - c);
}
return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define D7K_ICPC ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef long double ld;
using namespace std;
ll x,y,n,d,z,m,a,b,c,k;
int main()
{
   D7K_ICPC;
   string s;
   cin>>s;
   if(s == "ABC") cout<<"ARC";
   else cout<<"ABC";
   return 0;
}


Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int k = s.nextInt(),x=s.nextInt();
        long total = 0;
        for(int i=0;i<=k;i++){
            for(int j=0;j<=k;j++){
                long sum = i+j;
                if(x-sum<=k && x-sum>=0)total++;
            }
        }
        System.out.println(total);
    }


}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25660
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    int cnt = 0;
    rep(i,n){
        if(i+1 == a[i]){
            if(i != n){
                swap(a[i],a[i+1]);
            }
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
# include <bits/stdc++.h>
# define rep(i,a,b) for(int i=a;i<=b;++i)
# define mp make_pair
# define fi first
# define se second
# define pii pair<int,int>
# define pb push_back
# define VI vector<int>
# define fp freopen
# define mem(x,v) memset(x,v,sizeof x)
using namespace std;
typedef long long ll;
ll read(){
	ll x=0;char c=getchar();
	for(;c<'0'||c>'9';c=getchar());
	for(;c>='0'&&c<='9';c=getchar())x=x*10+c-'0';
	return x;
}
int n;
map<ll,int> cnt;
int main(){
//	freopen("tmp.in","r",stdin);
	n=read();
	rep(i,1,n){
		ll x; x=read();
		for(int j=2;1ll*j*j*j<=x;++j) while (x % (1ll*j*j*j) == 0) x/=1ll*j*j*j;
		++cnt[x];
	}
	int ans=0;
	if (cnt[1])ans=1,cnt.erase(1);
	for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it){
		ll x=it->fi,fix=1;
		int y=it->se;
		for(int j=2;1ll*j*j*j<=x;++j){
			if (x%j == 0){
				if (x%(1ll*j*j)==0) x/=(1ll*j*j),fix*=j;
				else x/=j,fix*=1ll*j*j;
			}
		}
		ll z=sqrt(x);
		if (z*z==x)fix*=z; else fix*=x*x;
		if (cnt.count(fix)==0) ans+=y;
		else ans+=max(y,cnt[fix]),cnt.erase(fix);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7296
#!/usr/bin/env python3

N=int(input())
a=[]
b=[]
c=[]
for i in range(N):
  x,y,z=map(int,input().split())
  a.append(x)
  b.append(y)
  c.append(z)

ha=[0 for _ in range(N)]
hb=[0 for _ in range(N)]
hc=[0 for _ in range(N)]
ha[0]=a[0]
hb[0]=b[0]
hc[0]=c[0]

for i in range(1,N):
  ha[i]=max(hb[i-1]+a[i],hc[i-1]+a[i])
  hb[i]=max(ha[i-1]+b[i],hc[i-1]+b[i])
  hc[i]=max(ha[i-1]+c[i],hb[i-1]+c[i])

print(max((ha[N-1],hb[N-1],hc[N-1])))


Measured memory_bytes: 26968
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	string S;
	cin>>S;
	int l=0;
	for (int i = 0; i < S.length(); ++i)
	{
		if(S[i]=='x')
		{
			l++;
		}
	}
	if(l<=7)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, m;
	cin >> n >> m;
	vector<vector<int>> dis(n, vector<int>(n, inf));
	vector<int> a(m), b(m), c(m);
	rep(i, m) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
		dis[a[i]][b[i]] = c[i];
		dis[b[i]][a[i]] = c[i];
	}
	rep(k, n) {
		rep(i, n) {
			rep(j, n) {
				chmin(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}
	int ans = m;
	rep(i, m) {
		if (dis[a[i]][b[i]] == c[i]) ans--;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 384