akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T x=0,f=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
#define int long long
namespace run{
	const int N=2e5+9;
	int num[N],A[N],n,ans;
	int main(){
		n=read<int>();
		for(int i=1;i<=n;i++) num[A[i]=read<int>()]++;
		for(int i=1;i<=n;i++) ans+=num[i]*(num[i]-1)/2;
		for(int i=1;i<=n;i++){
			int tmp=ans-num[A[i]]*max(0ll,(num[A[i]]-1))/2;
			printf("%lld\n",tmp+(max(num[A[i]]-1,0ll)*max(num[A[i]]-2,0ll)/2));
		}
		return 0;
	}
}
#undef int
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 4736
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int i = 1;
        while(ans < n){
            ans = i * i;
            i++;
            if(ans > n){
                ans = (i-2) * (i-2);
                break;
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;

using ll = long long;

ll solve(vector<ll> &va, ll x) {
  ll left = 0, right = 0, ans = 0;
  ll sum = 0;
  while (left < va.size()) {
    ll cnt = 0;
    while (right < va.size() && sum + va[right] <= x) {
      sum += va[right];
      right++;
      cnt++;
    }

    ans += right - left;

    if (left == right) {
      right++;
    } else {
      sum -= va[left];
    }

    left++;
  }

  return ans;
}

int main(int argc, const char *argv[]) {
  int n, q;
  cin >> n >> q;
  vector<ll> va(n);
  for (int i = 0; i < n; i++) {
    cin >> va[i];
  }

  vector<ll> vx(q);
  for (int i = 0; i < q; ++i) {
    cin >> vx[i];
  }

  for (auto x : vx) {
    cout << solve(va, x) << '\n';
  }

  return 0;
}


Measured memory_bytes: 3540
a, b, c, k = map(int, input().split())

#"ありうる値"の最大値なので、K枚選択時はa,b,cの順に選択する

card_num = 0 #カード枚数
card_sum = 0 #値の合計

#1card*k
if k <= a:
    card_sum = k
#1card*a + 0card*(k-a)
elif k <= a + b:
    card_sum = a
#1card*a + 0card*b + -1card*(k-a-b)
else:
    card_sum = a - (k-a-b)

print(card_sum)

Measured memory_bytes: 9184
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>
#include <complex>
 
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second
 
const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef complex<double> P;
int n;
 
double cross(P p1,P p2) {
    return (real(p1)*imag(p2) - imag(p1)*real(p2));
}
double calc_S(P p1,P p2,P p3) {
    double ret = 0.0;
    p1 -= p3;
    p2 -= p3;
 
    ret = cross(p1,p2)/2.0;
     
    return abs(ret);
}
 
int main() {
    cin>>n;
    while(n-->0) {
        double x1_,y1_;
        double x2_,y2_;
        double x3_,y3_;
        cin>>x1_>>y1_>>x2_>>y2_>>x3_>>y3_;
        P p1(x1_,y1_);
        P p2(x2_,y2_);
        P p3(x3_,y3_);
        P A = p1-p2;
        P B = p2-p3;
        P C = p1-p3;
        double S = calc_S(p1,p2,p3);
        double R = abs(A)*abs(B)*abs(C)/S;
        R /= 4.0;
         
        P A1 = 2.0*(p2-p1);
        P B1 = 2.0*(p3-p1);
        P C1 = P(norm(p1)-norm(p2),norm(p1)-norm(p3));
        double X = cross(P(imag(A1),imag(B1)),C1)/cross(A1,B1);
        double Y = cross(C1,P(real(A1),real(B1)))/cross(A1,B1);
        printf("%.3lf %.3lf %.3lf\n",X,Y,R);
 
    }
    return 0;
}

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

const int N=1e5+10;
int A[N], idx[N];
LL ans=0;
int main() {
	int n;
	scanf("%d", &n);
	REP(i,n) scanf("%d", &A[i]);
	REP(i,n) idx[A[i]]=i+1;

	set<int> s;
	s.insert(0);
	s.insert(n+1);
	for(int x=n; x>0; x--) { // permutation [1..n]
		int i=idx[x];
		LL c=0;
		{ // calculate ci
			if(s.size()==0) continue;
			int l1,l2,r1,r2; // l2 < l1 < i < r1 < r2
			auto it=s.upper_bound(i);
			auto it2=it;
			r1=*it;
			l1=*--it2;
			r2=(r1==n+1? r1:*++it);
			l2=(l1==0? 0:*--it2);
			// cout << l2 << ' ' << l1 << ' ' << r1 << ' ' << r2 << endl;;
			c=(LL)(l1-l2)*(r1-i)+(LL)(r2-r1)*(i-l1);
			s.insert(i);
		}
		ans+=x*c;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5760
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const tmp = readln.split.to!(int[]);
    const N = tmp[0], M = tmp[1], X = tmp[2], Y = tmp[3];

    const s0 = X+1;
    const e0 = Y;
    const s1 = readln.split.to!(int[]).sort!((a,b) => a < b).reduce!max + 1;
    const e1 = readln.split.to!(int[]).sort!((a,b) => a < b).reduce!min;

    writeln(s0 <= e0 && s1 <= e1 && s1 <= e0 && s0 <= e1 ? "No " : "", "War");
}



Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;

int main() {
	int i=0, j,k;
	int moji[30] = {};
	string S;
	cin >> S;
	for (i = 0; i < S.size(); ++i) {
		moji[S[i] - 'a'] = 1;
	}
	i = 0;
	for (i = 0; i < 26; ++i) {
		//cout<<moji[i];
	}
	i = 0;
	while (1) {
		
		if (moji[i] == 0) {
			cout << char(i+'a');
			break;
		}
		else if (i == 25) {
			cout << "None" << endl;
			break;
		}
		++i;
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
int main(void){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c-1){
        cout<<b+c<<endl;
    }else{
        cout<<a+b*2+1<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define INF 1e8
using namespace std;
int main(){
  int n,m,x,y,z,q,w,e;
  while(cin>>n>>m>>x>>y>>z,n++){
    int dp[n][n]={};
    r(i,n)r(j,n)if(i!=j)dp[i][j]=INF;
    r(i,m){
      cin>>q>>w>>e;
      dp[q][w]=e;
    }
    r(o,n)r(i,n)r(j,n)dp[i][j]=min(dp[i][j],dp[i][o]+dp[o][j]);
    int ans=INF;
    r(i,n)ans=min(ans,dp[x][i]+dp[i][y]+dp[i][z]);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3060
//QWsin
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

typedef long long ll;
const int INF=1<<30;
ll sqr(ll x){return x*x;}
int main()
{
//	freopen("std.in","r",stdin);
	ll a,b,c;cin>>a>>b>>c;
	if(c-a-b<=0){
		puts("No");
		return 0;	
	}
	if(4*a*b<sqr(c-a-b)){
		puts("Yes")	;
	}
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j;
  int A[N+1];
    int key;
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);

  
   for(i=2;i<n+1;i++){
    key=A[i];
    j=i-1;
    while(j>=0 && A[j]>key){
      A[j+1]=A[j];
      j--;
      A[j+1] = key;    
    }
   trace(A,n);
   }
   

  return 0;
}

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

using namespace std;

const int N = 1e5 + 7 ; 


int main(){
  //  freopen("in.in" , "r" , stdin); 
    long double a , b; 
    cin>> a; 
    a/=3.0;
    cout<<fixed<<setprecision(10)<< a * a * a ; 

    return 0 ;
}

Measured memory_bytes: 256
def main():
    import math
    from itertools import product
    x = int(input())
    k = math.ceil(x ** .5)
    l = [1]

    for i, j in product(range(2, k), range(2, 10)):
        if i ** j <= 1000:
            l.append(i ** j)
    ans = max([i for i in l if i <= x])
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, cnt = 0;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; ++i) {
    cin >> vec[i];
  }
  int sum;
  sort(vec.begin(), vec.end());
  
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      sum = vec[i] + vec[j];
      for (int k = n-1; j < k; --k) {
        if (vec[k] < sum) {
          cnt += k - j;
          break;
        }
      }
    }
  }
  
  cout << cnt << '\n';
}


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

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

    ll n,x,y,x1,y1,x2,y2,x3,x4,y3,y4;
    ll mx=LLONG_MIN,mn=LLONG_MAX,mx1=LLONG_MIN,mn1=LLONG_MAX;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        if(mx<x+y)
        {
            mx=x+y;
            x2=x,y2=y;
        }

        if(mn>x+y)
        {
            mn=x+y;
            x1=x,y1=y;
        }
        if(mx1<x-y)
        {
           mx1=x-y;
           x3=x,y3=y;
        }
        if(mn1>x-y)
        {
            mn1=x-y;
            x4=x,y4=y;
        }
    }
    
    cout<<max(((x2+y2)-(x1+y1)),(x3-y3)-(x4-y4))<<"\n";
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] array = new int[n*m+1];
		boolean[] fixed = new boolean[n*m+1];
		int[] a = new int[n];
		for(int i=0;i<n;i++) a[i] = in.nextInt();
		int[] b = new int[m];
		for(int j=0;j<m;j++) b[j] = in.nextInt();
		
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(a[i]==b[j]) fixed[a[i]] = true;
				else {
					array[Math.min(a[i], b[j])]++;
				}
			}
		}
		
		int mod = 1000000007;
		long ans = fixed[n*m]?1:0;
		array[n*m] = 1;
		for(int i=n*m-1;i>=1;i--) {
			if(fixed[i]) {
				array[i] += array[i+1];
				continue;
			}else if(array[i]>0) {
				ans = (ans * array[i]) % mod;
				array[i] += array[i+1];
				array[i]--;
			}else {
				array[i] += array[i+1];
				array[i]--;
				ans = (ans * array[i]) % mod;
			}
		}
		
		System.out.println(ans);
		in.close();
	}

}


