akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

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

    int ans = 1;
    for (int i = 1; i < 4; i++)
    {
        if (N[i] == N[i - 1])
        {
            ans++;
            if (ans == 3)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
        else
        {
            ans = 1;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
R=range
K=4000
S=[input()for i in R(3)]
A,B,C=S
a,b,c=[len(i)for i in S]
def F(S,T):
 Q=[1]*(K*2+1)
 for i in R(-len(T),len(S)):
  for j in R(max(i,0),min(len(S),len(T)+i)):
   if len(set([S[j],T[j-i],'?']))>2:Q[i]=0;break
 return Q
S=F(A,B)
T=F(A,C)
U=F(B,C)
m=K*3
for p in R(-K,K+1):
 if S[p]!=0:
  for q in R(-K,K+1):
   if T[q]!=0 and U[q-p]!=0:
    m=min(m,max(p+b,q+c,a)-min(p,q,0))
print(m)

Measured memory_bytes: 55348
import java.util.*;
import java.lang.*;

public class Main {

    static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();

        int left = 1, right = N;
        for(int m=0; m<M; m++){
            left = Math.max(left, sc.nextInt());
            right = Math.min(right, sc.nextInt());
        }
        System.out.println(Math.max(right-left+1, 0));
    }
}

Measured memory_bytes: 63232
import java.util.Scanner;
 
public class Main{
	public static boolean cheak(int a) {
		for(int i=2;i*i<=a;i++) {
			if(a%i==0)return false;
		}
		return true;
	}
	public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
        	while(sc.hasNext()) {
        		int n = sc.nextInt();
        		if(n==0)break;
        		
        		int cnt = 0;
        		for(int i=n+1;i<=2*n;i++) {
        			if(cheak(i)) cnt++;
        		}
        		System.out.println(cnt);
        	}
        }
    }
}





Measured memory_bytes: 27752
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    string_code(1, S, C),
*/

main:-
    get_number(N),
    get_number(R),
    X is R + 100 * max(10 - N, 0),
    writeln(X).


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

int main()
{
    int n, k;
    double n2;

    cin >> n;
    cin >> k;

    n2 = n;
    int bit[n], b[k];
    int selection[n];

    for( int i = 0; i < k; i++ )
        cin >> b[i];

   
    for( int i = 0; i < n; i++ )
    {
        bit[i] = i;
        selection[i] = 0;
    }
    
    for( int i = 0; i < pow( 2, n2 ); i++ )
    {
        int x = i;
        int j = 0;
        while( x > 1 )
        {
            selection[j] = x % 2;
            j++;
            x = x / 2;
        }
        selection[j] = x;

        bool judge = true;
        for( int t = 0; t < k; t++ )
            if( selection[b[t]] == 0 )
                judge = false;     

        if( judge == true )
        {
            cout << i << ":";
            for( int t = 0; t < n; t++ )
                if( selection[t] == 1 )
                    cout << " " << bit[t];
            cout<< endl;
        }
    }
    return 0;
}


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

int main() {
  std::vector<std::pair<int, int>> ops;
  std::vector<int> values;
  int nNum, nOps;
  std::cin >> nNum >> nOps;
  
  values.resize(nNum);
  for (int i = 0; i < nNum; ++i) {
    std::cin >> values[i];
  }
  
  ops.resize(nOps);
  for (int i = 0; i < nOps; ++i) {
    std::cin >> ops[i].second >> ops[i].first;
  }
  
  std::sort(ops.begin(), ops.end());
  std::sort(values.begin(), values.end());
  
  int iter = 0;
  for (int i = nOps - 1; i >= 0; --i) {
    for (int j = 0; j < ops[i].second && iter < nNum && values[iter] < ops[i].first; ++j, ++iter) {
      values[iter] = ops[i].first;
    }
  }
  
  long long sum = 0;
  for (int val : values) {
    sum += val;
  }
  std::cout << sum;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;

  std::vector<i64> f(N + 1, 0);
  for (i64 x = 1; x * x + 1 * 1 + 1 * 1 + x * 1 + 1 * 1 + 1 * x <= N; ++x) {
    for (i64 y = 1; x * x + y * y + 1 * 1 + x * y + y * 1 + 1 * x <= N; ++y) {
      for (i64 z = 1; x * x + y * y + z * z + x * y + y * z + z * x <= N; ++z) {
        ++f[x * x + y * y + z * z + x * y + y * z + z * x];
      }
    }
  }

  for (i64 i = 1; i <= N; ++i) {
    std::cout << f[i] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define INF 1000000007
#define inf 10000000
#define mod 1000000007
using namespace std;
template <typename T> T Max(T X,T Y){return X>Y?X:Y;}
template <typename T> T Min(T X,T Y){return X<Y?X:Y;}
int sum=0;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		int num=s[i]-'0';
		sum+=num;
	}
	if(sum%9==0)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 3748
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>


int main(){
	int n;
	int min;
	int max;
	int temp;
	int i;
		
	scanf("%d", &n);

	for(i=0 ; i<n ; i++){
		scanf("%d", &temp);

		if(i==0){
			min = temp;
			max = -1000000000;
		}
		else{
			if(max < temp - min){
				max = temp - min;
			}
			if(min > temp)
				min = temp;
		}
	}

	printf("%d\n", max);

	return 0;
}


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

bool C[27];
int n;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
	char tmp;
    cin >> tmp;
    C[tmp - 'A'] = 1;
  }
  int cnt = 0;
  for (int i = 0; i < 27; i++)
    	cnt += C[i];
  if (cnt == 3)
    	cout << "Three";
  else
    	cout << "Four";
}

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

