akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			Set<Character> set = new HashSet<>();
			set.add('a');
			set.add('e');
			set.add('i');
			set.add('o');
			set.add('u');

			char c = in.nextString().charAt(0);

			out.println(set.contains(c) ? "vowel" : "consonant");
		}
	}

	// other template
	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}

	static void fill(int[][] a, int value) {
		for (int i = 0; i < a.length; i++) {
			Arrays.fill(a[i], value);
		}
	}

	static void fill(long[][] a, int value) {
		for (int i = 0; i < a.length; i++) {
			Arrays.fill(a[i], value);
		}
	}

	static void fill(char[][] a, char c) {
		for (int i = 0; i < a.length; i++) {
			Arrays.fill(a[i], c);
		}
	}

	// faster input template
	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 22868
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			
			System.out.println(Math.max(A + B, Math.max(A - B, A * B)));
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
#include <time.h>

int main(void){
    long N,K;
    std::cin >> N >> K;
    long A[200000]={};
    for(long i=0; i<N; i++){
        std::cin >> A[i];
    }

    std::vector<long> B;
    bool flag[200000]={};
    B.push_back(0);
    flag[0]=1;
    bool flag2=1;
    long count=0;
    long loopnum=0;
    while(flag2){
        if(flag[A[B[count]]-1]){
            flag2=0;
            loopnum=A[B[B.size()-1]]-1;
        }else{
            flag[A[B[count]]-1]=1;
            B.push_back(A[B[count]]-1);
            count++;
        }
    }

    long len=B.size();
    long loop_size;
    long loop_start=0;
    for(long i=0; i<B.size(); i++){
        if(B[i]==loopnum){
            loop_size=len-i;
            loop_start=i;
        }
    }
    if(K<=loop_start){
        std::cout << B[K]+1 << std::endl;
    }else{
        long loop=K-loop_start;
        std::cout << B[loop_start+loop%loop_size]+1 << std::endl;
    }

    return 0;
}

Measured memory_bytes: 7048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  double sum = 0.0;
  cin >> N;
  vector<int> a(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> a[i];
    sum += a[i];
  }
  
  int SUM = round(sum/N);
  int ans = 0;
  for ( int i = 0; i < N; i++ ) {
    ans += ( a[i] - SUM ) * ( a[i] - SUM );
  }
  
  cout << ans << endl;
    
  return 0;
}

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    int N; cin >>N;
    vector<int> X(N); cin >> X;
    vector<int> Xs(X);
    
    sort(all(Xs));

    int lhs = Xs[N/2-1], rhs = Xs[N/2];

    rep(i, N) {
        if (X[i] <= lhs) {
            cout << rhs << endl;
        } else {
            cout << lhs << endl;
        } 
    }
}


Measured memory_bytes: 3840
from fractions import gcd
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=float('inf')
if k>max(a):
  print('IMPOSSIBLE')
else:
  for i in range(n):
    b=min(gcd(a[0],a[i]),b)
  if k%b==0:
     print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
    

Measured memory_bytes: 16212
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()) {
			int num = scanner.nextInt();
			int count = 0;
			if (num >= 2) {count++;}
			for(int i = 3; i <= num; i+=2) {
				if (isPrime(i)) {count++;}
			}
			System.out.println(count);
		}

	}
	
	private static boolean isPrime(int n) {
		if (n == 2) {return true;}
		if (n < 2 || n % 2 == 0) {return false;}

		for(int m = 3; m <= (int)(Math.sqrt(n)); m += 2) {
			if (n % m == 0) {return false;}
		}
		return true;
	}
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, k, x[100];

int main() {
	cin >> n >> k;
	inc(i, n) { cin >> x[i]; }
	
	int ans = 0;
	inc(i, n) { ans += min(x[i], k - x[i]) * 2; }
	
	cout << ans << endl;
	
	return 0;
}


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

