akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[][] p = new long[N][2];
		for (int i = 0; i < N; ++i) {
			p[i][0] = sc.nextLong();
			p[i][1] = sc.nextLong();
			Arrays.sort(p[i]);
		}
		Arrays.sort(p, new Comparator<long[]>() {
			@Override
			public int compare(long[] o1, long[] o2) {
				return Long.compare(o1[0], o2[0]);
			}
		});

		solve(N, p);
	}

	void solve(int N, long[][] p) {
		long ans = Long.MAX_VALUE;

		{
			long Rmax = -Long.MAX_VALUE / 16;
			long Bmax = -Long.MAX_VALUE / 16;
			long Rmin = Long.MAX_VALUE / 16;
			long Bmin = Long.MAX_VALUE / 16;
			for (int i = 0; i < N; ++i) {
				Rmax = Math.max(Rmax, p[i][1]);
				Rmin = Math.min(Rmin, p[i][1]);
				Bmax = Math.max(Bmax, p[i][0]);
				Bmin = Math.min(Bmin, p[i][0]);
			}
			ans = Math.min(ans, (Rmax - Rmin) * (Bmax - Bmin));
		}

		{
			long[] uXmin = new long[N];
			long[] lXmin = new long[N];
			long[] uXmax = new long[N];
			long[] lXmax = new long[N];
			long[] uYmin = new long[N];
			long[] lYmin = new long[N];
			long[] uYmax = new long[N];
			long[] lYmax = new long[N];
			for (int i = 0; i < N; ++i) {
				uXmin[i] = Math.min(i > 0 ? uXmin[i - 1] : Long.MAX_VALUE / 16, p[i][0]);
				uXmax[i] = Math.max(i > 0 ? uXmax[i - 1] : -Long.MAX_VALUE / 16, p[i][0]);
				uYmin[i] = Math.min(i > 0 ? uYmin[i - 1] : Long.MAX_VALUE / 16, p[i][1]);
				uYmax[i] = Math.max(i > 0 ? uYmax[i - 1] : -Long.MAX_VALUE / 16, p[i][1]);
			}
			for (int i = N - 1; i >= 0; --i) {
				lXmin[i] = Math.min(i + 1 < N ? lXmin[i + 1] : Long.MAX_VALUE / 16, p[i][0]);
				lXmax[i] = Math.max(i + 1 < N ? lXmax[i + 1] : -Long.MAX_VALUE / 16, p[i][0]);
				lYmin[i] = Math.min(i + 1 < N ? lYmin[i + 1] : Long.MAX_VALUE / 16, p[i][1]);
				lYmax[i] = Math.max(i + 1 < N ? lYmax[i + 1] : -Long.MAX_VALUE / 16, p[i][1]);
			}
			for (int i = 0; i < N; ++i) {
				long Rmax = Math.max(uXmax[i], i + 1 < N ? lYmax[i + 1] : -Long.MAX_VALUE / 16);
				long Rmin = Math.min(uXmin[i], i + 1 < N ? lYmin[i + 1] : Long.MAX_VALUE / 16);
				long Bmax = Math.max(uYmax[i], i + 1 < N ? lXmax[i + 1] : -Long.MAX_VALUE / 16);
				long Bmin = Math.min(uYmin[i], i + 1 < N ? lXmin[i + 1] : Long.MAX_VALUE / 16);
				ans = Math.min(ans, (Rmax - Rmin) * (Bmax - Bmin));
			}
		}
		System.out.println(ans);

	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int ans=0;

  int x=a%2+b%2+c%2;
  if(x==1){
    if(a%2==0)a++;
    if(b%2==0)b++;
    if(b%2==0)c++;
    ans++;
  }else if(x==2){
    if(a%2==1)a++;
    if(b%2==1)b++;
    if(c%2==1)c++;
    ans++;
  }

  int ma=max(a,max(b,c));
  ans+=(ma-a)/2;
  ans+=(ma-b)/2;
  ans+=(ma-c)/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    long a=n/k;
    long ans=a*a*a;
    if((k&1)==0){
      a=(n+k/2)/k;
      ans+=a*a*a;
    }
    System.out.println(ans);
  }
}

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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;
const ll llmx = 2e18;

int main(void){
  
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll ans = 0;
  while(A>0 && K>0){
    if(K>A){
      ans += A;
      K-=A;
      A=0;
    }else{
      ans += K;
      A-=K;
      K=0;
    }
  }
  while(B>0 && K>0){
    if(K>B){
      K-=B;
      B=0;
    }else{
      B-=K;
      K=0;
    }
  }
  while(C>0 && K>0){
    if(K>C){
      ans -= C;
      K-=C;
      C=0;
    }else{
      ans -= K;
      C-=K;
      K=0;
    }
  }
  
  cout << ans;
  
  return 0;
}


Measured memory_bytes: 3632
import math
x = input()

for i in xrange(x):
	x1,y1,r1,x2,y2,r2 = map(float, raw_input().split())
	d = math.sqrt((x1 - x2)**2 + (y1 - y2)**2)

	if d > (r1 + r2):
		print "0"
	elif abs(r1 - r2) <= d <= r1 + r2:
		print "1"
	elif d < abs(r1 + r2):
		if r1 > r2:
			print "2"
		else:
			print "-2"