Measured memory_bytes: 31592
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pq_small priority_queue<int,vector<int>,greater<int> >
/**==Info==
*Program:1
*Problem:Widespread
*Date:2017-10-6
*Algorithm:Binary Search+Simluate+Brute Force (TLE Possible JP)
*Stats:Unknown*/
ll n,a,b;
ll h[100005],t[100005];

bool check(ll m){
	//How to write this?
	//Evreryone minus b*m then find whether it is overflow!!!!
	ll cost=0;
	
	for(int i=0;i<n;i++){
		if(h[i]-b*m>0){
			cost+=(h[i]-b*m+(a-b-1))/(a-b);
		}
	}
	
	return cost<=m;
}
int main(){
	cin>>n>>a>>b;
	for(ll i=0;i<n;i++) cin>>h[i];
	
	ll l=1,r=1e9;
	while(l<=r){
		ll m=(l+r)/2;
		if(check(m)){
			r=m-1;
		}else{
			l=m+1;
		}
	}
	cout<<l<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <list>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <iomanip>
#include <queue>
#include <map>

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

	std::vector<int> p;
	for (int i = 0; i < n; i++) {
		int tmp;
		std::cin >> tmp;
		p.emplace_back(tmp);
	}

	int count = 0;
	for (int i = 1; i < n-1; i++) {//全探索
		if (p[i]<p[i - 1] && p[i]>p[i + 1]) {
			count++;
		}
		else if (p[i] > p[i - 1] && p[i] < p[i + 1]) {
			count++;
		}
		else {

		}
	}
	
	std::cout << count;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } 
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } 

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())