int main(){
  int n,m;
  long long p = 1000000007;
  cin >> n >> m;
  long long ans;
  if(abs(n-m) > 1){
    cout << 0 << endl;
    return 0;
  }else if(n == m){
    ans = 2;
  }else{
    ans = 1;
  }
  for(int i = 1; i <= n; i++)
    ans = ans * i % p;
  for(int i = 1; i <= m; i++)
    ans = ans * i % p;
  cout << ans << endl;
  return 0;
}


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

int main()
{
    char s[1000], t[1000];
    int s_len, t_len;
    int min = 10000, counts = 0;

    cin >> s >> t;
    s_len = strlen(s);
    min = t_len = strlen(t);

    //cout << s_len << " " << t_len << endl;

    for (int i = 0; i <= s_len - t_len; i++)
    {
        for (int j = 0; j < t_len; j++)
        {
            if (s[i + j] == t[j])
            {
            }
            else
            {
                counts++;
            }
        }
        if (counts < min)
        {
            min = counts;
        }
        counts = 0;
    }

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

Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
LL n,x,m,a[100005],cnt,sum[100005],mpd[100005];
bool vis[100005];
int main(){
	scanf("%lld %lld %lld",&n,&x,&m);
	LL now=x;
	while(!vis[now])
	{
		vis[now]=true;
		a[++cnt]=now;
		sum[cnt]=sum[cnt-1]+now;
		mpd[now]=cnt;
		now*=now;
		now%=m;
	}
	if(n<=cnt)	printf("%lld",sum[n]);
	else
	{
		LL ans=sum[cnt];
		LL beg=mpd[now];
		LL len=(cnt-beg+1);
		n-=cnt;
		LL dodo=n/len;
		ans+=dodo*(sum[cnt]-sum[beg-1]);
		n-=dodo*len;
		LL i=beg;
		while(n-->0)
		{
			ans+=a[i];
			++i;
		}
		printf("%lld",ans);
	}
	return 0;
}

Measured memory_bytes: 4832
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
int main()
{
	ll int n;
	cin>>n;
	ll int a[n];
	for(ll int i=0;i<n;i++)
	{
		a[i]=0;
	} 
	ll int v[n];
	for(ll int i=0;i<n;i++)
	{
		cin>>v[i];
		a[v[i]-1]++;
	}
	ll int k=0;
	for(ll int i=0;i<n;i++)
	{
		if(a[i]>1)
			k+=a[i]*(a[i]-1);
	}
	k/=2;
	for(ll int i=0;i<n;i++)
	{
		if(a[v[i]-1]>1)
			cout<<k-(a[v[i]-1]-1);
		else
			cout<<k;
		if(i!=n-1){cout<<endl;}
	}
	return 0;
} 


Measured memory_bytes: 5760
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int cnt=0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
	if(i*500+j*100+k*50==x)cnt++;
      }
    }
  }
  cout<<cnt<<endl;


  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import collections
import sys

input = sys.stdin.readline

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

# 2人の持つ番号の差の絶対値が、2人の身長の和に等しい。
# j - i = Ai + Aj
# j - Aj = Ai + i
l = [j - aj for j, aj in enumerate(a, 1)]
r = [i + ai for i, ai in enumerate(a, 1)]
cnt = collections.Counter(r)
ans = 0
for i in l:
    ans += cnt[i]
print(ans)


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

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


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << #x << ": " << x << '\n';
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  
  if (a < 10 && b < 10) {
    cout << a * b << '\n';
  } else {
    cout << -1 << '\n';
  }
}


Measured memory_bytes: 256
#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++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int N, K; cin >> N >> K;
    vector<ll> h(N+1, 0);
    rep(i, N) cin >> h[i+1];

    ll const inf = 1LL<<59;
    vector<vector<ll>> dp(N+5, vector<ll>(N+5, inf));
    dp[0][0] = 0;

    repr(i, 1, N+1) repr(j, 1, i+1) {
        rep(k, i) chmin(dp[i][j], dp[k][j-1]+max(h[i]-h[k], 0LL));
    }

    ll ans = inf;
    rep(i, N+1) chmin(ans, dp[i][N-K]);
    cout << ans << endl;
    //rep(i, N+1) cout << dp[i][N-K] << endl;

    return 0;
}




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