Measured memory_bytes: 6420
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define maxn 310
#define mod 1000000007
using namespace std;
typedef long long ll;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f; 
}
int n,m;
struct P{
    int l,co;
};
vector<P> v[maxn];
ll f[maxn][maxn][maxn];
void add(ll &x,ll y)
{
    x=(x+y)%mod;
}
ll ans;
int main()
{
    n=read();m=read();
    for(int i=1;i<=m;i++)
    {
        int x=read(),y=read(),z=read();
        P tmp;
        tmp.l=x;tmp.co=z;
        v[y].push_back(tmp);
    }
    f[0][0][0]=1;
    for(int r=0;r<=n;r++)
    {
        for(int g=0;g<=n;g++)
        {
            for(int b=0;b<=n;b++)
            {
                if(f[r][g][b])
                {
                    int k=max(r,max(g,b));
                    ll &val=f[r][g][b];
                    for(int i=0;i<v[k].size();i++)
                    {
                        int cnt=0;
                        if(v[k][i].l<=r)  cnt++;
                        if(v[k][i].l<=g)  cnt++;
                        if(v[k][i].l<=b)  cnt++;
                        if(cnt!=v[k][i].co)  val=0;
                    }
                    if(k<n)
                    {
                        add(f[r][g][k+1],val);
                        add(f[r][k+1][b],val);
                        add(f[k+1][g][b],val);
                    }
                    else{
                        add(ans,val); 
                    }
                }
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 227584
#include<iostream>
#include<fstream>
#include<vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iomanip>

using namespace std;

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N;
  cin>>N;
  vector<double> X(N),Y(N);
  for(int i=0;i<N;i++) cin>>X.at(i)>>Y.at(i);

  vector< vector <double> > Z( N,vector<double>(N) );
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      Z.at(i).at(j)=sqrt( pow(X.at(i)-X.at(j),2) + pow(Y.at(i)-Y.at(j),2) );
      //cout<<Z.at(i).at(j)<<endl;
    }
  }

  //順列組み合わせを作る
  vector<int> nums(N);
  iota(nums.begin(), nums.end(),0);
  //for(int i=0;i<N;i++) cout<<nums.at(i)<<endl;

  double ans=0;
  int kai=0;
  do {
    //for(int i=0;i<N;i++) cout<<nums.at(i)<<' ';
    //cout<<endl;シンプルにnumsが順列組み合わせになっている。
    for(int i=0;i<N-1;i++){
      int A,B;
      A=nums.at(i),B=nums.at(i+1);
      ans += Z.at(A).at(B);
    }
    kai++;
  } while (next_permutation(nums.begin(), nums.end()));
  
  cout << fixed<<setprecision(10) <<ans/kai<<endl;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    List<Integer> list = new ArrayList<>();
    int sum1 = 0;
    int sum2 = 0;
    int sum3 = 0;

    sum1 = a + b;
    sum2 = a - b;
    sum3 = a * b;

    if(sum1 >= sum2 && sum1 >= sum3){
        System.out.println(sum1);
    }else if(sum2 >= sum1 && sum2 >= sum3){
        System.out.println(sum2);
    }else{
        System.out.println(sum3);
    }


    

    
    
    



    





}
}

Measured memory_bytes: 35408
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <string>
#include <cstring>
using namespace std;

int main() {

	int n;
	cin>>n;
	int i=n;
	if ((i%2)) ++i;
	while (1) {
		if (!(i%n)) {
			cout<<i<<endl;
			return 0;
		}
		i+=2;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   int r;
   cin >> r; 
   cout << (r<1200 ? "ABC" : r<2800 ? "ARC" : "AGC") << endl;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1130&lang=jp Red and Black
//???????????????????£?10?????????????????°20???
#include<iostream>
#include<utility>
#include<queue>
using namespace std;

int tile[21][21]={0};
int d[21][21]={0};
int W,H;
char a;
pair<int,int> person;
int answer=0;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

bool valid(int x,int y){
    return (x>=0 && x<H && y>=0 && y<W && tile[x][y]==1);
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

void bfs(int x,int y){
    queue<pair<int,int>> Q;
    pair<int,int> place = make_pair(x,y);
    Q.push(place);
    ++answer;
    d[x][y]=1;
    //cout<<"visited ("<<x+1<<","<<y+1<<")\n";

    while(!Q.empty()){
        place=Q.front();
        Q.pop();
        for(int i=0;i<4;++i){
            pair<int,int> next=make_pair(place.first+dx[i],place.second+dy[i]);
            if(tile[next.first][next.second]!=0 && d[next.first][next.second]==0 && valid(next.first,next.second)){
                Q.push(next);
                d[next.first][next.second]=1;
                //cout<<"visited ("<<next.first+1<<","<<next.second+1<<")\n";
                ++answer;
            }
        }
    }
}

int main(){
    
    
    while(cin>>W>>H && W!=0){
        for(int i=0;i<H;++i){
            for(int j=0;j<W;++j){
                cin>>a;
                if(a=='.'){
                    tile[i][j]=1;
                }
                else if(a=='@'){
                    person.first=i;
                    person.second=j;
                }
            }
        }

        bfs(person.first,person.second);

        cout<<answer<<"\n";
        answer=0;
        Fill(tile,0);
        Fill(d,0);
    }
}

Measured memory_bytes: 3128
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))}
const main=()=>{
  const a=-tn()+abs(tn()-tn())
  to(a<0?0:a)
}
main()

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

