akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i, s, n) for(int i = s; i <= (int)n; ++i)
#define per(i, n) for(int i = n; i > 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define MP make_pair
#define PB push_back
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define int long long
using namespace std;
static const int INF = 1ll<<60;
int feld[15][10005];
int temp[15][10005];
int wide_white[10005];
int wide_black[10005];
int white;
int h,w;
int ans=-INF;
int v;
vector<int> tera;

void cal(int bit){
    int res=0;
    white=0;
    for(int x=0;x<=w;++x){
        wide_black[x]=0;
        wide_white[x]=0;
    }
    for(int y=1;y<=h;++y)for(int x=1;x<=w;++x)temp[y][x]=feld[y][x];
    for(int i=0;i<=h;++i){
        int b=1<<i;
        if(b&bit){
            tera.PB(i);
        }
    }
    for(int i=0;i<tera.size();++i){
        int t=tera[i];
        for(int x=1;x<=w;++x){
            temp[t][x]=!temp[t][x];
        }
    }
    for(int y=1;y<=h;++y){
        for(int x=1;x<=w;++x){
            if(temp[y][x]==0)white++;
        }
    }
    for(int x=1;x<=w;++x){
        for(int y=1;y<=h;++y){
            if(temp[y][x]==0)wide_black[x]++;
            else wide_white[x]++;
        }
    }
    res=white;
    for(int x=1;x<=w;++x){
        res+=max(wide_white[x]-wide_black[x],0ll);
    }
    ans=max(ans,res);
}

signed main(){
    while(1){
        cin>>h>>w;
        if(h==0&&w==0)break;
        for(int y=1;y<=h;++y)for(int x=1;x<=w;++x)cin>>feld[y][x];
        cal(0);
        for(int i=0;i<=pow(2,h+1);++i){
            tera.clear();
            cal(i);
        }
        cout<<ans<<endl;
        ans=0;
    }
}

