akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int N = GetInt();
		string A = GetString();
		string B = GetString();
		string C = GetString();

		int ans = 0;
		for(int i = 0; i < N; i++)
		{
			var set = new HashSet<int>();
			set.Add(A[i]);
			set.Add(B[i]);
			set.Add(C[i]);
			ans += set.Count - 1;
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

using namespace std;

const int n = 100;
const int m = 99;

int a, b;

bool ma[n + 1][m + 1];

int main()
{
    cin >> a >> b;
    a--;
    b--;
    for(int i = 1; i <= n / 2; i++)
    {
        if(i & 1)
        {
            for(int j = 1; j <= m; j++)
                ma[i][j] = 0;
            continue;
        }
        for(int j = 1; j <= m; j++)
            if(j & 1 || b == 0)
                ma[i][j] = 0;
            else
            {
                ma[i][j] = 1;
                b--;
            }
    }
    for(int i = n / 2 + 1; i <= n; i++)
    {
        if((i - n / 2) & 1)
        {
            for(int j = 1; j <= m; j++)
                ma[i][j] = 1;
            continue;
        }
        for(int j = 1; j <= m; j++)
            if(j & 1 || a == 0)
                ma[i][j] = 1;
            else
            {
                ma[i][j] = 0;
                a--;
            }
    }
    cout << n << " " << m << "\n";
    for(int i = 1; i <= n; i++, cout << "\n")
        for(int j = 1; j <= m; j++)
            if(ma[i][j] == 0)
                cout << '.';
            else
                cout << '#';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;
int main() {
    int x,y;
    while(true){
    scanf("%d%d",&x,&y);
    if(x == 0 && y == 0){return 0;}
        for(int i = 0; i < x; i++){
            for(int j = 0; j < y; j++){
                printf("#");
            }
            cout<<endl;
        }
        cout<<endl;}
}


Measured memory_bytes: 3244
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N;
const ll MAX_N = 10000;
string s[MAX_N];

int main(){
  cin >> N;
  REP(i, N) cin >> s[i];
  ll numa = 0, numb = 0, numab = 0;
  REP(i, N) {
    if(s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') {
      numab++;
    } else if(s[i][0] == 'B') {
      numb++;
    } else if(s[i][s[i].size() - 1] == 'A') {
      numa++;
    }
  }

  ll num = 0;
  REP(i, N) {
    REP(j, s[i].size() - 1) {
      if(s[i][j] == 'A' && s[i][j + 1] == 'B') {
        num++;
      } 
    }
  }

  ll m = min(numa, numb);
  if(m > 0) {
    cout << numab + m + num << endl;
  } else if(numa == numb && numab > 0) {
    cout << numab - 1 + num << endl;
  } else {
    cout << numab + num << endl;
  }


  return 0;
}


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

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

    multiset<pair<int,pair<int,int> > >p;
    int s,t,x;
    for (int i = 0; i < n; ++i) {
        cin>>s>>t>>x;
        p.insert({2*x,{2*s-2*x-1,2*t-2*x-1}});
        
    }

    int d;
    multiset<pair<int,int> >mm;
    for (int i = 0; i < q; ++i) {
        cin>>d;
        mm.insert({d*2,i});
    }

    int ans[q]={0};
    for(auto i:p)
    {
        auto it=mm.lower_bound({i.second.first,LONG_MIN});
        while (it!=mm.end() && i.second.second>it->first)
        {
            ans[it->second]=i.first;
            it=mm.erase(it);
        }
    }

    for (int i = 0; i < q; ++i) {
        if(ans[i]==0)
            cout<<-1<<endl;
        else
            cout<<ans[i]/2<<endl;
    }
}

Measured memory_bytes: 28416
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n][n];
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>a[i][j];
    for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(a[i][k]+a[k][j]<a[i][j]){
        cout<<"-1"<<endl;
        return 0;
    }
    long long x=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            bool b=1;
            for(int k=0;k<n;k++){
                if(i==k || j==k)continue;
                if(a[i][k]+a[k][j]==a[i][j])b=0;
            }
            if(b)x+=a[i][j];
        }
    }
    cout<<x<<endl;
    return 0;
}

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

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

  for (int i = 1; i < 46300; i++) {
    int a = i * 1.08;
    if (a == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1e18;

vector<vector<ll>> G(100005);
vector<ll> dp1(100005);
vector<ll> dp2(100005);

ll n,m;


ll dfs1(ll t, ll p){
  ll now=1;
  for (ll to: G[t]){
    if (to==p)continue;
    now*=(dfs1(to,t)+1);
    now%=m;
  }
  dp1[t]=now;
  return now;
}

void dfs2(ll t, ll p){
  //cout<<"t"<<t<<endl;
dp2[t]=dp1[t];
  ll n=G[t].size();
//  cout<<"N"<<n<<endl;
  vector<ll> cum1(n+1);
  vector<ll> cum2(n+1);
  rep(i,n+1){
    cum1[i]=1;
    cum2[i]=1;
  }
  rep(i,n){
    //if (G[t][i]==p)cum1[i+1]=cum1[i]*(dp1[G[t][i]]-1);
    cum1[i+1]=cum1[i]*(dp1[G[t][i]]+1);
    cum1[i+1]%=m;
  }
  rep(i,n){
    //if (G[t][i]==p)cum2[n-i-1]=cum2[n-i]*(dp1[G[t][n-i-1]]-1);
     cum2[n-i-1]=cum2[n-i]*(dp1[G[t][n-i-1]]+1);
    cum2[n-i-1]%=m;
  }
  rep(i,n){
      ll now=1;
//    cout<<"i"<<i<<endl;
  ll temp1=dp1[t];
  ll temp2=dp1[G[t][i]];

    if (G[t][i]==p)continue;
    now*=cum1[i];
  //  cout<<"cum1 "<<cum1[i]<<endl;
    now%=m;
    now*=cum2[i+1];
      now%=m;
  //  cout<<"cum2 "<<cum2[i+1]<<endl;


    now%=m;
  //  cout<<"now"<<now<<endl;
    dp1[t]=now;
    dp1[G[t][i]]*=(now+1);
    dp1[G[t][i]]%=m;
  //  cout<<"dp1[G[t][i]]"<<dp1[G[t][i]]<<endl;

    dp1[G[t][i]]%=m;
    dfs2(G[t][i],t);
    dp1[t]=temp1;
    dp1[G[t][i]]=temp2;
  }
  //return now;

}


int main() {
  cin>>n>>m;
  rep(i,n-1){
    ll x1,y1;
    cin>>x1>>y1;
    x1--;y1--;
    G[x1].push_back(y1);
    G[y1].push_back(x1);
  }
  dfs1(0,-1);
  //dp2[0]=dp1[0];
  dfs2(0,-1);
  rep(i,n){
    cout<<dp2[i]%m<<endl;
  }
}


Measured memory_bytes: 22964
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  string ans="No";
  if(abs(a-c)<=d||abs(a-b)<=d&&abs(b-c)<=d){
    ans="Yes";
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
il1 = input().split()
il2 = input().split()
il1 = [int(s) for s in il1]
il2 = [int(s) for s in il2]
ans = 0

sum_vote = sum(il2)

for i in il2:
    if(i < sum_vote/(4*il1[1])):
        pass
    else:
        ans = ans + 1
    
if ( ans >= il1[1]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

using int64 = long long;

constexpr int64 MOD = 1e9 + 7;

vector<int> enumerateDivisors(int num) {
    vector<int> divisors;
    for (int n = 1; n * n <= num; n++) {
        if (num % n == 0) {
            divisors.push_back(n);
            if (n * n != num) {
                divisors.push_back(num / n);
            }
        }
    }
    sort(begin(divisors), end(divisors));
    return divisors;
}

int64 powMod(int a, int b) {
    if (b == 0) return 1;
    if (b % 2 == 0) {
        int64 c = powMod(a, b / 2);
        return (c * c) % MOD;
    }
    return (a * powMod(a, b - 1)) % MOD;
}

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

    vector<int64> counter(K + 1, 0);
    int64 answer = 0;
    for (int gcd = K; gcd >= 1; gcd--) {
        (counter[gcd] += powMod(K / gcd, N)) %= MOD;
        (answer += gcd * counter[gcd]) %= MOD;

        auto divisors = enumerateDivisors(gcd);
        for (int div : divisors) {
            if (div == gcd) continue;
            counter[div] = (counter[div] + MOD - counter[gcd]) % MOD;
        }
    }
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 3608
//２つの整数の値を小さい順に出力するプログラム
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int x,y;//整数
	int tmp;//初期化しない

	
	while (1) {

		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0) break;
		if (x > y) {
			tmp = x;//交換
			x = y;
			y = tmp;

		}
		printf("%d %d\n", x, y);
	}

		
		return 0;
	}


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

bool Rectangle(int w, int h, int x, int y, int r) {
    if (x + r > w || x - r < 0 || y + r > h || y - r < 0) {
        return false;
    } else {
        return true;
    }
}

int main() {
    int w, h, x, y, r;
    
    cin >> w >> h >> x >> y >> r;
    
    if (Rectangle(w, h, x, y, r)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;

int main(){
    int a;
    cin>>a;
    for(int i=1; i<=9; ++i){
        for(int j=1; j<=9; ++j){
            if(i*j==a){
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
	int n, i, alen, blen, carry, out[82];
	char a[10000], b[10000];
	
	scanf("%d", &n);
	while (n-- > 0) {
		scanf("%s", a);
		scanf("%s", b);
		alen = (int)strlen(a);
		blen = (int)strlen(b);
		if (alen > 80 || blen > 80){
			printf("overflow\n");
			continue;
		}
		i = 0;
		carry = 0;
		while (alen || blen) {
			out[i] = carry;
			if (alen) out[i] += a[--alen] - '0';
			if (blen) out[i] += b[--blen] - '0';
			carry = out[i] / 10;
			out[i++] %= 10;
		}
		if (carry) out[i] = 1;
		else i--;
		if (i >= 80) {
			printf("overflow\n");
			continue;
		}
		for (; i >= 0; i--)
			printf("%d", out[i]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 620
N, M = map(int,input().split())
# 約数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
divs = sorted(make_divisors(M),reverse=True)
for div in divs:
    if N <= M/div:
        print(div)
        break
    

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

int main(){
	int n,m;
	while(std::cin >> n >> m){
		if(n == 0 && m == 0){
			break;
		}
		std::vector<int> vegetable(n,0);
		for(int i = 0; i < n; ++i){
			std::cin >> vegetable[i];
		}
		std::sort(vegetable.begin(), vegetable.end(), std::greater<int>());
		int price = 0;
		for(int i = 0; i < n; ++i){
		  if((i % m) != (m - 1)){
		        price += vegetable.at(i);
		    }
		}
		std::cout << price << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1216
### classes

class Group
  attr_accessor :id, :n, :reqs, :deps, :ms

  def initialize(_id)
    @id = _id; @n = 0; @reqs = []; @deps = []; @ms = []
  end
end

### main

loop do
  n = gets.to_i
  break if n == 0

  gids = {}
  gn = 0
  mlists = []

  n.times do
    gname, mlist = gets.strip.delete('.').split(':')
    gids[gname] = gn
    mlists << mlist
    gn += 1
  end
  #p gids
  #p mlists

  grps = (0...n).map{|id| Group.new(id)}
  mids = {}
  mn = 0

  for id in (0...n)
    grp = grps[id]

    for mem in mlists[id].split(',')
      gid = gids[mem]
      if gid.nil?
        if mids[mem].nil?
          mids[mem] = mn
          mn += 1
        end
        grp.ms << mids[mem]
      else
        grp.deps << gid
        grps[gid].reqs << id
      end
    end
  end
  #p grps

  q = grps.select{|g| g.deps.empty?}
  #p q

  while ! q.empty?
    grp = q.shift

    for req in grp.reqs
      greq = grps[req]
      greq.ms += grp.ms
      greq.ms.uniq!
      greq.n += 1

      if greq.n == greq.deps.length
        q << greq
      end
    end
  end
  #p grps

  puts grps.first.ms.length
end

Measured memory_bytes: 7156
(defun incf-ht (x ht)
  (if #1=(gethash x ht)
      (incf #1#)
      (setf #1# 1)))

(defparameter ht (make-hash-table :test #'equal))

(loop repeat (read) do
      (incf-ht (sort (read-line) #'char<) ht))

(princ (loop for key being the hash-keys of ht
             using (hash-value val)
             sum (/ (* val (1- val)) 2)))

Measured memory_bytes: 51688
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

struct Point
{
	int x, y;

	bool operator<(const Point &p) const
	{
		return make_pair(x, y) < make_pair(p.x, p.y);
	}
};

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

	vector<Point> P(n);
	for (int i = 0; i < n; i++)
	{
		cin >> P[i].x >> P[i].y;
	}

	sort(P.begin(), P.end());
	double sum = 0;
	int count = 0;
	do
	{
		double distance = 0;
		
		for (int i = 0; i < P.size() - 1; i++)
		{
			int dx = P[i].x - P[i + 1].x, dy = P[i].y - P[i + 1].y;
			distance += sqrt(dx * dx + dy * dy);
		}

		sum += distance;
		count++;
	} while (next_permutation(P.begin(), P.end()));

	double ans = sum / count;
	printf("%.10f\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

void ABC128E()
{
	int N, Q;
	cin >> N >> Q;
	set<tuple<int, int, int> > Y;
	for (int i = 0; i < N; ++i)
	{
		int S, T, X;
		cin >> S >> T >> X;
		S -= X;
		T -= X;
		Y.insert(make_tuple( X,S,T ));
	}

	map<int, int> D;
	for (int i = 0; i < Q; ++i)
	{
		int x;
		cin >> x;
		D.insert({ x,i });
	}

	vector<int> ret(Q, -1);
	for (const auto& z : Y)
	{
		int x = get<0>(z);
		int s = get<1>(z);
		int t = get<2>(z);
		auto p = D.lower_bound(s);
		auto q = D.lower_bound(t);
		for (auto w = p; w != q; ++w)
		{
			ret[w->second] = x;
		}
		D.erase(p, q);
	}
	for (int i = 0; i < Q; ++i)
	{
		cout << ret[i] << endl;
	}
}

int main()
{
	ABC128E();
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int N = 5000;
int n,t;
ii a[N]; //(b[i], a[i])
int f[N][N];
void mxm(int &a, int b) { a = max(a, b); }
int main() {
	cin >> n >> t;
	for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second;
	sort(a + 1, a + n + 1);
	for (int i = 0; i <= n; ++i)
		fill(f[i] + 0, f[i] + t, -1);
	f[0][0] = 0; int ans = 0;
	for (int i=0; i<n; ++i)
		for (int j = 0; j < t; ++j)
			if (f[i][j] >= 0) {
				//Call for i+1
				int k = j + a[i + 1].first;
				mxm(ans, f[i][j] + a[i + 1].second);
				if (k < t) {
					mxm(f[i + 1][k], f[i][j] + a[i + 1].second);
				}
				//Does not call for i+1
				mxm(ans, f[i][j]);
				mxm(f[i + 1][j], f[i][j]);
			}
	cout << ans << endl;
}

Measured memory_bytes: 59264
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b)
	{
		printf("a > b\n");
	}
	else if(a<b)
	{
		printf("a < b\n");
	}
	else
	{
	    printf("a == b\n");
	}
	return 0;
	
}


Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
int n, k;
int main() {
    cin >> n >> k;
    vector<int> x(n, 0);
    for(int i = 0; i < n; ++i) cin >> x.at(i);

    int minx = 1e9+7;

    for(int i = 0; i+k-1 < n; ++i) {
        int l = i;
        int r = i+k-1;
        int minl = abs(x.at(l)) + abs(x.at(l)-x.at(r));
        int minr = abs(x.at(r)) + abs(x.at(l)-x.at(r));
        int mincx = min({minl, minr});
        minx = min({minx, mincx});
    }

    cout << minx << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

struct edge{ int to,silver,time; };
using PP = pair<int,P>;

vector<edge> G[55];

int dec(int x,int y){
	if(x == 2500) return x;
	else return x - y;
}

signed main(){
	int n,m,s,c[55],d[55];
	cin >> n >> m >> s;
	for(int i = 0;i < m;i++){
		int u,v,a,b;
		cin >> u >> v >> a >> b; u--;v--;
		G[u].push_back({v,a,b});
		G[v].push_back({u,a,b});
	}
	for(int i = 0;i < n;i++){
		cin >> c[i] >> d[i];
	}
	int dist[55][2510];
	for(int i = 0;i < n;i++){
		for(int j = 0;j <= 2500;j++) dist[i][j] = INF;
	}
	dist[0][min(s,2500ll)] = 0;
	priority_queue<PP,vector<PP>,greater<PP>> que;
	que.emplace(0,P(0,min(s,2500ll)));
	while(!que.empty()){
		PP p = que.top();que.pop();
		int cost = p.first,v = p.second.first,silver = p.second.second;
		if(dist[v][silver] < cost) continue;
		for(edge &e : G[v]){
			if(e.silver <= silver && dist[e.to][dec(silver,e.silver)] > cost + e.time){
				dist[e.to][dec(silver,e.silver)] = cost + e.time;
				que.emplace(cost + e.time,P(e.to,dec(silver,e.silver)));
			}
		}
		if(dist[v][min(2500ll,silver + c[v])] > cost + d[v]){
			dist[v][min(2500ll,silver + c[v])] = cost + d[v];
			que.emplace(cost + d[v],P(v,min(2500ll,silver + c[v])));
		}
	}
	for(int i = 1;i < n;i++){
		int ans = INF;
		for(int j = 0;j <= 2500;j++) chmin(ans,dist[i][j]);
		cout << ans << endl;
	}
}


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

int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size();
    rep(i,n){
        bool flag = true;
        rep(j,n) if(s[(i+j)%n] != t[j]) flag = false;
        if(flag){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
using pi = pair<int,int>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
signed main(){
	//cout << fixed << setprecision(10);
    int n; cin >> n;
    vl a(n),b(n);
    rep(i,0,n){
        int x,y; cin >> x >> y;
        a[i] = x + y;
        b[i] = x - y;
    }
    sort(all(a));
    sort(all(b));
    cout << max(a[n-1] - a[0] , b[n-1] - b[0]) << endl;

	return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>x(n);
    for(int i=0; i<n; i++){
        cin >> x[i];
    }
    sort(x.begin(),x.end());
    long long ans = 1e9;
    for(int j=x[0]; j<=x[n-1]; j++ ){
        long long sum = 0;
        for(int i=0; i<n; i++){
            sum += pow(x[i]-j,2);
        }
        ans = min(sum, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vector <vector<int>> dp(n+10,vector <int>(100010));
    vector <int> cum(100030);
    dp[0][0] = 1;
    rep(i,n+1){
        cum[0] = 0;
        rep(j, k+2){
            cum[j+1] = (cum[j] + dp[i][j])%MOD;
        }
        int a; cin>>a;
        rep(j,k+2){
            dp[i+1][j] = (cum[j+1] - cum[max(0LL, j-a)] + MOD)%MOD;
        }
    }
    cout<<(dp[n][k] + MOD)%MOD<<endl;
}


Measured memory_bytes: 87296
import sys
input = sys.stdin.readline
import math 

X = int(input())
s = 0

for i in range(1,X+1):
   for j in range(1,X+1):
      ij = math.gcd(i,j)
      for k in range(1,X+1):
        s = s + math.gcd(ij,k)

print (s)

Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
using namespace std;



int main() {
	int a, b, c, x, cun = 0;
	cin >> a >> b >> c >> x;
	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)cun++;
			}
		}
	}
	cout << cun << endl;






	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (ll 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
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
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 gcd(int a, int b){
	if (a%b == 0)		return(b);
   else	return(gcd(b, a%b));
}

const int A = 1000005;

int main() {
	int N;	cin>>N;
  vector<ll> data(N);
  vector<ll> number(A,0);
  FOR(i,0,N){
    cin>>data.at(i);
    number.at(data.at(i))++;
  }

  bool p = true;
  FOR(i,2,A){
    int cnt = 0;
    for(int j=i; j<A; j+=i){
      cnt+=number.at(j);
      //cout<<cnt<<" ";
      if(cnt>=2){
        p = false;
        break;
      }
    }
    if(!p) break;
  }

  if(p){
    cout<<"pairwise coprime"<<endl;
    return 0;
  }

  int ans = data.at(0);

  FOR(i,1,N){
    ans = gcd(ans, data.at(i));
  }

  if(ans==1) cout<<"setwise coprime"<<endl;
  else cout<<"not coprime"<<endl;
	

	return 0;
}





Measured memory_bytes: 18764
n=gets.to_i
a=gets.split.map &:to_f
q=a.shift
t=[1-q,q]
a.each.with_index(2){|e,i|
x=[]
x[0]=t[0]*(1-e)
(1...i).each{|j|x[j]=t[j-1]*e+t[j]*(1-e)}
x[i]=t[i-1]*e
t=x
}
p t[n/2+1..-1].reduce(:+)

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

int main(){
    int n, k, ans;
    cin >> n >> k;
    ans = 0;
    vector<int> height(n);
    rep(i, n){
        cin >> height[i];
    }
    rep(i, n){
        if (height[i] >= k){
            ans++;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>

int main(){
        char s[1001], t[1001], kiri[1001];
        int n, m;
        scanf("%s%s", s, t);
        n=strlen(s); m=strlen(t);

        int i, j, min, diff;
        min=m;
        for(i=0; i<=n-m; i++){
                diff=0;
                for(j=0; j<m; j++){
                        if(t[j]!=s[i+j]){
                                diff++;
                        }
                }
                if(min>diff){
                        min=diff;
                }
        }
        printf("%d", min);


        return 0;
}


Measured memory_bytes: 1692
#include <stdio.h>
#include <math.h>

int		main(void)
{
	int		n;
	int		x;
	int		rst;
	int		hantei;
	int		i, j;

	rst = 0;
	scanf("%d",&n);
	for(i=0; i<n; i++)
	{
		scanf("%d",&x);
		if( x==2 )
		{
			rst=rst+1;
			continue;
		}
		else if( x==3 )
		{
			rst=rst+1;
			continue;
		}
		else if( x==5 )
		{
			rst=rst+1;
			continue;
		}
		else if( x==7 )
		{
			rst=rst+1;
			continue;
		}

		if( x%2 == 0 )
		{
			continue;
		}

		//hantei = 0;
		for(j=3; j<=sqrt(x); j=j+2)
		{
			//printf("sqrt(%d)=%f\n",x,sqrt(x));
			if(( x % j ) == 0 )
			{
				hantei = 0;
				break;
			}
			else
			{
				hantei = 1;
			}
		}
		if( hantei == 1 )
		{
			rst=rst+1;
			//printf("rst=%d\n",rst);
		}
	}
	printf("%d\n",rst);

	return 0;
}

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

int main() {
	int n;
	while (cin >> n) {
		int pow[10] = {}, p = 0, rem, quo;
		while (1) {
			rem = n % 2; quo = n / 2;
			if (rem) {
				pow[p]++;
			}
			if (quo == 0) break;
			p++;
			n = quo;
		}
		for (int i = 0, j = 0, r = 1; i < 10; i++, r *= 2) {
			if (pow[i]) {
				if (j) cout << " ";
				cout << r;
				j++;
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 3040
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>
#include<limits>
#include <unordered_map>
#include <numeric>
#include <array>
#include <queue>
#include <chrono>
#include <random>
#include <fstream>


using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)
#define INF (1<<29)
#define MD 1000000007


int main() {

	int a, b;
	cin >> a >> b;

	if (8 < a || 8 < b)cout << ":(" << endl;
	else cout << "Yay!" << endl;
	
	




	
	return 0;
}

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


def solve(N: int, S: str, T: str):
    result = ""
    for i in range(N):
        result = result + S[i] + T[i]
    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(N, S, T)


if __name__ == "__main__":
    main()


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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  vector<pair<int, int>> vp;
  for (int i = 1; i < N; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    vp.emplace_back(a, b);
  }

  int K = 0;
  map<pair<int, int>, int> I;
  vector<int> cs(N, 0);  // color of edge between its parent

  vector<int> used(N, 0);
  queue<int> que;
  used[0] = 1;
  que.emplace(0);
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    if (K < (int)G[v].size()) K = G[v].size();
    int cur = 1;
    for (int u : G[v]) {
      if (used[u]) continue;
      if (cur == cs[v]) cur++;
      cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
      used[u] = 1;
      que.emplace(u);
    }
  }

  cout << K << endl;
  for (auto p : vp) cout << I[p] << endl;
  return 0;
}


Measured memory_bytes: 23012
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int main() { IO;
  long long n, m;
  cin >> n >> m;

  vector<pair<long long, long long>> v(n);
  for (auto &x : v) {
    cin >> x.first >> x.second;
  }
  sort(v.begin(), v.end());

  long long ans = 0;
  for (auto &x : v) {
    long long k = min(x.second, m);
    ans += k * x.first;
    m -= k;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
s = gets.chomp.split('')
h = Hash.new(0)
s.each{|c|
    h[c] += 1
    }
if (h[?N] + h[?S] == 0 || h[?N] * h[?S] != 0) && (h[?E] + h[?W] == 0 || h[?E] * h[?W] != 0)
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
using namespace std;
long long int n, m, am = 1;
long long int ans(long long int n,long long int m){
  if(m > n)
    swap(n,m);
  am = n % m;
  while(am != 0){
    n = m;
    m = am;
    am = n % m;
  }
  return m;
}
int main(){
  cin >> n >> m;
  cout << n * m / ans(n,m) << endl;
}

Measured memory_bytes: 256
s=gets.chomp

n=s.length+1
count_l=Array.new(n,0)
count_r=Array.new(n,0)

count=0
(n-1).times do |i|
    if s[i]=="<"
        count+=1
    else
        count=0
    end
    count_l[i+1]=count
end

count=0
(n-2).downto(0) do |i|
    if s[i]==">"
        count+=1
    else
        count=0
    end
    count_r[i]=count
end

ans=0
n.times do |i|
    ans+=[count_l[i],count_r[i]].max
end
puts ans


Measured memory_bytes: 23272
/*input
217
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

void solve(){
 	int n;
 	cin >> n;
 	RE(i,n){
 		int x = 100*i;
 		if(x > n)break;
 		int rem = n-x;
 		if(rem > 5*i)continue;
 		//cout << i << " " << rem << endl;
 		cout << 1;
 		return;
 	} 
 	cout << 0;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

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

int main() {
  int A, B, C, D;
  
  cin >> A >> B >> C >> D;
  int L = A + B;
  int R = C + D;
  
  if (L == R) {
    cout << "Balanced" << endl;
  }
  else {
    if (L <= R) {
      cout << "Right" << endl;
    }
    else if (L >= R) {
      cout << "Left" << endl;
    } 
  }
}


Measured memory_bytes: 3592
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		task[] t = new task[n];
		int now = 0; boolean flag = true;

		for(int i = 0; i < n; i++) {
			t[i] = new task(sc.nextInt(), sc.nextInt());
		}

		Arrays.sort(t, new Comparator<task>() {
			public int compare(task t1, task t2) {
				return t1.b - t2.b;
			}
		});

		for(int i= 0; i < n; i++) {
			now += t[i].a;
			if(now > t[i].b) {
				flag = false;
				break;
			}
		}

		System.out.println(flag ? "Yes" : "No");
		sc.close();

	}

	private static class task{
		int a; int b;
		task(int a, int b){
			this.a = a; this.b = b;
		}
	}
}

Measured memory_bytes: 107476
#include <stdio.h>
#include <stdlib.h>
int main()
{    double n,m,k;
    int d,f=2;

    scanf("%lf %lf %d",&n,&m,&d);
    if(d==0){
        f=1;
    }
    k = (m-1)*f*(n-d)/n/n;
    printf("%.16f",k);
    return 0;
}


Measured memory_bytes: 128
import java.util.BitSet;
import java.util.Scanner;

/**
 * Created by sotetsuk on 2015/07/18.
 */
public class Main {

    static Scanner sc = new Scanner(System.in);
    static final int MAX_R = 15, MAX_C = 1005;
    static int R, C;
    static BitSet[] o = new BitSet[MAX_R];

    public static boolean read() {
        R = sc.nextInt();
        C = sc.nextInt();
        if(R == 0 && C == 0) return false;
        for(int i = 0; i < R; i++) {
            o[i] = new BitSet(MAX_C);
            for(int j = 0; j < C; j++) {
                if(sc.nextInt() == 1) o[i].set(j);
            }
        }
        return true;
    }

    public static void flip(int i) {
        for(int j = 0; j < R; j++) {
            if((i >> j & 1) == 1) {
                o[j].flip(0, C);
            }
        }
    }

    public static int count() {
        int ret = 0;
        for(int j = 0; j < C; j++) {
            int s = 0;
            for(int i = 0; i < R; i++) {
                s += o[i].get(j) ? 1 : 0;
            }
            ret += Math.max(s, R - s);
        }
        return ret;
    }

    public static void solve() {
        int ans = 0;
        // search all 2^R patterns
        for(int i = 0; i < (1 << R); i++) {
            flip(i);
            ans = Math.max(ans, count());
            flip(i);
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {
        while(read()) {
            solve();
        }
    }
}

Measured memory_bytes: 62368
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  long double md = m * 360.0 / 60.0;
  long double hd = (360.0 * h / 12.0) + 360.0 * m / (60.0 * 12.0);
  long double pi = acos(-1);
  long double diffd = abs(md - hd) * pi / 180.0;
  long double res = a*a + b*b - 2*a*b*cos(diffd);
  cout << setprecision(15);
  cout << sqrt(res) << endl;
}


Measured memory_bytes: 4184
#include<iostream>
using namespace std;
int main(){
	
	while (1){
		int N, M, n[1500] = { 0 }, m[1500] = { 0 },now=1,i;
		cin >> N >> M;
		if (N == 0 && M == 0){
			break;
		}
		for (i = 1; i <= N; i++){
			cin >> n[i];
		}
		for (i = 1; i <= M; i++){
			cin >> m[i];
		}
		for (i = 1; i <= 10000; i++){
			now = now + m[i] + n[now + m[i]];
			if (now >= N){
				break;
			}

		}
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 3008
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

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

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

	map<int, int> cnt;
	for (int i=0; i<n; i++)
		cnt[a[i]]++;

	for ( auto i = cnt.begin(); i != cnt.end(); ++i) {
		if (i->second > 1) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 10368
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		if(N == 2){
			Console.WriteLine("0.5\n0.5");
			return;
		}
		
		var L = new List<Pair>();
		for(int i=0;i<N;i++){
			L.Add(new Pair(X[i], Y[i], i));
		}
		
		var CH = Geo.GrahamScan(L);
		double[] ans = new double[N];
		if(CH.Count == 2){
			foreach(var p in CH){
				ans[p.Idx] = 0.5;
			}
			for(int i=0;i<N;i++){
				Console.WriteLine(ans[i]);
			}
			return;
		}
		
		int M = CH.Count;
		for(int i=0;i<M;i++){
			double theta = Pair.ang(CH[(i+1)%M] - CH[i], CH[(i+M-1)%M] - CH[i]);
			ans[CH[i].Idx] = (Math.PI - theta) / (2 * Math.PI);
		}
		for(int i=0;i<N;i++){
			Console.WriteLine(ans[i]);
		}
		
		
	}
	int N;
	long[] X,Y;
	public Sol(){
		N = ri();
		X = new long[N];
		Y = new long[N];
		for(int i=0;i<N;i++){
			var d = rla();
			X[i] = d[0]; Y[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}

class Pair{
	public long X;
	public long Y;
	public int Idx;
	public Pair(long x,long y, int idx){
		X=x;Y=y;Idx = idx;
	}
	public static Pair operator-(Pair p,Pair q){
		return new Pair(p.X-q.X,p.Y-q.Y, -1);
	}
	public static long det(Pair p,Pair q){
		return (p.X*q.Y-p.Y*q.X);
	}
	public static double ang(Pair p, Pair q){
		double a = (double) p.X;
		double b = (double) p.Y;
		double c = (double) q.X;
		double d = (double) q.Y;
		
		double cos = (a * c + b * d) / (Math.Sqrt( a *a + b * b) * Math.Sqrt(c * c + d * d)); 
		return Math.Acos(cos);
	}
	
	
	
}


class Geo{
	public static List<Pair> GrahamScan(List<Pair> L_){
		List<Pair> L=new List<Pair>(L_);
		L.Sort((x,y)=>x.X.CompareTo(y.X)==0?x.Y.CompareTo(y.Y):x.X.CompareTo(y.X));
		
		List<Pair> ret=new List<Pair>();
		int k=0;
		//右半分
		for(int i=0;i<L.Count;i++){
			//末尾削除はO(1)なのでどんどん使う。
			k=ret.Count;
			while(k>1 && det((ret[k-1].X-ret[k-2].X),(ret[k-1].Y-ret[k-2].Y),(L[i].X-ret[k-1].X),(L[i].Y-ret[k-1].Y)) <= 0){
				ret.RemoveAt(k-1);
				k=ret.Count;
			}
			ret.Add(L[i]);
		}
		//左半分
		int t=ret.Count;
		for(int i=L.Count-2;i>=0;i--){
			//末尾削除はO(1)なのでどんどん使う。
			k=ret.Count;
			while(k>t && det((ret[k-1].X-ret[k-2].X),(ret[k-1].Y-ret[k-2].Y),(L[i].X-ret[k-1].X),(L[i].Y-ret[k-1].Y)) <= 0){
				ret.RemoveAt(k-1);
				k=ret.Count;
			}
			ret.Add(L[i]);
		}
		ret.RemoveAt(ret.Count-1);
		return ret;
	}
	static long det(long a,long b,long c,long d){
		return a*d-b*c;
	}
}




Measured memory_bytes: 13396
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    AB = [[int(x) for x in input().split()] for _ in range(N)]

    if N % 2 == 1:
        ma = []
        mi = []
        for a, b in AB:
            ma.append(max(a, b))
            mi.append(min(a, b))
        ma.sort()
        mi.sort()
        print(ma[N // 2] - mi[N // 2] + 1)
    else:
        ma = []
        mi = []
        for a, b in AB:
            ma.append(max(a, b))
            mi.append(min(a, b))

        ma.sort()
        mi.sort()
        x = (ma[N // 2] + ma[N // 2 - 1]) / 2
        y = (mi[N // 2] + mi[N // 2 - 1]) / 2
        print(int((x - y) / 0.5) + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 46088
import bisect 
from itertools import combinations

coins = []
line = input()
n, k, l, r = list(map(int, line.split()))
line = input()
coins = list(map(int, line.split()))

def solve():
    n2 = n // 2
    c1 = [ list(map(sum, combinations(coins[:n2], z))) for z in range(0, n2 + 1) ]
    c2 = [ list(map(sum, combinations(coins[n2:], z))) for z in range(0, n - n2 + 1) ]
    for i in range(0, n - n2 + 1):
        c2[i].sort()
    ans = 0
    for i in range(0, k + 1):
        if k - i < 0 or k - i > n - n2 or i > n2:
            continue
        for a in c1[i]:
            low = bisect.bisect_left(c2[k - i], l - a)
            high = bisect.bisect_right(c2[k - i], r - a)
            ans += high - low
    return ans

print(solve())


Measured memory_bytes: 89584
import math

N = int(input())
s = 0

# def devisor(x):
#     count = 0
#     for i in range(1,math.floor(math.sqrt(x))+1):
#         if (x % i) == 0:
#             count += 2
#             if i**2 == x:
#                 count -= 1
#     return count

# for i in range(1, N+1):
#     s += i * devisor(i)

for i in range(1,N+1):
    y = math.floor(N/i)
    s += y*(y+1)*i//2

print(s)

Measured memory_bytes: 63876
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
//#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pii pair<int,int>
#define N 500500
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n;
ll a[N];
void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    sort(a + 1, a + n + 1);
    ll ans = a[n];
    int need = n - 2, ptr = n - 1;
    while (need != 0) {
        ans += a[ptr];
        --need;
        if (need == 0) break;
        ans += a[ptr--];
        --need;
    }
    cout << ans << "\n";
}

int main() {
//    freopen("sample.in", "r", stdin);
    dracarys
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; ++i) {
//        cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 5216
x, n = map(int, input().split())
p = list(map(int, input().split()))

def search(x, li):
  for i in range(int(len(li)/2)+2):
    if x-i not in li:
      print(x-i)
      return
    if x+i not in li:
      print(x+i)
      return
  return

search(x, p)

Measured memory_bytes: 9196
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC109
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            Dictionary<string, int> wdic = new Dictionary<string, int>();

            string[] W = new string[N];
            for (int i = 0; i < N; i++)
            {
                W[i] = Console.ReadLine();
            }

            char last = ' ';
            for (int i = 0; i < N; i++)
            {
                if (wdic.ContainsKey(W[i])) { Console.WriteLine("No"); return; }
                else { wdic.Add(W[i], 1); }

                if (0 < i && W[i][0] != last) { Console.WriteLine("No"); return; }

                last = W[i][W[i].Length - 1];
            }

            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 13152
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef string str;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

bool prime(int x){
	for(int i = 2; i * i <= x; i++){
		if(!(x%i))return 0;
	}
	return 1;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	int n;
	cin >> n;	
	for(int i = n; i <= 100000000000; i++){
		if(i%2 == 0 && i != 2)continue;
		else{
			if(prime(i)){
				cout << i;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>

#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 12;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    ll h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    if(m2<m1)     m2 += 60,h2--;
    ll dif = m2 - m1 + (h2-h1)*60;
    dif -= k;
    cout<<dif;
}

int main()
{
    FAST;
    ll t = 1;
  //  cin >> t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e9
typedef long long ll;
using namespace std;
//�I�[�o�[�t���[�ɋC���‚���您����������
//�m�F�Y���Ȃ您����������

int main() {
    int c1, c5, c10, c50, c100 , c500; cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
    if(c1+c5*5+c10*10+c50*50+c100*100+c500*500>=1000) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 3132
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_int
  gets.chomp.to_i
end

S = gets.chomp
T = gets.chomp

if S.length + 1 == T.length && T.start_with?(S)
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 14352
#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);

    short a[n];
    int i;
    for (i=0;i<n;i++)
    {
        scanf("%d", &a[i]);
    }
    for (i=n-1; i>=0;i--)
    {
        if (i==0)
        {
            printf("%d", a[0]);
        }
        else
        {
            printf("%d ",a[i]);
        }
    }
    printf("\n");
    return 0;
}


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

int main(){

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

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

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

	int ans=0;
	for(int i=0;i<k;i++)
		ans+=v[i];
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

int main(void)
{
        char b;

        scanf("%c", &b);

        if(b=='A') printf("T\n");
        else if(b=='T') printf("A\n");
        else if(b=='C') printf("G\n");
        else if(b=='G') printf("C\n");

        return 0;
}


Measured memory_bytes: 128