akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

int n, a[200200];
bool b[1001001] = {}, c[1001001] = {};
int main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
        if(c[a[i]])b[a[i]] = true;
        if(!b[a[i]]){
            for(int j=2; j*a[i] <= 1000000; j++){
                b[j*a[i]] = true;
            }
        }
        c[a[i]] = true;
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        ans += !b[a[i]];
    }
    printf("%d\n", ans);
}

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

#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define abs(x) ((x)>0?(x):-(x))

int main()
{
	int N;
	int W[100];
	int sum = 0;

	scanf("%d", &N);

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &W[i]);
		sum += W[i];
	}
	
	int min = sum;
	int n;

	for (int i = 0; i < N; i++)
	{
		n = 0;
		for (int k = 0; k <= i; k++)
		{
			n += W[k];
		}
		//printf("::::%d::::\n", n);
		//printf("[[[[%d]]]]\n",abs(n - (sum - n)));
		if (abs(n-(sum-n)) < min)
			min = abs(n-(sum-n));
	}

	printf("%d\n", min);
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int c[3][3];
    repi(i,3,0){
        repi(j,3,0){
            cin >> c[i][j];
        }
    }
    repi(i,101,-100){
        repi(j,101,-101){
            repi(k,101,-101){
                int cnt = 0;
                repi(l,3,0){
                    if(c[0][l] - i == c[1][l] - j && c[1][l] - j == c[2][l] - k && c[2][l] - k == c[0][l] - i)cnt++;
                }
                if(cnt == 3){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>




int main() {
	int n, k; std::cin >> n >> k;
	if (k == 1) {
		std::cout << 0 << std::endl;
	}
	else {
		std::cout << n - k << std::endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stack>
using namespace std;

int main() {
    int a, b;
    char s[100];
    stack<int> S;
    
    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a+b);
        } else if (s[0] == '-') {
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a-b);
        } else if (s[0] == '*') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a*b);
        } else {
            S.push(atoi(s));
        }
    }
    
    printf("%d\n", S.top());
    
    return 0;
}


Measured memory_bytes: 2756
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

bool checked[1000010];

int f(int n) {
    if(n % 2 == 0) return n / 2;
    else return 3 * n + 1;
}
 