int main()
{
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  vector<int> dp(n);
  dp[0] = 0;
  for (int i = 1; i < n; i++)
  {
    dp[i] = INT_MAX;
  }
  for (int i = 1; i < n; i++)
  {
    for (int j = 1; i >= j && j <= k; j++)
    {
      dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
    }
  }
  cout << dp[n-1];
}


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

int main () {

	int sum = 0;
	int koka[] = {1, 5, 10, 50, 100, 500, };

	for (int i =0; i < 6; i++){
		int c;
		cin >> c;
		sum += c * koka[i];
	}

	cout << (sum >= 1000 ? "1"  : "0") << endl;

return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int q,r;
int n;
int nmax;
int b;

void calc(){
	if(n/10==0)return;
	r++;
	int keta=0;
	b=0;
	for (int i = n; i > 0; i/=10){
		keta++;
	}
	for(int i=0; i<keta; i++){
		int x,y;
		int k=10;
		for (int j = 0; j < i; ++j){
			k*=10;
		}
		x=n/k;
		y=n%k;
		if(!b){
			nmax=x*y;
			b=1;
		}
		else{
			if(nmax<x*y){
				nmax=x*y;
			}
		}
	}
	n=nmax;
	//cout<<"n:"<<n<<endl;
	calc();
}

int main(){
	cin>>q;
	for (int i = 0; i < q; ++i){
		cin>>n;
		r=0;
		calc();
		cout<<r<<endl;
	}
}

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

int main() {

  int N;
  string S;
  cin >> N >> S;

  for(int i = 0; i < S.size(); i++){
    S.at(i) = S.at(i) + N;
    if((int)S.at(i) > 90){
      S.at(i) = S.at(i) - 26;
    }
  }
  cout << S << endl;
}


Measured memory_bytes: 256
def dist(a,b)
  if a >= 0
    b
  elsif b <= 0
    -a
  else
    zab = b - 2 * a
    zba = b * 2 - a
    zab < zba ? zab : zba
  end
end

N,K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
puts (0 .. N - K).map{|i| dist(A[i], A[i + K- 1]) }.min



Measured memory_bytes: 8964
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    ll n;
    ll a[100001];
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    vector<string> result;
    sort(a,a+n);
    ll up0 = distance(a,upper_bound(a,a+n,0));
    
    if(up0==0){
        for (int i = 1; i < n-1; i++) {
            result.push_back(to_string(a[0])+" "+to_string(a[i]));
            a[0] -= a[i];
        }
        result.push_back(to_string(a[n-1])+" "+to_string(a[0]));
        a[n-1]-=a[0];
    }else if(up0==n){
        for (int i = 0; i < n-1; i++) {
            result.push_back(to_string(a[n-1])+" "+to_string(a[i]));
            a[n-1]-=a[i];
        }
    }else{
        for (int i = up0; i < n-1; i++) {
            result.push_back(to_string(a[0])+" "+to_string(a[i]));
            a[0] -= a[i];
        }
        for (int i = 0; i < up0; i++) {
            result.push_back(to_string(a[n-1])+" "+to_string(a[i]));
            a[n-1]-=a[i];
        }
    }
    
    std::cout << a[n-1] << std::endl;
    for (auto e : result) {
        std::cout << e << std::endl;
    }
}


Measured memory_bytes: 9716
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define INF 1000000001
#define MOD 1000000007




using namespace std;

void  inl(vector<int> &v, int n) {
	REP(i, n) {
		int a;
		cin >> a;
		v.push_back(a);
	}
	return;
}

int main() {
	int n;
	cin >> n;
	vector<int> x, y;
	double d=0;
	inl(x, n);
	inl(y, n);
	REP(i, 3) {
		REP(j, n) {
			d += pow(abs(x[j] - y[j]), i + 1);
		}
		cout << fixed << setprecision(8) << pow(d,1.00000000000000000/(i+1))<<endl;
		d = 0;
	}
	
	REP(i, n) {
		if (d < abs(x[i] - y[i])) d = abs(x[i] - y[i]);
	}
	cout << d << endl;


	return 0;
}

Measured memory_bytes: 3452
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;
const int maxn=3e3+5;

int n,m;
int dp[maxn][maxn];
char s[maxn],t[maxn];
pii f[maxn][maxn];
vector<char> ans;