int n;
int a[100010];
#define MOD 1000000007;

long long modPow(long long x, long long y){
    long long r=1, a=x%MOD;
    while(y > 0){
        if((y&1) == 1) r = (r*a) % MOD;
        a = (a*a) % MOD;
        y /= 2;
    }
    return r;
}

void init() {
}

void input() {
	cin >> n;
	REP(i, n) cin >> a[i];
}

void solve() {
	int b[n];
	REP(i, n) b[i] = 0;
	REP(i, n) b[a[i]]++;

	if(n%2) {
		for(int i = 1; i < n; i+=2) if(b[i] != 0){
			cout << 0 << endl;
			return;
		}
		for(int i = 2; i < n; i+=2) if(b[i] != 2){
			cout << 0 << endl;
			return;
		}
		if(b[0]!=1){
			cout << 0 << endl;
			return;
		}
		cout << modPow(2, (n-1)/2) << endl;
	}
	else {
		for(int i = 1; i < n; i+=2) if(b[i] != 2){
			cout << 0 << endl;
			return;
		}
		for(int i = 0; i < n; i+=2) if(b[i] != 0){
			cout << 0 << endl;
			return;
		}
		cout << modPow(2, n/2) << endl;
	}
}

int main() {
	init();
    input();
    solve();
	return 0;
}








Measured memory_bytes: 1024
def main():
  N = int(input())

  counter = 0

  for i in range(N+1):
    if i%3 == 0 and i%5 == 0:
      pass
    elif i%3 == 0 :
      pass
    elif i%5 == 0:
      pass
    else:
      counter += i
    
  print(counter)


if __name__ == "__main__":
  main()

Measured memory_bytes: 9168
class UnionFind:
  def __init__(self, n):
    self.par = [i for i in range(n+1)]
    self.rank = [0] * (n+1)
 
    # 検索
  def find(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]
 
  # 併合
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if self.rank[x] < self.rank[y]:
      self.par[x] = y
    else:
      self.par[y] = x
      if self.rank[x] == self.rank[y]:
        self.rank[x] += 1
 
  # 同じ集合に属するか判定
  def same_check(self, x, y):
    return self.find(x) == self.find(y)