signed main() {
    int s; cin >> s;

    for(int i=1; ; i++) {
        if(checked[s]) {
            cout << i << endl;
            return 0;
        }
        checked[s] = true;
        s = f(s);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(auto i=a;i<b;i++)
#define FORI(i,a,b) for(auto i=a;i<=b;i++)
#define RFOR(i,a,b) for(auto i=a;i>=b;i--)
#define FORV(i,a) for(auto i=a.begin();i!=a.end();i++)
#define VI vector<int>
#define PB push_back
#define VL vector<long>
#define VLL vector<long long>
#define VS vector<string>
#define VC vector<char>
#define READ(n) int n; cin>>n
#define READARR(a,n) FOR(i,0,n) {cin>>a[i];}
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e3; int n;
const int mid = 2*maxN;
char ss[maxN + 1];
string a, b, c;

bool ab[2*mid+1], ac[2*mid+1], bc[2*mid+1];
bool match(char ca, char cb)
{
  return ca == cb || ca == '?' || cb == '?';
}
void fillMatches(string &s, string &t, bool shifts[])
{
  memset(shifts, true, sizeof(bool)*(2*mid+1));
  for (int i = 0; i < s.size(); i++)
    for (int j = 0; j < t.size(); j++)
      shifts[mid + (i - j)] &= match(s[i], t[j]);
}

int main()
{
  while (scanf(" %s", ss) != EOF)
  {
    a = string(ss);
    scanf(" %s", ss); b = string(ss);
    scanf(" %s", ss); c = string(ss);
    DEBUG printf("%s - %s - %s\n", a.c_str(), b.c_str(), c.c_str());

    fillMatches(a, b, ab);
    fillMatches(a, c, ac);
    fillMatches(b, c, bc);

    int ans = 3*maxN;
    int aSize = a.size(), bSize = b.size(), cSize = c.size();
    for (int i = -mid; i <= mid; i++)
      for (int j = -mid; j <= mid; j++)
        if (ab[mid + i] && ac[mid + j] && bc[mid + (j - i)])
        {
          int left = max({-i, -j, 0});
          int right = max({(i + bSize) - aSize, (j + cSize) - aSize, 0});
          ans = min(ans, left + aSize + right);
        }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
 
namespace std{
  bool operator < (const P &a,const P &b){
    return (a.real()<b.real()||(a.real()==b.real() && a.imag()<b.imag()));
  }
}
 
double eps=1e-10;
 
double Sqrt(double x){
  return sqrt(max(0.0,x));
}
 
struct S{
  P p,q;
  S(P p,P q):p(p),q(q){}
};
 
struct C{
  P p;
  double r;
  C(P p,double r):p(p),r(r){}
  C(double x,double y,double r):p(P(x,y)),r(r){}
};
 
S getTangent(C a,P p){
  P base=a.p-p;
  double w=Sqrt(norm(base)-a.r*a.r);
  P s=p+base*P(w,a.r)/norm(base)*w;
  P t=p+base*P(w,-a.r)/norm(base)*w;
  return S(s,t);
}
 
int main(){
  double ax,ay,ar,bx,by;
  cin>>bx>>by>>ax>>ay>>ar;
  S ans=getTangent(C(ax,ay,ar),P(bx,by));
  if(ans.q<ans.p)swap(ans.q,ans.p);
  printf("%.10f %.10f\n",ans.p.real(),ans.p.imag());
  printf("%.10f %.10f\n",ans.q.real(),ans.q.imag());
  return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <vector>
int main()
{
    long long n, x = 0;
    std::cin >> n;
    std::vector<long long> a(n);
    for (long long i = 0; i < n; ++i) {
        std::cin >> a[i];
        x ^= a[i];
    }
    for (long long i = 0; i < n; ++i) {
        if (i != 0) std::cout << ' ';
        std::cout << (x ^ a[i]);
    }
    std::cout << std::endl;
}


Measured memory_bytes: 4752
#include <stdio.h>

int main(void)
{
	int x , y , d , tmp;
	scanf("%d %d",&x,&y);
	if(x < y)
	{
		tmp = x;
		x = y;
		y = tmp;
	}
	d = x % y;
	while(d != 0)
	{
		x = y;
		y = d;
		d = x % y;
	}
	printf("%d\n",y);
}


Measured memory_bytes: 2092
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int h = scanner.nextInt();
        int a = scanner.nextInt();

        int result = h / a;
        result = (h % a) == 0 ? result : result + 1;

        System.out.println(result);
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
class UnionFind {
public:
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool connect(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main(){
    int H,W;cin >> H >> W;
    vector<string> field;
    for(int a = 0;a < H;a++){
        string s;cin >> s;
        field.push_back(s);
    }
    vector<UnionFind> tate(H, UnionFind(W));
    for(int a = 0;a < H;a++){
        for(int b = 1;b < W;b++){
            if(field.at(a).at(b) == '#' || field.at(a).at(b-1) == '#')continue;
            tate.at(a).connect(b, b-1);
        }
    }
    vector<UnionFind> yoko(W, UnionFind(H));
    for(int a = 0;a < W;a++){
        for(int b = 1;b < H;b++){
            if(field.at(b).at(a) == '#' || field.at(b-1).at(a) == '#')continue;
            yoko.at(a).connect(b, b-1);
        }
    }
    int ans = 0;
    for(int a = 0;a < H;a++){
        for(int b = 0;b < W;b++){
            if(field.at(a).at(b) == '#'){
                continue;
            }
            ans = max(ans, tate.at(a).size(b) + yoko.at(b).size(a)-1);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 35840
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pm(m) for(auto itr=(m).begin();itr!=(m).end();itr++){itr->first<<" "<<itr->second<<"\n";}
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
#define bug(x) cout<<(x)<<" ";exit(0);
int mod = 1000000007;
int mod1 = 998244353;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}


void dfs(int u){

	vis[u]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(vis[v]!=1)
			dfs(v);
	}
}



int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void u(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb]){
            v[ra] = v[rb];
            sz[rb]+=sz[ra];
        }else{
            v[rb]=v[ra];
            sz[ra]+=sz[rb];
        }
    }
    bool f(int a,int b){
        //same set
        return (root(a)==root(b));
    }
   
    
};
vector<int> matmul(vector<int> a,vector<int> b){
    vector<int> c(4,0);
    c[0] = (a[0]%mod*b[0]%mod + a[1]%mod*b[2]%mod)%mod;
    c[1] = (a[0]%mod*b[1]%mod + a[1]%mod*b[3]%mod)%mod;
    c[2] = (a[2]%mod*b[0]%mod + a[3]%mod*b[2]%mod)%mod;
    c[3] = (a[2]%mod*b[1]%mod + a[3]%mod*b[3]%mod)%mod;
    return c;
}
vector<int> id={1,0,0,1};

int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    int ans=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(v[i]==v[j] or v[i]==v[k] or v[k]==v[j])continue;
                if(v[i]+v[j]>v[k] and v[j]+v[k]>v[i] and v[i]+v[k]>v[j])ans++;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 6008
import scala.io.StdIn

object Main extends App {

  val Array(a, b, c) = StdIn.readLine().split(' ').map(_.toDouble)
  val rad = scala.math.toRadians(c)
  val s = (scala.math.sin(rad) * a * b ) / 2
  val h = scala.math.sin(rad) * b
  // 余弦定理
  val x = scala.math.sqrt(a*a + b*b - 2*b*a*scala.math.cos(rad)) + a + b
  
  println(f"$s%.8f")
  println(f"$x%.8f")
  println(f"$h%.8f")
  
}


Measured memory_bytes: 44360
from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))

ans = 0
d = defaultdict(int)
for i in A:
    d[i] += 1

for i in range(1, n+1):
    ans += d[i] * (d[i] -1) // 2

for i in A:
    if d[i] <= 1:
        print(ans)
    else:
        print(ans - (d[i] * (d[i] -1)//2) + ((d[i] - 1) * (d[i] - 2) // 2))


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

#define ll long long
#define ar array

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)

#define E_ACH2(x, a) for (auto& x: a)
#define E_ACH3(x, y, a) for (auto& [x, y]: a)
#define E_ACH4(x, y, z, a) for (auto& [x, y, z]: a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...) E_ACHC(__VA_ARGS__)(__VA_ARGS__)

const int mxN=2e5, M=1e9+7;
int n, k;
vector<ll> ap, an;

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

	cin >> n >> k;
	FOR(n) {
		ll a;
		cin >> a;
		if(a>0)
			ap.push_back(a);
		else
			an.push_back(-a);
	}
	sort(all(ap));
	sort(all(an));
	if(k==n?an.size()%2==0:ap.size()||k%2==0) {
		reverse(all(ap));
		reverse(all(an));
		ll ans=1;
		int i=0, j=0;
		for(; k; --k) {
			if(i<ap.size()&&(j>=an.size()||ap[i]>an[j])) {
				ans=ans*ap[i]%M;
				++i;
			} else {
				ans=ans*an[j]%M;
				++j;
			}
		}
		if(j&1) {
			//i j-2
			//i-2 j
			ans=1;
			if(i<ap.size()&&j-1>=0&&(j>=an.size()||i-1<0||ap[i]*ap[i-1]>an[j]*an[j-1])) {
				FOR(k, i+1)
					ans=ans*ap[k]%M;
				FOR(k, j-1)
					ans=ans*an[k]%M;
				//ans=ans*a[i]%M;
				//ans=ans*a[i+1]%M;
			} else {
				FOR(k, i-1)
					ans=ans*ap[k]%M;
				FOR(k, j+1)
					ans=ans*an[k]%M;
				//ans=ans*a[i]%M;
				//ans=ans*a[i+1]%M;
			}
		}
		cout << ans;
		return 0;
	}
	ll ans=1;
	for(int i=0, j=0; k; --k) {
		if(i<ap.size()&&(j>=an.size()||ap[i]<an[j])) {
			ans=ans*ap[i]%M;
			++i;
		} else {
			ans=ans*an[j]%M;
			++j;
		}
	}
	cout << (M-ans)%M;
}

Measured memory_bytes: 5556
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>
#include <iomanip>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

const double pi = acos(-1.0);

template <class T = double>
struct coord {
  T x, y;
  coord<T> operator-() const {return {-x, -y};}
  T norm_sq() const {return x * x + y * y;}
  coord<T> operator+(const coord &p) const {return {x + p.x, y + p.y};}
  coord<T> operator-(const coord &p) const {return {x - p.x, y - p.y};}
  T operator*(const coord &p) const {return x * p.x + y * p.y;}
  T det(const coord &p) const {return x * p.y - y * p.x;}
  bool operator<(const coord &p) const {
    if(x != p.x) return x < p.x;
    return y < p.y;
  }
};

template <class T = double>
struct point {
  int id;
  coord<T> cd;
  bool operator<(const point &p) const {
    return cd < p.cd;
  }
};

vector<point<>> convex_hull(const vector<point<>> &ps) {
  int n = ps.size();
  int k = 0;
  vector<point<>> qs(n * 2);
  REP(i,0,n) {
    while(k > 1 && (qs[k-1].cd-qs[k-2].cd).det(ps[i].cd-qs[k-1].cd) <= 0) {
      k--;
    }
    qs[k++] = ps[i];
  }
  for(int i = n-2, t = k; i >= 0; i--) {
    while (k > t && (qs[k-1].cd-qs[k-2].cd).det(ps[i].cd-qs[k-1].cd) <= 0) {
      k--;
    }
    qs[k++] = ps[i];
  }
  qs.resize(k - 1);
  return qs;
}

double arg(coord<double> p, coord<double> q) {
  double norm = sqrt(p.norm_sq() * q.norm_sq());
  return acos(p * q / norm) / pi / 2.0;
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<point<>> ps(n);
  REP(i,0,n) {
    ps[i].id = i;
  }
  FOR(p,ps) {
    cin >> p.cd.x >> p.cd.y;
  }
  sort(ps.begin(), ps.end());
  vector<point<>> qs = convex_hull(ps);
  int k = qs.size();
  vector<double> ans(n, 0.0);
  REP(i,0,k) {
    int prev = (i - 1 + k) % k;
    int next = (i + 1) % k;
    coord<> v1 = qs[i].cd - qs[prev].cd;
    coord<> v2 = qs[next].cd - qs[i].cd;
    double t = arg(v1, v2);
    ans[qs[i].id] = t;
  }
  FOR(a,ans) {
    cout << setprecision(20) << a << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAX_N = 100000;
const int MAX_LOG_N = 17;
 
int m[MAX_LOG_N][MAX_N];
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++) cin >> x[i];
	int L, q;
	cin >> L >> q;
	for (int i = 0; i < n; i++) {
		int nex = upper_bound(x.begin() + i, x.end(), x[i] + L) - x.begin();
		nex--;
		m[0][i] = nex;
	}
 
	for (int i = 0; i + 1 < MAX_LOG_N; i++) {
		for (int j = 0; j < n; j++) {
			if (m[i][j] == n) m[i + 1][j] = n;
			else m[i + 1][j] = m[i][m[i][j]];
		}
	}
 
	for (int i = 0; i < q; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		if (a > b) swap(a, b);
		int ng = 0, ok = n - 1;
		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			int cur = a;
			for (int i = 0; i < MAX_LOG_N; i++) {
				if (mid & (1 << i)) cur = m[i][cur]; 
			}
			if (cur >= b) ok = mid;
			else ng = mid;
		}
		cout << ok << endl;
	}
	return 0;
}

Measured memory_bytes: 7936
n = int(input())
s = list(input())
cum = [0]*(n+1)
for i in range(1,n+1):
    cum[i] = cum[i-1]
    if s[i-1] == 'E':
        cum[i] += 1
cnt = n
for i in range(1,n+1):
    cnt = min(cnt, (i-1)-cum[i-1]+cum[n]-cum[i])
print(cnt)

Measured memory_bytes: 17484
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	l := a + b
	r := c + d
	switch {
	case l > r:
		fmt.Println("Left")
	case l < r:
		fmt.Println("Right")
	default:
		fmt.Println("Balanced")
	}
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int A,B;
    scanf("%d",&A);
    scanf("%d",&B);
    if(A==B*4/5){
        printf("%d",B*10);
        return 0;
    }else if(A*25%2==0 && A*5/4==B){
        printf("%d",A*100/8);
        return 0;
    }else if(A*25%2!=0 && A*5/4==B){
        printf("%d",A*25/2+1);
        return 0;
    }else{
        printf("%d",-1);
        return 0;
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    set<int>s;
    int n;
    int a[211111];
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        s.insert(a[i]);
    }
    if(s.size()<n)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 10368
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
bool check753(ll n){
  int shichi = 0, go = 0, san = 0;
  while(n){
    switch(n % 10){
      case 3: san++; break;
      case 5: go++; break;
      case 7: shichi++; break;
    }
    n /= 10;
  }
  return san > 0 && go > 0 && shichi > 0;
}
int main(){
  int n;
  cin >> n;
  vector<ll> shichigosan{3,5,7};
  int cnt = 3, before = 0;
  while(shichigosan[cnt - 1] < n){
    for(int i = before; i < cnt; i++){
      ll num = shichigosan[i] * 10;
      shichigosan.push_back(num + 3);
      shichigosan.push_back(num + 5);
      shichigosan.push_back(num + 7);
    }
    before = cnt;
    cnt *= 3;
  }
  int ans = 0;
  for(ll i : shichigosan){
    if(i > n) break;
    if(check753(i)){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll h,n; cin >> h >> n;
    ll sum = 0;
    rep(i,n){
        ll a; cin >> a;
        sum += a;
    }
    cout << (sum >= h ? "Yes" : "No") << endl;
}

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

using namespace std;

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

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

    vector <int> cost(n + 1);
    cost[2] = abs(a[2] - a[1]);
    for(int i = 3; i <= n; i++)
        cost[i] = min(cost[i - 1] + abs(a[i] - a[i - 1]),
                              cost[i - 2] + abs(a[i] - a[i - 2]));

    cout << cost[n];
    return 0;
}

Measured memory_bytes: 3948
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
O = input()
E = input()

Oq = deque(O)
Eq = deque(E)
ans = []
for i in range(len(O)):
    ans.append(Oq.popleft())
    if len(Eq)>0:
        ans.append(Eq.popleft())

print(*ans,sep="")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>
int main()
{   int n,q;
    scanf("%d%d",&n,&q);
    int l[q],r[q];
    char s[n+1];
    scanf("%s",s);
    for(int i=0;i<q;i++){
        scanf("%d%d",&l[i],&r[i]);
    }
    int chk[100001]={0};
    for(int i=1;i<n;i++){
        if(s[i]=='C'&&s[i-1]=='A'){
            chk[i]=chk[i-1]+1;
        }else{
            chk[i]=chk[i-1];
        }
        
    }
    for(int i=0;i<q;i++){
        printf("%d\n",chk[r[i]-1]-chk[l[i]-1]);   
    }
    
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    vector<string> vec;
    string tmp;
    vec.resize(3);
    cin >> vec[0] >> vec[1] >> vec[2];
    
    std::sort(vec.begin(),vec.end());
    
    tmp = vec[2] + vec[1];
    cout << std::stoi(tmp) + std::stoi(vec[0]) << endl;
    
    return 0;
}


Measured memory_bytes: 256
loop do
  n, m = gets.split.map(&:to_i)
  
  break if n == 0
  
  arr, cur, flg = n.times.map{ gets.to_i }, 0, false
  
  m.times do |i|
    
    cur += gets.to_i
    cur += arr[cur] if arr[cur]
    
    if cur >= n - 1 && !flg
      puts i + 1
      flg = true
    end
  end
end

Measured memory_bytes: 8812
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define MOD 1000000007
#define INF 2000000001

using namespace std;

int n, m, ans = INF, A[200001];
string s;
int main() {
	cin >> s;
	rep(i, s.size() - 2) {
		string t;
		t += s[i];
		t += s[i + 1];
		t += s[i + 2];
		int x =stoi(t);
		ans = min(ans, abs(x - 753));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    double D, T, S;
    cin >> D >> T >> S;
    if (D/S > T) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3668
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main(){
    
    H := nextInt()
    W := nextInt()
    N := nextInt()
    
    ans := make([]int, 10)
    
    p := make(map[Pair]struct{})
    set := make(map[Pair]struct{})
    
    for i := 1; i <= N; i++ {
        ai := nextInt()
        bi := nextInt()
        p[Pair{ai, bi}] = struct{}{}
        set[Pair{ai, bi}] = struct{}{}
        set[Pair{ai, bi-1}] = struct{}{}
        set[Pair{ai, bi-2}] = struct{}{}
        set[Pair{ai-1, bi}] = struct{}{}
        set[Pair{ai-1, bi-1}] = struct{}{}
        set[Pair{ai-1, bi-2}] = struct{}{}
        set[Pair{ai-2, bi}] = struct{}{}
        set[Pair{ai-2, bi-1}] = struct{}{}
        set[Pair{ai-2, bi-2}] = struct{}{}
        
    }
    tot := (Max([]int{0,H-2})*Max([]int{0,W-2}));
    for k, _ := range set {
        cnt := 0
        x := k.first
        y := k.second
        if InBoard(H, W, x, y) {
            continue
        }
        for i := 0; i <= 2; i++{
            for j := 0; j <= 2; j++{
                _, ok := p[Pair{x+i, y+j}]
                if ok {
                    cnt++
                }
            }
        }
        ans[cnt]++
    }
    sum := 0
    for i := 1; i <= 9; i++ {
        sum += ans[i]
    }
    ans[0] = tot-sum
    for i := 0; i < 10; i++ {
        fmt.Println(ans[i])
    }

}

func InBoard(H, W, x, y int) bool {
    return x<1 || (x>H-2) || y<1 || y>(W-2)
}

/* templates */


func Max(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    first, second int
}
 
type Pairs []Pair
  
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}

func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}

func nextStrings(n int) []string {
    r := make([]string, n)
    for i := 0; i < n; i++ {
        r[i] = nextString()
    }
    return r
}

func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}


Measured memory_bytes: 80256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#pragma warning( disable:4996 )
using namespace std;

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))