int main(){
	scanf("%s%s",s+1,t+1);
	n=strlen(s+1);
	m=strlen(t+1);
	dp[0][0]=0;
	REP(i,1,n){
		REP(j,1,m){
			if(s[i]==t[j]){
				dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
				if(dp[i][j]==dp[i-1][j-1]+1) f[i][j]=MP(i-1,j-1);
			}
			dp[i][j]=max(dp[i][j],dp[i-1][j]);
			if(dp[i][j]==dp[i-1][j]) f[i][j]=MP(i-1,j);
			dp[i][j]=max(dp[i][j],dp[i][j-1]);
			if(dp[i][j]==dp[i][j-1]) f[i][j]=MP(i,j-1);
		}
	}
	int x=n,y=m;
	while(x||y){
		if(f[x][y]==MP(x-1,y-1)) ans.PB(s[x]);
		int nx=f[x][y].fst,ny=f[x][y].snd;
		x=nx,y=ny;
	}
	for(int i=ans.size()-1;i>=0;--i) printf("%c",ans[i]);
	return 0;
}


Measured memory_bytes: 105984
n = int(input())
f = [list(map(int, input().split())) for i in range(n)]
p = [list(map(int, input().split())) for i in range(n)]
 
ans = -1234567890
for mask in range(1,2**10):
    tmp = 0
    for i in range(n):
        cnt = 0
        for x in range(10):
            if (mask>>x) % 2 == 1 and f[i][x] == 1: cnt += 1
        tmp += p[i][cnt]
    ans = max(ans, tmp)
 
print(ans)

Measured memory_bytes: 3316
x = int(input())
s = list(input())
di = {'R':0, 'G':0, 'B':0}
for i in s:
    di[i] += 1
c = 0 #重複を数える
p = (len(s) - 3) / 2
for i in range(len(s)-2):
    j = 1
    while(j <= p + 1and i+(2*j)<=len(s)-1):
        ss = s[i] + s[i+j] + s[i+(2*j)]
        j += 1
        if ss == 'GBR'or ss ==  'GRB' or ss ==  'RBG' or ss == 'RGB' or  ss == 'BGR' or ss == 'BRG':
                c += 1
print(di['R'] * di['G'] * di['B'] - c)

Measured memory_bytes: 73892
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N;
    cin >> N;
    vector<ll> ais(N);
    unordered_map<ll, ll> ais_cnt;
    for (ll i = 0; i < N; i++) {
        cin >> ais[i];
        ais_cnt[ais[i]]++;
    }
    if (ais_cnt.size() >= 3) {
        cout << "No" << endl;
        return 0;
    }
    if (ais_cnt.size() == 1) {
        ll val = ais_cnt.begin()->first;
        if (N == val + 1) {
            cout << "Yes" << endl;
            return 0;
        } else if (N >= val * 2) {
            cout << "Yes" << endl;
            return 0;
        } else {
            cout << "No" << endl;
            return 0;
        }
    } else {
        ll a = ais_cnt.begin()->first;
        ll b = next(ais_cnt.begin())->first;
        ll groups = max(a, b);
        ll singletons = ais_cnt[groups-1];
        ll non_singletons = groups - singletons;
        if (singletons <= 0 || non_singletons <= 0) {
            cout << "No" << endl;
            return 0;
        }
        if (N < singletons + 2 * non_singletons) {
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
        return 0;
    }
}



Measured memory_bytes: 6560
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;

#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

int n;
int w[101];