using ll = long long;
using namespace std;

const int N = 1e5 + 1;
int h[N], dp[N];

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

#ifdef LOCAL_DEFINE	
	freopen("in.txt", "r", stdin);
#endif
	
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) cin >> h[i];

	for (int i = 1; i < n; ++i)
		dp[i] = 1e9;

	for (int i = 0; i < n; ++i) {
		for (int j = 1; j <= k; ++j)
		{
			dp[i + j] = min(dp[i + j], abs(h[i + j] - h[i]) + dp[i]);
		}
	}

	cout << dp[n - 1] << '\n';

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define int long long
#define mod 1000000007
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define ms(v,n) memset((v),n,sizeof(v));
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define ad(a,b)  (a%mod+b%mod+mod)%mod
#define nl endl
#define inf 1e18
#define cases ll t;cin>>t;while(t--)
#define BLOCK 500
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
 
using namespace std;

void add_self(int &a,int b)
{
    a+=b;
    if(a>=mod)
    a-=mod;

}

void sub_self(int &a,int b)
{
    a-=b;
    if(a<0)
    a+=mod;

}

const int N=105;
const int MAX=1e5+5;
ll n,k;
ll a[N];
//dp[i]=no of ways of distributing i candies so far
ll dp[MAX];
ll fake[MAX];


int main()
{
    
    fast

    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> dp(k + 1);
    // dp[i] - the number of ways such that we used i candies so far
    dp[0] = 1;
    for(int child = 0; child < n; ++child) {
        int up_to;
        scanf("%d", &up_to);
        vector<int> fake(k + 1);
        for(int used = k; used >= 0; --used) {
            int tmp = dp[used];
            int L = used + 1;
            int R = used + min(up_to, k - used);
            if(L <= R) {
                add_self(fake[L], tmp);
                if(R + 1 <= k) {
                    sub_self(fake[R+1], tmp);
                }
            }
            //~ for(int i = L; i <= R; ++i) {
                //~ add_self(dp[i], tmp);
            //~ }
        }
        int prefix_sum = 0;
        for(int i = 0; i <= k; ++i) {
            add_self(prefix_sum, fake[i]);
            add_self(dp[i], prefix_sum);
        }
    }
    printf("%d\n", dp[k]);
       
    return 0;
    
}