n,q = map(int,input().split())
uf = UnionFind(n)
for _ in range(q):
  t,u,v = map(int,input().split())
  if t == 0:
    uf.union(u,v)
  else:
    print(int(uf.same_check(u,v)))

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N,M;	cin>>N>>M;
	if(N==M)	Yes();
	else No();
	
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<list<long long>>v(200010);
long long g=0,visit[200010],par[200010],ans[200010],ans2[200010];
void dfs(long long a)
{
	visit[a]=1;
	ans2[g]=a;
	g++;
	for(auto it=v[a].begin();it!=v[a].end();it++)
	{
		if(visit[*it]==0)
			dfs(*it);
	}
}
int main()
{
	long long n,q,a,b,x,i;
	cin>>n>>q;
	par[1]=0;
	for(i=2;i<=n;i++)
	{
		par[i]=1;
		ans[i]=0;
		ans2[i]=0;
	}
	for(i=0;i<n-1;i++)
	{
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(b);
		par[b]=a;
	}
	while(q--)
	{
		cin>>a>>b;
		ans[a]+=b;
	}
	dfs(1);
	for(i=1;i<g;i++)
	{
		ans[ans2[i]]+=ans[par[ans2[i]]];
	}
	for(i=1;i<=n;i++)
	{
		printf("%lld ",ans[i]);
	}
	printf("\n");
}


Measured memory_bytes: 30464
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  cin >> n>>k;
  int d=1;//桁数（最低1桁）
  int e=0;
  for(int i=1;i<100;i++){
    int f=std::pow(k,i);//k進数の桁が増える基準（初めてべき乗使う）
    e=f-1;
    if(e>n){//次にはいけない
      break;
    }
    else if(e<n){//次の桁可能
      d++;
  }
  }
  cout << d << endl;
}

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

using namespace std;

#define int long long