int main(){
    cin >> n;
    w[0] = 0;
    rep(i,n){
        cin >> w[i];
    }

    int ans = 9999999;
    for(int t=1; t<n; t++){
        int left = accumulate(w, w+t, 0);
        int right = accumulate(w+t, w+n, 0);
        ans = min(ans, abs(right - left));
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let nm: Vec<usize> = read_vec();
    let m = nm[1];
    let mut abv_prt: Vec<Vec<u32>> = read_vec2(m);
    abv_prt.sort_by(|x, y| x[0].partial_cmp(&y[0]).unwrap());

    let mut abv: Vec<Vec<u32>> = vec![abv_prt[0].clone()];
    for i in 1..m {
        let l = abv.len();
        let a = abv_prt[i][0];
        let b = abv_prt[i][1];

        if b <= abv[l - 1][1] {
            while abv.len() > 0 && b <= abv[abv.len() - 1][1] {
                abv.pop();
            }
            abv.push(vec![a, b]);
        } else if abv[l - 1][0] < a {
            abv.push(vec![a, b]);
        }
    }

    let mut i = 0;
    let mut r;
    let mut ans = 0;
    while i < abv.len() {
        r = abv[i][1];
        while i < abv.len() && abv[i][0] < r {
            i += 1;
        }
        ans += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;
const int MOD = 1000000007;

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll sum = a+b;
  ll x = n/sum;
  ll answer = 0;
  answer += x*a;
  if(n%sum >=a){
    answer += a;
  }else{
    answer += n%sum;
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

int main()
{
    std::string S;
    std::cin >> S;

    // 全探索する
    // 一番良い選択の文字で置き換える 
    // Dでも指数は1増え、PDでも指数は1増えるのだから、全部Dにすればよい？ 
    std::string T;
    for(int i=0; i<S.size(); i++)
    {
        char now = S[i];

        if(now == '?')
        {
            now = 'D';
        }

        std::cout << now;
    } 

    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 3724
def roll(dice,dir)
  case dir
  when "N" then dice[0],dice[1],dice[5],dice[4] = dice[1],dice[5],dice[4],dice[0]
  when "S" then dice[0],dice[1],dice[5],dice[4] = dice[4],dice[0],dice[1],dice[5]
  when "E" then dice[0],dice[2],dice[5],dice[3] = dice[3],dice[0],dice[2],dice[5]
  when "W" then dice[0],dice[2],dice[5],dice[3] = dice[2],dice[5],dice[3],dice[0]
  end
  dice
end

d1 = gets.split(" ").map{|i| i.to_i}
d2 = gets.split(" ").map{|i| i.to_i}

yn = false    
for i in 1..6
  d = Marshal.load(Marshal.dump(d2))
  case i
  when 2 then d = roll(d,"S")
  when 3 then d = roll(roll(d,"W"),"S")
  when 4 then d = roll(d,"N")
  when 5 then d = roll(roll(d,"E"),"S")
  when 6 then d = roll(roll(d,"S"),"S")
  end
  for j in 1..4
    d = roll(d,"W")
    yn = (d == d1)
    break if yn
  end
  break if yn
end

puts(yn ? "Yes" : "No")

Measured memory_bytes: 8720
//
// Created by yuu on 2019-04-14.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>

using namespace std;


int main(void){
    char s;
    cin>>s;
    char ans;
    switch(s){
        case 'A':
            ans='T';
            break;
        case 'T':
            ans='A';
            break;
        case 'C':
            ans='G';
            break;
        case 'G':
            ans='C';
            break;
    }

    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline
#template input
import bisect

def IT(): #整数1個
    return int(input())
def IL(): #整数複数
    return [int(_) for _ in input().split()]
def IS(): #文字列複数
    return [_ for _ in input().split()]
def ILS(n): #整数1つ　縦にズラーってなってるやつ
    return [int(input()) for _ in range(n)]
def SLS(n): #文字列　縦にズラーってなってるやつ
    return [input() for _ in range(n)]
def ILSS(n): #整数複数　縦にズラーってなってるやつ
    return [[int(_) for _ in input().split()] for j in range(n)]

#template technique
def bit_full_search(ss):
    n = len(ss)
    for i in range(1 << n):
        s = ""
        for j in range(n + 1):
            if ((1 & i >> j) == 1):
                s += ss[j]
        print(s)
def bit_full_search2(A):
    #https://blog.rossywhite.com/2018/08/06/bit-search/
    value = []
    for i in range(1 << len(A)):
        output = []

        for j in range(len(A)):
            if ((i >> j) & 1) == 1:
                #output.append(A[j])
                output.append(A[j])
        value.append([format(i, 'b').zfill(16), sum(output)])

    value.sort(key=lambda x:x[1])
    bin = [value[k][0] for k in range(len(value))]
    val = [value[k][1] for k in range(len(value))]
    return bin, val
def matching_bisect(list1_val, list2_val, n):
    #2分探索
    j = 0
    for i in range(len(list1_val)):
        j = bisect.bisect_left(list2_val, n - list1_val[i])
        if j < len(list2_val):
            if list1_val[i] + list2_val[j] == n:
                #ans = list2_bin[j] + list1_bin[i]
                break
    return j

"""ここからメインコード"""
def main():
    n = IT()
    l = IL()
    l.sort()
    l2 = l[-1]
    l.pop()
    if l2 < sum(l):
        print("Yes")
    else:
        print("No")


main()


Measured memory_bytes: 3316
#include<iostream>
int main(){
int a,b;
char op;

while(std::cin>>a>>op>>b,op-63){
if(op==43)std::cout<<a+b;
else if(op==45)std::cout<<a-b;
else if(op==42)std::cout<<a*b;
else if(op==47)std::cout<<a/b;
std::cout<<std::endl;
}
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		String d = sc.next();
		char c1 = c.charAt(0);
		char c2 = c.charAt(1);
		char c3 = c.charAt(2);
		char d1 = d.charAt(0);
		char d2 = d.charAt(1);
		char d3 = d.charAt(2);
		boolean ans = true;
		if (c1 != d3 || c2 != d2 || c3 != d1) {
			ans = false;
		}
		System.out.println(ans ? "YES" : "NO");
	}

}


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

 #define   ll      long long 
 #define   pb      push_back
 #define   mp      make_pair

 typedef vector<int> vi;
 typedef vector<ll> vl;
 typedef pair<int,int> pii;
 typedef map<int,int> mii;

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

      ll t;
      t=1;
      //cin>>t;

      while(t--)
      {
         int n;
         cin>>n;
         int a,b;
          int c=0;
          int d=0;
         for(int i=0;i<n;i++)
         {
         	cin>>a>>b;
         	if(a==b)
         		c++;
         	else
         		c=0;

         	if(c==3)
         		d++;
         }

         if(d)
         	cout<<"Yes"<<endl;
         else
         	cout<<"No"<<endl;


      }

      return 0;
 }




Measured memory_bytes: 3648
#!/usr/bin/ruby
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>?5*8},'ruby',$0)
require 'set'
def dfs(z,c)
	f=S[c]
	r=[0,c]
	G[c].each{|e|
		next if e==z
		t=dfs(c,e)
		r=[r,[t[0]+f,t[1]]].max
	}
	r
end
N=gets.to_i
G=Hash.new{|h,k|h[k]=Set.new}
(N-1).times{
	a,b=gets.split.map(&:to_i)
	G[a-1]<<b-1
	G[b-1]<<a-1
}
A=gets.chomp
(p A.count(?W);exit) if A.count(?W)<2
r=N-1
Q=N.times.select{|i|G[i].size==1}
while !Q.empty?
	c=Q.shift
	next if A[c]==?W
	r-=1
	G[c].each{|e|
		G[e].delete c
		Q<<e if G[e].size==1
	}
	G.delete c
end
r*=2
S={}
G.keys.each{|k|
	G.delete k if G[k].empty?
	r+=S[k]=((A[k]==?B?0:1)+G[k].size)%2
}
p r-dfs(-1,dfs(-1,G.each_key.first)[1])[0]*2


Measured memory_bytes: 370852
def memorize(func):
    memo = {}
    def wrapper(*args):
        if args not in memo:
            memo[args] = func(*args)
        return memo[args]
    return wrapper

@memorize
def amida(W):   # W本の棒に対する1行アミダの引き方
    if W<2:
        return 1
    else:
        return amida(W-1)+amida(W-2)

@memorize
def amida2(H, W, x):
    if H==0:
        return 1 if x==1 else 0
    a = 0 if x==1 else amida(x-2)*amida(W-x)*amida2(H-1, W, x-1)
    b = amida(x-1)*amida(W-x)*amida2(H-1, W, x)
    c = 0 if x==W else amida(x-1)*amida(W-x-1)*amida2(H-1, W, x+1)
    return (a+b+c)%1000000007
print(amida2(*map(int, input().split())))

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#include <map>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int x,n;
map<int,int>mm;
int main(){
	cin>>x>>n;
	for(int i=1;i<=n;i++){
		int x;cin>>x;mm[x]++;
	}
	int mn=INF,ans;
	for(int i=-300;i<=300;i++){
		if(!mm[i]){
			if(abs(i-x)<mn)mn=abs(i-x),ans=i;
		}
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin>>N;
  string S;
  cin>>S;
  int st[N][10]={0};
  int l[N][10]={0};
  for(int i=1;i<N;i++)
  {
      for(int j=0;j<10;j++)
      st[i][j]=st[i-1][j];
      st[i][S[i-1]-'0']=1;
  }
  
  for(int i=N-2;i>=0;i--)
  {
      for(int j=0;j<10;j++)
      l[i][j]=l[i+1][j];
      
      l[i][S[i+1]-'0']=1;
  }
    set<int> M;
  for(int i=1;i<N-1;i++)
  {
      for(int j=0;j<=9;j++)
      {
          if(st[i][j]==1)
          for(int k=0;k<=9;k++)
          {
              if(l[i][k]==1)
              M.insert((k)+10*(S[i]-'0')+100*(j));
          }
      }
  }
  cout<<M.size();
  return 0;
}

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

int main() {
	long n,k=0,r=0;
	cin>>n;
	long a[n],b[n];
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	if(n==2)cout<<a[1]-a[0];
	else{
		for(int i=0;i<n-1;i++){
			b[i]=a[i+1]-a[i];
		}
		sort(b,b+n-1);
	if(n%2==0){
	for(int i=0;i<n;i++){
		k+=2*a[i];
	}
	for(int i=0;i<n/2;i++){
		k-=4*a[i];
	}
	k-=a[n/2]-a[n/2-1];
	cout<<k<<endl;
	}
	else{
		for(int i=0;i<n;i++){
			r+=2*a[i];
		}
		for(int i=0;i<n/2+1;i++){
			r-=4*a[i];
		}
		r+=2*a[n/2];
		r-=(min(a[n/2]-a[n/2-1],a[n/2+1]-a[n/2]));
		cout<<r<<endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1792
/*
[abc142] A - Odds of Oddness
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

int N;

double solve() { return ((N + 1) / 2) * 1.0 / N; }

int main() {
    cin >> N;

    cout << setprecision(16) << solve() << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    
    vector<int> vx(n);
    vector<int> vy(m);
    int xm = -1000, ym = 1000;
    for (int i=0; i<n; i++){
        cin >> vx[i];
        xm = max(vx[i], xm);
    }
    for (int i=0; i<m; i++){
        cin >> vy[i];
        ym = min(vy[i], ym);
    }

    bool find = false;
    for (int z=x+1; z<=y; z++){
        if ( xm < z && ym >= z ) {
            find = true;
            break;
        }
    }

    cout << ( find ? "No War" : "War" ) << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
t = [int(s) for s in input().split()]
m = int(input())
px = []
for _ in range(m):
    p, x = map(int, input().split())
    px.append((p - 1, x))
s = sum(t)
for p, x in px:
    print(s - t[p] + x)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n;
int x;
int t;
double sd;
int main()
{
	scanf("%d %d %d",&n,&x,&t);
	if(n%x==0)
	{
		printf("%d",n/x*t);
	}
	else
	{
		printf("%d",(n/x+1)*t);
	}
}

Measured memory_bytes: 3620
while True:
    try:
        a, op, b = input().split()
        a, b = int(a), int(b)
        if op == '?':
            break
        elif op == '+':
            print(a + b)
        elif op == '-':
            print(a - b)
        elif op == '*':
            print(a * b)
        else:
            print(a // b)
    except EOFError as err:
        break



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define FUP(i, a, b) for(int i = a; i <= b; i++)
#define FDOWN(i, a, b) for(int i = a; i >= b; i--)
#define MS(a, b) memset(a, b, sizeof(a))
#define ALL(v) v.begin(), v.end()
#define CIN(a) cin >> a;
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a
#define COUT2(a, b) cout << a << ' ' << b
#define COUT3(a, b, c) cout << a << ' ' << b << ' ' << c
#define ENDL cout << '\n'
int dy[4] = { -1, 1, 0, 0 };
int dx[4] = { 0, 0, 1, -1 };

int H, W, M, h[300001], w[300001], mh = 0, mw = 0;
set<pair<int, int>> S;
vector<int> vh, vw;

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

	MS(h, 0);
	MS(w, 0);
	CIN3(H, W, M);
	while (M--)
	{
		int hh, ww;
		CIN2(hh, ww);
		S.insert({ hh, ww });
		if (mh < ++h[hh])
		{
			vh.clear();
			mh = h[hh];
			vh.push_back(hh);
		}
		else if (mh == h[hh]) vh.push_back(hh);
		if (mw < ++w[ww])
		{
			vw.clear();
			mw = w[ww];
			vw.push_back(ww);
		}
		else if (mw == w[ww]) vw.push_back(ww);
	}
	for (int hh : vh)
	{
		for (int ww : vw)
		{
			if (S.count({ hh, ww }) == 0)
			{
				COUT(mh + mw);
				return 0;
			}
		}
	}
	COUT(mh + mw - 1);

	return 0;
}

Measured memory_bytes: 21780
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class BMagic2 {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int r,g,b;
        cin>>r>>g>>b;
        int k;
        cin>>k;
        if (g<=r){
            while (g<=r&&k>0){
                k--;
                g*=2;
            }
        }
        if (b<=g){
            while (b<=g&&k>0){
                k--;
                b*=2;
            }
        }
        if (b>g&&g>r)
            cout<<"Yes";
        else cout<<"No";
	}
};


int main() {
	BMagic2 solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3648
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;		

void Main()
{
	int H, W, A, B;
	std::cin >> H >> W >> A >> B;
	boost::multi_array<int, 2> data(boost::extents[H][W]);
	for (int i : boost::irange(0, B))
	{
		for (int j : boost::irange(0, A))
		{
			data[i][j] = 1;
		}
	}
	for (int i : boost::irange(B, H))
	{
		for (int j : boost::irange(A, W))
		{
			data[i][j] = 1;
		}
	}
	for (int i : boost::irange(0, H))
	{
		for (int j : boost::irange(0, W))
		{
			std::cout << data[i][j];
		}
		std::cout << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  int l,r,d;
  cin>>l>>r>>d;
  int ans=0;
  REP(i,l,r+1){
    if(i%d==0) ans++;
  }
  out(ans);
}

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


Measured memory_bytes: 3652
#include<iostream>
#define x 1000000007;
using namespace std;
typedef long long ll;
int main() {
	int N, M;
	cin >> N >> M;
	ll ans = 1;
	if (abs(N - M) >= 2) {
		cout << 0 << endl;
		return 0;
	}
	else {
		for (int i = 1; i <= N; ++i) {
			ans *= i;
			ans %= x;
		}
		for (int i = 1; i <= M; ++i) {
			ans *= i;
			ans %= x;
		}
		if (N == M) {
			ans *= 2;
			ans %= x;
			cout << ans << endl;
		}
		else
			cout << ans << endl;
	}
	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int a, b;
  cin >> a >> b;
  cout << (a+b == 15? "+" : (a*b==15?"*" : "x")) << endl;

  return 0;
}


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

/* -128 ~ 127 */
using i8  = int8_t;
/* 0 ~ 255 */
using u8  = uint8_t;
/* -32,768 ~ 32,767 */
using i16 = int16_t;
/* 0 ~ 65,535 */
using u16 = uint16_t;
/* -2,147,483,648 ~ 2,147,483,647 */
using i32 = int32_t;
/* 0 ~ 4,294,967,295 */
using u32 = uint32_t;
/* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using i64 = int64_t;
/* 0 ~ 18,446,744,073,709,551,615 */
using u64 = uint64_t;
/* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f32 = float;
/* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f64 = double;
using f80 = __float80;

template <class T>
using Vec = vector<T>;

template <typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

/* 定数 */
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define fn auto
#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) // 最大公約数
#define LCM(a, b) a / __gcd(a, b) * b // 最小公倍数

fn Main() {
    u32 M;
    cin >> M;
    cout << 24 * 2 - M << endl;
}

fn main() -> int {
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}




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

int main() {
 long long n;
  cin>>n;
  long long a[n];
  map<int,long long> freq;
  for(long long i=0;i<n;i++)
  {
    cin>>a[i];
    freq[a[i]]++;
    
  }

  long long answer=0;
  for(auto i=freq.begin();i!=freq.end();++i)
  {
    long long count = i->second;
      answer+=(count*(count-1))/2;
  }
  for(long long i=0;i<n;i++)
  {

      cout<<answer-freq[a[i]]+1<<endl;
  
  }
  
	return 0;
}

Measured memory_bytes: 11904
X,Y=map(int,input().split())
if X % 2 ==0:
    if (Y-X) % 4 == 0:
        print(0^Y)
    elif (Y-X) % 4 == 1:
        print(1)
    elif (Y-X) % 4 == 2:
        print(1^Y)
    elif (Y-X) % 4 == 3:
        print(0)
elif X % 2 ==1:
    if (Y-X) % 4 == 0:
        print(X^0)
    elif (Y-X) % 4 == 1:
        print(X^Y)
    elif (Y-X) % 4 == 2:
        print(X^1)
    elif (Y-X) % 4 == 3:
        print(X^1^Y)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(long long i=0; i<x;i++)
#define mod 1000000007
#define INF 10000000000000000
typedef long long ll;
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; }


struct UnionFind {
	vector<int> par;
  
  UnionFind(int N): par(N){
  	for(int i=0;i<N;i++) par[i] =i;
  }
  
  
};



int main(){
  ios::sync_with_stdio(false);
  
  int A,B;
  cin>>A>>B;
  
  ll ans = -1;
  queue<int> que;
  
  int i = A*100/8;
  if((A*100)%8 > 0) i++; 
  
  for(; (i*8)/100 == A;i++){
  	//que.push(i);
     if(i /10 == B){
    	ans = i;
      break;
    }
  }
  /*while(!que.empty()){
  	int defau = que.front();
    que.pop();
    
    if(defau /10 == B){
    	ans = defau;
      break;
    }
  }
  */
  
  cout<<ans;
}

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

using namespace std;

int main()
{
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    if(abs(x-a)>abs(x-b))
    {
        printf("B\n");
    }
    else
    {
        printf("A\n");
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double x1 = sc.nextDouble();
		double y1 = sc.nextDouble();
		double x2 = sc.nextDouble();
		double y2 = sc.nextDouble();
		double x = 0, y = 0;
		double result = 0;
		x = Math.pow(x1 - x2, 2);
		y = Math.pow(y1 - y2, 2);
		result = Math.sqrt(x + y);
		System.out.printf("%.8f%n", result);
		sc.close();
	}
}


Measured memory_bytes: 28052
S = input()

if not S[:-1]:
    print(0)
else:

  out1 = out2 = 0
  for i, j in enumerate(S):
    xor = (j == '1') ^ (i % 2)
    out1 += xor

  print(out1 if out1 < (i + 1) - out1 else (i + 1) - out1)

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

int main(){
  int n,sum=0,now=0;
  cin >> n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    sum+=abs(now-a.at(i));
    now=a.at(i);
  }
  a.push_back(0);
  sum+=abs(a.at(n-1));
  vector<int>ne(n);
  now=0;
  for(int i=0;i<n;i++){
    ne.at(i)=abs(now-a.at(i))+abs(a.at(i)-a.at(i+1))-abs(now-a.at(i+1));
    now=a.at(i);
  }
  for(int i=0;i<n;i++)
    cout << sum-ne.at(i) << endl;
  return 0;
}

Measured memory_bytes: 4036
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

    set<string> s;

    for (int i = 0; i < n; i++)
    {
        string x;
        cin >>x ;

        s.insert(x);
    }

    cout << s.size() << endl;
}


Measured memory_bytes: 19260
#include<iostream>
using namespace std;
int main(){
    string str;
    string comp[4] = {"dream","erase"};
    cin >> str;
    for(int i=0;i<str.size();i++){
        if(str[i]=='d'){
            for(int j=0;j<comp[0].size();j++){
                if(str[i+j]!=comp[0][j]){
                    cout << "NO";
                    return 0;
                }
            }
            i+=4;
            if(i+3<=str.size()&&str[i+1]=='e'&&str[i+2]=='r'&&str[i+3]!='a')    i+=2;
            continue;
            
        }
        else if(str[i]=='e'){
            for(int j=0;j<comp[1].size();j++){
                if(str[i+j]!=comp[1][j]){
                    cout << "NO";
                    return 0;
                }
            }
            i+=4;
            if(i+1<=str.size()&&str[i+1]=='r') i++;
            continue;
        }
        else{
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

int main(){

    lli n;
    cin>>n;
    vector<lli> a(n);
    map<lli,lli> cnt;
    REP(i,0,n){
        cin>>a[i];
        a[i]-=i;
        cnt[a[i]]++;
    }

    lli ans = 0;
    REP(i,0,n){
        lli num = a[i]+i*2;
        ans += (cnt[-num]);
        cnt[a[i]]--;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 27484
def count_divisor(n):
    a = 0
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            a += 1
            if i != n // i:
                a += 1
    return a

if __name__ == '__main__':
    n = int(input())
    c = 0

    for i in range(1, n + 1):
        if i % 2 == 0:
            continue
        if count_divisor(i) == 8:
            c += 1
    print(c)

Measured memory_bytes: 3188