Measured memory_bytes: 1024
def main():
    N = int(input())
    S = input()
    
    ans = S.count('R') * S.count('G') * S.count('B')
    colors = set(list('RGB'))

    for i in range(N-2):
        for j in range(i+1, i+1+(N-1-i)//2):
            k = j + (j - i)
            if set([S[i], S[j], S[k]]) == colors:
                ans -= 1
            
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 68252
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 205

using namespace std;

ll frq[10];

ll fun(ll x)
{
    if(x>=1&&x<=399)
        frq[1]++;

    else if(x>=400&&x<=799)
        frq[2]++;

    else if(x>=800&&x<=1199)
        frq[3]++;

    else if(x>=1200&&x<=1599)
        frq[4]++;

    else if(x>=1600&&x<=1999)
        frq[5]++;

    else if(x>=2000&&x<=2399)
        frq[6]++;

    else if(x>=2400&&x<=2799)
        frq[7]++;

    else if(x>=2800&&x<=3199)
        frq[8]++;

    else if(x>=3200)
        frq[9]++;
}

int main()
{
    ll n,x,a,b;

    scanf("%lld",&n);

    memset(frq,0,sizeof(frq));

    for(ll i=1; i<=n; i++)
    {
        scanf("%lld",&x);

        fun(x);
    }

    ll cnt=0;

    for(ll i=1; i<=8; i++)
    {
        if(frq[i])
            cnt++;
    }

    if(cnt==0&&frq[9]>=1)
        a=1;

    else
        a=cnt;

    b=cnt+frq[9];

    printf("%lld %lld\n",a,b);

    return (0);
}




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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	string s;
	cin >> n >> s;
	int r = 0, b = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') {
			r++;
		}
		else {
			b++;
		}
	}
	if (r > b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 340000
#define M 998244353
 
using namespace std;
typedef long long ll;
ll dp[maxn][3][3],n,t,f,ans,g;
char s[maxn];
 
int main()
{
    scanf("%s",s); n=strlen(s); ans=1; g=1;
    f=1; for (int i=1;i<n;i++) f&=s[i]!=s[i-1],g&=s[i]==s[i-1],ans=ans*3%M;
    if (g) {cout << 1 << endl; return 0;}
    if (n==2) {cout << 1+(s[0]!=s[1]) << endl;return 0;}
    if (n==3) {
        if (s[0]==s[1]&&s[0]==s[2]) cout << 1 << endl;
        else if (s[0]!=s[1]&&s[1]!=s[2]&&s[0]!=s[2]) cout << 3 << endl;
        else cout << 6+f << endl;
        return 0;
    }
    for (int i=0;i<n;i++) t=(t+s[i]-'a')%3;
    for (int i=0;i<3;i++) dp[1][i][i]=1;
    for (int i=2;i<=n;i++)
        for (int j=0;j<3;j++)
            for (int k=0;k<3;k++)
                for (int l=0;l<3;l++)
                    if (k!=l) (dp[i][(j+l)%3][l]+=dp[i-1][j][k])%=M;
    cout << ((ans-dp[n][t][0]-dp[n][t][1]-dp[n][t][2])%M+M+f)%M << endl;
    return 0;
}

Measured memory_bytes: 16512
#include<bits/stdc++.h>
#define read() Read<int>()
namespace pb_ds{   
    namespace io{
        const int MaxBuff=1<<15;
        const int Output=1<<23;
        char B[MaxBuff],*S=B,*T=B;
		#define getc() ((S==T)&&(T=(S=B)+fread(B,1,MaxBuff,stdin),S==T)?0:*S++)
        char Out[Output],*iter=Out;
        inline void flush(){
            fwrite(Out,1,iter-Out,stdout);
            iter=Out;
        }
    }
    template<class Type> inline Type Read(){
        using namespace io;
        register char ch;
        register Type ans=0; 
        register bool neg=0;
        while(ch=getc(),(ch<'0' || ch>'9') && ch!='-');
        ch=='-'?neg=1:ans=ch-'0';
        while(ch=getc(),'0'<= ch && ch<='9') ans=ans*10+ch-'0';
        return neg?-ans:ans;
    }
    template<class Type> inline void Print(register Type x,register char ch='\n'){
        using namespace io;
        if(!x) *iter++='0';
        else{
            if(x<0) *iter++='-',x=-x;
            static int s[100]; 
            register int t=0;
            while(x) s[++t]=x%10,x/=10;
            while(t) *iter++='0'+s[t--];
        }
        *iter++=ch;
    }
}
using namespace pb_ds;
using namespace std;
typedef long long ll;
const int N=505;
const ll inf=(ll)1e18;
int n;
int a[N][N],b[N][N];
ll ans=inf;
ll c[N][N],d[N][N],dp[N][N];
int main(){
	//freopen("negative.in","r",stdin);
	//freopen("negative.out","w",stdout);
	n=read();
	for (int i=1;i<=n;++i){
		for (int j=1;j<i;++j) a[j][i]=read();
		for (int j=i+1;j<=n;++j) b[i][j]=read();
	}
	for (int i=1;i<=n+1;++i){
		for (int j=i;j<=n+1;++j){
			c[i][j]=c[i-1][j];
			for (int k=j;k<=n;++k) c[i][j]+=a[i][k];
		}
	}
	for (int i=n+1;i;--i){
		for (int j=i;j<=n+1;++j){
			d[i][j]=d[i+1][j];
			for (int k=i;k<=j;++k) d[i][j]+=b[i][k];
		}
	}
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	for (int i=1;i<=n+1;++i)
		for (int j=0;j<i;++j)
			for (int k=0;k<=j;++k)
				dp[i][j]=min(dp[i][j],dp[j][k]+c[j][i+1]-c[k][i+1]+d[j+1][i]);
	for (int i=0;i<=n;++i)
		ans=min(ans,dp[n+1][i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8576
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, x;

ll work(ll x, ll y)
{
    if (x % y == 0) return (x / y * 2 - 1) * y;
    return x / y * 2 * y + work(y, x % y);
}

int main()
{
    scanf("%lld%lld", &n, &x);
    printf("%lld\n", n + work(n - x, x));
    return 0;
}


Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    ans = [[] for j in range(M)]

    if N % 2:
        for i in range(M):
            ans[i].append(i + 1)
            ans[i].append(N - i - 1)
    else:
        memo = 0
        f = False
        for i in range(M):
            memo = i
            if (i + 1) * 4 >= N:
                f = True
                break
            ans[i].append(i + 1)
            ans[i].append(N - i - 1)

        if f:
            for j in range(memo, M):
                ans[j].append(j + 1)
                ans[j].append(N - j - 2)
    for a in ans:
        print(*a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23860
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long
#define vi vector<int>

int main(){
    LL n, k;
    string s;

    cin >> n >> k;
    cin >> s;

    s.at(k-1) = s.at(k-1) - ('A' - 'a');

    cout << s << endl;
  
    return 0;
}

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

int main()
{
  cout << fixed << setprecision(10);
  double n;
  double ans=0;
  cin >> n;
  vector<double> x(n);
  vector<double> y(n);
  for(int i=0;i<n;++i){
    cin >> x.at(i) >> y.at(i);
  }
  for(int i=0;i<n-1;++i){
    for(int j=i+1;j<n;++j){
      ans+=sqrt((x.at(i)-x.at(j))*(x.at(i)-x.at(j))+(y.at(i)-y.at(j))*(y.at(i)-y.at(j)));
    }
  }
  cout << ans*2/n;
  return 0;
}

Measured memory_bytes: 256
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/

void solve()
{
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;

    ll r[a],g[b],z[c];
    f(i,a) cin>>r[i];
    f(i,b) cin>>g[i];
    f(i,c) cin>>z[i];

    sort(r,r+a,greater<ll>());
    sort(g,g+b,greater<ll>());
    sort(z,z+c,greater<ll>());

    ll ans=0;

    vector<ll> pq;

    f(i,x) pq.pb(r[i]);
    f(i,y) pq.pb(g[i]);

    f(i,c) pq.pb(z[i]);

    sort(pq.begin(), pq.end(),greater<ll>());

    //ll ans=0;

    f(i,x+y)  ans+=pq[i];
    cout<<ans<<"\n";

    return;
}

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

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

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

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 8816
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] line1 = line.split(" ");
        int a = Integer.parseInt(line1[0]);
        int b = Integer.parseInt(line1[1]);
        if(a > 2 * b)   System.out.println(a - 2 * b);
        else System.out.println(0);
    }
}

Measured memory_bytes: 23636
object Main {
  def main (args: Array[String]) {
    var count:Int = 0
    val Array(v1, v2) = scala.io.StdIn.readLine.split(" ").map(_.toLong)
    println( f"${v1/v2}%d ${v1%v2}%d ${v1.toDouble/v2.toDouble}%.5f" )
  }
}

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

#define ll long long

int main() {
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    ll A[X];
    ll B[Y];
    ll C[Z];
    for(int i = 0;i < X;i++) {
        cin >> A[i];
    }
    for(int i = 0;i < Y;i++) {
        cin >> B[i];
    }
    for(int i = 0;i < Z;i++) {
        cin >> C[i];
    }

    ll AB[X*Y];
    for(int i = 0;i < X;i++) {
        for(int j = 0;j < Y;j++) {
            AB[i*Y + j] = A[i] + B[j];
        }
    }
    sort(AB, AB + X*Y, greater<ll>());
    ll N = min<ll>(K, X*Y);
    ll res[N*Z];
    for(int i = 0;i < N;i++) {
        for(int j = 0;j < Z;j++) {
            res[i*Z + j] = AB[i] + C[j];
        }
    }
    sort(res, res + N*Z, greater<ll>());
    for(int i = 0;i < K;i++) {
        cout << res[i] << endl;
    }
}


Measured memory_bytes: 31616
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j){
            for(int k = j+1; k < n; ++k){
                if(l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
                if(l[i]+l[j] > l[k]) ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#define ll unsigned long long int
#define vi vector<ll>
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define iiii pair<ii,ii>
#define pb push_back
#define fi first
#define se second
using namespace std;
ll d,n;
ll a[(ll) 4e5+5];
ll ong[(ll)4e5+5];

int main(){
	cin>>d>>n;
	ll ans = 0;
	for(ll i = 0;i<n;i++){
		cin>>a[i];
	}
	ll nbaru = n+n-1;
	ll j = 0;
	for(ll i = 0;i<nbaru;i++){
		if(i >= n){
			a[i] = a[j++]+d;
		}
	}
//	for(ll i = 0;i<nbaru;i++) cout<<a[i]<<" ";cout<<"\n";
	for(ll i = 1;i<nbaru;i++){
		ong[i-1] = a[i]-a[i-1];
	}
	for(ll i = 1;i<nbaru;i++) ong[i]+=ong[i-1];
//	for(ll i= 0;i<nbaru;i++) cout<<ong[i]<<" ";cout<<"\n";
	j = 0;
	ll mini = ong[n-2];
	for(ll i = n-1;i<nbaru-1;i++){
		mini = min(mini,ong[i]-ong[j]);
//		cout<<ong[i]-ong[j]<<"\n";
		j++;
	}
	cout<<mini<<"\n";
//	cout<<mini<<"\n";
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < 10 && b < 10) cout << a * b << endl;
  else cout << -1 << endl;
}


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

int main(){
	
	long long int n;
	string str;
	
	while(cin >> n, n){
		stringstream ss;
		
		while(n){
			if(n < 0){
				ss << (-(n * 10) + n) % 10;
				n = -floor(1.0 * n / 10);
			}else{
				ss << n % 10;
				n = n / -10;
			}
		}
		
		str = ss.str();
		reverse(str.begin(), str.end());
		cout << str << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1212
n = int(input())
can = True
time = 0
x = 0
y = 0
for _ in range(n):
    t, xx, yy = map(int,input().split())
    distance = abs(x-xx) + abs(y - yy)
    difft = t - time
    if difft < distance:
        can = False
        break
    if (distance - difft) % 2 == 1:
        can = False
        break


    x = xx
    y = yy
    time = t
print("Yes" if can else "No")

Measured memory_bytes: 9084
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
    static long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int M = sc.nextInt();
        int[] hcount = new int[H];
        int[] wcount = new int[W];
        Set<String> hw = new HashSet<>();
        int maxH = 0;
        int maxW = 0;
        Set<Integer> candidateH = new HashSet<>();
        Set<Integer> candidateW = new HashSet<>();

        for(int i=0;i<M;i++){
            int h = sc.nextInt()-1;
            int w = sc.nextInt()-1;
            hw.add(h + ":" + w);
            hcount[h]++;
            wcount[w]++;
            maxH = Math.max(maxH,hcount[h]);
            maxW = Math.max(maxW,wcount[w]);
        }

        for(int i=0;i<H;i++){
            if(maxH == hcount[i]){
                candidateH.add(i);
            }
        }

        for(int j=0;j<W;j++){
            if(maxW == wcount[j]){
                candidateW.add(j);
            }
        }


        boolean find = false;
        for(int i : candidateH){
            if(find){
                break;
            }
            for(int j : candidateW){
                if(!hw.contains(i + ":" + j)){
                    find = true;
                    break;
                }
            }
        }

        if(find){
            System.out.println(maxH + maxW);
        } else {
            System.out.println(maxH + maxW -1);
        }


    }

}




Measured memory_bytes: 113468
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b==c+d) cout<<"Balanced"<<endl;
    else cout<<(a+b<c+d?"Right":"Left")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <queue>
#define INF 1<<19
const int MOD = 1000000007;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N;
    int a[110];
    int cnt = 0;
    cin >> N;
    rep(i,N) cin >> a[i];
    rep(i,N-1){
        if(a[i] == a[i+1]){
            i++; cnt++;
        }
    }
    cout << cnt <<endl;
}

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

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

	int count = 0;
	int a = n;
	while (10 < a) {
		a /= 10;
		count++;
	}
	int harshad = 0;
	int num;
	int b = n;
	for (int i = count; 0 <= i; i--) {
		num = b / pow(10, i);
		harshad += num;
		b -= num * pow(10, i);
	}
	string ans = "No";
	if (n % harshad == 0) {
		ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> p(n), pos(n + 1);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    pos[p[i]] = i;
  }
  vector<int> a(n + 1), b(n + 1);
  a[1] = 1, b[1] = 1e9;
  for (int i = 2; i <= n; ++i) {
    a[i] = a[i - 1] + 1;
    b[i] = b[i - 1] - 1;
    int k = pos[i] - pos[i - 1];
    if (k < 0) {
      b[i] += k;
    } else {
      a[i] += k;
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << a[i] << ' ';
  }
  cout << endl;
  for (int i = 1; i <= n; ++i) {
    cout << b[i] << ' ';
  }
  cout << endl;
  return 0;
}

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

using namespace std;

bool ask(int x)
{
    cout << x << endl;
    string str;
    cin >> str;
    if (str == "Vacant") exit(0);
    return str == "Male";
}

signed main()
{
    int n;
    cin >> n;

    int l = 0, r = n-1;
    bool bl = ask(l), br = ask(r), bm;
    while (1) {
        int m = (l + r) / 2;
		bm = ask(m);
        if ((m ^ l) & 1) {
            if (bl == bm) r = m, br = bm;
            else l = m, bl = bm;
        } else {
            if (bl == bm) l = m, bl = bm;
            else r = m, br = bm;
        }
    }
}


Measured memory_bytes: 852
#include <stdio.h>

int main(){
	char A[101],B[101];
	int ketaA,ketaB;

	scanf("%s %s",A,B);

	for(ketaA=0;A[ketaA]!='\0';ketaA++){}
	for(ketaB=0;B[ketaB]!='\0';ketaB++){}

	if(ketaA!=ketaB){
		if(ketaA>ketaB)printf("GREATER");
		if(ketaA<ketaB)printf("LESS");
	}
	if(ketaA==ketaB){
		int i;
		for(i=0;i<=ketaA;i++){
			if((int)A[i]>(int)B[i]){
				printf("GREATER");
				break;
			}
			if((int)A[i]<(int)B[i]){
				printf("LESS");
				break;
			}
			if((int)A[i]==(int)B[i] && i==ketaA)printf("EQUAL");
		}
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	double n,k;
	cin>>n>>k;
	double sum=0;
	for(ll i=1;i<=n;i++){
		double now=i;
		double nosum=1/n;
		while(now<k){
			now*=2;
			nosum/=2;
		}
		sum+=nosum;
	}
	printf("%.10f",sum);
	// your code goes here
	return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n;
  for(int i=0; i<n; i++){
    int point=0, out_count=0;
    int r[3];
    for(int i=0; i<3; i++) r[i] = 0;
    while(out_count != 3){
      cin >> s;
      if(s == "HOMERUN"){
	point++;
	for(int i=0; i<3; i++){
	  if(r[i] != 0){
	    point++;
	    r[i] = 0;
	  }
	}
      }
      if(s == "HIT"){
	r[0]++;
	if(r[0] > 1 && r[0] != 0){
	  r[0]--;
	  r[1]++;
	}
	if(r[1] > 1 && r[1] != 0){
	  r[1]--;
	  r[2]++;
	}
	if(r[2] > 1 && r[2] != 0){
	  r[2]--;
	  point++;
	}
      }
      if(s == "OUT") out_count++;
    }
    cout << point << endl;
  }
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b == 100) b = 101;
		if(a == 0) System.out.println(b);
		else if(a == 1) System.out.println(100 * b);
		else System.out.println(10000 * b);
		
	}
}

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> l(k);
    vector<ll> r(k);
    rep(i,k) cin >> l[i] >> r[i];
    
    vector<ll> vec;
    
    vec.push_back(1);
    ll nagasa=1;
    ll total=0;
    
    for(ll i=0;i<n-1;i++){
        rep(i,k){
            if(l[i]<=nagasa){
                total=(total+vec[nagasa-l[i]])%mod;
            }
        }
        rep(i,k){
            if(r[i]<=nagasa-1){
                total=(total+mod-vec[nagasa-r[i]-1])%mod;
            }
        }
        vec.push_back(total);
        nagasa++;
    }
    
    
    cout << vec[nagasa-1] << endl;

    return 0;
}











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