Measured memory_bytes: 3052
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int MOD = 1000000007;
int n, k, len, i, j, a[50005], f[50005], ans;
inline int ksm(int x, int y, int z)
{
	int b = 1;
	while (y)
	{
		if (y & 1) b = 1ll * b * x % z;
		x = 1ll * x * x % z;
		y >>= 1;
	}
	return b;
}
int main()
{
	cin >> n >> k;
	for(i = 1; i * i <= n; i ++)
		if (n % i == 0)
		{
			a[++len] = i;
			if (n / i != i) a[++len] = n / i;
		}
	sort(a + 1, a + 1 + len);
	int inv2 = (MOD + 1) >> 1;
	for(i = 1; i <= len; i ++)
	{
		f[i] = ksm(k, (a[i] + 1) >> 1, MOD);
		for(j = 1; j < i; j ++)
			if (a[i] % a[j] == 0) f[i] = (f[i] + MOD - f[j]) % MOD;
		if (a[i] & 1) ans = (ans + 1ll * f[i] * a[i]) % MOD;
		else ans = (ans + 1ll * f[i] * a[i] % MOD * inv2) % MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using int64 = long long;

int main() {
    int64 q,h,s,d,n;
    cin >> q >> h >> s >> d >> n;
    int64 _1 = min({4*q, 2*q+h, 2*h, s});
    int64 ans = min(n*_1, (n/2*d + (n%2)*_1));
    cout << ans << endl;
    return 0;
}


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

int main() {
  int k,x;
  cin >> k >> x;
  int ans=x-k;
  for(int i=0; i<2*k-1; i++){
    ans++;
    if(i==2*k-2) cout <<ans <<endl;
    else cout <<ans <<" ";
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;



signed main()
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    cout << a[0] + a[1] << endl;
}


Measured memory_bytes: 256
n = int(input())
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S","H","C","D"]
for i in range(n):
    ch,a = map(str,input().split())
    rank = int(a)
    cards[pattern.index(ch)][rank-1] = True
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j+1)



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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n;cin >> n;
    lint a, b;
    cin >> a >> b;
    lint ans;
    ans = n / (a + b) * a +min(n%(a+b),a);
    cout << ans << "\n";
    return 0;
}

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

int main(){
  long long N, X;
  cin >> N >> X;
  --X;
  long long ans = 0;
  for(int i = N; i >= 0; --i){
    long long m = ((4LL<<i)-3)/2;
    //cerr << i << " " << m << endl;
    if(X < m){
      --X;
      continue;
    }
    ans += (1LL<<(i));
    X -= m+1;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
    long K, X, Y;
    cin >> K >> X >> Y;
    long x, y;
    x = X+Y;
    y = X-Y;
    //cout << x <<  ' ' << y << endl;
    if(max(abs(x) , abs(y)) == K){
        cout << 1 << endl;
        cout << X << ' ' << Y << endl;
        return 0;
    } 
    vector<long> ansx, ansy;
    if(K%2 == 0 && abs(x)%2 == 1){
        cout << -1 << endl;
        return 0;
    }
    long m = max(abs(x), abs(y));
    long n = m/K;
    
    if(K%2 == 1){
        if(m%K != 0) n++;
        if(abs(x)%2 == 1){
            if(n%2 == 0) n++;
            if(n == 1) n += 2;
        }else{
            if(n%2 == 1) n++;
            if(n == 0) n += 2;
        }
    }else{
        if(m%K != 0) n++;
        if(n <= 1) n = 2;
    }
    
    long tmp = 0;
    for(long i = 0; i < n-1; i++) {
        if(tmp <= abs(x)){
            ansx.push_back(K);
            tmp += K;
        }else{
            ansx.push_back(-K);
            tmp -= K;
        }
    }
    ansx.push_back(abs(x)-tmp);
    
    tmp = 0;
    for(long i = 0; i < n-1; i++) {
        if(tmp <= abs(y)){
            ansy.push_back(K);
            tmp += K;
        }else{
            ansy.push_back(-K);
            tmp -= K;
        }
    }
    ansy.push_back(abs(y)-tmp);
    long tmpx = 0, tmpy = 0;
    cout << n << endl;
    for(long i = 0; i < n; i++){
        long mx_, my_;
        mx_ = ansx[i];
        if(x < 0) mx_*=-1;
        my_ = ansy[n-i-1];
        if(y < 0) my_*=-1;
        
        long mx = (mx_+my_)/2;
        long my = (mx_-my_)/2;
        tmpx += mx;
        tmpy += my;
        cout << tmpx << ' ' << tmpy << endl;
    }
}

Measured memory_bytes: 5744
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>
#include <bitset>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

int main(void){
    string a,b;
    cin >> a >> b;
    a = a+b;
    int O = stoi(a);
    for(int i=1;i<1000;i++){
        if(O == pow(i,2)){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;

#define ll long long
#define mem(Arr,x) memset(Arr,x,sizeof(Arr))
#define lowbit(x) ((x)&(-x))

const int maxN=300010;
const int inf=2147483647;

class Range
{
public:
	int l,r,len;
};

bool operator < (Range A,Range B) {return A.len<B.len;}

int n,m;
Range R[maxN];
int TA[maxN];

void Add(int pos,int key);
int GetSum(int pos);

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++){scanf("%d%d",&R[i].l,&R[i].r);R[i].len=R[i].r-R[i].l+1;}
	sort(&R[1],&R[n+1]);
	int r=1;//单调右指针
	for (int i=1;i<=m;i++)
	{
		for (;(r<=n)&&(R[r].len<i);r++)
		{
			Add(R[r].l,1);
			Add(R[r].r+1,-1);
		}
		int Ans=n-r+1;
		for (int j=i;j<=m;j=j+i)
			Ans=Ans+GetSum(j);
		printf("%d\n",Ans);
	}
	return 0;
}

void Add(int pos,int key)
{
	while (pos<=m+1)
	{
		TA[pos]+=key;pos+=lowbit(pos);
	}
	return;
}

int GetSum(int pos)
{
	int ret=0;
	while (pos)
	{
		ret=ret+TA[pos];pos-=lowbit(pos);
	}
	return ret;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int main() {
	int H,W;
	cin>>H>>W;
	bool flag;
	char A[100][100];
	int h=0,w=0;
	for(int i=0;i<H-h;i++){
		flag=true;
		for(int j=0;j<W;j++){
			cin>>A[i][j];
			if(A[i][j]=='#')flag=false;
		}
		if(flag==true){
			i--;
			h++;
		}
	}
	
	bool pass[100];
	for(int i=0;i<100;i++){
		pass[i]=false;
	}
	for(int i=0;i<W;i++){
		flag=true;
		for(int j=0;j<H-h;j++){
			if(A[j][i]=='#')flag=false;
		}
		if(flag==true){
			w--;
			pass[i]=true;
		}
	}
	for(int i=0;i<H-h;i++){
		for(int j=0;j<W;j++){
			if(pass[j]==false)cout<<A[i][j];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 256
#include <stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
const int INF=0x3f3f3f3f;
#define mod 1000000007
using namespace std;
//priority_queue

int main()
{

    int a,b;
    cin>>a>>b;
    if(a<b)cout<<0<<endl;
    else cout<<10<<endl;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DPeopleOnALine solver = new DPeopleOnALine();
        solver.solve(1, in, out);
        out.close();
    }

    static class DPeopleOnALine {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            WeightedUnionFind wuf = new WeightedUnionFind(n);
            for (int i = 0; i < m; i++) {
                int l = in.nextInt() - 1;
                int r = in.nextInt() - 1;
                int w = in.nextInt();
                if (wuf.same(l, r)) {
                    if (wuf.dif(l, r) != w) {
                        out.println("No");
                        return;
                    }
                } else {
                    wuf.union(l, r, w);
                }
            }
            out.println("Yes");

        }

    }

    static class WeightedUnionFind extends UnionFind {
        long[] dif;

        public WeightedUnionFind(int n) {
            super(n);
            dif = new long[n];
        }

        public void union(int x, int y, long w) {
            w = w + dif[x] - dif[y];
            x = find(x);
            y = find(y);
            if (height[x] < height[y]) {
                int tmp = x;
                x = y;
                y = tmp;
                w = -w;
            }
            if (height[x] == height[y]) {
                ++height[x];
            }
            parent[y] = x;
            dif[y] = w;
        }

        public int find(int x) {
            if (parent[x] == x) return x;
            int r = find(parent[x]);
            dif[x] += dif[parent[x]];
            return parent[x] = r;
        }

        public long dif(int x, int y) {
            return dif[y] - dif[x];
        }

    }

    static class UnionFind {
        protected int[] parent;
        protected int[] height;
        protected int[] size;

        public UnionFind(int size) {
            this.parent = new int[size];
            this.height = new int[size];
            this.size = new int[size];

            for (int i = 0; i < size; i++) {
                makeSet(i);
            }
        }

        private void makeSet(int i) {
            parent[i] = i;
            height[i] = 0;
            size[i] = 1;
        }

        public int find(int x) {
            if (x != parent[x]) {
                parent[x] = find(parent[x]);
            }
            return parent[x];
        }

        public boolean same(int x, int y) {
            return find(x) == find(y);
        }

    }
}



Measured memory_bytes: 153536
from itertools import*
N,K,Q,*A=map(int,open(0).read().split())
s=sorted
print(min((s(sum((v[:1-K or None]for v in(k*s(v)for k,v in groupby(A,lambda a:a>=Y))),[]))[Q-1:]+[2e9])[0]-Y for Y in A))

Measured memory_bytes: 101468
n=int(input())
def prime_factor(n):
  ass=[]
  for i in range(2,int(n**0.5)+1):
    while n%i==0:ass.append(i);n//=i
  if n!=1:ass.append(n)
  return ass
p=prime_factor(n)
from collections import Counter
c=Counter(p)
ans=0
for i in c:
  m=c[i]
  for j in range(1,10**20):
    if j>m:break
    ans+=1
    m-=j
print(ans)

Measured memory_bytes: 9708
///Nahid Hasan Raju
#include <bits/stdc++.h>

#define MS(ARRAY,VALUE) memset(ARRAY,VALUE,sizeof(ARRAY))
#define Fin freopen("input.txt","r",stdin)
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define Fout freopen("output.txt","w",stdout)
#define rep(i,a,b) for(i=a;i<=b;i++)
#define EPS 0.00000001
#define INF INT_MAX
#define PI 2*acos(0.0)
#define P1(XX) cout<<"db1: "<<XX<<endl
#define P2(XX,YY) cout<<"db2: "<<XX<<" "<<YY<<endl
#define P3(XX,YY,ZZ) cout<<"db3: "<<XX<<" "<<YY<<" "<<ZZ<<endl
#define set(XX,POS) XX|=(1<<POS)
#define reset(XX,POS) XX&=(~(1<<POS))
#define check(XX,POS) (bool)(XX&(1<<POS))
#define toggle(XX,POS) (XX^(1<<POS))
#define SORT(v) sort(v.begin(),v.end())
#define REVERSE(V) reverse(v.begin(),v.end())
#define VALID(X,Y,R,C) X>=0 && X<R && Y>=0 && Y<C
#define SIZE(ARRAY) sizeof(ARRAY)/sizeof(ARRAY[0])
#define RT printf("Run Time : %0.3lf seconds\n", clock()/(CLOCKS_PER_SEC*1.0))
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>


using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree< pair<int,int> , null_type, less< pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> odrst;

#define MOD 1000000007LL
#define MX 4000005


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

ll m, n;
string s;
ll a[MX];
map<ll,ll>mp;
int main()
{
    int test, tc=0;
    ll b,bl, i, j;
    //scanf("%d", &test);
    test=1;
    while(test--)
    {
        ll res=0, r=1;
        cin>>n;
        r=n;
        for(i=0;i<3;i++)
        {
            res+=r;
            r*=n;
        }
       cout<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;
import java.io.*;
import java.text.*;

public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[] a = new int[n];
        long[] n_1_N = new long[n+1];
        for(int i=0; i<=n; i++){
            n_1_N[i]=0;
        }
        
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            n_1_N[a[i]]++;
        }
        
        long combi_sum = 0;
        for(int i=1; i<=n; i++){
            long tmp = n_1_N[i];
            if(tmp > 1) combi_sum += tmp*(tmp-1);
        }
        combi_sum /=2;
        
        for(int i=0; i<n; i++){
            long tmp = n_1_N[a[i]];
            if(tmp > 1){
                tmp--;
                System.out.println(combi_sum-tmp);
            }else{
                System.out.println(combi_sum);
            }
        }
        
    }
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 75924
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <queue>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    int h, w;
    cin >> h >> w;

    string s[h];
    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
    }
    

    for (int i = -1; i < h+1; i++)
    {
        for (int j = -1; j < w+1; j++)
        {
            if (i == -1 || i == h)
            {
                cout << "#";
                continue;
            }
            
            if (j == -1 || j == w)
            {
                cout << "#";
                continue;
            }
            cout << s[i][j];
        }
        cout << "" << endl;;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  LL n;
  cin >> n;
  n--;
  LL res =(n*n+n)/2;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main(){
	IOS;
	int s,w;
	cin>>s>>w;
	if(w>=s)
	cout<<"unsafe";
	else
	cout<<"safe";}

Measured memory_bytes: 3596
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define clr clear()
#define ins insert
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define cusmem(x,val) for(auto &i:x) i=val;
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);\
            cin.tie(NULL);\
            cout.tie(NULL);
using namespace std;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int>pli;
typedef vector<ll> vl;
typedef vector<pll> vpll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vpii;
string impossible;

mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
// const int N=6;
const int N=1e5+5;
const int L=31;
ll mod=1e12+7;
ll n,i,j,k,x,m,b,a,da,db,u,v;
bool f0,f1,f2;
const int MAXN=1e6+5;
string s;
int main(){
    #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin); 
            freopen("output.txt","w",stdout);
    #endif
    fastio
    cout<<fixed<<setprecision(11);
    int tests=1;    
    // cin>>tests;
    for(int te=1;te<=tests;te++){
        cin>>a>>b>>u>>v;
        ll ans=max(a*v,b*u);
        cout<<max(max(a*u,b*v),ans);
    }
    return 0;
}





Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int r;
    cin >> r;
    cout << pow(r,2) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int main()
{
    ll n , k;
    cin >> n >> k;
    double ans = 0.0;
    for(int i = 1 ; i <= n ; i++){
    		int x = i;
    		double q = 1.0/n;
    		while(x < k){
    			x *= 2;
    			q /= 2;
    		}
    		ans += q;
    }
    cout<< fixed << setprecision(12) << ans << endl;
    return 0;
}

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

#define __speed() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define dbg(x) cout << "--- " << #x << " = " << x << " ---\n";
#define findmax(v) *max_element(v.begin(), v.end())
#define _sum(a) accumulate(a.begin(), a.end(), 0)
#define tt int t;for(cin>>t; t--; )
#define f0(i, n) for(i = 0; i < int(n); i++)
#define f1(i, n) for(i = 1; i<= int(n); i++)
#define all(x) x.begin(), x.end()
#define pq priority_queue
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define S second
#define ar array
#define F first

using namespace std;
using mii = map<int, int>;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
const int mod = 1e9+7,mxN = 2e6+5;

template<typename... Args>void print(Args... args){((cout << args << " "), ...);cout << endl;}
ll mod_pow(ll x, ll y){ll res=1;x%=mod;for(;y>0; y>>=1, x=(x*x)%mod)if(y&1)res=(res*x) % mod; return res; }ll mod_inv ( ll n ){ll ans = mod_pow ( n , mod - 2 ) ;return ans ;}ll mul(ll a, ll b){a%=mod, b%=mod;return (a*b)%mod;}ll sub(ll a,ll b){a%=mod, b%=mod;return (a-b+mod)%mod;}ll add(ll a, ll b){a%=mod, b%=mod;return (a+b)%mod;}
bool prime(ll n){if(n<2)return 0;if(n<4)return 1;if(n%2==0||n%3==0)return 0;for(ll i=5;i*i<=n;i+=6)if(n%i==0||n%(i+2)==0)return 0;return 1;}

/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>  
using namespace __gnu_pbds; 
#define iset tree<ll , null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define iof order_of_key
#define findat find_by_order */
int bcr[7], bcc[7], total, tbcr[7], tbcc[7];
string st[7];
void solve(){ //B
	int i, j, p, q, r, c, k, ans=0, y;
	char x;
	cin >> r >> c >> k;
	f0(i, r)
		cin >> st[i];
		f0(p, (1<<r))
			f0(q, (1<<c)){
				int bc =0;
				f0(i, r)
					f0(j, c)
						if(((p >> i) & 1) == 0 && ((q >> j) & 1) == 0 && st[i][j] == '#')
							bc++;
				ans += bc==k;
			}
	print(ans);
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
    __speed();
    solve();
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cctype>
#include<iostream>
#include<cstring>
using namespace std;
int main() {
  int n;
  cin>>n;

  int ap = 0, bp = 0;
  string a, b;
  for (int i = 0; i < n; i++) {

    cin >> a >> b;

    if (a > b) ap += 3;
    else if (a < b) bp += 3;
    else ap++, bp++;
  }
  cout<<ap<<" "<<bp<<endl;
  return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define ll long long
const long long INF = 1LL << 60;

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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}//約数求める


ll kaijou(int n) {
	ll temp = 1;
	for (int i = 2; i <= n; i++) {
		temp *= i;
		temp %= MOD;
	}
	return temp;
}


int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int> x(N + 1);
	vector<int> y(M + 1);
	for (int i = 0; i < N; i++) cin >> x[i];
	for (int i = 0; i < M; i++) cin >> y[i];
	x[N] = X;
	y[M] = Y;
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	if (x[N] < y[0]) {
		cout << "No War";
	}
	else {
		cout << "War";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, K;
    cin >> N >> K;

    cout << K * ll(pow(K - 1LL, N - 1LL)) << endl;
}

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

using namespace std;
typedef long long ll;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;

const int mn = 1e6 + 1e5;
const int mod = 1000000007;

int n, a[mn];
int f[mn];

int s[mn];
set<pii> S;
unordered_set<int> h;
vector<int> v[mn];

int count(int c) {
    int cnt = 0;
    int curpos = 0;
    int sum0 = 1, sumc = 0;
    int nxt0, nxtc;
    while (curpos < n) {
        auto u = upper_bound(all(v[0]), curpos);
        auto w = upper_bound(all(v[c]), curpos);
        if (u == end(v[0])) nxt0 = n + 1;
        else nxt0 = *u;
        if (w == end(v[c])) nxtc = n + 1;
        else nxtc = *w;
        if (nxt0 == n + 1) {
            return (sum0 - 1 + mod) % mod;
        }
        if (nxtc == n + 1) {
            return sumc;
        }
        if (nxt0 > nxtc) {
            int count = lower_bound(all(v[c]), nxt0) - upper_bound(all(v[c]), curpos);
            sumc = (sumc + 1ll * sum0 * count) % mod;
            sum0 = (sum0 + sumc) % mod;
            curpos = nxt0;
        } else {
            int count = lower_bound(all(v[0]), nxtc) - upper_bound(all(v[0]), curpos);
            sum0 = (sum0 + 1ll * sumc * count) % mod;
            sumc = (sum0 + sumc) % mod;
            curpos = nxtc;
        }
        //printf("%d %d %d\n", curpos, sum0, sumc);
        if (curpos == n) return (nxt0 == n ? sumc : (sum0 + mod - 1) % mod);
    }
    return 0;
}

int main() {
#ifdef trote
    freopen("../1.txt", "r", stdin);
#endif
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        s[i] = s[i - 1] ^ a[i];
        S.insert({s[i], i});
        v[s[i]].pb(i);
    }
    int ans = 0;
    if (s[n] == 0) {
        h.insert(0);
        int u = sz(v[0]);
        ans = 1;
        for (int i = 1; i < u; i++) {
            ans = ans * 2 % mod;
        }
        for (int i = 1; i <= n; i++) {
            if (h.count(s[i])) continue;
            h.insert(s[i]);
            int u = count(s[i]);
            //printf("%d %d %d %d\n", i, s[i], u, ans);
            ans = (ans + u) % mod;
        }
    } else {
        int u = count(s[n]) + 1;
        ans = u;
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 80152
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main() {
    int n, d;
    cin >> n >> d;
    int x[n][d];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) cin >> x[i][j];
    }

    int pivot = n * (n - 1) / 2;
    int dis[pivot];
    int now = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            dis[now] = 0;
            for (int k = 0; k < d; k++) {
                dis[now] += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            now++;
        }
    }

    int ans = 0;
    for (int i = 0; i < pivot; i++) {
        int judge = 1;
        while (judge * judge <= dis[i]) {
            if (judge * judge == dis[i]) ans++;
            judge++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static int Count(int x) {
		int y = (int) Math.log10(x) + 1;
		return y;

	}

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			int a = scan.nextInt();
			int b = scan.nextInt();
			int x = Count(a + b);
			System.out.println(x);
		}
	}

}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    string s;
    cin >> s;
    ll cnt = 0;
    ll ans = 0;
    for (char c : s) {
        if (c == 'B')
            cnt++;
        else
            ans += cnt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())

ll n, k;
vector<ll> a(101);
ll dp[100001];

bool rec(ll l) {
    if (dp[l] != 0) {
        if (dp[l] == 1)
            return true;
        else
            return false;
    }
    bool res = false;
    rep(i, n) {
        if (l - a[i] >= 0 && !rec(l - a[i])) res = true;
    }
    if (res)
        dp[l] = 1;
    else
        dp[l] = -1;
    return res;
}

int main() {
    cin >> n >> k;
    rep(i, n) cin >> a[i];
    if (rec(k))
        cout << "First" << endl;
    else
        cout << "Second" << endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


void run_case() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(auto &x: a) cin >> x;
    sort(a.begin(), a.end(), greater<int>());
    LL ans = 0;
    for(int i = k; i < n; ++i)
        ans += a[i];
    cout << ans;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    string s;
    cin>>s;
    long long ans=0,cnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='W'){
            ans=ans+cnt;
        }
        else cnt++;
    }   
    cout<<ans;
}



Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <numeric>
#include <iomanip>
#include <sstream>
using namespace std;

vector<string> split(const string& s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;
	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}
	return elems;
}

