akhauriyash/Code-Regression huggingface dataset:
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    ball = dict()
    for i in range(n):
        if a[i] in ball:
            ball[a[i]] += 1
        else:
            ball[a[i]] = 1

    ans = 0
    for b in ball:
        if ball[b] > 1:
            ans += ball[b] * (ball[b]-1) // 2

    for i in range(n):
        if a[i] in ball and ball[a[i]] > 1:
            tmp = ans
            tmp -= ball[a[i]] * (ball[a[i]]-1) // 2
            tmp += (ball[a[i]]-1) * (ball[a[i]]-2) // 2
            print(tmp)
        else:
            print(ans)


Measured memory_bytes: 26140
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll N, a[100100], ans=0, next=0;
    in(N);
    rep(i, N) in(a[i]);
    for(ll can=N+5; can; can--){
        next = a[next];
        ans++;
        if(next==2){
            put(ans);
            return 0;
        }
        next--;
    }
    puts("-1");
    return 0;
}


Measured memory_bytes: 896
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
using namespace std;
//
const int inf=1e9+7;//0x3f
//
int main(){
	double x0,y0,x1,y1,x2,y2;
	cin>>x0>>y0>>x1>>y1>>x2>>y2;
	double a=hypot(x0-x1,y0-y1);
	double b=hypot(x1-x2,y1-y2);
	double c=hypot(x2-x0,y2-y0);
	double s=(a+b+c)*0.5;
	double S=sqrt(s*(s-a)*(s-b)*(s-c));
	double r=2*S/(a+b+c);
	double k=max(a,max(b,c));
	cout<<fixed<<setprecision(15)<<(r*k)/(2*r+k)<<endl;
	return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,a,b;
	t = 1;
	while(t--) {
	 cin >> a >> b;
	 if(a > 12)
      cout << b << endl;
     else if(a < 6)
      cout << 0 << endl;
     else
      cout << b / 2 << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int

using namespace std;

int main() {
    string s;
    lli t=1;
    cin>>s;
    for(lli i=0;i<s.length();i++)
    {
       if((i)%2==0)
       {
           if(s[i]=='L')
           {
               cout<<"No"<<endl;
               t=0;
               break;
           }
       }
       else
       {
           if(s[i]=='R')
           {
               cout<<"No"<<endl;
               t=0;
               break;
           }
       }
    }
    if(t)cout<<"Yes"<<endl;
    
}

Measured memory_bytes: 256
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        long a=sc.nextInt();
        long b=sc.nextInt();
        long p=gcd(a,b);

    	System.out.println((a/p)*(b/p)*p);
    }


private static long gcd(long a,long b){
   if(b==0){
   	return a;
   }
	return gcd(b, a%b);
}
}

Measured memory_bytes: 23252
exec("def nWord(): nWord.cache = raw_input() if not hasattr(nWord, 'cache') or nWord.cache=='' else nWord.cache ; pos = nWord.cache.find(nWord.sep) ; ret, nWord.cache = (nWord.cache, '') if pos==-1 else (nWord.cache[:pos], nWord.cache[pos+1:].lstrip(nWord.sep)) ; return ret") ; exec("nWord.sep = ' '") ; exec("def ___nLine2(): ret, nWord.cache = (raw_input(), nWord.cache if hasattr(nWord, 'cache') else '') if not hasattr(nWord, 'cache') or nWord.cache=='' else (nWord.cache, '') ; return ret") ; exec('def nInt(): return int(nWord())') ; exec('def nFloat(): return float(nWord())') ; exec("def ___nAuto2():\n ret = nWord()\n try: return int(ret)\n except: pass\n try: return float(ret)\n except: return ret") ; exec("def nAuto(n=None): return ___nAuto2() if n is None else [___nAuto2() for i in range(n)]") ; exec("def nLine(n=None): return ___nLine2() if n is None else [___nLine2() for i in range(n)]")
 
N = nAuto()
S = nAuto(N)
 
H = N
W = N
 
def fH(p, H2):
    for k in range(1, p):
        for i in range(H2):
            for j in range(W):
                if S[i][j]!=S[i+k*H2][j]:
                    return False
    return True
 
def fW(p, W2):
    for k in range(1, p):
        for i in range(H):
            for j in range(W2):
                if S[i][j]!=S[i][j+k*W2]:
                    return False
    return True
 
rate = 1
for p in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 39, 41, 43, 47]:
    while H % p == 0:
        H2 = H / p
        if fH(p, H2):
            H = H2
            rate *= p
        else:
            break
    while W % p == 0:
        W2 = W / p
        if fW(p, W2):
            W = W2
            rate *= p
        else:
            break
 
D = {}
for  i in range(H):
    for j in range(W):
        c = S[i][j]
        if c in D:
            D[c] += 1
        else:
            D[c] = 1
 