int main()
{
  int n, ans = 1 << 30;
  cin >> n;
  for (int i = 1; i < n; i++)
  {
    int a = i, b = n - i, tmp = 0;
    while (a > 0)
    {
      tmp += a % 10;
      a /= 10;
    }
    while (b > 0)
    {
      tmp += b % 10;
      b /= 10;
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int digit[10], len;

ll dfs(int c, int f)
{
    if (c == len - 1)
    {
        ll d = 1, ret = digit[len - 1];
        for (int i = 0; i < len - 1; i++)
        {
            if (f & (1 << i))
                d = 1;
            else
                d *= 10;
            ret += digit[len - 2 - i] * d;
        }
        return ret;
    }
    return dfs(c + 1, f << 1) + dfs(c + 1, (f << 1) + 1);
}

int main()
{
    string s;
    cin >> s;
    len = s.size();
    for (int i = 0; i < len; i++)
        digit[i] = s.at(i) - '0';
    cout << dfs(0, 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    ll n;
    cin >> n;
    map<ll,ll> mp;
    for (ll i = 2; i * i < n; i++) {
        if (n % i) continue;
        while (n % i == 0) {
            n /= i;
            mp[i]++;
        }
    }
    if (n != 1) mp[n]++;

    ll ans = 0;
    for (auto m: mp) {
        ll x = m.second;
        int j = 1;
        while (x >= j) {
            x -= j;
            j++;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
int N, M;
  cin >> N >> M;
  
  int sum=0;
for (int i = 0; i < M; i++) {
  int A;
  cin >> A;
  sum+=A;
}
if(N-sum<0){
  cout << -1 <<endl;
}
  else{cout<< N-sum << endl;}
  
}




Measured memory_bytes: 3640
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		BigInteger a = new BigInteger(sc.next());
		BigInteger b = new BigInteger(sc.next());

		int ans = a.compareTo(b);

		if (ans < 0) {
			System.out.println("LESS");
		} else if (ans == 0) {
			System.out.println("EQUAL");
		} else {
			System.out.println("GREATER");
		}
	}

}


Measured memory_bytes: 24148
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int n,a[200010];
int main(){
	std::cin>>n;
	lint sum=0;
	rep(i,n){
		std::cin>>a[i];
		sum^=a[i];
	}
	rep(i,n)a[i]^=sum;
	printArray(a,a+n);
	return 0;
}


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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m;
ll x;
string s;
int a[N];
vector < int > g[N];
int u[N];
ll ans;

ll get (ll k) {
    int c = 0;
    ll res = 0;
    For (i, 0, k - 1) g[i].clear();
    FOr (i, n, 1) {
        if (g[c].size()) {
            res += (g[c].back() - a[i]) * (g[c].size() + 1) * (g[c].size() + 1);
        } else {
            res += a[i];
        }
        g[c].pb(a[i]);
        c ++;
        if (c >= k) c -= k;
    }
    For (i, 0, k - 1) res += g[i].back() * (g[i].size() + 1) * (g[i].size() + 1);
    return res + x * n + x * k;
}

int main () {
	cin >> n >> x;
	For (i, 1, n) {
	    cin >> a[i];
	    
	}
	ans = INF;
	ll l = 1, r = n;
	while (l + 10 < r) {
	    ll m1 = l, m2 = r;
	    m1 += (r - l) / 3;
	    m2 -= (r - l) / 3;
	    if (get(m1) > get(m2)) l = m1;
	    else r = m2;
	}
	For (i, l, r) {
	    ans = min(ans, get(i));
	}
	
	cout << ans << '\n';
	return Accepted;
}

// Coded By OB

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

using namespace std;

typedef long long int ll;

#define limit ll(1e7+9)


ll nod[limit];

void nodInit(){
  for(int i = 1; i <= limit; i++){
    for(int j = i; j <= limit; j+= i){
      nod[j]++;
    }
  }
}

int main()
{
  nodInit();

  ll n,sum = 0;
  cin >> n;


  for(int i = 1; i <= n; i++){
    sum += (i * nod[i]);
  }

  cout << sum << endl;
  return 0;
}

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

int main(){
        ll t;
        cin >> t;
        ll a[t];
        set <ll> s;
        for (int i=0; i<t; i++){
                cin >> a[i];
                s.insert (a[i]);
        }

        if (t == s.size()){
                cout << "YES" << endl;
        }
        else {
                cout << "NO" << endl;
        }
        return 0;
}




Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String word = sc.next().toLowerCase();
		String text;
		int count = 0;

		while (true) {
			text = sc.next();
			if (text.contentEquals("END_OF_TEXT")) {
				break;
			} else {
				if (text.toLowerCase().equals(word)) {
					count++;
				}
			}
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 26108
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=9999999999;


int main(){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
    }
    int ans=(n-1+k-2)/(k-1);
    cout<<ans<<endl;


}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
    int N; cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++)cin>>A[i];
    sort(A.begin(),A.end());
    int end=A[N-1];
    vector<bool> tes(end+1000100,false);
    int ans=0;
    for(int i=0;i<N;i++){
        if(i!=N-1){
            if(A[i]==1){
                if(A[i+1]==1){cout<<0<<endl; return 0;}
                else {cout<<1<<endl; return 0;}
            }else{
                int now=A[i];
                if(A[i]==A[i+1])goto b;
                
                if(tes[A[i]]==false)ans++;
                b:
                while(now<=end){
                    tes[now]=true;
                    now+=A[i];
                }
            }
        }else{
            if(i==0)ans++;
            else if(A[i-1]!=A[i] and tes[A[i]]==false)ans++;
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if(a <= 8 && b <= 8)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
        String str = "";
        for (int i = 1;; i++) {
            str = br.readLine();
            if (str.equals("0"))
                break;
            System.out.println("Case " + i + ": " + str);
        }
    }
}

Measured memory_bytes: 31468
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let _ = line.trim().parse::<usize>().unwrap();
    let line = gets();
    let v: Vec<i128> = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<i128>().unwrap())
        .collect();
    if v.contains(&0) {
        println!("0");
        return;
    }
    let mut ans = 1;
    for x in v {
        ans *= x;
        if ans > 1000000000000000000 {
            println!("-1");
            return;
        }
    }
    println!("{}", ans);
}


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

int main(){
	int n;
	scanf("%d", &n);
	int bf = 0, x, an = 0, w[2];
	vector<int> v { 0 };
	vector<pair<int, int> > u;
	f(i, 0, n + 1){
		i == n ? x = 0 : scanf("%d", &x);
		w[0] = 0;
		w[1] = x - bf;
		if (w[0] < w[1])swap(w[0], w[1]);
		u.clear();
		f(j, 0, 2)f(k, 0, v.size())u.emplace_back(v[k] + w[j], v.size() - 1 - k + j);
		u.emplace_back(0, 2);
		for (auto &t: u)t.first = max(0, t.first);
		sort(u.begin(), u.end());
		v.clear();
		int lst = 2;
		f(i, 0, u.size())if (u[i].first <= x){
			int mn = u[i].second;
			while (i + 1 < u.size() && u[i + 1].first == u[i].first)++i, mn = min(mn, u[i].second);
			while (lst >= mn){
				v.push_back(u[i].first);
				--lst;
			}
		}
		an += lst + 1;
		bf = x;
	}
	printf("%d\n", an);
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,n,k,r,s,p;
    cin>>n>>k>>r>>s>>p;
    string t;
    cin>>t;

    ll dp[n+1][3];//n回目に出した手が0=r,1=s,2=pであったときの合計の最大スコア
    dp[0][0]=0;//初期化
    dp[0][1]=0;
    dp[0][2]=0;
    ll winscore[n+1];//条件を無視して全勝した場合のスコア(累積和用)
    winscore[0]=0;
    for(int i=1;i<=k;i++){
        switch(t[i-1]){
            case 'r':
                winscore[i]=winscore[i-1]+p;
                break;
            case 's':
                winscore[i]=winscore[i-1]+r;
                break;
            case 'p':
                winscore[i]=winscore[i-1]+s;
                break;
        }
    }

    for(int i=1;i<=n;i++){
        if(i<=k){
            ll a=0,b=0,c=0;
            switch(t[i-1]){
                case 'r':
                    a=1;
                    break;
                case 's':
                    b=1;
                    break;
                case 'p':
                    c=1;
                    break;
            }

            dp[i][0]=winscore[i-1+a];
            dp[i][1]=winscore[i-1+b];
            dp[i][2]=winscore[i-1+c];
        }else{
            switch(t[i-1]){
                case 'r':
                    dp[i][0]=winscore[i-1]-winscore[i-k]+p+max(dp[i-k][1],dp[i-k][2]);
                    dp[i][1]=winscore[i-1]-winscore[i-k]+max(dp[i-k][0],dp[i-k][2]);
                    dp[i][2]=winscore[i-1]-winscore[i-k]+max(dp[i-k][1],dp[i-k][0]);
                    break;
                case 's':
                    dp[i][1]=winscore[i-1]-winscore[i-k]+r+max(dp[i-k][2],dp[i-k][0]);
                    dp[i][0]=winscore[i-1]-winscore[i-k]+max(dp[i-k][2],dp[i-k][1]);
                    dp[i][2]=winscore[i-1]-winscore[i-k]+max(dp[i-k][1],dp[i-k][0]);
                    break;
                case 'p':
                    dp[i][2]=winscore[i-1]-winscore[i-k]+s+max(dp[i-k][0],dp[i-k][1]);
                    dp[i][1]=winscore[i-1]-winscore[i-k]+max(dp[i-k][0],dp[i-k][2]);
                    dp[i][0]=winscore[i-1]-winscore[i-k]+max(dp[i-k][2],dp[i-k][1]);
                    break;
            }
            winscore[i]=max(max(dp[i][0],dp[i][1]),dp[i][2]);
        }
        dbg cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<" "<<winscore[i-1]<<endl;
    }
    ans=max(max(dp[n][0],dp[n][1]),dp[n][2]);

    cout <<ans<<endl;

    return 0;

}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);

  for (int i = 0; i < h; i++) {
    cin >> a.at(i);
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a.at(i)[j] == '.') {
        int x = 0;
        for (int k = i - 1; k <= i + 1; k++) {
          for (int l = j - 1; l <= j + 1; l++) {
            if ((k < 0) or (j < 0) or (k >= h) or (l >= w)) {
              continue;
            }
            if (a.at(k)[l] == '#') {
              x++;
            }
          }
        }
        a.at(i)[j] = char('0' + x);
      }
    }
  }
  for (int i = 0; i < h; i++) {
    cout << a.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N, X = map( int, input().split())
a, b = max(X, N-X), min(X, N-X) #a >= b
ans = a + b
if a == b:
    ans += a
while a != b:
    if a%b == 0:
        ans += (a//b*2-1)*b
        break
    ans += a//b*2*b
    a, b = b, a%b
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

bool isPrime(long long x) {
    if (x == 1) return true;
    for (long long i = 2; i*i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

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

vector<long long> common_divisors(long long a, long long b) {
    long long n = gcd(a, b);
    vector<long long> ans;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (n / i == i) {
                ans.push_back(i);
            }
            else {
                ans.push_back(n / i);
                ans.push_back(i);
            }
        }
    }
    return ans;
}

int main() {
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i < x + k; i++) {
        cout << i << " ";
    }
    return 0;
}

Measured memory_bytes: 3616