typedef signed long long ll;
const int N = 55;
int A[N];

int main() {
	int n;
	ll ans = 0, sum = 0;
	cin >> n;
	for(int i = 0; i < n; cin >> A[i], sum += A[i], i++);
	for(int i = 0; i < n; sum -= A[i], ans += (sum * (ll)A[i]), i++);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//include
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

// conversion
inline int
toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

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

//math
template <class T>
inline T sqr(T x) { return x * x; }

template <class T>
inline T nCr(T n, T r)
{
    T num = 1;
    for (int i = 1; i <= r; ++i)
    {
        num *= (n - i + 1) / i;
    }
    return num;
}
template <class T>
inline T nPr(T n, T r)
{
    r = n - r;
    T sum = 1;
    int i;
    for (i = n; i >= r + 1; --i)
        sum *= i;
    return sum;
}

template <class T>
inline T facctorial(T k)
{
    T sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

//numeric
template <class T>
inline T gcd(T a, T b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

template <class T>
inline T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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())

//repetition
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

//constant
constexpr double EPS = 1e-10;
const double PI = acos(-1.0);
constexpr LL INF = 1e10;

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

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

int main()
{
    int n;
    cin >> n;
    cout << n * n * n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
map<int, int> factor(int m) {
	map<int, int>res;
	for (int i = 2; i*i <= m; i++) {
		while (m%i == 0) {
			res[i]++;
			m /= i;
		}
	}
	if (m != 1)res[m]++;
	return res;
}

/*--------Library Zone!--------*/

int n, ans;
multiset<int>se;
int fu(int x) {
	int s = 1;
	while (s <= x)s *= 2;
	return s;
}
signed main() {
	cin >> n;
	rep(i, n) {
		int a;
		cin >> a;
		se.insert(a);
	}
	while (se.size() > 1) {
		auto s = *se.rbegin();
		se.erase(--se.end());
		auto it = se.find(fu(s) - s);
		if (it != se.end()) {
			se.erase(it);
			ans++;
		}
	}
	cout << ans << endl;
	endre;
}


Measured memory_bytes: 9600
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  ll N; cin >> N;
  vector<ll> T;
  rep(i,N){
    ll inp; cin >> inp;
    T.pb(inp);
  }
  
  ll M; cin >> M;
  
  vector<pair<ll,ll> > PX;
  rep(i,M){
    ll p,x; cin >> p >> x;
    PX.pb(mp(p,x));
  }
  ll ans = 0;
  rep(i,N) ans += T[i];
  
  rep(i,M){
    cout << ans - T[PX[i].first-1] + PX[i].second << endl;
  }
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    try {
        val sc = Scanner(System.`in`)
        val n = Integer.parseInt(sc.nextLine())
        val a = sc.nextLine()
                .split(" ")
                .toTypedArray()
        if (n < 1 || n > 36 || n != a.size) throw Exception("Illegal input")
        val aBubbleSorted = bubbleSort(a.clone())
        val aSelectionSorted = selectionSort(a.clone())
        println(aBubbleSorted.joinToString(" "))
        println(isStable(a, aBubbleSorted))
        println(aSelectionSorted.joinToString(" "))
        println(isStable(a, aSelectionSorted))
    } catch (e: Exception) {
        println(e)
    }
}

fun isStable(original: Array<String>, sorted: Array<String>): String {
    val s = original.size
    for (i in 0 until s) {
        for (j in i + 1 until s) {
            for (a in 0 until s) {
                for (b in a + 1 until s) {
                    val ni = getN(original[i])
                    val nj = getN(original[j])
                    if (ni == nj && original[i] == sorted[b] && original[j] == sorted[a]) return "Not stable"
                }
            }
        }
    }
    return "Stable"
}

fun getN(card: String): Int = Integer.parseInt(card.substring(1))

fun bubbleSort(a: Array<String>): Array<String> {
    for (i in a.size downTo 0) {
        for (j in 1 until i) {
            if (getN(a[j - 1]) > getN(a[j])) {
                val tmp = a[j]
                a[j] = a[j - 1]
                a[j - 1] = tmp
            }
        }
    }
    return a
}

fun selectionSort(a: Array<String>): Array<String> {
    for (i in 0 until a.size) {
        var minJ = i
        for (j in i until a.size) {
            if (getN(a[j]) < getN(a[minJ])) {
                minJ = j
            }
        }
        if (i == minJ) continue
        val tmp = a[i]
        a[i] = a[minJ]
        a[minJ] = tmp
    }
    return a
}



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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		
		String[] w = new String[n];
		Set<String> set = new HashSet<>();
		for (int i = 0; i < n; i++) {
			w[i] = sc.next();
			set.add(w[i]);
		}
		
		for (int i = 1; i < n; i++) {
			if (w[i].charAt(0) != w[i - 1].charAt(w[i - 1].length() - 1)) {
				System.out.println("No");
				return;
			}
		}
		
		System.out.println((set.size() == n) ? "Yes" : "No");

	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	int cp = n;
	int sum = 0;
	while(cp){
		sum += cp % 10;
		cp /=10;
	}
	bool f = n % sum == 0;
	cout << (f ? "Yes" : "No") << endl;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  string n;
  cin >> n;

  ll last = n.size() - 1;

  if (n[last] == '3') {
    cout << "bon"
         << "\n";
  } else if (n[last] == '0' || n[last] == '1' || n[last] == '6' ||
             n[last] == '8') {
    cout << "pon"
         << "\n";
  } else {
    cout << "hon"
         << "\n";
  }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,t,c[10000],m[10000];
  cin>>n>>t;
  vector<pair<int, int> > pp(n);
  for(int i=0;i<n;i++){
    cin>>c[i]>>m[i];
    pp[i] = make_pair(c[i],m[i]);
  }
  sort(pp.begin(),pp.end());
  for(int i=0;i<n;i++){
    if(t>=pp[i].second){
       cout<<pp[i].first;
      return(0);
    }
  }
  cout<<"TLE\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	char b='-';
	string s;
	bool flag=true;
	map<string,int>mp;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s[0]!=b&&b!='-')flag=false;
		if(mp[s]++==1)flag=false;
		b=s.back();
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
import os

MOD = 10 ** 9 + 7


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

    A, B, K = list(map(int, sys.stdin.buffer.readline().split()))
    print(A-K, B) if K <= A else print(0, B-(K-A)) if K <= A+B else print(0, 0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int h,w;cin>>h>>w;
    vvin a(h,vin(w)),b(h,vin(w)),c(h,vin(w));
    rep(i,h)rep(j,w)cin>>a[i][j];
    rep(i,h)rep(j,w){
        cin>>b[i][j];
        c[i][j]=abs(a[i][j]-b[i][j]);
    }
    const int num=80*160*2+1;
    vector<vvin> dp(2,vvin(w,vin(num)));//0,1
    dp[0][0][80*160+c[0][0]]=1;
    dp[0][0][80*160-c[0][0]]=1;
    int tmp;
    rep(i,h){
        tmp=i%2;
        if(i>0)rep(j,w)rep2(k,num/2-80*(i+j+2),num/2+80*(i+j+2)+1)dp[tmp][j][k]=0;//kの範囲を80*160-80(i+j+2)~80*160+80(i+j+2)にすればもうちょっと早い
        rep(j,w)rep2(k,num/2-80*(i+j+2),num/2+80*(i+j+2)+1){
            if(j>0&&dp[tmp][j-1][k]){
                dp[tmp][j][k+c[i][j]]=1;
                dp[tmp][j][k-c[i][j]]=1;
            }
            if(i>0&&dp[(tmp+1)%2][j][k]){
                dp[tmp][j][k+c[i][j]]=1;
                dp[tmp][j][k-c[i][j]]=1;
            }
        }
    }
    rep(i,num/2+1){
        if(dp[(h-1)%2][w-1][80*160+i]||dp[(h-1)%2][w-1][80*160-i]){
            cout<<i<<endl;
            return 0;
        }
    }
}

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

#define world main
#define fate cin
#define reinforce cout
#define moratorium return
#define zero 0
#define nostalgia endl
#define eternal while
#define de >>
#define the <<
#define key )
#define night (
#define destiny 1
#define lost =
#define as +
#define secret 10
#define get ()
#define down {
#define death }
#define have /=
#define done ;
typedef int dark;


dark world get down
	dark vais, leon done
	eternal night fate de vais de leon key down
		dark god lost destiny done
		dark ex lost vais as leon done
		eternal night ex have secret key god++ done
		reinforce the god the nostalgia done
	death
	moratorium zero done
death

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
#include<deque>
#include<map>

typedef long long ll;

#define debug(x) cout << #x << "=" << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++)cout << a[i] << " "
#define inf 100000000000
#define loop(i,n) for(ll i = 0; i < n; i++)

using namespace std;

ll num = 1000000007;

ll multiplication(ll a, ll b){
    ll aa = a % num;
    ll bb = b % num;
    return (aa * bb) % num;
}

ll exp(ll x, ll n){
    if(n == 1)return x;
    if(n % 2 == 1) return multiplication(exp(x, n-1) ,x);
    ll tmp = exp(x, n/2);
    return multiplication(tmp, tmp);
}

ll factorial(ll a){
    ll result = 1;
    loop(i,a){
        result = multiplication(result, a-i);
    }
    return result;
}

ll combination(ll n,ll a){
    // x/y を求める 
    ll x = 1;
    // if(a * 2 > n) a = n-a;
    loop(i,a){
        x = multiplication(x, n-i);
    }
    ll factA = factorial(a);
    ll yRev = exp(factA, num -2);
    return multiplication(x,yRev);
}

int main(){
    ll n,a,b,result;
    cin >>n >>a >>b;
    result = exp(2,n);
    ll combA = combination(n,a);
    ll combB = combination(n,b);

    result = result - combA - combB - 1;
    while(result < 0){
        result += num;
    }

    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e11;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    ll n,m,a,b;
    P city[100005];
    ll pre[100005];
    ll c[100005] = {0};
    cin >> n >> m;
    rep(i,m){
        cin >> a >> b;
        city[i] = P(b,i);
        pre[i] = a;
    }
    sort(city,city+m);
    ll ans[100005][2];
    rep(i,m){
        a = pre[city[i].second];
        c[a]++;
        ans[city[i].second][0] = a;
        ans[city[i].second][1] = c[a];
    }
    rep(i,m){
        printf("%06d",ans[i][0]);
        printf("%06d\n",ans[i][1]);
    }
}

Measured memory_bytes: 6144
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

s = 0
for i in range(N + 1):
    if i % 3 != 0 and i % 5 != 0:
        s += i

print(s)

Measured memory_bytes: 9692
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      r = i*500 + j*100 + k*50
      if r == X:
        count = count + 1

print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
   ll a,b,c;
   cin>>a>>b>>c;
   ll s=c-a-b;
   if(s>0&&(4*a*b)<(s*s))cout<<"Yes";
   else
    cout<<"No";
    return 0;
}







Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
long long a[300005];
long long all1[300005][65];
long long all0[300005][65];
int main(){
	long long n;
	cin>>n;
	long long cnt;
	for(long long i=0;i<n;i++){
		if(i!=0){
			for(long long j=0;j<65;j++){
				all1[i][j]=all1[i-1][j];
				all0[i][j]=all0[i-1][j];
			}
		}
		cnt=0;
		cin>>a[i];
		long long tmp=a[i];
		while(tmp!=0){
			cnt++;
			if(tmp%2==0){
				all0[i][cnt]++;
			}else if(tmp%2==1){
				all1[i][cnt]++;
			}
			tmp/=2;
		}
		for(long long j=cnt+1;j<65;j++){
			all0[i][j]++;
		}
	}
	long long ans=0;
	for(long long i=0;i<n;i++){
		long long tmp=a[i];
		cnt=0;
		while(tmp!=0){
			cnt++;
			long long p=pow(2,cnt-1);
			long long mul=p%1000000007;
			if(tmp%2==1){
				long long cha=(all0[n-1][cnt]-all0[i][cnt])%1000000007;
				long long anss=mul*cha%1000000007;
				ans=ans%1000000007+anss;
				ans=ans%1000000007;
			}else if(tmp%2==0){
				long long cha=(all1[n-1][cnt]-all1[i][cnt])%1000000007;
				long long anss=mul*cha%1000000007;
				ans=ans%1000000007+anss;
				ans%=1000000007;
			}
			tmp/=2;
		}
		for(int j=cnt+1;j<65;j++){
			long long p=pow(2,j-1);
			long long mul=p%1000000007;
			long long cha=(all1[n-1][j]-all1[i][j])%1000000007;
			long long anss=mul*cha%1000000007;
			ans=ans%1000000007+anss;
			ans=ans%1000000007;
		}
	}
	cout<<ans;
//	cout<<endl;
//	for(int i=0;i<10;i++){
//		cout<<all0[n-1][i]<<endl;
//	} 
	return 0;
}

