akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

int x[5];

int main(){
    rep(i,5) cin>>x[i];

    int ans;
    rep(i,5){
        if(x[i]==0) ans=i+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3564
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N,Y;
LL x,y,z;

int main()
{
	in>>N>>Y;

	for(int x=0;x<=N;++x)
	{
		for(int y=0;y<=N;++y)
		{
			if(x+y>N)continue;
			int z=N-(x+y);
			if(10000*x+5000*y+1000*z==Y)
			{
				out<<x<<" "<<y<<" "<<z<<std::endl;
				return 0;
			}
		}
	}
	out<<-1<<" "<<-1<<" "<<-1<<std::endl;
	return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
s=list(s)
t=list(t)
s.sort()
t.sort(reverse=True)
s=''.join(s)
t=''.join(t)
if s==t:
    print('No')
    exit()
a=[s,t]
a.sort()
if a[0]==s:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
def solve():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A.sort()
    if N%2==0:
        ans = (sum(A[N//2:])-sum(A[:N//2]))*2-A[N//2]+A[(N-2)//2]
    else:
        ans = (sum(A[(N+1)//2:])-sum(A[:(N-1)//2]))*2 + max(A[(N-1)//2]-A[(N+1)//2], A[(N-3)//2]-A[(N-1)//2])
    return ans
print(solve())

Measured memory_bytes: 7496
class Combinatorics:
    def __init__(self, N, mod):
        '''
        Preprocess for calculating binomial coefficients nCr (0 <= r <= n, 0 <= n <= N)
        over the finite field Z/(mod)Z.
        Input:
            N (int): maximum n
            mod (int): a prime number. The order of the field Z/(mod)Z over which nCr is calculated.
        '''
        self.mod = mod
        self.fact = {i: None for i in range(N+1)}         # n!
        self.inverse = {i: None for i in range(1, N+1)}   # inverse of n in the field Z/(MOD)Z
        self.fact_inverse = {i: None for i in range(N+1)} # inverse of n! in the field Z/(MOD)Z
        
        # preprocess
        self.fact[0] = self.fact[1] = 1
        self.fact_inverse[0] = self.fact_inverse[1] = 1
        self.inverse[1] = 1
        for i in range(2, N+1):
            self.fact[i] = i * self.fact[i-1] % self.mod
            q, r = divmod(self.mod, i)
            self.inverse[i] = (- (q % self.mod) * self.inverse[r]) % self.mod
            self.fact_inverse[i] = self.inverse[i] * self.fact_inverse[i-1] % self.mod
    
    def perm(self, n, r):
        '''
        Calculate nPr = n! / (n-r)! % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return (self.fact[n] * self.fact_inverse[n-r]) % self.mod
    
    def binom(self, n, r):
        '''
        Calculate nCr = n! /(r! (n-r)!) % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod
        
    def hom(self, n, r):
        '''
        Calculate nHr = {n+r-1}Cr % mod.
        Assign r objects to one of n classes.
        Arrangement of r circles and n-1 partitions:
            o o o | o o | | | o | | | o o | | o
        '''
        if n == 0 and r > 0:
            return 0
        if n >= 0 and r == 0:
            return 1
        return self.binom(n + r - 1, r)

def extended_euclid(a, b):
    x1, y1, m = 1, 0, a
    x2, y2, n = 0, 1, b
    while m % n != 0:
        q, r = divmod(m, n)
        x1, y1, m, x2, y2, n = x2, y2, n, x1 - q * x2, y1 - q * y2, r
    return (x2, y2, n)

def modular_inverse(a, mod):
    x, _, g = extended_euclid(a, mod)
    if g != 1:
        return None # Modular inverse of a does not exist
    else:
        return x % mod


N, A, B, C = map(int, input().split())
MOD = 10**9 + 7
com = Combinatorics(2*N, MOD)
pa = A * modular_inverse(A+B, MOD); pb = B * modular_inverse(A+B, MOD);
n_first_AB = (100 * modular_inverse(100 - C, MOD)) % MOD
ans = 0
for m in range(N, 2*N): # E[X] = E_M[ E[X | M] ]
    Exp_X_given_M = (m * n_first_AB) % MOD
    prob_m = com.binom(m-1, N-1) * ((pow(pa, N, MOD) * pow(pb, m-N, MOD)) % MOD + (pow(pa, m-N, MOD) * pow(pb, N, MOD)) % MOD) % MOD
    ans = (ans + Exp_X_given_M * prob_m) % MOD
print(ans)

Measured memory_bytes: 78060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>

#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#include <utility>
#include <list>

#include <cmath>
#include <algorithm>
#include <cassert>
#include <bitset>
#include <complex>
#include <climits>
#include <functional>
#include <unordered_set>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
#define mp make_pair
#define pb push_back

#define debug(x) cerr << #x << " = " << x << " "


int main()
{
  int n; cin >> n;
  vector<ii> e;
  int target = n - (n%2) + 1;
  for (int i = 1; i <= n; ++i)
    for (int j = i+1; j <= n; ++j)
      if (i + j != target)
	e.pb(mp(i, j));
  cout << e.size() << endl;
  for (auto ee : e)
    cout << ee.first << " " << ee.second << endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> vec(N, vector<int>(2));
    rep(i, N) cin >> vec[i][0];
    rep(i, N) cin >> vec[i][1];
    int ans = 0;
    int tmp;
    rep(i, N) {
        tmp = vec[i][0] - vec[i][1];
        if (tmp > 0) ans += tmp;
    }
    cout << ans << endl;
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

class BIT{
  public:
    int n,MAX_N;
    vector<int> bit;
    BIT(){};
    BIT(int _n){
      n = _n;
      MAX_N = _n;
      bit.resize(MAX_N+1);
    }
    int sum(int i){
      int s= 0;
      while(i > 0){
        s += bit[i];
        i -= i & -i;
      }
      return s;
    }
    void add(int i,int x){
      while(i <= n){
        bit[i] += x;
        i += i & -i;
      }
    }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,q,c,x,y;
  cin >> n >> q;
  BIT bit(n);
  rep(i,q){
    cin >> c >> x >> y;
    if(c){
      cout << bit.sum(y) - bit.sum(x-1) << endl;
    }
    else{
      bit.add(x,y);
    }
  }
  return 0;
}

Measured memory_bytes: 3368
n = int(input())
ans = [100]*26
for i in range(n):
  s =input()
  lst = [0]*26
  for j in s:
    num = ord(j)-97
    lst[num] += 1
  for k in range(26):
    ans[k] = min(ans[k],lst[k])
for l in range(26):
  if ans[l] > 0:
    print(chr(l+97)*ans[l],end="")

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<int>
#define ll long long
using namespace std;

void selectionSort(V A, int N){
    int ans = 0;

    rep(i, 0, N){
        int minj = i;
        rep(j, i, N){
            if(A[j] < A[minj]){
                minj = j;
            }
        }

        swap(A[i], A[minj]);
        if(i != minj) ans++;
    }

    rep(i, 0, N){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl << ans << endl;
}

int main() {

    int n; cin >> n;
    V A(n);
    rep(i,0,n) cin >> A[i];
    
    selectionSort(A, n);

}



Measured memory_bytes: 3172
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n = ni()
a = nl()
l = [0 for _ in range(9)]
for i in range(n):
    if a[i] <= 399:
        l[0] += 1
    elif 400 <= a[i] <= 799:
        l[1] += 1
    elif 800 <= a[i] <= 1199:
        l[2] += 1
    elif 1200 <= a[i] <= 1599:
        l[3] += 1
    elif 1600 <= a[i] <= 1999:
        l[4] += 1
    elif 2000 <= a[i] <= 2399:
        l[5] += 1
    elif 2400 <= a[i] <= 2799:
        l[6] += 1
    elif 2800 <= a[i] <= 3199:
        l[7] += 1
    elif 3200 <= a[i]:
        l[8] += 1
if l[8] == 0:
    print(9 - l.count(0), 9 - l.count(0))
else:
    if l.count(0) == 8:
        print(1, l[8])
    else:
        print(8 - l.count(0), 8 - l.count(0) + l[8])


Measured memory_bytes: 3316
import java.util.*;
public class Main {

	public static void main(String[] args) {
		int i1, i2;
		Scanner sc = new Scanner(System.in);
		i1 = sc.nextInt();
		i2 = sc.nextInt();
		System.out.println(i1 * i2 +" "+ 2 * (i1 + i2));
	}

}

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

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

            return;
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;

            var SqrtN = Sqrt(N);

            var IntSqrtN = (int)SqrtN;

            WriteLine(IntSqrtN * IntSqrtN);
        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

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

Measured memory_bytes: 11348
from collections import defaultdict
n = int(input())

ans = defaultdict(int)
for i in range(n):
    ans[input()] += 1

print('AC x ' + str(ans['AC']))
print('WA x ' + str(ans['WA']))
print('TLE x ' + str(ans['TLE']))
print('RE x ' + str(ans['RE']))



Measured memory_bytes: 9456
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n,a[20],b[20],f[51][1001000],cnt[1001000];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
	n=read();
	rep(i,1,n) a[i]=read();
	rep(i,1,n) b[i]=read();
	int lim=(1<<n)-1,mx=0;
	rep(i,1,n) mx=max(mx,max(a[i],b[i]));
	memset(f,0x3f,sizeof(f));f[0][0]=0;
	rep(i,0,lim) cnt[i]=cnt[i>>1]+(i&1);
	rep(pre,0,lim)
	{
		int stp=0;
		rep(i,1,n)
		{
			if ((pre>>(i-1))&1) continue;
			int rnk=cnt[pre]+1,now,sta=pre|(1<<(i-1));
			if (abs(rnk-i)&1) now=b[i];else now=a[i];
			rep(j,0,now)
				f[now][sta]=min(f[now][sta],f[j][pre]+stp);
			stp++;
		}
	}
	int ans=maxd;
	rep(i,0,mx) ans=min(ans,f[i][lim]);
	if (ans==maxd) ans=-1;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 202496
//#include </Users/kmudda/Downloads/Karthik/stdc++.h>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <climits>
#define ll long long int
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define vvl vector< vl >
#define vvi vector< vi >
#define pb push_back
#define mp make_pair
#define max_int_value 2147483647
#define max_long_value 9223372036854775807
#define min_long_value -9223372036854775806
#define ii pair<ll,ll>
#define F first
#define S second
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)
 
#define CLR(v, d)     memset(v, d, sizeof(v))
 
template<typename T> T gcd(T a, T b){return (b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return (a*(b/gcd(a,b)));}
template<typename T> T mod(T a, T b) {return (a<b ? a : a%b);}
template<typename T> T mod_neg(T a, T b) {return ((a%b)+b)%b;}
ll mulmod(ll a,ll b, ll m){ll q=(ll)(((ld)a*(ld)b)/(ld)m);ll r=a*b-q*m;if(r>m)r%=m;if(r<0)r+=m;return r;}
template<typename T> T expo(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T> T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mod(x*p,m);p=mod(p*p,m);n>>=1;}return x;}
template<typename T> T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T> T mod_inverse(T a, T n){T x,y;T d = extended_euclid(a, n, x, y);return (d>1?-1:mod_neg(x,n));}
 
using namespace std;
 
string IntToString (int a)
{
    ostringstream temp;
    temp<<a;
    return temp.str();
}
 
int StringToInt (string str)
{
    int xx;
    stringstream ss;
    ss << str;
    ss >> xx;
    return xx;
}
 
ll powerwithmodulus(ll base, ll exponent,ll modulus){
    ll result = 1; base%=modulus;
    while (exponent > 0)
    {
        if (exponent % 2 == 1) result = (result * base) % modulus;
        exponent = exponent >> 1;
        base = (base * base) % modulus;
    }
    return result;
}

/*  NCR using DP
for(int n = 0; n <= 1000; n++)
        for(int r = 0; r <= n; r++)
            if(r == 0 || n == r) ncr[n][r] = 1;
            else ncr[n][r] = (ncr[n-1][r-1] + ncr[n-1][r]) % mod;

*/

 
ll largestPowerOf2(ll n)
{
    return (ll)pow(2, floor(log(n) / log(2)));
}

inline bool cmp1(pair<ll,ll> &p1, pair<ll,ll> &p2) {
    if(p1.F == p2.F)
        return p1.S < p2.S;
    else
        return p1.F < p2.F;
}
 
//lower case std::transform(str.begin(), str.end(), str.begin(), ::tolower);
//Ascii A-65 Z-90 a-97 z-122 0-48 9-57

int cal(int pow, int val, int MOD){
   if(pow <= 0)
      return 1;
   int v = cal(pow/2, val, MOD);
   if(pow % 2 == 0)
      return (v*v) % MOD; 
   else
      return (((v*val) % MOD) * v) % MOD;
}

ll t,n,m,sum=0,coun=0,m1,m2,m3,i,j,k,sum1,sum2,p,q,r,p1,q1;
bool flag2;

int main() {

  fast_io;
  //freopen("inputf.in", "r", stdin);
  //freopen("outputf.in", "w", stdout);
  cin>>n>>k;
  if(n < k) cout<<"0"<<endl;
  else cout<<"10"<<endl;
}


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

int main()
{
	char t[300000];
	char *p, *c;
	int i,m=0;
	scanf("%s", &t);
	p = t;
	c = p;
	m = strlen(p);
	for (i = 0; i < m; i++)
	{
		if (i == 0) {
			if (*p == '?')
				*p = 'D';
		}
		else if (i == m - 1) {
			if (*p == '?')
				*p = 'D';
		}

		if(*p=='?'){
			if (*(p - 1) == 'P')
				*p = 'D';
			else
				*p = 'D';
		}
		*(p++);
	}

	for (i = 0; i < m; i++)
	{
		printf("%c", *c);
		*(c++);
	}

	return 0;
}

Measured memory_bytes: 2248
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int lm[114514],rm[114514];
signed main(){
	int n;
	cin>>n;
	vector<pair<int,int> > gd,gd2;
	vector<int> l,r;
	vector<int> sa;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		gd.pb(mp(x,y));
		gd2.pb(mp(y,x));
		l.pb(x);
		r.pb(y);
		sa.pb( y - x + 1 );
	}
	sort(gd.begin(), gd.end());
	sort(gd2.begin(),gd2.end());
	sort( l.begin(), l.end() );
	sort( r.begin(), r.end() );
	sort( sa.begin(), sa.end() );
	int lmx = l[l.size()-1];
	int rmi = r[0];
	int ans = max( 0LL , rmi-lmx+1 ) + sa[sa.size()-1];
	pair<int,int> lef = gd[ gd.size()-1 ], rig = mp( gd2[0].second, gd2[0].first);
	//cout<<lef.first<<" "<<lef.second<<" "<<rig.first<<" "<<rig.second<<endl;
	lm[0] = gd[0].first;
	for(int i=1;i<n;i++){
		lm[i] = max( lm[i-1], gd[i].first );
		//cout<<i<<" "<<lm[i]<<endl;
	}
	rm[n-1] = gd[n-1].second;
	for(int i=n-2;i>=0;i--){
		rm[i] = min( rm[i+1], gd[i].second );
		//cout<<i<<" "<<rm[i]<<endl;
	}
	for(int i=0;i<n-1;i++){
		int tmp = max( rig.second - max( lm[i], rig.first ) + 1 , 0LL ) + max( min( rm[i+1], lef.second ) - lef.first + 1, 0LL );
		if( tmp > ans ) ans = tmp;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    ll N,K;cin>>N>>K;
    ll ans=pow(N/K,3);
    if(!(K%2))ans+=pow((N+K/2)/K,3);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;


class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int Q = Integer.parseInt(sc.next());
		long[] s = new long[A];
		long[] t = new long[B];
		long[] x = new long[Q];
		for (int i=0;i<A;i++) {
			s[i]=Long.parseLong(sc.next());
		}
		for (int i=0;i<B;i++) {
			t[i]=Long.parseLong(sc.next());
		}
		for (int i=0;i<Q;i++) {
			x[i]=Long.parseLong(sc.next());
		}

		ArrayList<long[]> list = new ArrayList<long[]>();
		list.add(s);
		list.add(t);
		list.add(t);
		list.add(s);
		ArrayList<Integer> limit = new ArrayList<Integer>();
		limit.add(A);
		limit.add(B);
		limit.add(B);
		limit.add(A);

		for (int i=0;i<Q;i++) {
			long[] dist = new long[8];

			for (int k=0;k<2;k++) {
				int[] index = new int[2];
				long[] S = list.get(2*k);
				long[] T = list.get(2*k+1);
				int A_A = limit.get(2*k);
				int B_B = limit.get(2*k+1);
		    	int result_1 = Arrays.binarySearch(S, x[i]);
		    	long[] dist_tmp = new long[2];
		    	if (result_1<0) {
		    		if (-result_1-2==-1) {
		    			dist_tmp[0]+=Math.abs(S[-result_1-1]-x[i]);
		    			dist_tmp[1]+=Math.abs(S[-result_1-1]-x[i]);
		    			index[0]=-result_1-1;
		    			index[1]=-result_1-1;
		    		} else if (-result_1-1==A_A) {
		    			dist_tmp[0]+=Math.abs(S[-result_1-2]-x[i]);
		    			dist_tmp[1]+=Math.abs(S[-result_1-2]-x[i]);
		    			index[0]=-result_1-2;
		    			index[1]=-result_1-2;
		    		} else {
		    			dist_tmp[0]+=Math.abs(S[-result_1-2]-x[i]);
		    			dist_tmp[1]+=Math.abs(S[-result_1-1]-x[i]);
		    			index[0]=-result_1-2;
		    			index[1]=-result_1-1;
		    		}
		    	}
		    	for (int j=0;j<2;j++) {
			    	int result_t = Arrays.binarySearch(T, S[index[j]]);
			    	if (result_t<0) {
			    		if (-result_t-2==-1) {
			    			dist[4*k+2*j]=dist_tmp[j]+Math.abs(T[-result_t-1]-S[index[j]]);
			    			dist[4*k+2*j+1]=dist_tmp[j]+Math.abs(T[-result_t-1]-S[index[j]]);
			    		} else if (-result_t-1==B_B) {
			    			dist[4*k+2*j]=dist_tmp[j]+Math.abs(T[-result_t-2]-S[index[j]]);
			    			dist[4*k+2*j+1]=dist_tmp[j]+Math.abs(T[-result_t-2]-S[index[j]]);
			    		} else {
			    			dist[4*k+2*j]=dist_tmp[j]+Math.abs(T[-result_t-2]-S[index[j]]);
			    			dist[4*k+2*j+1]=dist_tmp[j]+Math.abs(T[-result_t-1]-S[index[j]]);
			    		}
			    	}
			    }
			}
			Arrays.sort(dist);
	    	System.out.println(dist[0]);
    	}
	}
}

Measured memory_bytes: 86192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc139_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S, T;
  cin >> S >> T;
  

  ll ans = 0;
  rep(i, S.size()) {
    if (S[i] == T[i]) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(int argc,char const *argv[]) {
   ios_base::sync_with_stdio(false); cin.tie(0);
   string str;
   cin>>str;
   cout<<str[0]<<str.size()-2<<str[str.size()-1]<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string t, p;
    cin >> t;
    cin >> p;

    t += "$";
    p += "$";

    vector<bool> exists(p.size());
    bool duplicated = false;
    int i = 0;
    char tmp = '!';
    for (int j = 0; j < t.size(); ++j) {
        if (p[i] == t[j]) {
            if (!exists[i]) {
                exists[i] = true;
                tmp = p[i];
                i += 1;
            }
        }
        else if (tmp == t[j]) {
            duplicated = true;
        }
        else {
            if (exists[i]) {
                i += 1;
            }
        }
    }

    if (accumulate(begin(exists), end(exists), true, logical_and<>())) {
        if (!duplicated) {
            cout << "yes" << endl;
            return 0;
        }
    }
    cout << "no" << endl;
}

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

using namespace std;

int main()
{
    int N;

    cin >> N;
    vector<long long> A(N);

    rep(i, N)
    {
        cin >> A[i];
    }

    unordered_map<long long, long long> hm;
    rep(i, N)
    {
        hm[A[i]]++;
    }

    long long all = 0;
    for (auto it : hm)
    {
        long long v = it.second;
        all += (v * (v - 1)) / 2;
    }

    rep(i, N)
    {
        long long t = hm[A[i]];
        long long m = (t * (t - 1)) / 2;
        long long n = ((t - 1) * (t - 2)) / 2;

        cout << all - m + n << endl;
    }
}


Measured memory_bytes: 9160
import sys
s = ""
for e in sys.stdin:
    s += e
letters = "abcdefghijklmnopqrstuvwxyz"
ans = [0] * 26

for i in s:
    index = 0
    for j in letters:
        if i == j or i == j.upper():
            ans[index] += 1
            break
        index += 1

for i in range(len(letters)):
    print("%s : %d"%(letters[i], ans[i]))


Measured memory_bytes: 5564
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> P(A), Q(B), R(C);
  REP(i, A) { cin >> P[i]; }
  REP(i, B) { cin >> Q[i]; }
  REP(i, C) { cin >> R[i]; }
  sort(P.begin(), P.end(), greater<int>());
  sort(Q.begin(), Q.end(), greater<int>());
  sort(R.begin(), R.end(), greater<int>());
  int tA = 0, tB = 0, tC = 0;
  LL ret = 0;
  while(tA + tB + tC < X + Y) {
    if(tA == X) {
      if(Q[tB] < R[tC]) {
        ret += R[tC++];
      } else {
        ret += Q[tB++];
      }
    } else if(tB == Y) {
      if(P[tA] < R[tC]) {
        ret += R[tC++];
      } else {
        ret += P[tA++];
      }
    } else {
      if(P[tA] < R[tC] && Q[tB] < R[tC]) {
        ret += R[tC++];
      } else if(P[tA] < Q[tB]) {
        ret += Q[tB++];
      } else {
        ret += P[tA++];
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
a[100],b[100],s,c;int main(){
	int i,j,as=0;
	for(i=0;scanf("%d,%d",&a[i],&b[i])!=EOF;i++){
		s+=a[i]*b[i];as+=b[i];c++;
	}
	printf("%d\n%d\n",s,(int)((double)((double)as/(double)c)+0.5));exit(0);
}

Measured memory_bytes: 0
import sys

def divisor(i):
    count = 0
    for j in range(1, i + 1):
        if j ** 2 > i: break
        if i % j == 0:
            if j ** 2 == i: count += 1
            else: count += 2
    return count


def solve():
    N = int(input())
    ans = 0
    for i in range(1, N+1):
        if i % 2 > 0:
            if divisor(i) == 8: ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)

vector<ll> divisor_enumerate(ll N){
    vector<ll> front,back;
    for(ll i=1;i*i<N+1;i++){
        if(N%i==0){
            front.push_back(i);
            back.push_back(N/i);
        }
    }
    while(!back.empty()){
        if(back.back()==front.back()) back.pop_back();
        else{
            front.push_back(back.back());
            back.pop_back();
        }
    }
    return front;
}

int main(){
    int N,M;
    cin>>N>>M;
    vector<ll> vec;
    vec=divisor_enumerate(M);
    rep(i,vec.size()){
        if(vec[i]>N-1){
            cout<<M/vec[i]<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int n,k,a,b,c,i;
	scanf("%d%d",&n,&k);
	for(i=0;i<k;i++){
		scanf("%d%d",&a,&b);
	if(n+1-a<a){
		a=n+1-a;
	}
	if(n+1-b<b){
		b=n+1-b;
	}
	if(b>a){
		c=(a-1)%3+1;
	}
	else{
		c=(b-1)%3+1;
	}
	printf("%d\n",c);
	}
	return 0;
}


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

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class DCardEater {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    map<int, int> A;
    rep(i, N) {
      int temp;
      cin >> temp;
      A[temp]++;
    }
    int ret = 0;
    FOR(i, A) {
      if (i.second >= 2) {
        ret += i.second - 1;
      }
    }
    cout << N - ret - (ret % 2) << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  DCardEater solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 9708
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAXX = 1e9;

LL getSqrt(LL x)
{
    LL y = sqrt(x);
    if ((y+1)*(y+1)==x) y++;
    return y;
}

int main()
{
    LL S;
    cin >> S;
    LL x1 = 0, y1 = 0;

    LL g = getSqrt(S);
    if (g * g < S) g++;

    LL x2 = g, y3 = g;

    while (x2 * y3 - S > MAXX) y3--;

    LL x3 = 1, y2 = x2*y3 - S;

    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;

    assert(x2*y3-x3*y2==S);


    return 0;
}


Measured memory_bytes: 256
N = int(input())
b = list(map(int, input().split()))
ans = [0] * N

for i in range(N):
    for j in range(N - i - 1, -1, -1):
        if b[j] == j + 1:
            ans[N - i - 1] = j + 1
            del b[j]
            break
    else:
        print(-1)
        exit()
else:
    for j in range(N):
        print(ans[j])


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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   int D;
   cin>>D;
   string s = "Christmas";
   string e = "Eve";
   if(D==25)cout<<s;
   else if(D==24)cout<<s<<" "<<e;
   else if(D==23)cout<<s<<" "<<e<<" "<<e;
   else if(D==22)cout<<s<<" "<<e<<" "<<e<<" "<<e;
   return 0; 
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

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

	cout << r * r << endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
As = list(map(int, input().split()))
Fs = list(map(int, input().split()))

As.sort()
Fs.sort(reverse=True)
maxAF = max([A*F for A, F in zip(As, Fs)])

def isOK(X):
    rest = K
    for A, F in zip(As, Fs):
        if A*F > X:
            A2 = X//F
            d = A-A2
            if d > rest:
                return False
            rest -= d
    return True

ng, ok = -1, maxAF
while abs(ok-ng) > 1:
    mid = (ng+ok) // 2
    if isOK(mid):
        ok = mid
    else:
        ng = mid

print(ok)


Measured memory_bytes: 119500
"use strict"
function main(arg) {
    var data = arg.trim().split("\n")
    var tmp = data.shift().split(' ').map(Number)
    var N = tmp[0]
    var D = tmp[1]
    data = data.map(e => e.split(' ').map(Number))

    var ans = 0

    for (var i = 0; i < N; i++) {
        for (var j = i; j < N; j++) {
            if (i === j) continue
            // console.log(`${i}:${j}`)
            var row1 = data[i]
            var row2 = data[j]
            var yz = 0
            for (var d = 0; d < D; d++) {
                // console.log(`${i}:${j}`)
                var t = Math.abs(row1[d] - row2[d])
                yz += t * t
            }
            var tAns = Math.sqrt(yz)
            if (!(String(tAns).split('.').length > 1)) {
                // console.log(tAns)
                ans++
            }
        }
    }
    console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7756
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する


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

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

    cout << (a - 1) * (b - 1) << endl;


    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;
LL n,m;
LL a[100010];
LL s[100010];
PL nibu(LL k){
  LL ko=0;
  LL sum=0;
  for(LL i=0;i<n;i++){
    LL po=lower_bound(a,a+n,k-a[i])-a;
    if(po<=n-1)sum+=s[po];
    po=n-po;
    ko+=po;
    sum+=po*a[i];
  }
  return PL(ko,sum);
}
  
int main(){
  cin>>n>>m;
  
  for(LL i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  
  for(LL i=n-1;i>=0;i--){
    if(i==n-1)s[i]=a[i];
    else s[i]=s[i+1]+a[i];
    //cout<<s[i]<<endl;
  }
  
  LL l=0,r=100100100100100100;
  while(r-l>1){
    LL mid=(l+r)/2;
    PL hoge=nibu(mid);
    if(hoge.first==m){
      //cout<<mid<<endl;
      //cout<<hoge.first<<endl;
      cout<<hoge.second<<endl;
      return 0;
    }
    if(hoge.first<m)r=mid;
    else l=mid;
  }
  LL a=nibu(l).first,b=nibu(l).second;
  cout<<b-(a-m)*l<<endl;
  
  return 0;
}

Measured memory_bytes: 1792
// 今向いている方向にとっての左から始めて、時計回りに壁を探して、最初にみつけた壁の方向に進む
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
struct Direction {
  bool u, d, r, l;
};

void dump_Direction(Direction di) {
  cout << "[" << di.u << di.r << di.d << di.l << "]";
}



int main() {
  // ifstream cin("../test.txt");
  Direction g[5][5];
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      g[i][j].u = false;
      g[i][j].d = false;
      g[i][j].r = false;
      g[i][j].l = false;
    }
  }
  for (int i = 0; i < 9; i++) {
    string s;
    cin >> s;
    if (i % 2 == 0) {
      for (int j = 0; j < 4; j++) {
        int k = i / 2;
        g[k][j].r = (s[j] == '1');
        g[k][j+1].l = (s[j] == '1');
      }
    } else {
      for (int j = 0; j < 5; j++) {
        int k = i / 2;
        g[k][j].d = (s[j] == '1');
        g[k+1][j].u = (s[j] == '1');
      }
    }
  }
  // 表示用
  // for (int i = 0; i < 5; i++) {
  //   for (int  j = 0; j < 5; j++) {
  //     dump_Direction(g[i][j]);
  //   }
  //   cout << endl;
  // }

  int x = 0;
  int y = 0;
  int d = 0; // 0: u, 1: r, 2: d, 3: l
  int dx[] = {0,1,0,-1};
  int dy[] = {-1,0,1,0};
  char c[] = {'U','R','D','L'};
  while (true) {
    bool dir[] = {g[y][x].u, g[y][x].r, g[y][x].d, g[y][x].l};
    // dump_Direction(g[y][x]);
    int i = 0;
    for (;i < 4; i++) {
      if (dir[(i+d)%4]) break;
    }
    int j = (i+d)%4;
    // cout << j;
    x += dx[j];
    y += dy[j];
    cout << c[j];
    d = (j + 3) % 4;
    if (!(x|y)) break;
  }
  cout << endl;
}

Measured memory_bytes: 1180
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

bool solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n+1);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    for (int i = 1; i <= n; ++i) {
        if (g[i].size() % 2 == 1) return false;
    }

    vector<int> qv;
    for (int i = 1; i <= n; ++i) {
        if (g[i].size() >= 6) return true;
        if (g[i].size() == 4) {
            qv.push_back(i);
            if (qv.size() >= 3) return true;
        }
    }
    if (qv.size() < 2) return false;

    for (auto &e: g[qv[0]]) {
        int v = e;
        int p = qv[0];
        while (v != qv[0] && v != qv[1]) {
            if (g[v][0] == p) swap(g[v][0], g[v][1]);
            p = v;
            v = g[v][0];
        }
        if (v == qv[0]) return true;
    }

    return false;
}

int main() {
    if (solve()) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

ll p2(ll n)
{
	return (1ll<<n);
}

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
ll pos[55]={0},ans=0,b[55],a[55];
rep(i,0,n-1)
{
	int x;
	cin>>x;
	a[i]=x;
	pos[i]=p2(x);
}

rep(i,0,n-1)
{
	cin>>b[i];
}

rep(i,0,n-1)
{
	if(a[i]<=2*b[i]&&a[i]!=b[i])
	{
		ol("-1");
		return 0;
	}
}
while(1)
{
	int mx=0;
	
	rep(i,0,n-1)
	{
		if(pos[i]&p2(b[i]))
		continue;
		int mn=107;
		rep(j,0,50)
		{
			if(pos[i]&p2(j))
			{
				rep(k,1,50)
				{
					if(j%k==b[i]||j%k>2*b[i])
					mn=min(mn,k);
				}
			}
		}
		mx=max(mx,mn);
	}
	if(mx==0)
	break;
	rep(i,0,n-1)
	{
		ll x=pos[i];
		rep(j,0,50)
		{
			if(pos[i]&p2(j))
			x|=p2(j%mx);
		}
		pos[i]=x;
	}
	
	ans+=p2(mx);
}
ol(ans);
return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <chrono>
#include <numeric>
 
using namespace std;
 
int binary_search(const int x, const vector<int> &v, const int s, const int e){
  if (x <= v[s])
    return(s-1);
  if (v[e] < x) {
    return(e);
  }
  int idx = (e - s)/2 + s;
  if (v[idx] < x) {
    if (e == idx+1) {
      return(idx);
    }
    return(binary_search(x, v, idx, e));
  } else {
    if (s == idx-1) {
      return(idx-1);
    }
    return(binary_search(x, v, s, idx));
  }
}
 
int main(){
  long long result = 0;
  int n;
  vector<int> a, b, c;
  vector<long long> acc;
  cin >> n;
  for (int i=0;i<n;i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());
  for (int i=0;i<n;i++) {
    int tmp;
    cin >> tmp;
    b.push_back(tmp);
  }
  sort(b.begin(), b.end());
  for (int i=0;i<n;i++) {
    int tmp;
    cin >> tmp;
    c.push_back(tmp);
  }
  sort(c.begin(), c.end());
  long long prev = 0;
  for (int i=0;i<n;i++) {
    int tmp1 = binary_search(b[i], a, 0, n-1) + 1;
    vector<int>::iterator tmp_iter = lower_bound(a.begin(), a.end(), b[i]);
    int tmp = tmp_iter - a.begin();
    acc.push_back((long long)tmp + prev);
    prev += (long long)tmp;
  }
  for (int i=0;i<n;i++) {
    int tmp1 = binary_search(c[i], b, 0, n-1);
    vector<int>::iterator tmp_iter = lower_bound(b.begin(), b.end(), c[i]);
    int tmp = tmp_iter - b.begin();
    tmp--;
    if (tmp  >= 0)
      result += acc[tmp];
  }
  cout << result << endl;
}

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

int main(){
    int n,q;cin>>n>>q;
    int S,T,X;
    vector<tuple<int,int,int>> ban(n);
    rep(i,n){
        cin>>S>>T>>X;
        ban[i]=make_tuple(X,S-X,T-X);
    }
    sort(all(ban));
    int d;
    map<int,int> num;
    set<int> time;
    rep(i,q){
        cin>>d;
        num[d]=i;
        time.insert(d);
    }
    time.insert(inf);
    vin ans(q,-1);
    //s<=d<tなるdをxが小さい順に見つけていく
    queue<int> que;
    int x,s,t;
    rep(i,n){
        if(time.size()==1)break;
        x=get<0>(ban[i]);
        s=get<1>(ban[i]);
        t=get<2>(ban[i]);
        auto l=time.lower_bound(s);
        auto r=time.lower_bound(t);
        for(auto itr=l;itr!=r;itr++){
            ans[num[*itr]]=x;
            que.push(*itr);
        }
        while(que.size()){
            time.erase(que.front());
            que.pop();
        }
    }
    rep(i,q)cout<<ans[i]<<endl;
}

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

int main() {
int a;
cin >> a;
int b,c,d,e;
b = a/100;
c = a%100;
d = c/10;
e = c%10;

	if(b == 7 || d ==7 || e == 7){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
}
return 0;
}

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

typedef pair<int, int> ii;
const int MAX_N = (int)2e5 + 5;

vector<int> g[MAX_N << 1];
bool used[MAX_N << 1];
int scc[MAX_N << 1], n;
map<ii, int> res;

void dfs(vector<int> g[], int v, const int& id) {
    static int tme = 0;
    used[v] = true;
    scc[v] = id;
    for (int& x : g[v])
        if (!used[x]) dfs(g, x, id);
}

int main() {
    int k, l, p, q;
    scanf("%d%d%d", &n, &k, &l);
    for (int i = 0; i < k; i++) {
        scanf("%d%d", &p, &q);
        g[p].push_back(q);
        g[q].push_back(p);
    }
    for (int i = 0; i < l; i++) {
        scanf("%d%d", &p, &q);
        g[p + n].push_back(q + n);
        g[q + n].push_back(p + n);
    }
    for (int i = 1, id = 0; i <= (n << 1); i++)
        if (!used[i]) dfs(g, i, ++id);
    for (int i = 1; i <= n; i++)
        res[{scc[i], scc[i + n]}]++;
    for (int i = 1; i <= n; i++) printf("%d ", res[{scc[i], scc[i + n]}]);
}

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

int main() {
  int n; scanf("%d", &n);
  vector<int> A(n),B(n),C(n);
  for (int i=0; i<n; i++) scanf("%d", &A[i]);
  for (int i=0; i<n; i++) scanf("%d", &B[i]);
  for (int i=0; i<n; i++) scanf("%d", &C[i]);

  sort(A.begin(), A.end());
  sort(C.begin(), C.end());
  long long res=0;
  for (int i=0; i<n; i++) {
    int top=lower_bound(A.begin(), A.end(), B[i])-A.begin();
    int bottom=n-(upper_bound(C.begin(), C.end(), B[i])-C.begin());
    res+=(long long)top*(long long)bottom;
  }
  printf("%lld\n",res);
}


Measured memory_bytes: 1408
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int a;

  std::cin >> a;

  std::cout << a + a * a + a * a * a << std::endl;

  return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int Case = 1;
		
		int t = scan.nextInt();
		
		while(t-- != 0){
			System.out.println("Case " + Case++ + ":");
			
			int x = scan.nextInt();
			x *= x;
			
			for(int i = 0; i < 10; i++){
				String s = x + "";
				while(s.length() < 8)s = "0" + s;
				x = Integer.parseInt(s.substring(2,6));
				System.out.println(x);
				x *= x;
			}
		}
	}
}

Measured memory_bytes: 26216
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var q = long.Parse(Console.ReadLine().Trim());
            if (q == -1) break;
            var prev = (double)q / 2;
            while (true)
            {
                var temp = prev - (Math.Pow(prev, 3) - q) / (3 * Math.Pow(prev, 2));
                if (Math.Abs( Math.Pow(temp,3) - q) < 0.00001 * q)
                {
                    Console.WriteLine(temp);
                    break;
                }
                else prev = temp;
            }
        }
    }
}

Measured memory_bytes: 9200
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    map<int, int> m;
    auto prime_factorize = [&](int n) -> void {
        for (int i = 2; i*i <= n; i++)
        {
            if (n%i != 0) continue;
            while (n%i == 0)
            {
                m[i]++;
                n /= i;
            }
        }
        if (n != 1) m[n]++;
    };

    for (int i = 1; i <= n; i++)
    {
        prime_factorize(i);
    }
    
    auto rec = [&](auto &&rec, auto p, int k) -> int {
        if (p == m.end()) {
            if (k == 1) return 1;
            return 0;
        }
        int res = 0;
        for (int i = 0; i <= p->second; i++)
        {
            if (k%(i+1) != 0) continue;
            res += rec(rec, ++p, k/(i+1));
            p--;
        }
        return res;
    };
    cout << rec(rec, m.begin(), 75) << endl;
    return 0;
}

Measured memory_bytes: 256
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        String s = scanner.next();
        int ans = 0, combo = 0;
        for (int i = 0; i < s.length(); i++) {
            if ("ACGT".contains(String.valueOf(s.charAt(i)))) {
                combo++;
            } else {
                ans = Math.max(ans, combo);
                combo = 0;
            }
        }
        System.out.println(Math.max(ans, combo));
    }
}

Measured memory_bytes: 25172