int main() {

	int cnt = 0;

	for (int i = 0; i < 5; i++) {
		int t;
		cin >> t;
		if (t == 0) {
			cnt = i + 1;
			break;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

 int main (void)
 {

 int S,h,m,s;

 scanf("%d",&S);

 h = S/3600;

 m = (S%3600)/60;

 s = S%60;

 printf("%d:%d:%d\n",h,m,s);

 return 0;

 }

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	ll s, best = INT_MAX;
	cin >>  s;
	while(s > 100){
		best = min(best, abs(s%1000 - 753));
		s /= 10;
	}
	cout << best;
		
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
long a,b,c,k;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin>>a>>b>>c>>k;

  if(b>a)swap(a,b);
  if(c>a)swap(c,a);

  while(k--)
    a=2*a;

  cout<<a+b+c<<endl;

  return 0;
}


Measured memory_bytes: 256
#####

import numpy as np
# from collections import Counter
# import itertools

#####

def getIntList(inp):
	return [int(_) for _ in inp]


from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs


def main(inputs):
	n,x,y=getIntList(inputs[0])
	
	count=np.zeros(n-1, np.int32)
	
	between=y-x-1
	if between%2==0:
		middleL=between//2
		middleR=between//2
	else:
		middleL=between//2+1
		middleR=between//2
	left=x-1
	right=n-y
	
	depth0=x+middleL
	depth1=x+middleR+1
	depth2=x+right+1
	length=max(depth0,depth1,depth2)
	numDepth=np.zeros(length)
	numDepth[:x]=1
	numDepth[x:depth0]+=1
	numDepth[x:depth1]+=1
	numDepth[x+1:depth2]+=1
	
	for d in range(1, length):
		count[d-1]=numDepth[d:d+x-1].sum()
# 	print("a",count)
# 	count[...]=0 ###
	
	x0=x
	y0=y
	
	x=n-(y0-1)
	y=n-(x0-1)
	
	between=y-x-1
	if between%2==0:
		middleL=between//2
		middleR=between//2
	else:
		middleL=between//2+1
		middleR=between//2
	left=x-1
	right=n-y
	
	depth0=x+middleL
	depth1=x+middleR+1
	length=max(depth0,depth1)
	numDepth=np.zeros(length)
	numDepth[:x]=1
	numDepth[x:depth0]+=1
	numDepth[x:depth1]+=1
# 	print(numDepth)
	
	for d in range(1, length):
		count[d-1]+=numDepth[d:d+x-1].sum()
# 	print("b",count)
# 	count[...]=0 ###
	
	middle=middleL+middleR+2
	if middle%2==1:
		count[:middle//2]+=middle
	else:
		count[:middle//2-1]+=middle
		count[middle//2-1]+=middle//2
# 	print("c", count)
	
	for c in count: print(c)
	
# 	return count


if __name__=="__main__":
	inputs=getInputs()
# 	inputs=simInputs()
	main(inputs)


Measured memory_bytes: 14304
$MAX = 100
$WHITE = 0
$GRAY = 1
$BLACK = 2
$m = nil
$n = nil
def prim
	d = Array.new($n){Float::INFINITY}
	pp = Array.new($n){-1}
	color = Array.new($n){$WHITE}
	d[0] = 0

	loop{
		minv = Float::INFINITY
		u = -1
		$n.times do |i|
			if minv > d[i] && color[i] != $BLACK 
				u = i
				minv = d[i]
			end
		end

		break if u == -1
		color[u] = $BLACK
		$n.times do |v|
			if color[v] != $BLACK && $m[u][v] != Float::INFINITY
				if d[v] > $m[u][v] 
					d[v] = $m[u][v]
					pp[v] = u
					color[v] = $GRAY
				end
			end
		end
	}

	sum = 0
	$n.times do |i|
		sum += $m[i][pp[i]] unless pp[i]  == -1
	end
	return sum
end

$n = gets.to_i
$m = []
$n.times do |i|
	mm = gets.split.map(&:to_i)
	mm.map! { |mmm|
		mmm = mmm == -1 ? Float::INFINITY : mmm
	}
	$m << mm
	end

	puts prim

Measured memory_bytes: 8792
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
bc = []
for i in range(m):
    bc.append(list(map(int, input().split())))
bc.sort(key=lambda x: x[1], reverse=True)
for i in bc:
    if a[0] < i[1]:
        for j in range(i[0]):
            if a[0] < i[1]:
                a.append(i[1])
                del a[0]
            else:
                break
    else:
        break
print(sum(a))

Measured memory_bytes: 33108
import math

n = int(input())
xy = []
for _ in range(n):
    xxyy = list(map(int, input().split()))
    xy.append(xxyy)

dist = 0
for i, xyi in enumerate(xy):
    for xyj in xy[i+1:]:
        dist += math.sqrt((xyi[0] - xyj[0])**2 + (xyi[1] - xyj[1])**2)
print(dist*2/n)


Measured memory_bytes: 38384
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;
int main(void) {
    int a, b, b_r, x, result;
    double x_t;

    cin >> a >> b;
    
    x_t = double(a) / 0.08;
    x = x_t;
    if ( x != x_t) x += 1;

    while (1){
        b_r = x * 0.1;
        if(b_r == b){
            result = x;
            break;
        }else{
            x += 1;
        }
        if (int(x * 0.08) != a){
            result = -1;
            break;
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 256
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_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

mod = N % 10

case mod
when 2, 4, 5, 7, 9
  puts 'hon'
when 0, 1, 6, 8
  puts 'pon'
when 3
  puts 'bon'
end


Measured memory_bytes: 14416
#! /usr/local/bin/python3
# coding: utf-8

from math import pi
from cmath import rect

def fromPolar(r, theta):
    return r * complex(cos(theta), sin(theta))

def print_xy(z):
    print(z.real, z.imag)

def koch(p1, p2, level):
    if level == 0:
        return
    l = p2 - p1
    s = p1 + (1/3) * l
    t = p1 + (2/3) * l
    u = s + (1/3) * l * rect(1, pi/3)
    koch(p1, s, level - 1)
    print_xy(s)
    koch(s, u, level - 1)
    print_xy(u)
    koch(u, t, level - 1)
    print_xy(t)
    koch(t, p2, level - 1)

def main():
    n = int(input())
    print_xy(0+0j)
    koch(0+0j, 100+0j, n)
    print_xy(100+0j)

main()



Measured memory_bytes: 5844
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define INFTY 999999


int main(void){
    int a,b;
    scanf("%d %d",&a, &b);

    if(b%a==0){
        printf("%d\n",a+b);
    }
    else{
        printf("%d\n",b-a);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int main() {
    string s;
    cin >> s;
    if (s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  	double w,h;
  	int x,y;
  	cin >> w >> h >> x >> y;
  	printf("%lf ", w*h/2.0);
  	if(x == w/2 && y == h/2){
    	cout << 1 << endl;
    }
  	else{
  		cout << 0 << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int a[200001];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<n;i++){
        int x;
        cin>>x;
        a[x]++;
    }
    for(int i=1;i<=n;i++){
        cout<<a[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int a[1000001];
main() {
	int n=read(),maxx=0,js=0;
	for(int i=1; i<=n; i++)
		a[i]=read();
	for(int i=1; i<=n; i++) {
		if(a[i]<=a[i-1])
			js++;
		else js=0;
		maxx=max(maxx,js);
	}
	cout<<maxx;
}

Measured memory_bytes: 640
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
int p[15], n, k, a1, a2, a3, a4, a5, power[16], dp[15000000];
queue<int>Q;
int main() {
	while (true) {
		cin >> n >> k; power[0] = 1; for (int i = 1; i < 16; i++)power[i] = power[i - 1] * 3; a5 = 0;
		if (n == 0 && k == 0)break;
		cin >> a1; for (int i = 0; i < a1; i++) { cin >> a4; p[a4 - 1] = 0; }
		cin >> a2; for (int i = 0; i < a2; i++) { cin >> a4; p[a4 - 1] = 1; }
		cin >> a3; for (int i = 0; i < a3; i++) { cin >> a4; p[a4 - 1] = 2; }
		for (int i = 0; i < n; i++) { a5 += power[i] * p[i]; }
		for (int i = 0; i < power[n]; i++)dp[i] = 1000000000; dp[a5] = 0; Q.push(a5);
		while (!Q.empty()) {
			int a1 = Q.front(); Q.pop();
			vector<int>b[4];
			int C = 0;
			for (int i = n - 1; i >= 0; i--) {
				int p1 = (a1 / power[i]) % 3;
				b[p1 + 1].push_back(i);
				if (b[p1 + 1].size() == 1)C++;
				if (C == 3)break;
			}
			if (b[1].size() >= 1 && (b[2].size() == 0 || b[1][0] > b[2][0])) {
				int F = a1 + power[b[1][0]];
				if (dp[F] == 1000000000) { dp[F] = dp[a1] + 1; Q.push(F); }
			}
			if (b[2].size() >= 1 && (b[1].size() == 0 || b[1][0] < b[2][0])) {
				int F = a1 - power[b[2][0]];
				if (dp[F] == 1000000000) { dp[F] = dp[a1] + 1; Q.push(F); }
			}
			if (b[2].size() >= 1 && (b[3].size() == 0 || b[2][0] > b[3][0])) {
				int F = a1 + power[b[2][0]];
				if (dp[F] == 1000000000) { dp[F] = dp[a1] + 1; Q.push(F); }
			}
			if (b[3].size() >= 1 && (b[2].size() == 0 || b[2][0] < b[3][0])) {
				int F = a1 - power[b[3][0]];
				if (dp[F] == 1000000000) { dp[F] = dp[a1] + 1; Q.push(F); }
			}
		}
		int ans = min(dp[0], dp[power[n] - 1]);
		if (ans > k)ans = -1;
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
int n;
cin >> n;
int a[100];
for(int i = 0;i < n;i++) cin >> a[i] ;
for(int j = 0;j < n-1-j;j++) swap(a[j],a[n-1-j]);
for(int k = 0 ;k < n; k++)
if (k == 0)cout << a[k]; 
else cout << " " << a[k];
 cout << endl;



return (0);
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <queue>
#include <cmath>
#include <string>
#include <bitset>

using namespace std;

typedef long long ll;

int main(){
    string s;
    cin >> s;
    
    // "BC" → "D"に変更(後ろから走査)
    bool flag = false;
    for(int i = s.length() - 1; i >= 0; --i){
        if(!flag){
            if(s[i] == 'C')     flag = true;
        }
        
        else{   // if(flag)
            if(s[i] == 'C')     continue;
            
            if(s[i] == 'B'){
                s.erase(i, 2);
                s.insert(i, "D");
            }
            flag = false;
        }
    }
    cerr << s << endl;
    
    ll res = 0;
    int d_cnt = 0;
    for(int i = s.length() - 1; i >= 0; --i){
        if(s[i] == 'B' || s[i] == 'C'){
            d_cnt = 0;
        }
        
        else if(s[i] == 'D'){
            d_cnt++;
        }
        
        else{       // s[i] == 'A'
            res += d_cnt;
        }
        
        cerr << d_cnt << " ";
        cerr << res << endl;
    }
    
    cout << res << endl;
}

Measured memory_bytes: 640
s_list = list(input())

s_strat = -1
s_end = -1
for i in range(len(s_list)):
    if i==len(s_list)-1:
        break
    elif i==len(s_list)-2:
        if s_list[i]==s_list[i+1]:
            s_strat = i+1
            s_end = i+2
            break
    elif s_list[i]==s_list[i+1]:
        s_strat = i+1
        s_end = i+2
        break
    elif s_list[i]==s_list[i+2]:
        s_strat = i+1
        s_end = i+3
        break
print(s_strat,s_end)

Measured memory_bytes: 3956
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    S = int(input())
    mod = 10**9 + 7
    
    dp = [0] * (S + 4)
    dp[0] = 1
    dp[3] = 1
    for i in range(4, S + 1):
        for k in range(i - 2):
            dp[i] += dp[k]
    
    print(dp[S] % mod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9164