Measured memory_bytes: 307328
#include<iostream>
#include<cstdio>
using namespace std;
int n,cnt;
long long up[101010],siz[101010],a[101010];
int nxt[202020],to[202020],fir[101010];
char S[3][10]={"NO","YES"};
void add(int x,int y)
{
	nxt[++cnt]=fir[x];fir[x]=cnt;
	to[cnt]=y;
}
int dfs(int x,int f)
{
	siz[x]=up[x]=0;
	int c=0;
	for(int i=fir[x];i;i=nxt[i])
	if(to[i]!=f)
	{
		c++;
		int di=dfs(to[i],x);
		if(!di) return 0;
		long long k=up[to[i]];
		long long f2=min(k,up[x]);
		k-=f2;up[x]-=f2;
		long long fl=min(siz[x],k/2);
		k-=fl*2;siz[x]+=fl+f2;
		up[x]+=k;
	}
	if(c==0) { up[x]=a[x]; return 1; }
	if(x==1)
	{
		if(c==1) return up[x]==a[x];
		else return up[x]==0&&siz[x]==a[x];
	}
	else if(up[x]+siz[x]>a[x]) return 0;
	else if(up[x]+siz[x]<=a[x])
	{
		long long k=a[x]-up[x]-siz[x];
		if(siz[x]<k) return 0;
		siz[x]-=k;up[x]+=k*2;
	}
	return 1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n-1;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
	}
	printf("%s\n",S[dfs(1,0)]);
	return 0;
}

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