max_c = 'a'
max_count = 0
for c in D:
    if max_count < D[c]:
        max_count = D[c]
        max_c = c
 
L = []
for  i in range(H):
    for j in range(W):
        c = S[i][j]
        if c!=max_c:
            L.append((i, j, c))
 
def check(A, B):
    for i2, j2, c in L:
        i = (i2-A+N) % N
        j = (j2-B+N) % N
        if c!=S[(A+j) % N][(B+i) % N]:
            return False
    return True
 
ng = 0
count = 0
for A in range(H):
    if check(A, 0):
        count += W
    else:
        ng += W
print count * rate

Measured memory_bytes: 42792
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-9;

void foo(double& x, double& y, double xo, double yo, double dx, double dy) {
	double _x = x - xo, _y = y - yo;
	x = dx * _x + dy * _y;
	y = dx * _y - dy * _x;
}

int main() {
	int T; cin >> T;
	while (T--) {
		double xa, ya, xb, yb;
		cin >> xa >> ya >> xb >> yb;
		int N; cin >> N;
		vector<double> xs(N), ys(N), xt(N), yt(N);
		vector<int> o(N), l(N);
		for (int i = 0; i < N; i++)
			cin >> xs[i] >> ys[i] >> xt[i] >> yt[i] >> o[i] >> l[i];
		double dx = xb - xa, dy = yb - ya, r = dx * dx + dy * dy;
		vector<d_i> v;
		for (int i = 0; i < N; i++) {
			foo(xs[i], ys[i], xa, ya, dx, dy);
			foo(xt[i], yt[i], xa, ya, dx, dy);
			if (ys[i] * yt[i] >= 0) continue;
			double x = (yt[i] * xs[i] - ys[i] * xt[i]) / (yt[i] - ys[i]);
			if (x < 0 || x > r) continue;
			v.push_back(d_i(x, o[i] ^ l[i]));
		}
		sort(v.begin(), v.end());
		int cnt = 0;
		for (int j = 0; j + 1 < v.size(); j++)
			if (v[j].second ^ v[j + 1].second)
				cnt++;
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int, int>;
const int C = 100000;

int main() {
    int N; cin >> N;
    vector<vector<int>> graph(C * 2);
    for(int i = 0; i < N; ++i) {
        int a, b; cin >> a >> b;
        a--, b = b - 1 + C;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
    vector<int> visited(C * 2);
    auto add = [&](Pair &p, int v) {
        if(v < C) p.first++;
        else p.second++;
    };
    auto merge = [&](Pair &p, Pair q) {
        p.first += q.first;
        p.second += q.second;
    };
    auto dfs = [&](auto &&dfs, int cur) -> Pair {
        Pair res;
        if(visited[cur]) return res;
        visited[cur] = 1;
        add(res, cur);
        for(auto &to : graph[cur]) {
            merge(res, dfs(dfs, to));
        }
        return res;
    };
    int64_t ans = 0;
    for(int i = 0; i < C * 2; ++i) {
        auto[x, y] = dfs(dfs, i);
        ans += (int64_t)x * y;
    }
    cout << ans - N << '\n';
    return 0;
}


Measured memory_bytes: 15552
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


k, x = list(map(int, sys.stdin.buffer.readline().split()))
ok = 500 * k >= x
if ok\
        :
    print('Yes')
else:
    print('No')


Measured memory_bytes: 13892
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[100005], b[10005];
int main()
{
	int k, t, ans;
	while (~scanf("%d%d",&k,&t))
	{
		for (int i = 1; i <= t; i ++) scanf("%d", &a[i]);
		sort(a + 1, a + t + 1);
		if (t == 1) ans = k - 1;
		else{
			ans = 0;
			for (int i = 1; i < t; i ++) ans += a[i];
			ans = max(0, a[t] - ans - 1);
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
bool check(string a) {
	ll l = 0, r = a.length() -1 ;
	while(l <= r) {
		if(a[l] != a[r]) {
			return false;
		}
		l++;
		r--;
	}
	return true;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll n = s.length();
    if(n % 2 == 0) {
    	cout<<"Yes\n";
    	return 0;
    }
    string a = s.substr(0, n / 2);
    string b = s.substr((n/2) + 1, n/2);
    if(check(s) && check(a) && check(b)) {
    	cout<<"Yes\n";
    } else {
    	cout<<"No\n";
    }
}

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

int dv;
int maxDepth = -1;
int findDeepestV(int v, unordered_map<int, vector<int> > mp) {
    int visit[200001] = {0, }, cnt = -1;
    int depth[200001] = {0, };
    queue<pair<int, int> > q;
    q.push(make_pair(v, 1));
    visit[v] = 1;
    while (q.size() != 0) {
        pair<int, int> now = q.front();
        q.pop();
        if (cnt < now.second) cnt = now.second;
        for (auto child : mp[now.first]) {
            if (visit[child] == 0) {
                visit[child] = 1;
                q.push(make_pair(child, now.second + 1));
                dv = child;
            }
        }
    }
    return cnt;
}

int getDiameter(unordered_map<int, vector<int> > mp) {
    findDeepestV(1, mp);
    return findDeepestV(dv, mp);
}
 
int main() {
    int n, i, a, b;
    cin >> n;
    unordered_map<int, vector<int> > mp;
    for (i = 0; i < n - 1; i++) {
        cin >> a >> b;
        if (mp.find(a) == mp.end()) {
            mp.insert(make_pair(a, vector<int>()));
        }
        mp[a].push_back(b);
        if (mp.find(b) == mp.end()) {
            mp.insert(make_pair(b, vector<int>()));
        }
        mp[b].push_back(a);
    }
    int diameter = getDiameter(mp);
    int d[200001] = {0, };
    d[0] = -1;
    for (int i = 1; i <= diameter; i++) {
        d[i] = d[i - 1] == -1 ? 1 : -1;
        if (i > 2 && d[i] != 1) {
            d[i] = d[i - 2] == -1 ? 1 : -1;
        }
    }
    if (d[diameter] == 1) {
        cout << "First";
    } else cout << "Second";
    return 0;
}

Measured memory_bytes: 57960
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;




int main(void) {
    ll N, M;
    cin >> N >> M;
    ll a[55], b[55];
    ll c[55], d[55];
    ll i, j;
    
    for(i=0; i<N; i++) cin >> a[i] >> b[i];
    for(i=0; i<M; i++) cin >> c[i] >> d[i];
    
    for(i=0; i<N; i++) {
        ll min=INF;
        ll ans=-1;
        for(j=0; j<M; j++) {
            ll di=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(min>di) {
                min=di;
                ans=j;
            }
        }
        
        pt(ans+1);
    }
    
    
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n+1); i++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
   while(1){
       int n,x,k,ans=0;
       cin>>n>>x;
       if(n==0)break;
       rep2(i,1,n-2){
           rep2(j,i+1,n-1){
               k=x-i-j;
               if(j<k&&k<=n)ans++;
           }
       }cout<<ans<<endl;
   }
}

   
    

   


    

   



Measured memory_bytes: 3076
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
int read(char *s){
	R int len=0;R char ch;while(((ch=getc())>'Z'||ch<'A'));
	for(s[++len]=ch;(ch=getc())>='A'&&ch<='Z';s[++len]=ch);
	return s[len+1]='\0',len;
}
inline char getop(){R char ch;while((ch=getc())>'Z'||ch<'A');return ch;}
const int N=2e5+5;
struct node{char c,d;}q[N];char s[N];
int n,m,l,r,mid,ansl,ansr;
bool ck(int pos){
	int x=mid;
	fp(i,1,m)if(s[x]==q[i].c){
		q[i].d=='L'?--x:++x;
		if(x<1||x>n)return x==pos;
	}
	return false;
}
int main(){
//	freopen("testdata.in","r",stdin);
	n=read(),m=read(),read(s);
	fp(i,1,m)q[i].c=getop(),q[i].d=getop();
	l=1,r=n,ansl=0;
	while(l<=r){
		mid=(l+r)>>1;
		ck(0)?(ansl=mid,l=mid+1):r=mid-1;
	}
	l=1,r=n,ansr=n+1;
	while(l<=r){
		mid=(l+r)>>1;
		ck(n+1)?(ansr=mid,r=mid-1):l=mid+1;
	}
	printf("%d\n",ansr-ansl-1);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

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

    int buf;
    vector<int> hugaa;
    for (int a = 0; a < num; ++a) {
        cin >> buf;
        hugaa.push_back(buf);
    }

    auto st = hugaa.end();
    --st;
    
    while(1){
        if(st != hugaa.begin()){
            cout << *st << " ";
            --st;
        }else{
            cout << *st << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3148
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int m=0, i, a[100000], b[100000], k, n, j, c[100000], z;
    scanf("%d %d",&k,&n);
    char s[100000];
    getchar();
    for(i=0;i<k;i++)
    {
        scanf("%c",&s[i]);
    }
    for(i=0;i<n;i++)
    scanf("%d %d",&a[i],&b[i]);
    for(i=0;i<k-1;i++)
    {
        c[i]=m;
        if(s[i]=='A'&&s[i+1]=='C')
        {
            m++;
        }
    }
    c[i]=m;
    for(j=0;j<n;j++)
    {
         z=c[(b[j])-1]-c[(a[j])-1];
         printf("%d\n",z);
    }
    return 0;
}


Measured memory_bytes: 2048
N, K = map(int, input().split())

kMod = 10**9+7

ans = 0

for k in range(K, N+2):
    lb = (k-1) * k // 2
    ub = (N+1-k + N) * k // 2
    ans += (ub-lb+1)
    ans %= kMod
print(ans)

Measured memory_bytes: 63812
class ConvexHullTrick:
	length = 0

	def __init__(self,size):
		self.A = [0]*size
		self.B = [0]*size

	def check(self,a,b):
		lhs = (self.B[self.length-2]-self.B[self.length-1])*(a-self.A[self.length-1])
		rhs = (self.B[self.length-1]-b)*(self.A[self.length-1]-self.A[self.length-2])
		return lhs>=rhs

	# 直線の傾きaは単調現象であること
	# Add a line y=a*x+b
	def add(self,a,b):
		while 2<=self.length and self.check(a,b):
			self.length -= 1
		self.A[self.length] = a
		self.B[self.length] = b
		self.length += 1
		return
	# min_i {a[i]*x+b[i]}
	def query(self,x):
		l,r = -1, self.length-1
		while l+1<r:
			m = (l+r)//2
			if self.eval(m+1,x)<=self.eval(m,x):
				l = m
			else:
				r = m
		return self.eval(r,x)

	def eval(self,k,x):
		return self.A[k]*x + self.B[k]

N,C = map(int,input().split())
h = list(map(int,input().split()))
#print(h)

cht = ConvexHullTrick(N)

dp = [0]*N
dp[0] = 0
cht.add(-2*h[0],h[0]**2+dp[0])
for i in range(1,N):
	#best = 99999999999999
	# for j in range(i):
	# 	#cost = dp[j]+(h[i]-h[j])**2+C
	# 	cost = (-2*h[j])*h[i]+(h[j]**2+dp[j])
	# 	best = min(best,cost)
	best = cht.query(h[i])
	dp[i] = best+h[i]**2+C

	cht.add(-2*h[i],h[i]**2+dp[i])

ans = dp[N-1]
print(ans)


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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    string s;
    std::deque<string> deq(n,"00000000000000000000000000");
    std::map<string, long long int> map;
    for (int i=0;i<n;i++) {
        cin>>s;
        for (int j=0;j<s.size();j++) {
            string tmp=deq[i];
            if (tmp[s[j]-97]=='0') {
                tmp[s[j]-97]='1';
            } else if (tmp[s[j]-97]=='1') {
                tmp[s[j]-97]='2';
            } else if (tmp[s[j]-97]=='2') {
                tmp[s[j]-97]='3';
            } else if (tmp[s[j]-97]=='3') {
                tmp[s[j]-97]='4';
            } else if (tmp[s[j]-97]=='4') {
                tmp[s[j]-97]='5';
            } else if (tmp[s[j]-97]=='5') {
                tmp[s[j]-97]='6';
            } else if (tmp[s[j]-97]=='6') {
                tmp[s[j]-97]='7';
            } else if (tmp[s[j]-97]=='7') {
                tmp[s[j]-97]='8';
            } else if (tmp[s[j]-97]=='8') {
                tmp[s[j]-97]='9';
            } else if (tmp[s[j]-97]=='9') {
                tmp[s[j]-97]='-';
            }
            deq[i]=tmp;
        }
        if (map[deq[i]]==0) {
            map.emplace(deq[i],0);
            map[deq[i]]++;
        } else {
            map[deq[i]]++;
        }
    }
    long long int ans=0;
    for (auto itr=map.begin();itr!=map.end();itr++) {
        ans+=(itr->second*(itr->second-1))/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 13568
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
typedef long long LL;
using namespace std;

LL gcd(LL a, LL b){
    LL tmp; 
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    tmp = a%b;
    while(tmp!=0){
        a = b;
        b = tmp;
        tmp = a%b;
    }

    return b;
}

int main(){
    int n;
    vector<LL> a;
    LL a_tmp;
    LL tmp;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a_tmp;
        a.push_back(a_tmp);
    }
    tmp = a[0];
    for(int i=1; i<n; i++){
        tmp = gcd(tmp, a[i]);
    }
    cout << tmp << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long


using namespace std;

int MOD = 1000000007;
int main(){
  int n;
  int k;
  cin >> n >> k;
  vector<ll> a(n+1);
  for( int i = 0 ; i < n ; i++ ){
    cin >> a[i];	  
  }
  vector<vector<ll>> dp(n+100,vector<ll> (k+100,0));
  for( int i = 0 ; i <= a[0] ; i++ ) dp[0][i] = 1;
  for( int i = 1 ; i < n ; i++ ){
    for( int j = 0 ; j <= k ; j++ ){
      if( j <= a[i] ){//[0,a[i]]
        if( j == 0 ) dp[i][j] = dp[i-1][j];
        else{
          dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % MOD;
        }
      }
      else{
        dp[i][j] = (dp[i][j-1]  - dp[i-1][j-a[i]-1] + MOD + dp[i-1][j] ) % MOD;
      }
    }
  }
///  for( int i = 0 ; i < n ; i++ ){
///    for( int j = 0 ; j <= k ; j++ ){
///      cout << dp[i][j] << " " ;
///    }
///    cout << endl;
///  }
  cout << dp[n-1][k] << endl;
  return 0;
}


Measured memory_bytes: 158324
// Born Sinner
// old but im not that old
// fuck all you hoes get a grip
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next(){
            while(st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
        long nextLong(){
            return Long.parseLong(next());
        }
        double nextDouble(){
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            } catch (Exception e){
                e.printStackTrace();
            }
            return str;
        }
    }
    static int modPower(int x, int y, int mod){
        int res = 1;
        x %= mod;
        if(x==0) return 0;
        while(y>0){
            if(y%2==1){
                res = (res*x)%mod;
            }
            y = y>>1;
            x = (x*x)%mod;
        }
        return res;
    }
    static class pair<T1, T2>{
        T1 first;
        T2 second;
        pair(T1 first, T2 second){
            this.first = first;
            this.second = second;
        }
    }
    static int bfs(Map<Integer,Set<Integer>> g, int u, boolean[] vis){
      if(vis[u]) return 0;
      Queue<Integer> q = new LinkedList<>();
      q.add(u);
      int c = 0;
      Set<Integer> s = new HashSet<>();
      while(!q.isEmpty()){
        int x = q.remove();
        vis[x] = true;
        s.add(x);
        if(g.containsKey(x)) for(int i : g.get(x)) {
          if(!vis[i]) {
            q.add(i);
          }
        }
      }
      return s.size();
    }
    public static void main (String[] args) throws java.lang.Exception
    {
        FastReader in = new FastReader();
        int t = 1;
        //t = in.nextInt();
        while(t-->0){
            int n = in.nextInt(), m = in.nextInt();
            Map<Integer, Set<Integer>> g = new HashMap<>();
            for(int i = 0; i < m; i++) {
              int a = in.nextInt(), b = in.nextInt();
              if(!g.containsKey(a)) {
                g.put(a, new HashSet<>());
              }
              if(!g.containsKey(b)) {
                g.put(b, new HashSet<>());
              }
              g.get(a).add(b);
              g.get(b).add(a);
            }
            int ans = 0;
            boolean[] vis = new boolean[n+1];
            for(int i = 1; i <= n; i++){
              ans = Math.max(ans, bfs(g, i, vis));
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 147536
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

string query(int index){
    cout << index << endl;
    fflush(stdout);
    string result;cin >> result;
    if(result == "Vacant"){
        //main()に戻らずにプログラムを終了する
        exit(0);
    }
    else {
        return result;
    }
}

int main() {
    int N;cin >> N;
    string L = query(0);
    string R = query(N-1);
    int left = 0;
    int right = N-1;
    for(int i = 0;i<20;i++){
        int mid = left+(right-left)/2;
        string M = query(mid);
        //左の区間が偶数個かつ両端が同じ　または　左の区間が奇数個かつ両端が異なる
        //ならば左の区間に必ず空席が含まれるので左の区間に合わせる
        if((mid-left) % 2 == 1 && M == L || (mid-left) % 2 == 0 && M != L){
            right = mid;
            R = M;
        }
        else{
            left = mid;
            L = M;
        }
    }
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
long long a[100001],dp[100001],i,n,k;
long long cal(long long i)
{
    long long j;
    if (i>=n) return 0;
    if (dp[i]!=-1) return dp[i];
    else dp[i]=1e18; 
    for (j=1;j<=k;j++) {
        if (i+j<=n)
        dp[i]=min(cal(i+j)+abs(a[i+j]-a[i]),dp[i]);
    }
    //  else dp[i]=cal(i+1)+abs(a[i+1]-a[i]);
    return dp[i];
}
int main()
{
    cin>>n>>k;
    for (i=1;i<=n;i++)
    {
        cin>>a[i];
        dp[i]=-1;
    }
    cout<<cal(1);
}


Measured memory_bytes: 4864
n = int(input())
l = [[0,0] for _ in range(n)]

for i in range(n):
    l[i][0],l[i][1] = map(int,input().split())

l.sort(key = lambda x:x[1])

t = 0
flag = True
for i in range(n):
    t += l[i][0]
    if t > l[i][1]:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38976
n,l=map(int,input().split())
a=list(map(int,input().split()))
last=-1
for i in range(n-1):
  if a[i]+a[i+1]>=l:
    last=i+1
    break
if last==-1:
  print("Impossible")
else:
  print("Possible")
  for i in range(1,last):
    print(i)
  for i in range(len(a)-1,last-1,-1):
    print(i)


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(LL i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (LL)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;
const int MAX = 100005;
int a[MAX] , b[MAX];
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //freopen("In.txt" , "r" , stdin);
	LL diff = 0;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		cin >> b[i];
	vector<int> chng;
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		if(a[i] < b[i])
		{
			ans++;
			diff += b[i] - a[i];
		}
		else
			chng.PB(a[i] - b[i]);
	}
	sort(chng.begin() , chng.end());
	while(diff > 0 && chng.size())
	{
		diff -= chng.back();
		chng.pop_back();
		ans++;
	}
	if(diff > 0)
	{
	cout << -1;
	return 0;
	}
	cout << ans;
}

Measured memory_bytes: 1660
#include <iostream>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const int MOD = 1000000007;
const int INF = INT_MAX;



int main(int argc, char const *argv[])
{
    int n, i;
    cin >> n >> i;

    cout << n-i+1 << endl;

    return 0;
}




//              g++ -std=c++1z  

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	long long int n,b = 0,c = 0,d = 0,e = 0,f = 0;
	scanf("%lld",&n);
	while(n--)
	{
		char q[12];
		scanf("%s",q);
		if(q[0] == 'M')
			b++;
			else if(q[0] == 'A')
				c++;
				else if(q[0] == 'R')
					d++;
					else if(q[0] == 'C')
						e++;
						else if(q[0] == 'H')
							f++;
	}
	long long int ans = b * c * d + b * c * e + b * c * f + b * d * e + b * d * f + b * e * f +c * e * f + c * d * e + c * d * f + d * e * f;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {

	long long n, k, ans;
	cin >> n >> k;
	ans = k;
	for (int i = 1; i < n; i++) {
		ans *= (k-1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <math.h>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
unsigned long long MOD = 1e9 + 7;
ll INF = 1e18;
ll v, e;
VV gragh;
V in_num;
void dfs(ll x)
{
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> v >> e;
    gragh.resize(v);
    in_num.resize(v);
    rep(i, e)
    {
        ll x, y;
        cin >> x >> y;
        gragh[x].push_back(y);
        in_num[y]++;
    }
    queue<ll> q;
    rep(i, v)
    {
        if (in_num[i] == 0)
            q.push(i);
    }
    V result;
    while (!q.empty())
    {
        ll x = q.front();
        q.pop();
        result.push_back(x);
        rep(i, gragh[x].size())
        {
            in_num[gragh[x][i]]--;
            if (in_num[gragh[x][i]] == 0)
            {
                q.push(gragh[x][i]);
            }
        }
    }
    rep(i,v){
        cout << result[i] << endl;
    }
}



Measured memory_bytes: 4176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();

		if(A >= 10) {
			System.out.println(-1);
			return;
		}
		if(B >= 10) {
			System.out.println(-1);
			return;
		}

		System.out.println(A * B);
	}
}

Measured memory_bytes: 23892
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};

int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    ll N;cin>>N;
    for(ll h=1;h<=3500;h++){
        for(ll n=1;n<=3500;n++){
          if(4*h*n-N*n-N*h==0) continue;
            double w=(double)(N*h*n)/(double)(4*h*n-N*n-N*h);
            if(w>=1&&w<=3500&&floor(w)==ceil(w)){
                cout<<h<<' '<<n<<' '<<w<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define re register
#define ll long long
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=300010;
int a[N],n,m,ans;
bool check(int mid)
{
	for(int l=mid*2-1,r=n+n,i=mid*2-1;i<=n+n;i++,l++,r--)
		if(a[l]+a[r]<m)return false;
	return true;
}
int main()
{
	n=gi();m=gi();
	for(int i=1;i<=2*n;i++)a[i]=gi();
	sort(a+1,a+n+n+1);
	int l=1,r=n,ret=n+1;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))ret=mid,r=mid-1;
		else l=mid+1;
	}
	for(int i=1,l=1,r=ret*2-2;i<=ret*2-2;i++,l++,r--)ans=max(ans,(a[l]+a[r])%m);
	for(int i=ret*2-1,l=ret*2-1,r=n+n;i<=n+n;i++,l++,r--)ans=max(ans,(a[l]+a[r])%m);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

/*
cin.tie(0);
ios::sync_with_stdio(false);
*/

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

class Union_Find{
private:
    vector<int> par, rank;

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
public:
    Union_Find(int Max_Node){
        par.resize(Max_Node);
        rank.resize(Max_Node);
    }

    void init(int n) {
        for(int i = 0; i < n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y)return ;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y])rank[x]++;
        }
    }

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> in(n);
  rep(i,n)cin>>in[i];
  Union_Find uf(n+10);
  uf.init(n+1);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    uf.unite(a,b);
    uf.unite(b,a);
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    if(uf.same(in[i],i+1)){
      //cout<<i+1<<": "<<"Yes"<<endl;
      ans++;
    }//else cout<<i+1<<": "<<"no"<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1408
program main 
   implicit none
   integer::a(6),counter(4)=0
   integer i
   do i=1,3
      read(*,*)a(i*2-1),a(i*2)
   enddo
   do i=1,6
      counter(a(i))=      counter(a(i))+1
   enddo
   if(any(counter>=3))then
      print "(a)","NO"
   else
   print "(a)","YES"
   endif
end program main


Measured memory_bytes: 256
#include<stdio.h>

int main (void){
int n,i,a,b,ai[10001];
long c;
 scanf("%d",&n);
 for(i=0;i<n;i++){
	scanf("%d",&ai[i]);
  	if(i==0){
 		 a=ai[0];
  		 b=ai[0];
  } else{
 	if(a<=ai[i]){
 		a=ai[i];
  }
   if(b>=ai[i]){
    b=ai[i];
   }
  }
 } 
  c=0;
 for(i=0;i<n;i++){
 	c+=ai[i];
 }


 printf("%d %d %ld\n",b,a,c);
 return 0;
}

Measured memory_bytes: 640
import kotlin.math.*

fun main() {
    val list = readLine()!!.split(" ")
    val x = list[0].toLong()
    val k = list[1].toLong()
    val d = list[2].toLong()
    val minimum: Double = x.toDouble() / 1000000.0 - k * d.toDouble() / 1000000.0
    val maximum: Double = x.toDouble() / 1000000.0 + k * d.toDouble() / 1000000.0

    if (k == 0L || d == 0L) {
        println(x)
    }else if (maximum * minimum >= 0) {
        if (x < 0) {
            println(abs(x + k * d))
        } else if (x > 0) {
            println(abs(x - k * d))
        }
    } else if (minimum < 0 && x >= 0) {
        val howMany: Long = x / d
        val nam: Long = k - howMany
        if (nam % 2 == 1L) {
            println(min(abs(x - (howMany - 1) * d), abs(x - (howMany + 1) * d)))
        } else {
            println(abs(x - howMany * d))
        }

    } else if (minimum < 0 && x < 0) {
        val howMany: Long = (-x) / d
        val nam: Long = k - howMany
        if (nam % 2 == 1L) {
            println(min(abs(x + (howMany - 1) * d), abs(x + (howMany + 1) * d)))
        } else {
            println(abs(x + howMany * d))
        }


    }
}

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

using namespace std;
int n,cnt,ans;
string c;
int main()
{
    scanf("%d",&n);
    cin>>c;
    int len=c.length();
    for(int i=0;i<len;i++){
        if(c[i]=='W')
            cnt++;
    }
    for(int i=0;i<len;i++){
        if(c[i]=='W'&&i<len-cnt){
            ans++;
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 3840
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public ArrayList<Integer> sh;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] f = new int[n][10];
		int[][] p = new int[n][11];
		int re = Integer.MIN_VALUE;
		
		for(int i = 0;i < n;++i){
			for(int j = 0;j < 10;++j){
				f[i][j] = sc.nextInt();
			}
		}
		
		for(int i = 0;i < n;++i){
			for(int j = 0;j < 11;++j){
				p[i][j] = sc.nextInt();
			}
		}

		for(int i = 1;i < 1024;++i){
			String bin = Integer.toBinaryString(i);
			int[] sh = new int[n];
			int tm = 0;
			bin = String.format("%10s", bin).replaceAll(" ", "0");
			//比較して被ってる分を数える
			for(int j = 0;j < 10;++j){
				int d = bin.charAt(j);
				if(d == '1'){
					for(int k = 0;k < n;++k){
						if(f[k][j] == 1) sh[k] += 1;
					}
				}
			}
			
			for(int k = 0;k < n;++k){
				tm += p[k][sh[k]];
			}
			
			re = Math.max(re, tm);
		}

		System.out.println(re);
	}
}


Measured memory_bytes: 31676
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main()
{
  int N,ans=0;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  for(int i=55;i>=0;i--){
    if(A.size()==0)break;
    while(N>1 && (1ll<<i)<=A[N-1]){
      // cout<<i<<endl<<A[N-1]<<endl;
      // cout<<(1<<(i+1))-A[N-1]<<endl;
      // cout<<"aaaaaaaaa"<<endl;
      // for(int j=0;j<N;j++){
      //   cout<<A[j]<<" ";
      // }
      // cout<<endl<<"aaaaaaaaa"<<endl;
      auto up=upper_bound(A.begin(),A.end()-1,(1ll<<(i+1))-A[N-1]);
      auto lo=lower_bound(A.begin(),A.end()-1,(1ll<<(i+1))-A[N-1]);
      if(up-lo!=0){
        ans+=1;
        A.erase(lo);
        A.pop_back();
        N-=2;
      }else{
        A.pop_back();
        N--;
      }
    }
  }

  cout<< ans <<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1001

ll nCm[NUM][NUM];
ll fact[NUM];
ll memo[NUM];
ll POW[NUM];

ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

ll mod_fact(ll n,ll p,ll &e){
	e = 0;
	if(n == 0)return 1;

	int res = mod_fact(n/p,p,e);
	e += n/p;

	if(n/p%2 != 0)return res*(p-fact[n%p])%p;
	return res*fact[n%p]%p;
}

int main(){

	ll N,K;
	scanf("%lld %lld",&N,&K);

	fact[0] = 1;
	for(ll i = 1; i <= K; i++){
		fact[i] = i*fact[i-1];
		fact[i] %= MOD;
	}

	POW[0] = 1;
	ll tmp;
	for(ll i = 1; i <= K; i++){
		tmp = 1;
		for(int loop = 0; loop < N; loop++){
			tmp *= i;
			tmp %= MOD;
		}
		POW[i] = tmp;
	}

	nCm[0][0] = 1;
	for(int n = 1; n <= K; n++){
		for(int m = 0; m <= K; m++){

			if(n == 0){

				nCm[n][m] = 1;

			}else{

				nCm[n][m] = nCm[n-1][m]+nCm[n-1][m-1];

			}
			nCm[n][m] %= MOD;
		}
	}

	memo[1] = 1;
	ll ans = 0;

	for(ll num = 1; num <= min(N,K); num++){

		memo[num] = POW[num];

		for(int i = 1; i <= num-1; i++){
			memo[num] -= nCm[num][i]*memo[i];
			memo[num] %= MOD;
			if(memo[num] < 0)memo[num] += MOD;
		}

		tmp = memo[num]*mod_inverse(fact[num],MOD);
		tmp %= MOD;
		if(tmp < 0)tmp += MOD;
		ans += tmp;
		ans %= MOD;
		if(ans < 0)ans += MOD;
	}

	printf("%lld\n",ans);

	return 0;
}




Measured memory_bytes: 11032
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << "[DBG] " << #X << "=" << (X) << '\n';
	#define SAY(X) cout << "[SAY] " << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = (int)1e5;
vector<int> g[MAXN];
int deg[MAXN], n, m;
int found = 0;
int used[MAXN];

void dfs(int v, int p, int start) {
	used[v] = 1;
	for(auto& u: g[v]) {
		if(!used[u] && deg[u] == 2) {
			dfs(u, v, start);
		}
		if(u == start && u != p) {
			found = 1;
		}
	}
}

void solve() {
	cin >> n >> m;
	for(int i = 0; i < m; ++i) {
		int v = fetch<int>() - 1;
		int u = fetch<int>() - 1;
		g[v].push_back(u);
		g[u].push_back(v);
		++deg[v]; ++deg[u];
	}
	/*if(m < 9) {
		cout << "No\n";
		return;
	}*/
	for(int i = 0; i < n; ++i) {
		if(deg[i]&1) {
			cout << "No\n";
			return;
		}
	}
	for(int i = 0; i < n; ++i) {
		if(deg[i] >= 6) {
			cout << "Yes\n";
			return;
		}
	}
	int cnt = 0;
	for(int i = 0; i < n; ++i) {
		cnt += (deg[i] == 4);
	}
	if(cnt <= 1) {
		cout << "No\n";
		return;
	}
	if(cnt >= 3) {
		cout << "Yes\n";
		return;
	}
	int v = NIL;
	for(int i = 0; i < n; ++i) {
		if(deg[i] == 4) {
			v = i;
			break;
		}
	}
	assert(v != NIL);
	dfs(v, NIL, v);
	cout << (found ? "Yes\n" : "No\n");
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;

int main(void) {
  ll n; cin >> n;
  if (n * 100 % 108 == 0) plexit(n*100/108)
  else {
    rep(i,50000){
      double x = (double)i * 1.08;
      if (n == floor(x)) {
        plexit(i)
      }
    }
  }
  pl(":(")
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

main(){
  int p = 1, i, ans;
  char c;
  cin >> ans;
  while(c != '='){
    if(p) cin >> c;
    else{
      cin >> i;
      if(c == '+') ans += i;
      if(c == '-') ans -= i;
      if(c == '*') ans *= i;
      if(c == '/') ans /= i;
    }
    p = 1 - p;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1160