signed main(void) {
	int N; cin >> N;
	vector<string> S(2);
	for (int i = 0; i < 2; ++i) cin >> S[i];

	vector<int> v;
	for (int i = 0; i < N; ++i) {
		if (S[0][i] == S[1][i])
			v.push_back(1);
		else {
			v.push_back(2);
			++i;
		}
	}

	int res = (v[0] == 1 ? 3 : 6);
	int MOD = 1000000007;
	for (int i = 1; i < v.size(); ++i) {
		if (v[i - 1] == 1) {
			res *= 2;
			res %= MOD;
		}
		else {
			if (v[i] != 1) {
				res *= 3;
				res %= MOD;
			}
		}
	}
	cout << res << endl;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   long gcd(long x, long y) {
      if( y == 0 ) return x;
      return gcd(y, x%y);
   }
   long table[333][333];
   void solve() {
      long n, m; scan(n, m);
      for(long i = 0; i < n; ++i) {
         for(long k = 0; k < m; ++k) {
            scan(table[i][k]);
         }
      }
      LI xs(m+1, 0);
      for(long i = 0; i < n; ++i) {
         for(long k = 0; k < m; ++k) {
            xs[table[i][k]] += k;
         }
      }
      std::vector<std::pair<long, long>> ys(m);
      for(long i = 1; i <= m; ++i) {
         ys[i-1] = std::make_pair(xs[i], i);
      }
      std::sort(ys.begin(), ys.end());
      // for(auto xy : ys) {
      //    dumpll(xy.first, xy.second);
      // }
      LI pass(m+1, 1);
      long res = (1LL << 53);
      for(long t = 0; t < m; ++t) {
         LI count2(m+1, 0);
         for(long i = 0; i < n; ++i) {
            for(long k = 0; k < m; ++k) {
               if( pass[table[i][k]] == 1 ) {
                  count2[table[i][k]] += 1;
                  break;
               }
            }
         }
         long temp = 0;
         long tempI = 0;
         for(long i = 1; i <= m; ++i) {
            if( temp < count2[i] ) {
               temp = count2[i];
               tempI = i;
            }
         }
         res = std::min(res, temp);
         pass[tempI] = 0;
      }
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 1024
import sys
n = int(input())
INF = 10**18
a_ls = [int(i) for i in sys.stdin.readline().split()]
max_ind = 1
_max = a_ls[0]
min_ind = 1
_min = a_ls[0]

for i, a in enumerate(a_ls, 1):
    if a > _max:
        _max = a
        max_ind = i
    if a < _min:
        _min = a
        min_ind = i


flg = abs(_max) >= abs(_min)
ls = []
if flg:
    for i in range(1,n+1):
        if i != max_ind:
            ls.append((max_ind, i))
    for i in range(1,n):
        ls.append((i, i+1))
else:
    for i in range(1, n + 1):
        if i != min_ind:
            ls.append((min_ind, i))
    for i in range(n, 1, -1):
        ls.append((i, i - 1))
print(len(ls))
for x, y in ls:
    print(x, y)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
#define P pair<int,int>
#define pb push_back
#define lb(x) (x&(-x))
#define ALL(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long LL;
const int M = 220000;
const int inf = 1e9;
int c[M]={0};
P p[M];
vector<P> g[M];
int n,m,k;
int dd[M];
char s[M];
bool ok(int i){
	return s[i]=='W'||s[i]=='B';
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	int u,v;
	fo(i,1,n){
		cin>>p[i].first;
		dd[i]=p[i].first;
		p[i].second=i;
	}
	sort(p+1,p+1+n);
	fo(i,1,m){
		cin>>u>>v;
		g[u].push_back({v,i});
		g[v].push_back({u,i});
	}
	int flag=1;
	fo(i,1,n){
		int id=p[i].second;
		if(ok(id)) continue;
		int d=p[i].first;
		bool done=0;
		for(P to:g[id]){
			if(ok(to.first)){
				c[to.second]=d;
				s[id]=(s[to.first]=='W'?'B':'W');
				done=1;
				break;
			}
		}
		if(!done){
			for(P to:g[id]){
				if(dd[to.first]==d){
					done=1;
					s[id]='W';
					s[to.first]='B';
					c[to.second]=d;
				}
			}
		}
		if(!done){
			flag=0;
			break;
		}
	}
	if(flag){
		s[n+1]='\0';
		cout<<s+1<<endl;
		fo(i,1,m){
			cout<<(c[i]?c[i]:inf)<<endl;
		}
	}
	else cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 16128
import bisect
from itertools import accumulate

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

a.sort()
b.sort()
c.sort()

AonB=[]
BonC=[]
ans=0
for i in range(n):
    AonB.append(bisect.bisect_left(a,b[i]))

AonB=list(accumulate(AonB))

ans=0
for g in range(n):
    search=bisect.bisect_left(b,c[g])-1
    if search>=0:
        ans+=AonB[search]

print(ans)

Measured memory_bytes: 111204
#include <stdio.h>

int main()
{
  long long n, m, t = 1;
  scanf("%lld %lld", &n, &m);
  for(long long i = 0; i < n; i++)
    t = t * 100;
    if(m % 100 == 0) m = m + 1;
    printf("%d", t * m);
}


Measured memory_bytes: 128
n=int(input())
A=list(map(int,input().split()))
binA=[None]*n
for i in range(n):
  binA[i]=bin(A[i])[2:]
  
keta=[0]*60
for i in range(n):
  tar=binA[i]
  for j in range(len(tar)-1,-1,-1):
    if tar[j]=="1":
      keta[len(tar)-1-j]+=1

pair=[0]*60
for i in range(len(keta)):
  pair[i]=keta[i]*(len(A)-keta[i])
  
ans=0
mul=1
DIV=10**9+7
for i in range(len(pair)):
  ans+=pair[i]*mul
  ans%=DIV
  mul*=2
print(ans)


Measured memory_bytes: 132496
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, unsigned long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll a,v,b,w,t;
  std::cin>>a>>v>>b>>w>>t;

  ll d=std::abs(a-b);

  if(d<=(v-w)*t)std::cout<<"YES\n";
  else std::cout<<"NO\n";

  return 0;
}

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

int main() {
  int N, score_a=0, score_b=0;
  cin >> N;
  vector<int> number(N);
  for (int i=0; i<N; i++) {
    cin >> number.at(i);
  }
  sort(number.begin(), number.end()); // 小さい順に並べ替え
  reverse(number.begin(), number.end()); // 大きい順に並べ替え
  for (int i=0; i<N; i+=2) {
    score_a += number.at(i);
  }
  for (int i=0; i<N-1; i+=2) {
    score_b += number.at(i+1);
  }
  cout << score_a-score_b << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  string str;
  
  cin>>str;
  
  
  if(str=="Sunny"){
    cout<<"Cloudy\n";
      return 0;
  }
  
  if(str=="Cloudy"){
    cout<<"Rainy\n";
      return 0;
  }
  
  if(str=="Rainy"){
    cout<<"Sunny\n";
      return 0;
  }
  
  
  return 0;
}

Measured memory_bytes: 256
//Ace
#include <bits/stdc++.h>
using namespace std;
using in = long long;
using str = string;
using pi = pair<in, in>;
using vi = vector<in>;
#define F first
#define S second
#define pb push_back
#define rep(i, k, n) for (in i = k; i < n; ++i)
#define repr(i, k, n) for (in i = k; i >= n; --i)
#define sz(x) (in) x.size()
#define all(x) begin(x), end(x)
const in MOD = 1e9 + 7;
const in N = 1e5 + 1;

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

    str s, t;
    cin >> s >> t;
    in ans = INT_MAX;
    rep(i, sz(t) - 1, sz(s))
    {
        in nc = 0;
        rep(j, 0, sz(t)) nc += (s[i - sz(t) + j + 1] != t[j]);
        ans = min(ans, nc);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(){
    int n,k; cin >> n >> k;
    map <int, int> mp;
    for(int i=0; i<n; ++i){
        int tmp; cin >> tmp;
        if(mp.count(tmp) == 0) mp[tmp] = 1;
        else ++mp[tmp];
    }
    int min[mp.size()];
    int i = 0;
    for(auto x : mp){
        min[i++] = x.second;
    }
    sort(min,min+mp.size());
    int result = 0;
    for(int i = 0; i<(int)(mp.size()-k); i++) result += min[i];
    cout << result << endl; return 0;
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int A, B;
	cin >> A >> B;
	cout << A * B - A - B + 1 << "\n";
}

Measured memory_bytes: 3432
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
int pic[50][50];
int all[100][100];
int n,m;

void rotate(){
	rep(i,0,m)rep(j,0,i)swap(pic[i][j],pic[j][i]);
	rep(i,0,m)reverse(pic[i],pic[i]+m);
}

int main(){
	bool flag = 0;
	int X,Y,f_x,f_y,first;
	while(cin >> n >> m && n && m){
		X = Y = (1<<21);
		
		rep(i,0,n)rep(j,0,n){
			cin >> all[i][j];
		}
		rep(i,0,m)rep(j,0,m){
			cin >> pic[i][j];
		}
		rep(y,0,n-m+1){
			rep(x,0,n-m+1){
				rep(b,0,4){
					first = flag = true;
					rep(i,0,m)rep(j,0,m){
						//cout << x+j << "," << y+i << endl;
						if(pic[i][j]==-1)continue;
					
						if(pic[i][j]!=all[y+i][x+j]){
							flag = false;
						}else if(first){
							f_y = y+i;
							f_x = x+j;
							first = false;
						}
					}
					if(flag){
						if(f_y < Y){
							Y = f_y;
							X = f_x;
						}else if(f_y == Y){
							if(f_x < X){
								X = f_x;
							}
						}
					}
					rotate();
				}
				
			}
		}
		if( X == (1<<21) )cout << "NA" << endl;
		else cout << X+1 << " " << Y+1 << endl;
	}	
}

Measured memory_bytes: 924
import math
a, b = map(int, input().split())
c = 0

if b < 10:
    c = a*10 + b
elif 10 <= b <= 99:
    c = a*100 + b
elif b == 100:
    c = a*1000 + b

d = math.sqrt(c)

if d.is_integer():
    print("Yes")
else:
    print("No")


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

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

    for(int i=0; i<=n; i++){
        for(int j=0; j<=m; j++){
            if(m*i + n*j - 2*i*j == k){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
}

Measured memory_bytes: 256
<?php

$n = trim(fgets(STDIN));
$a = explode(' ', trim(fgets(STDIN)));
rsort($a);

$a_total = 0;
$b_total = 0;
foreach($a as $idx => $val) {
  if(($idx + 1) % 2) { // alice
    $a_total += $val;
  } else { // bob
    $b_total += $val;
  }
}

echo $a_total - $b_total;


Measured memory_bytes: 3828
N = int(input())
a = list(map(int, input().split()))
n = 0

even = True
while even:
  for i in range(N):
    b = list(map(lambda x: x % 2 == 0, a))
    if False in b:
      even = False
      break
    a = list(map(lambda  x: int(x/2), a))
    n += 1

print(n)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof a);
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define per(i,a,b) for(int i = a; i >= b; i--)
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef double db;
const int N = 1e5+100;
const db EPS = 1e-9;
using namespace std;

void dbg() {cout << "\n";}
template<typename T, typename... A> void dbg(T a, A... x) {cout << a << ' '; dbg(x...);}
#define logs(x...) {cout << #x << " -> "; dbg(x);}

int n,m,a[N],pre[N][70];
ll x[N],k,v[N],ans[N];

void init(){
	for(ll j = 1; (1ll<<j) <= k; j++)
		for(int i = 0; i <= n; i++)
			pre[i][j] = pre[pre[i][j-1]][j-1];
}

int query(int pos,ll t){
	if(t == 0) return pos;
	for(ll j = 62; j >= 0; j--)
		if((1ll<<j) <= t) return query(pre[pos][j],t-(1ll<<j));
}

int main()
{
	scanf("%d",&n);
	rep(i,1,n) scanf("%lld",&x[i]);
	x[n+1] = x[n-1]; x[0] = x[2];
	v[0] = x[0];
	rep(i,1,n+1) v[i] = x[i]-x[i-1];
	rep(i,0,n+1) pre[i][0] = i;
	scanf("%d%lld",&m,&k);
	rep(i,1,m){
		scanf("%d",&a[i]);
		swap(pre[a[i]][0],pre[a[i]+1][0]);
	}
	init();
	rep(i,0,n+1) ans[i] = v[i];
	rep(i,1,n) ans[i] = v[query(i,k)];
	rep(i,1,n){
		ans[i] = ans[i-1]+ans[i];
		printf("%lld.0\n",ans[i]);
	}
	return 0;
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

ll gcd(ll a, ll b){
    return b == 0 ? a : gcd(b, a%b);
}

ll lcm(ll a, ll b){
    return (a / gcd(a, b)) * b;
}

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

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

    ll L = a[0]/2;
    for(ll i = 1; i < n; i++) L = lcm(L, a[i]/2);
    
    ll ans = 0;
    for(ll i = 0; i < n; i++) if((L / (a[i] / 2)) % 2 == 0) return cout << 0, 0;

    for(ll i = L; i <= m; i += 2LL*L) ans++;

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace Line
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var A = cin.ReadInt;
            var B = cin.ReadInt;
            var C = cin.ReadInt;
            var X = cin.ReadInt;
            var ans = 0;
            for (int i = 0; i <= A; ++i)
                for (int j = 0; j <= B; ++j)
                    for (int k = 0; k <= C; ++k)
                        if (500 * i + 100 * j + 50 * k == X)
                            ans++;
            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string S;
  ll K;
  cin >> S >> K;
  rep(i, S.size()){
    if(S[i]-'0'==1){
      K--;
    }else{
      K=0;
    }
    if(K==0){
      cout << S[i];
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define A(i) (a[i] >= x)

const int N = 200054;

int n;
int a[N];

inline bool check(int x) {
	int l = n, r = n;
	for (; l > 1; --l, ++r) {
		if (A(l) == A(l - 1)) return A(l);
		if (A(r) == A(r + 1)) return A(r);
	}
	return A(1);
}

int main() {
	int i, L, R, M, *$1, *$2;
	scanf("%d", &n);
	for (i = 1; i < 2 * n; ++i) scanf("%d", a + i);
	std::tie($1, $2) = std::minmax_element(a + 1, a + 2 * n);
	for (L = *$1, R = *$2; L < R; )
		check(M = (L + R + 1) / 2) ? L = M : R = M - 1;
	printf("%d\n", L);
	return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    char a, b;
    cin >> a >> b;
    if(a == b){
        cout << '=' << endl;
    }else if(a > b){
        cout << '>' << endl;
    }else {
        cout << '<' << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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 int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  COUT(n == 0 ? 1 : 0);
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char ans[1000];
int main(){
    ll n;
    scanf("%lld", &n);
    int j = 0;
    while(n > 0){
        n--;
        ans[j++] = n%26+'a';
        n/=26;
    }
    for(int i=j-1;i>=0;i--) printf("%c", ans[i]);
}

Measured memory_bytes: 3748
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String S = sc.next();
        int yyyy = Integer.parseInt(S.substring(0, 4));
        int mm = Integer.parseInt(S.substring(5, 7));
        int dd = Integer.parseInt(S.substring(8, 10));
        sc.close();

        boolean heisei = false;
        if (yyyy < 2019) {
            heisei = true;
        } else if (yyyy == 2019) {
            if (mm <= 4) {
                heisei = true;
            }
        }
        if (heisei) {
            out.printf("Heisei\n");
        } else {
            out.printf("TBD\n");
        }
        out.flush();
    }
}


Measured memory_bytes: 21844
n = gets.chomp.to_i
d, x = gets.split(" ").map(&:to_i)

array = []
n.times do
  array << gets.chomp.to_i
end

eat_day = 0

n.times do |a|
    (1..d).each do |i|
        if i == 1
            x += 1
            eat_day += array[a] + 1
        elsif i == eat_day
            x += 1
            eat_day += array[a]
        end
    end
    eat_day = 0
end

puts x


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
    int X,Y;
    cin >> X >> Y;
    int sum = 0;
    if (X == 1) {
        sum += 300000;
    }
    if (X == 2) {
        sum += 200000;
    }
    if (X == 3) {
        sum += 100000;
    }
    if (Y == 1) {
        sum += 300000;
    }
    if (Y == 2) {
        sum += 200000;
    }
    if (Y == 3) {
        sum += 100000;
    }
    if (X == 1 && Y == 1) {
        sum += 400000;
    }
    cout << sum << endl;
}

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

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

int dp[22][11][160] = {};
int dfs(int n, int k, int s) {
	if (n == s&&k == 1) { return 1; }
	if (n <= 0)return 0;
	if (k <= 0)return 0;
	if (s <= 0)return 0;
	if (dp[n][k][s] != -1)return dp[n][k][s];
	int ret = 0;
	rep(i, 1, n) {
		ret += dfs(i, k - 1, s - n);
	}
	return dp[n][k][s] = ret;
}

signed main() {
	for (int n, k, s; cin >> n >> k >> s&&n;) {
		memset(dp, -1, sizeof(dp));
		int ans = 0;
		rep(i, 1, n + 1)ans += dfs(i, k, s);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3260
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++)    cin>>A[i];
    int tmp=A[0];
    int res=1,flag=-1;
    for(int j=0;j<N;j++){
        if(tmp>A[j]) {
            if(flag==1){
                res++;
                flag=-1;
            }else{
                flag=0;
            }
        }
        if (tmp < A[j])
        {
            if (flag == 0)
            {
                res++;
                flag = -1;
            }
            else{
                flag = 1;
            }
        }
        

        //if(tmp<A[j])    flag=1;//increse
        //if(tmp>A[j])    flag=0;//decrease
        tmp=A[j];
        //cout<<flag<<endl;
    }
    
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
 unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if(cur == nil)break;
    if(isf == 0)printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t == nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);

}

void deleteLast(){
  deleteNode(nil->prev);
}

void delete(int key){
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int i, n, key, s, p=0, d=0;
  char com[20];

  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); p++; s++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
    if ( com[6] == 'F' ) deleteFirst();
    else if ( com[6] == 'L' ) deleteLast();
      } else {
    delete(key); d++;
      }
      s--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 33004
#!/usr/bin/env python3
import sys, math
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=0

x,y=map(int,input().split())
while x<=y:
    x*=2
    count+=1
print(count)

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

int main(){
    string s, t; cin >> s >> t;
    string res = "";
    for(int i = 0; i < s.size(); i++){
        bool can = true;
        string tmp = s;
        for(int j = 0; j < t.size(); j++){
            if(i+j>=s.size()) {can = false; break;}
            if(s[i+j]!='?' && s[i+j]!=t[j]) {can = false; break;}
            tmp[i+j] = t[j];
        }
        if(can){
            for(int i = 0; i < s.size(); i++){
                if(tmp[i]=='?') tmp[i] = 'a';
            }
            if(res=="") res = tmp;
            else res = min(res,tmp);
        }
    }
    if(res!="") cout << res << endl;
    else cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	int n;
	cin>>n;
	pair<int, int> ar1[n], ar2[n];
	bool mar[n];
	mem(mar, 0);
	fore(i, 0, n) cin>>ar1[i].f>>ar1[i].s;
	fore(i, 0, n) cin>>ar2[i].f>>ar2[i].s;
	sort(ar2, ar2 + n);
	int may, mayo;
	int res = 0;
	fore(i, 0, n)
	{
		may = -1;
		mayo = -MOD;
		fore(j, 0, n)
		{
			if(!mar[j] && ar1[j].f < ar2[i].f && ar1[j].s < ar2[i].s)
			{
				if(ar1[j].s > mayo)
				{
					mayo = ar1[j].s;
					may = j;
				}
			}
		}
		if(may > -1)
		{
			mar[may] = 1;
			res++;
		}
	}
	cout<<res<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 256