std::vector<std::vector<long long>> comb(int n, int r) {
	std::vector<std::vector<long long>> v(n + 1, std::vector<long long>(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]) % 1000000007;
		}
	}
	return v;
}

/*
#include <cstdint>
uintmax_t ccombination(unsigned int n, unsigned int r) {
	if (r * 2 > n) r = n - r;
	uintmax_t dividend = 1;
	uintmax_t divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
		//dividend %= 1000000007;
		//divisor %= 1000000007;
	}
	return dividend / divisor;
}*/
int main(void) {
	//FermatCombination *fc;
	//fc = new FermatCombination(100000, (long)1);
	int n, k;
	scanf("%d %d", &n, &k);
	std::vector<std::vector<long long>> v = comb(n, n);
	for (int i = 1; i <= k; i++) {

		 //printf("%lld\n", comb(n - k + 1, i)[n-k+1][i]* comb(k - 1, i - 1)[k-1][i-1] % 1000000007);
		printf("%lld\n", v[n - k + 1][i] * v[k - 1][i - 1] % 1000000007);
	}
	//delete fc;
	
	return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N;cin>>N;
    int bill,count;
    bill=count=1000;
    while(1){
        if(N>count){
            count+=bill;
        }
        else{
            cout<<count-N;
            return 0;
        }
    }
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(){
    string str;
    string answer = "CODEFESTIVAL2016";
    int count = 0;
  
    cin >> str;
    for(int i = 0; i < 16; i++){
      if(str[i] != answer[i]) count++;
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

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

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

    stable_sort(d.begin(), d.end());

    cout << d[N/2] - d[N/2 - 1] << endl;

    return 0;
}

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

const char vowels[] = {'a', 'i', 'u', 'e', 'o'};

bool isvowel(char c){
  for(int i = 0; i < 5; i++){
    if(c == vowels[i]) return true;
  }
  return false;
}

int main(void){
  while(1){
    int n; cin >> n;
    if(n == 0) break;
    vector<string> s(n);
    for(auto& _s: s) cin >> _s;

    vector<string> c(n);
    for(int i = 0; i < n; i++){
      string str("");
      string org = s[i];
      str += org[0];
      for(int i = 0; i < (int)org.size()-1; i++){
        if(isvowel(org[i])) str += org[i+1];
      }
      c[i] = str;
    }

    int kmax = 10000;
    for(int i = 0; i < (int)c.size(); i++){
      kmax = min(kmax, (int)c[i].size());
    }

    bool isinvalid = true;

    for(int k = 0; k <= 52; k++){
      vector<string> maybeunique(n);
      for(int i = 0; i < n; i++){
        maybeunique[i] = c[i].substr(0, min(k, (int)c[i].size()));
      }

      bool res = true;
      for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
          if(maybeunique[i] == maybeunique[j]){
            res = false;
          }
        }
      }
      if(res){
        isinvalid = false;
        cout << k << endl;
        break;
      }
    }
    if(isinvalid){
      cout << -1 << endl;
    }
  }
  return 0;
}



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

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

    cin>>a>>b;

    if(a<b){
        swap(a,b);
    }
    c=(a*b)/gcd(a,b);

    cout<<c<<endl;

    return 0;
}



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