using namespace std;

int main() {
	long long int N;
	cin >> N;
	vector<long long int>A( N ), B( N ), Hmax( N ), Hmin( N, 1 ), Wmax( N ), Wmin( N, 1 );
	for( size_t i = 0; i < N; i++ ) {
		cin >> A[i];
		if( (i&&A[i] - A[i - 1]) || i == 0 ) {
			Hmax[i] = A[i];
			Hmin[i] = A[i];
		} else {
			Hmax[i] = A[i];
			Hmin[i] = 1;
		}
	}
	for( size_t i = 0; i < N; i++ ) {
		cin >> B[i];
	}
	for( int i = N - 1; i >= 0; i-- ) {
		if( (i != N - 1 && B[i] - B[i + 1]) || i == N - 1 ) {
			Wmax[i] = B[i];
			Wmin[i] = B[i];
		} else {
			Wmax[i] = B[i];
			Wmin[i] = 1;
		}
	}
	long long int ans = 1;
	for( size_t i = 0; i < N; i++ ) {
		//cout << min( Hmax[i], Wmax[i] ) << " " << max( Hmin[i], Wmin[i] ) << endl;
		ans *= max( 0LL, (min( Hmax[i], Wmax[i] ) - max( Hmin[i], Wmin[i] ) + 1LL) ) % 1000000007LL;
		ans %= 1000000007LL;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4992
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printde(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int main(){
    int n; cin >> n;
    vector<vector<pair<int, int>>> edges(n);
    for(int i = 0; i < n - 1; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edges[a].emplace_back(b, c);
        edges[b].emplace_back(a, c);
    }
    int q, k;
    cin >> q >> k;
    k--;
    priority_queue<pair<ll, int>> pq;
    pq.push({0, k});
    vector<char> visited(n);
    vector<ll> lens(n, MLL);
    while(pq.size()){
        auto e = pq.top(); pq.pop();
        if(visited[e.second] || lens[e.second] <= e.first){ continue; }
        visited[e.second] = true;
        lens[e.second] = - e.first;
        for(auto edge : edges[e.second]){
            pq.push({e.first - edge.second, edge.first});
        }
    }
    prints(lens);
    for(int i = 0; i < q; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << lens[x] + lens[y] << '\n';
    }
    return 0;
}


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


int a, b, c, x;
  int solve(){
    int ans = 0;
    int res;
    for(int i = 0; i <= a; i++) {
      for(int j = 0; j <= b; j++) {
        for(int k = 0; k <= c; k++) {
         int res = i * 500 + j * 100 + k * 50;
         if(res == x){
           ans++;
         }
        }
      }
    }
    return ans;
  }

int main(void) {
  cin >> a >> b >> c >> x;
 int ans = solve();
 cout << ans << endl;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  ll N, K;
  cin >> N >> K;

  ll ans = 0;

  REP (b, K + 1, N + 1) {
    ans += (N + 1) / b * (b - K) + max(0LL, (N + 1) % b - K);
    if (K == 0) ans--;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  i64 a, b, c, d;
  cin >> a >> b >> c >> d;

  i64 r = max(max(a * c, a * d), max(b * c, b * d));
  cout << r;
}
#endif


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

const int N = 50 + 10;
double a[N];

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

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

vector<ll> memo(100000);

ll dfs(ll num) {
  if (num < 0) {
    return 1000000;
  } else if (num == 0) {
    return 0;
  } else if (num < 6) {
    return num;
  }
  if (memo[num] > 0) return memo[num];
  ll res = LLONG_MAX;
  for (ll i = 1; i <= num; i *= 6)
    res = min(res, 1 + dfs(num - i));
  for (ll i = 1; i <= num; i *= 9)
    res = min(res, 1 + dfs(num - i));

  return memo[num] = res;
}

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

  cout << dfs(n) << endl;
}

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

using namespace std;

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

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

typedef long long ll;
typedef unsigned long long ull;
typedef long long C;
typedef complex<C> P;
#define real X
#define imag Y

#ifndef ONLINE_JUDGE
#define debug(...) cerr << '[' << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  string s;
  cin >> s;
  if ((int) s.find("RRR") >= 0) {
    cout << 3;
  }
  else if ((int) s.find("RR") >= 0) {
    cout << 2;    
  }
  else if ((int) s.find("R") >= 0) {
    cout << 1;
  }
  else {
    cout << 0;
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int UI;

using namespace std;

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


    int n, x;
    cin >> n >> x;
    vector<int> m(n);

    REP(i, n)
    {
        cin >> m[i];
        x -= m[i];
    }

    int ans = n;

    sort(m.begin(), m.end());

    ans += (x / m[0]);

    cout << ans << endl;

    return 0;
}

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

using ll = long long;

void compress(vector<ll>& xs) {
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
}

int main() {
    ll n, L; cin >> n >> L;
    vector<ll> l(n), r(n);
    vector<ll> not_cover_cand, ps;
    for(int i = 0; i < n; ++i) {
        cin >> l[i] >> r[i];
        ps.push_back(l[i]);
        ps.push_back(r[i]);
        if(l[i] != 0) {
            not_cover_cand.push_back(l[i] - 1);
            ps.push_back(l[i] - 1);
        }
        if(r[i] != L) {
            not_cover_cand.push_back(r[i]);
        }
    }
    compress(ps);
    compress(not_cover_cand);

    const int m = ps.size();
    vector<ll> max_to(ps.size(), -1);
    for(int i = 0; i < n; ++i) {
        l[i] = lower_bound(ps.begin(), ps.end(), l[i]) - ps.begin();
        r[i] = lower_bound(ps.begin(), ps.end(), r[i]) - ps.begin();
        max_to[l[i]] = max(max_to[l[i]], r[i]);
    }
    for(int i = 0; i + 1 < m; ++i) {
        max_to[i + 1] = max(max_to[i + 1], max_to[i]);
    }

    int x = 0;
    for(ll i = 0, cur = 0; i < m && cur != m - 1; ++i) {
        x += 1;
        cur = max_to[cur];
    }

    vector<int> sum_l(m + 1), sum_r(m + 1);
    for(int i = 0; i < n; ++i) {
        sum_l[r[i]] += 1;
        if(l[i] != 0) {
            sum_r[l[i] - 1] += 1;
        }
    }
    for(int i = 0; i < m; ++i) {
        sum_l[i + 1] += sum_l[i];
    }
    for(int i = m - 1; i >= 0; --i) {
        sum_r[i] += sum_r[i + 1];
    }
    int y = 0;
    for(auto p : not_cover_cand) {
        p = lower_bound(ps.begin(), ps.end(), p) - ps.begin();
        //cout << ps[p] << " " << " -> " << sum_l[p] << " " << sum_r[p] << endl;
        y = max(y, sum_l[p] + sum_r[p]);
    }
    cout << x << " " << y + 1 << endl;
}



Measured memory_bytes: 22436
x1, y1, x2, y2 = gets.split.map(&:to_i)
xdif = x1 - x2
ydif = y1 - y2
x3 = x2 + ydif
y3 = y2 - xdif
x4 = x1 + ydif
y4 = y1 - xdif
puts "#{x3} #{y3} #{x4} #{y4}"

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX
#include <iomanip>

using namespace std;
int MOD = 998244353;
const int mxN = 2e5 + 9;

int ar[mxN];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int N,M,tmp;
	int sm = 0;
	cin >> N >> M;
	for(int i=1; i <= M; i++){
        cin >> tmp;
        sm += tmp;
	}
	if( sm > N ) cout << -1;
	else{
        cout << N-sm;
	}

}


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

bool checkInput(int iInput);

int main()
{
	int iInputA; //A
	int iInputB; //B
	int iInputC; //C
	int iLoop;
	int iYakusuuCount;
	
	//入力
	cin >> iInputA >> iInputB >> iInputC;
	//数値チェック
	if ((checkInput(iInputA) == false)
		|| (checkInput(iInputB) == false)
		|| (checkInput(iInputC) == false)){
		//1から10000までの整数を入力してください。

		return (-1);
	}
	else if (iInputA > iInputB){

		//A<=Bの数値を入力してください。
		return (-2);
	}

	iYakusuuCount = 0;
	//
	for (iLoop = iInputA; iLoop <= iInputB; iLoop++) {
		//CがA～Bの数値を割り切れるか
		if ((iInputC % iLoop) == 0) {
			//割り切れたため、約数の数を＋１
			iYakusuuCount++;
		}
	}

	//約数の数を出力
	cout << iYakusuuCount << endl;
}

//入力数値チェック(1<= 入力数値 <= 10000)
bool checkInput(int iInput)
{
	if ((iInput < 1)|| (iInput >10000))
	{
		return false;
	}
	return true;
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <stdlib.h>
 
int		main()
{
	int		N, sum, mid;
	int		*rally;
	int		i, r1 = 0, r2 = 0, result = 0;
 
	sum = 0;
	i = 0;
	r1 = scanf("%d\n", &N);
	if (N < 1 || N > 100 || r1 == EOF)
		return (-1);
	rally = (int *)malloc(sizeof(int) * N + 1);
	if (!rally)
	    return (-1);
	while (i < N)
	{
		r2 = scanf("%d", &rally[i]);
		if(rally[i] < 1 || rally[i] > 100 || r2 == EOF)
		    return (-1);
		sum += rally[i];
		i++;
	}
	mid = sum / N;
	if (sum % N != 0 && (sum % N) > (N / 2))
		mid++;
	i = 0;
	while (i < N)
	{
		result += ((rally[i] - mid) * (rally[i] - mid));
		i++;
	}
	printf ("%d\n", result);
	return (0);
}

Measured memory_bytes: 128