int main(){
	int i = 1;
	int n;
	cin>>n;
	
	for(;i<=n;i++){
 		int x = i;
  		if ( x % 3 == 0 ){
    			cout << " " << i;
   		 }
  		else if ( x % 10 == 3 ){
    		cout << " " << i;
  		}
  		else if ( (x/10) % 10 == 3 )
    			cout << " " << i;
    		else if ( (x/100) % 10 == 3 )
    			cout << " " << i;
    		else if ( (x/1000) % 10 == 3 )
    			cout << " " << i;
    	 }
  	cout<<endl;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
int main() {
	int x; cin >> x;
  	if (x == 22)
      cout << "Christmas Eve Eve Eve" << endl;
  if (x == 23)
      cout << "Christmas Eve Eve" << endl;
  if (x == 24)
      cout << "Christmas Eve" << endl;
  if (x == 25)
      cout << "Christmas" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

template <typename T>
void quit(T a)
{
    cout << a << endl;
    exit(0);
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double pi = acos(-1);

int main()
{
    int n, m;
    cin >> n >> m;
    if (n == m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }



signed main()
{
	int a, b, c;
	cin >> a >> b >> c;
	YesNo(a + b >= c);
}



Measured memory_bytes: 3040
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
#define M0 1599937
#define M1 1599977

typedef long long ll;
ll mh_[2];
char S1[1000001];
char S2[10001];
int n,N;

ll mod_pow_s(ll m, int n, ll mod, char s){//
    ll x = 1;
    while (n > 0) {
        if (n&1) {
            x = (x*m)%mod;
        }
        m = (m*m)%mod;
        n >>= 1;
    }
    x = (x*s)%mod;
    return x;
}

ll makeMH(char S[],int n, ll m){//
    ll mh = 0;
    for (int i = 1; i <= n; i++) {
        mh = (mh + mod_pow_s(128,n-i,m,S[i-1]) )%m;
    }
    return mh;
}

bool CHECK(ll o[], ll s[]){//
    if (o[0] == s[0] && o[1] == s[1]) {
        return true;
    }else{
        return false;
    }
}

ll moding(ll h,ll m, int i){//
    h = (h - mod_pow_s(128,n-1,m,S1[i]) + m)%m;
    h = (h*128)%m;
    h = (h + S1[n+i])%m;
    return h;
}

void rolling(int N, int n){
    ll ORG[2];
    ORG[0] = makeMH(S2,n,M0);
    ORG[1] = makeMH(S2,n,M1);
    
    mh_[0] = makeMH(S1,n,M0);
    mh_[1] = makeMH(S1,n,M1);
    
    if(CHECK(ORG,mh_)){
        printf("0\n");
    }
    
    for (int i = 0; i < N - n; i++) {
        mh_[0] = moding(mh_[0],M0,i);
        mh_[1] = moding(mh_[1],M1,i);
        if (CHECK(ORG,mh_)) {
            printf("%d\n",i+1);
        }
    }
}

int main(){
    cin >> S1 >> S2;
    N = strlen(S1);
    n = strlen(S2);

    rolling(N,n);
    
    return 0;
}

Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define fi first
#define ii pair<int,int>
#define iil pair<ll,ll>
#define se second
#define ld long double
#define mod 1000000007
#define popcount __builtin_popcountll
#define x0 zxcxzcsacasd
#define x1 ghfghujfgfg
#define y0 olkjhdnncvcv
#define y1 bhvgrewm345345435
#define debug(x) std::cerr<<#x<<": "<<(x)<<'\n'
#define all(x) x.begin(), x.end()
using namespace std;

int main(){
	ll a, b, c, d;
	cin>>a>>b>>c>>d;
	ll amid = a * c;
	amid = max(amid, a * d);
	amid = max(amid, b * c);
	amid = max(amid, b * d);
	cout<<amid<<endl;
}


Measured memory_bytes: 3616
package main

import (
	"fmt"
	"math"
)

func makePattern(num int) [][]int {
    length := int(math.Pow(2, float64(num)))
    result := make([][]int, length)

    for i := 0; i < length; i++ {
        bi := i
        s := []int{}
        for n := 0; n < num; n++ {
            if bi % 2 != 0 {
                s = append(s, n)
            }
            bi = bi / 2

        }
        result[i] = s
    }

    return result
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

func countElem(c [][]bool, exRows []int, exCols []int) int {
	count := 0
	for i := 0; i < len(c); i++ {
		if (contains(exRows, i)) {
			continue
		}
		for j := 0; j < len(c[i]); j++ {
			if (contains(exCols, j)) {
				continue
			}
			if (c[i][j]) {
				count++
			}
		}
	}
	return count
}

func main() {
	var h, w, k int
	fmt.Scanf("%d %d %d", &h, &w, &k)
	c := make([][]bool, h)
	rowCount := make([]int, h)
	total := 0
	for i := 0; i < h; i++ {
		c[i] = make([]bool, w)
		rowCount[i] = 0;
		for j := 0; j < w; j++ {
			var tmp int
			fmt.Scanf("%c", &tmp)
			if (tmp == int('#')) {
				c[i][j] = true
				rowCount[i]++
			} else {
				c[i][j] = false
			}
		}
		fmt.Scanf("%s")		// 行末まで捨てる
		total += rowCount[i]
	}
    // fmt.Printf("%v", &c)

	answer := 0;
	rowPattern := makePattern(h)
	columnPattern := makePattern(w)
	for i := 0; i < len(rowPattern); i++ {
		remain := total
		for x := 0; x < len(rowPattern[i]); x++ {
			remain -= rowCount[rowPattern[i][x]]
		}
		if remain < k{
			continue
		}
		for j := 0; j < len(columnPattern); j++ {
			if k == countElem(c, rowPattern[i], columnPattern[j]) {
				answer++
			}
		}
	}
    fmt.Printf("%d", answer)
}


Measured memory_bytes: 1892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1LL << 60);
const ll MD = 1000000007LL;
// fprintf(stderr, "%d %lld \n", x, xll);

class Node{
public:
	vector<int> children;
	int parent;
	int op_same;
	int op_diff;
};

class Tree{
public:
	vector<Node> nodes;
	Tree(int n) {
		rep(i, n) { Node n;  nodes.push_back(n); }
	}
	Node& operator[](int i){
		return nodes[i];
	}
};

Tree T(0);
int X[1000];
int dp[5001][1001];

bool dfs(int ii){

    // fprintf(stderr, "in %d\n", ii);
	Node &n = T[ii];
	int x = X[ii];

	if (n.children.size() == 0){
		n.op_same = x;
		n.op_diff = 0;
        // fprintf(stderr, "out %d - %d %d\n", ii, n.op_same, n.op_diff);
		return true;
	}
	else{
		int nn = n.children.size();

		rep(i, nn) {
            int c = n.children[i];
			bool success = dfs(c);
			if(!success) return false;
		}

		// dp initialize
		for(int v = 0; v <= 5000; v++)
			for(int i = 0; i <= nn; i++)
				dp[v][i] = 0;
		dp[0][0] = 1;

		// dp
		for(int i = 0; i < nn; i++){
			int c = n.children[i];
			int v1 = T[c].op_same;
			int v2 = T[c].op_diff;
			for (int v = 0; v <= 5000; v++) {
				if (v - v1 >= 0 && dp[v - v1][i] == 1) dp[v][i+1] = 1;
				if (v - v2 >= 0 && dp[v - v2][i] == 1) dp[v][i+1] = 1;
			}
		}

		// answer
		int all = 0;
		rep(i, nn){
			int c = n.children[i];
			all += T[c].op_same + T[c].op_diff;
		}

		int max_eqless_x = -1;
		for(int v = 0; v <= x; v++) if(dp[v][nn] == 1){
			max_eqless_x = v;
		}

		if(max_eqless_x == -1){
			return false;
		}
		else{
			n.op_same = x;
			n.op_diff = all - max_eqless_x;
            // fprintf(stderr, "out %d - %d %d - %d\n", ii, n.op_same, n.op_diff, max_eqless_x);
            return true;
		}
	}
}


int main() {

	int N;
	cin >> N;
	T = Tree(N);

	// create tree
	T[0].parent = -1;
	for(int i = 1; i < N; i++){
		int p; cin >> p; p--;
		T[i].parent = p;
		T[p].children.push_back(i);
	}
	rep(i, N) cin >> X[i];

    /*
    rep(i, N){
        fprintf(stderr, "%d --- p:%d c:", i,  T[i].parent);
        rep(j, T[i].children.size()) fprintf(stderr, "%d ", T[i].children[j]);
        fprintf(stderr, "\n");
    }
     */

	// run dfs
	bool success = dfs(0);
	cout << (success ? "POSSIBLE" : "IMPOSSIBLE") << endl;

}

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

int main() {
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC" << endl;
  }
  else {
    cout << "ABC" << endl;
  }
}

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

using namespace std;

typedef long long ll;

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << W * H / 2. << " " << (2 * x == W && 2 * y == H) << endl;
    return 0;
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 x;
  cin >> x;
  ANS(10-x/200);
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

typedef vector<int> vi;

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

const int MAX = 1e5;

int N, M;
int Y[MAX], P[MAX];
vi cities[MAX];
map<int, int> mp[MAX];

int main() {

  cin >> N >> M;
  REP (i, M) {
    cin >> Y[i] >> P[i];
    Y[i]--;
    cities[Y[i]].push_back(P[i]);
  }

  REP (i, N) {
    vi c = cities[i];
    sort(c.begin(), c.end());
    REP (j, c.size()) {
      mp[i][c[j]] = j+1;
    }
  }

  REP (i, M) {
    cout << setw(6) << setfill('0') << Y[i]+1;
    cout << setw(6) << setfill('0') << mp[Y[i]][P[i]] << endl;
  }
}

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

using namespace std;

using ll = long long;
using ld = long double;

void solve() {
    int n;
    cin >> n;
    vector<ld> a(n);
    for (auto &e : a) cin >> e;

    vector<vector<ld>> dp(n + 1, vector<ld>(n + 1));
    dp[0][0] = 1;

    for (int i = 1; i <= n; i++) {
        dp[i][0] = dp[i - 1][0] * (1 - a[i - 1]);
        for (int j = 1; j <= i; j++) {
            dp[i][j] = dp[i - 1][j] * (1 - a[i - 1]);
            dp[i][j] += dp[i - 1][j - 1] * a[i - 1];
        }
    }

    ld ans = 0;
    for (int i = 0; i <= n; i++) {
        if (i > n - i) {
            ans += dp[n][i];
        }
    }

    cout << ans;
}

int main() {
    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}


Measured memory_bytes: 141056
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for _ in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)


d = {a: 0 for a in set(A)}
for a in A:
    d[a] += 1

ans = sum(A)
for b, c in zip(B, C):
    if b not in d.keys():
        print(ans)
        continue

    ans += c * d[b] - b * d[b]

    if c not in d.keys():
        d[c] = 0
    d[c] += d[b]
    del d[b]

    print(ans)


Measured memory_bytes: 105300