akhauriyash/Code-Regression huggingface dataset:
n=int(input())
A=list(map(int,input().split()))
m=int(input())
B=list(map(int,input().split()))
c=0
def binary(A,key):
    global c
    left=0
    right=len(A)
    while left<right:
        mid=(left+right)//2
        
        if A[mid]==key:
            c+=1
            return c
        elif A[mid]<key:
            left=mid+1
        else:
            right=mid
    return False
for i in B:
    binary(A,i)
    
print(c)



Measured memory_bytes: 16716
#include <bits/stdc++.h>
using namespace std;
#define reps(i,j,k) for(int i=j;i<k;i++)
#define rep(i,j) reps(i,0,j)

bool PRIME[10000010];

void e(){
	PRIME[0] = PRIME[1] = true;
	for(int i = 2; i * i <= 10000000; i++){
		if(!PRIME[i]){
			for(int j = i*i; j <= 10000000; j+=i){
				PRIME[j] = true;
			}
		}
	}
	return ;
}

int main(){
	e();
	int a,d,n;
	while(scanf("%d%d%d",&a,&d,&n),(a+d+n)){
		vector < int > O;
		int index = 0;
		while(true){
			if(!PRIME[a]){
				index++;
			}
			if(index == n){
				printf("%d\n",a);
				break;
			}
			a+=d;
		}
	}
	return 0;
}

Measured memory_bytes: 10952
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    int a;
    cin >> a;
    cout << 3 * (a*a);
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<string.h>
char a[110];
int main()
{
    int n,m,i,j,k;
    scanf("%d%d",&n,&m);
    scanf("%s",a);
    k=strlen(a);
    if(k!=n+m+1)
    {
        printf("No\n");
        return 0;
    }
    for(i=0;i<n;i++)
    if(a[i]<'0'||a[i]>'9')
    {
        printf("No\n");
        return 0;
    }
    if(a[n]!='-')
    {
        printf("No\n");
        return 0;
    }
    for(i=n+1;i<k;i++)
    if(a[i]<'0'||a[i]>'9')
    {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define MAX 101
#define INF 100000000


void MCO(int *);

int n;

int min[MAX][MAX];

int main()
{

  int i,j,goukei=0;
  
  scanf("%d",&n);

  int p[n+1];
  
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&p[i],&p[i+1]);
    }

  MCO(p);

  printf("%d\n",min[1][n]);

  return 0;
}

void MCO(int *p)
{
  int i,j,k,l,q;

  for(i=1;i<=n;i++)
    {
      min[i][i]=0;
    }
  
  for(l=2;l<=n;l++)
    {
      for(i=1;i<=n-l+1;i++)
	{
	  j=i+l-1;
	  min[i][j]=INF;
	  for(k=i;k<j;k++)
	    {
	      q=min[i][k] + min[k+1][j] + (p[i-1]*p[k]*p[j]);
	      
	      if(min[i][j]>q)min[i][j]=q;
	    }
	}
    }
}



Measured memory_bytes: 2036
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 998244353

const int N = 600031;

int n;
long long L[N],R[N],ans;

set<pair<long long, long long> > ::iterator it;
set<pair<long long, long long> > L_set,R_set;
int cur_ps,id;

int get_l(){
	it=L_set.end();
	--it;
	return (*it).second;
}

int get_r(){
	it=R_set.begin();
//	--it;
	return (*it).second;
}

int make_move(int ps,int id){
	if (ps>=L[id]&&ps<=R[id])
		return ps;
	if (ps<L[id])
		return L[id];
	if (ps>R[id])
		return R[id];
	return 0;
}

long long solver(){
	L_set.clear();
	R_set.clear();
	long long ret=0;
	for (int i=1;i<=n;i++){
		L_set.insert(make_pair(L[i],i));
		R_set.insert(make_pair(R[i],i));
	}
	cur_ps=0;
	for (int i=1;i<=n;i++){
		if (i%2){
			id=get_l();
		}
		else
		{
			id=get_r();
		}
	//	cout<<id<<endl;
		int new_ps=make_move(cur_ps,id);
		ret+=abs(new_ps-cur_ps);
		L_set.erase(make_pair(L[id],id));
		R_set.erase(make_pair(R[id],id));
		cur_ps=new_ps;
	}
	return ret+abs(cur_ps);
}

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>L[i]>>R[i];
	}
	ans=solver();
	for (int i=1;i<=n;i++){
		swap(L[i],R[i]);
		L[i]*=-1;
		R[i]*=-1;
	}
	ans=max(ans,solver());
	cout<<ans<<endl;


//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 17664
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include<complex>

using namespace std;

typedef long long            ll;
typedef unsigned             ui;
typedef unsigned long long   ull;
typedef pair<int,int>        i_i;
typedef pair<ll,int>         ll_i;
typedef pair<ll,ll>          ll_ll;
typedef pair<double,int>     d_i;
typedef pair<double,double>  d_d;
typedef vector<int>          vi;
typedef vector<vector<int> > vii;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      x.begin(),x.end()
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  in(int,n,x);
  int sum=0;
  int i;
  int l[11234];
  rep(i,n){
    in(int,d);
    l[i+1]=l[i]+d;
  }
  darray(l,n+1);
  rep(i,n+1){
    if(l[i]>x){
      putv(i);
      return 0;
    }
    if(l[i]==x){
      putv(i+1);
      return 0;
    }
  }
  putv(n+1);
  return 0;
}


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

typedef long long ll;
using namespace std;
int main()
{

  ll n,x=0,max=0;
  string s;
  cin>>n>>s;

  rep(i,s.length()){
    s[i]=='I'?x++:x--;
    if(x>max)max=x;
  }

  cout<<max<<endl;
return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define mx 100000
#define pb push_back
#define siz(v) v.size();
typedef unsigned long  ull;
typedef long long int lli;
using namespace std;

int main()
{
 	ios_base::sync_with_stdio(0);
 	cin.tie(0); cin.tie(0);
	
	int a;
	cin>>a;
	int x=a%10,y=(a/10)%10,z=(a/100)%10;
	if (x==7||y==7||z==7) cout<<"Yes\n";
	else cout<<"No\n";






 return 0;
 }


Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <cmath>
#include <array>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI;
typedef pair<int,int> pii;
const int mod = (int)1e9+7;


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m;
	cin >> n >>m;
	VI x(m), y(m);
	rep(i,m){
		cin >> x[i] >> y[i];
		x[i]--; y[i]--;
	}
	VI red(n), cnt(n,1); red[0]=1;
	
	rep(i,m){
		int cx=x[i], cy=y[i];
		if(red[cx]==1 && cnt[cx]==1){
			cnt[cx]=0; red[cx]=0;
			cnt[cy]++; red[cy]=1;
		}else if(red[cx]==1){
			cnt[cx]--;
			cnt[cy]++; red[cy]=1;
		}else{
			cnt[cx]--; cnt[cy]++;
		}
	
	}
	int ans=0;
	rep(i,n) if(red[i]) ans++;
	//for(auto x :red) printf("%d, ",x); puts("");
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 1792
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_num(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int a, b;

int main() {
	cin >> a >> b;
	cout << (a + b) / 2 << endl;
}


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

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        CTaxIncrease solver = new CTaxIncrease();
        solver.solve(1, in, out);
        out.close();
    }

    static class CTaxIncrease {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            double a = in.nextInt();
            double b = in.nextInt();
            int nedan = -1;

            for (int i = 1; i <= 10000; i++) {
                if ((int) (i * 0.08) == a) {
                    if ((int) (i * 0.10) == b) {
                        nedan = i;
                        break;
                    }
                }
            }

            out.println(nedan);
        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.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 byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        public int nextInt() {
            if (!hasNext()) throw new NoSuchElementException();
            int n = 0;
            boolean minus = false;
            byte 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();
            }
        }

    }
}



Measured memory_bytes: 21460
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

ll N;
string s;
vector<bool> solve(bool a, bool b){
	vector<bool> res(N+2);
	res[0] = a;
	res[1] = b;
	FOR(i,1,N+1){
		if(s[i]=='o'){
			res[i+1]=(res[i]==true)?res[i-1]:!res[i-1];
		}else{
			res[i+1]=(res[i]==true)?!res[i-1]:res[i-1];
		}
	}
	return res;
}

//判定をする
//始めの条件から得られる値と最後の値が等しいのか
bool judge(vector<bool> c){
	bool temp= (c[0]==true)?c[1]:!c[1];
	bool top;
	if(s[0]=='o'){
		top=(c[N-1]==temp);
	}else{	
		top=(c[N-1]==!temp);
	}
	return (top&&(c[N]==c[0]));
}

int main(){
	cin>>N;
	cin>>s;
	string ans ="-1";
	vector<bool> sig;
	bool flag=true;
	//始めと隣が決まれば全部決まる.
	int dx[4]={0,1,0,1},dy[4]={0,0,1,1};
	rep(i,4){
		sig=solve(dx[i],dy[i]);
		if(judge(sig)){
			ans="";
			rep(i,N){
				if(sig[i]){
					ans+='S';
				}else{
					ans+='W';
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}












Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c >= a && c <= b) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

//Ctrl+Aを使わない

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

int main() {

int s,w;
cin>>s>>w;
string ans="Yes";

  if(s<=w)
  {ans="unsafe";}
  else
  {ans="safe";}
  


cout << ans<<endl;




}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

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

int main(){

	int mt[10];
	int i;
	
	for(i=0;i<10;i++){
		std::cin >> mt[i];
	}
	
	std::sort(mt,mt+10,std::greater<int>());
	
	for(i=0;i<3;i++){
		std::cout << mt[i] << std::endl;
	}
}

Measured memory_bytes: 1176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		long x = Long.parseLong(str[0]);
		long k = Long.parseLong(str[1]);
		long d = Long.parseLong(str[2]);

		long kaisu = x / d;
		long near = x % d;
		long revnear = (near < 0) ? near + d : near - d;

		if (Math.abs(kaisu) >= k) {
			if (x < 0) {
				System.out.println(Math.abs(x + k * d));
			} else
				System.out.println(x - k * d);
		} else {
			if ((k - kaisu) % 2 == 0) {
				System.out.println(Math.abs(near));
			} else {
				System.out.println(Math.abs(revnear));
			}
		}
	}
}


Measured memory_bytes: 32532
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int mod=1e9+7;
inline void Add(int &x,int y) { x+=y; if(x>=mod) x-=mod; }

const int N=310;
int a[N<<1],n;
int dp[N<<1][N<<1][N<<1];
int p[N<<1],m;
int vis[N<<1],vis2[N<<1];
int main() {
	rd(n);
	for(int i=1;i<=2*n;++i) rd(a[i]);
	int cnt=0;
	for(int i=1;i<2*n;i+=2) if(a[i]==-1||a[i+1]==-1) {
		if(a[i]!=-1) vis2[a[i]]=1;
		else if(a[i+1]!=-1) vis2[a[i+1]]=1;
		else cnt++;
	}
	else vis[a[i]]=vis[a[i+1]]=1;
	for(int i=1;i<=2*n;++i)
		if(!vis[i]) p[++m]=vis2[i];
//	for(int i=1;i<=m;++i) printf("%d ",p[i]); puts("");
	
	dp[m+1][0][0]=1;
	for(int i=m;i>=1;--i)
	for(int j=0;j<=m-i;++j)
	for(int k=0;k<=m-i;++k) if(dp[i+1][j][k]) {
		int v=dp[i+1][j][k];
		if(!p[i]&&k) Add(dp[i][j][k-1],1ll*v*k%mod);
		Add(dp[i][j-1][k],v);
		if(p[i]) Add(dp[i][j][k+1],v);
		else Add(dp[i][j+1][k],v);
	}
	int res=dp[1][0][0];
	for(int i=1;i<=cnt;++i) res=1ll*res*i%mod;
	printf("%d ",res);
	return 0;
}

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

int ch[300010];
int cw[300010];

int main(){
  int H,W,M;
  cin >> H >> W >> M;
  set< pair<int, int> > blk;
  REP(i,M) {
    int h,w;
    cin >> h >> w;
    h--; w--;
    blk.emplace(h,w);
    ch[h]++;
    cw[w]++;
  }
  int maxh = 0;
  int maxw = 0;
  REP(i,H) maxh = max( maxh, ch[i] );
  REP(i,W) maxw = max( maxw, cw[i] );

  vector<int> lh, lw;
  int ans = maxh + maxw - 1;
  REP(i,H) if ( ch[i] == maxh ) lh.emplace_back( i );
  REP(i,W) if ( cw[i] == maxw ) lw.emplace_back( i );
  for ( auto h : lh ) {
    int f = 0;
    for ( auto w : lw ) {
      if ( blk.find( make_pair(h,w) ) == blk.end() ) {
        f = 1;
        ans++;
        break;
      }
    }
    if (f==1) break;
  }
  
  cout << ans << endl;
}


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

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000009
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>

vector <int> v[26];

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

	for(int i = 0; i < s.size(); i++) {
		v[s[i]-'a'].pb(i);
	}

	ll ans = 1, pre = -1, x, ch;
	for(int i = 0; i < t.size(); i++) {
		ch = t[i]-'a';

		if(v[ch].empty()) {
			cout<<"-1"<<endl;
			return 0;
		}

		x = lower_bound(v[ch].begin(), v[ch].end(), pre+1) - v[ch].begin();

		if(x == v[ch].size()) ans++, pre = v[ch][0];
		else pre = v[ch][x];
	}

	ans = (ans-1) * s.size() + pre + 1;

	cout<<ans<<endl;
}


Measured memory_bytes: 1344
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll dat[1200010];
ll n;
void init(ll n_){
  n=1;
while(n<=n_)n*=2;
  for(ll i=0;i<2*n-1;i++)
    dat[i]=0;
}
void add(ll k,ll a){
k+=n-1;
  dat[k]+=a;
  while(0<k){
  k=(k-1)/2;
    dat[k]=dat[2*k+1]+dat[2*k+2];
  }
}
ll query(ll a,ll b,ll k,ll l,ll r){
if(a<=l && r<=b)
  return dat[k];
  else if(b<=l || r<=a)
    return 0;
  else {
  ll val=query(a,b,2*k+1,l,(l+r)/2);
    ll var=query(a,b,2*k+2,(l+r)/2,r);
    return (val+var);
  }
}
ll N;
int main(){
  cin>>N;
  vector<ll>a(N);
  for(ll i=0;i<N;i++)
    cin>>a[i];
  ll left=0;ll right=1000000001;vector<ll>b(N+1);
  while(1<right-left){
    b[0]=0;
  ll mid=left+(right-left)/2;
    for(ll i=0;i<N;i++)
      if(a[i]<=mid)
        b[i+1]=b[i]+1;
    else
      b[i+1]=b[i];
    for(ll i=0;i<=N;i++)
      b[i]=(2*b[i]-i+N);
  init(3*N);
    ll sum=0;
    for(ll i=0;i<=N;i++){
    sum+=query(0,b[i],0,0,n);
      add(b[i],1);
     }
  if(N*(N+1)<4*sum)
    right=mid;
    else
      left=mid;
  
  }cout<<right<<endl;
  return 0;
}

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

#define int            long long int
#define float          long double
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define inf            1e18
#define set_pre(x,y)   fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
using namespace std;
int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main(){
    int n,k;
    cin>>n>>k;
    vector<int>v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    bool dp[k+1]={true};
    int l=v[0];
    for(int i=0;i<l;i++)
    {
        dp[i]=false;
    }
    for(int i=l;i<=k;i++)
    {
        int t=0;
        int f=0;
        for(auto c:v)
        {
            if(i>=c)
            {
                if(dp[i-c]==true)
                    t++;
                else
                    f++;
            }
        }
        if(f>0)
            dp[i]=true;
        else
            dp[i]=false;
    }
    if(dp[k])
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
}

Measured memory_bytes: 384
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
static const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) {}
	ModInt(signed sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt &operator%=(ModInt that) { x %= that.x; return *this; }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
  ModInt operator%(ModInt that) const { return ModInt(*this) %= that; }

	ModInt inverse() const {
		signed a = x, b = MOD, u = 1, v = 0;
		while(b) {
			signed t = a / b;
			a -= t * b; std::swap(a, b);
			u -= t * v; std::swap(u, v);
		}
		if(u < 0) u += Mod;
		ModInt res; res.x = (unsigned)u;
		return res;
	}

	bool operator==(ModInt that) const { return x == that.x; }
	bool operator!=(ModInt that) const { return x != that.x; }
	ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
};
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
	ModInt<MOD> r = 1;
	while(k) {
		if(k & 1) r *= a;
		a *= a;
		k >>= 1;
	}
	return r;
}

typedef ModInt<mod> mint;

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

signed main(){
  cin.tie(nullptr); ios::sync_with_stdio(false);

  cin>>n>>m; mint a[n],b[m];
  rep(i,n)cin>>a[i]; rep(i,m)cin>>b[i];
  mint an=0,bn=0;
  rep(i,n)an+=a[i]*(2*i-n+1);
  rep(i,m)bn+=b[i]*(2*i-m+1);
  cout<<an*bn<<'\n';
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll a,b,n;
  cin>>a>>b>>n;

  ll ans;
  if(b-1<=n)
    ans=a*(b-1)/b;
  else
    ans=a*n/b;
  cout<<ans<<endl;
}



Measured memory_bytes: 3608
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
  x = int(input())
  b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
  res = INF
  for S in [s[b - 1], s[b]]:
    for T in [t[d - 1], t[d]]:
      d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
      res = min(res, d1, d2)
  print(res)

Measured memory_bytes: 78168
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define int int64_t
#define pcnt __builtin_popcount
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define vec vector<int>
#define mat vector<vector<int>> //mat データ名(縦,vec(横));
#define F first
#define S second
int INF = 1000000000000000001; //10^18+1
int MOD = 1000000007; //10^9+7
double pie = 3.141592653589793238;
//cout << fixed << setprecision(15); (小数点以下表示)

signed main () {
  double A,B,H,M,Hd,Hx,Hy,Md,Mx,My,ans;
  cin >> A >> B >> H >> M;
  Hd=(60*H+M)/360*pie;
  Md=M/30*pie;
  Hx=A*cos(Hd);
  Hy=A*sin(Hd);
  Mx=B*cos(Md);
  My=B*sin(Md);
  ans=sqrt(pow(Hx-Mx,2)+pow(Hy-My,2));
  cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 4100
#include "math.h"
#include "stdio.h"
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>

using namespace std;


/** Problem0042 : A Thief
 Time Limit Exceeded **/

#define MAX_N 1100
#define MAX_W 1100

int W, N, tre[1100][2]={0}, solW, solN;
int dp[MAX_N][MAX_W];
int dpW[MAX_N][MAX_W];

pair<int, int> solve(int i, int j)
{
	if (dp[i][j] >= 0)
		return pair<int, int>(dp[i][j], dpW[i][j]);
	
	pair<int, int> res;
	if (i == N) {
		res = pair<int, int>(0, W-j);
	} else if (j < tre[i][1]) {
		res = solve(i+1, j);
	} else {
		//res.first = max(solve(i+1, j).first, solve(i+1, j-tre[i][1]).first+tre[i][0]);
		
		if (solve(i+1, j).first > solve(i+1, j-tre[i][1]).first+tre[i][0]) {
			res = solve(i+1, j);
		} else if (solve(i+1, j).first < solve(i+1, j-tre[i][1]).first+tre[i][0]) {
			res = pair<int, int>(solve(i+1, j-tre[i][1]).first+tre[i][0], solve(i+1, j-tre[i][1]).second);
		} else {
			res = pair<int, int>(solve(i+1, j).first, min(solve(i+1, j).second, solve(i+1, j-tre[i][1]).second));
		}
	}
	
	dp[i][j] = res.first;
	dpW[i][j] = res.second;
	return res;
}

int main()
{
	int set=0; char cam;
	while (1) {
		set++;
		
		cin >> W;
		solW = 0; solN = 0;
		if (W==0) break;
		cin >> N;
		
		memset(dp, -1, sizeof(dp));
		memset(dp, -1, sizeof(dp));
		
		for (int i=0; i<N; i++) {
			cin >> tre[i][0] >> cam >> tre[i][1];
		}
		
		pair<int, int> sol = solve(0, W);
		
		cout << "Case " << set << ":" << endl;
		cout << sol.first << endl;
		cout << sol.second << endl;
	}
	return 0;
} 

Measured memory_bytes: 10700
N,M = map(int,input().split())
A = [0] * N
B = [0] * N
C = [[0,0] for i in range(N)]
check = 0
money = 0
a = 0
k = 0

for i in range(N):

    A[i],B[i] = map(int,input().split())
    C[i] = [A[i],B[i]]

C.sort()

while a == 0:

    if check + C[k][1] < M:

        check += C[k][1]
        money += C[k][0]*C[k][1]
        k += 1

        
    else:

        money += C[k][0] * (M-check)
        a += 1

print(money)

Measured memory_bytes: 21676
import math
a, b, x = map(int, input().split())
if a ** 2 * b / 2 <= x:
  theta = math.atan(2 * b / a - 2 * x / (a ** 3))
else:
  theta = math.pi / 2 - math.atan(2 * x / (a * b * b))
print(math.degrees(theta))

Measured memory_bytes: 9304
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

const int MOD = 1000000007;

Int Factorial(Int n) {
    Int res = 1;
    rep(i, 1, n+1) {
        res *= i;
        res %= MOD;
    }
    return res;
}

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

    Int N, M; cin >> N >> M;

    if (abs(N-M) >= 2) {
        cout << 0 << endl;
        return 0;
    }

    Int nPn = Factorial(N);
    Int mPm = Factorial(M);
    Int res = nPn * mPm % MOD;
    if (abs(N-M) == 0) {
        res *= 2;
        res %= MOD;
    } 
    cout << res << endl;
}


Measured memory_bytes: 384
N=int(input())
S=input()
count=[]
for i in range(len(S)):
    a=[]
    b=[]
    for k in range(i):
        a.append(S[k])
    for h in range(i,len(S)):
        b.append(S[h])
    A=set(a)
    B=set(b)
    count.append(len(A&B))

print(max(count))


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

int main() {
    int N, s, e;
    cin >> N;
    int ans = 0;
    for(int i = 0;i<N ; i++) {
      cin >> s >> e;
      ans += e-s+1;
    }
  
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b;
    cin>>a>>b;
    if(a==1&&b!=1){
        cout<<b-2<<endl;
    }
    else if(a!=1&&b==1){
        cout<<a-2<<endl;
    }
    else if(a==1&&b==1){
        cout<<1<<endl;
    }
    else{
        cout<<a*b+4-((a+b)*2)<<endl;
    }
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> vec(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            vec[i][j] = 1;
        }
    }
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < m; j++) {
            vec[i][j] = 0;
        }
    }
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < n; j++) {
            vec[j][i] = 0;
        }
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            res += vec[i][j];
        }
    }
    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;

bool cmp(const PP &p,const PP &q){
  if(p.S.F != q.S.F)return p.S.F > q.S.F;
  if(p.S.S != q.S.S)return p.S.S < q.S.S;
}


int main(){
  int n;
  int I,U,A,Po;
  while(cin >> n && n){
    vector<PP> vec;
    map<int,int> entitle; 
    for(int i=0;i<n;i++){
      cin >> I >> U >> A >> Po;
      vec.push_back(PP(P(I,U),P(A,Po)));
    }
    sort(vec.begin(),vec.end(),cmp);
    int norisuke = 0; 
    int limit;
    for(int i=0;i<n;i++){
      limit = norisuke<10?3:norisuke<20?2:norisuke<26?1:0;
      int AD = vec[i].F.S;
      if(entitle[AD] < limit){
	entitle[AD]++;
	cout << vec[i].F.F << endl;
	norisuke++;
      }
    }

  }
  return 0;
}

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

int main() {
    int N, T, ans = 1001;
    cin >> N >> T;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        if (T >= b) {
            ans = min(ans, a);
        }

    }
    if (ans == 1001){
        cout << "TLE" << endl;
    }
    else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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

const double PI=3.14159265358979323846;

int mod = 1e9+7;
int INF = 1e9+7;
// const long long INF = 1LL<<60;


int main(){
  string str;
  cin >> str;
  vector<int> nums(64);
  reverse(str.begin(), str.end());

  ll N = 0;
  ll N2 = 0;

  int not_zero = 0;
  int first_nine = -1;
  bool lasting = true;

  // cout << "str:" << str << endl;

  ll mul = 1;
  rep(i, str.size()){
    nums[i] = str[i] - '0';
    if(nums[i] != 0){
      not_zero = i;
    }
    if(nums[i] == 9 && lasting){
      first_nine = i;
    }
    if(nums[i] != 9){
      lasting = false;
    }

    N += nums[i];
    N2 += nums[i] * 10;
    mul *= 10;
  }

  if(N2<10){
    cout << N2 << endl;
    return 0;
  }

  if(not_zero - first_nine <= 1){
    cout << N << endl;
    return 0;
  }else{
    int ans = nums[not_zero] - 1;
    ans += 9 * not_zero;
    cout << ans << endl;
    return 0;
  }



  return 0;
}


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

int lcs(std::string x, std::string y) {
	if (x.length() > y.length()) { x.swap(y); }
	int lx = x.length(), ly = y.length();
	std::vector<std::vector<int>> dp(ly, std::vector<int>(lx));

	dp.at(0).at(0) = (int)(x[0] == y[0]);
	for (int i = 1; i < ly; i++) {
		dp.at(i).at(0) = std::max(dp.at(i - 1).at(0), (int)(x[0] == y[i]));
		if (i < lx) { dp.at(0).at(i) = std::max(dp.at(0).at(i - 1), (int)(x[i] == y[0])); }
	}

	for (int i = 1; i < lx; i++) {
		dp.at(i).at(i) = std::max(dp.at(i - 1).at(i), dp.at(i).at(i - 1));
		if (x[i] == y[i]) { dp.at(i).at(i) = dp.at(i - 1).at(i - 1) + 1; }
		
		for (int t = i + 1; t < ly; t++) {
			if (x[i] == y[t]) { dp.at(t).at(i) = dp.at(t - 1).at(i - 1) + 1; } 
			else { dp.at(t).at(i) = std::max(dp.at(t).at(i - 1), dp.at(t - 1).at(i)); }

			if (t < lx) {
				if (x[t] == y[i]) { dp.at(i).at(t) = dp.at(i - 1).at(t - 1) + 1; } 
				else { dp.at(i).at(t) = std::max(dp.at(i).at(t - 1), dp.at(i - 1).at(t)); }

			}
		}
	}
	return dp.at(ly-1).at(lx-1);
}

int main() {
	int q;
	std::cin >> q;
	
	for (int i = 0; i < q; i++) {
		std::string x, y;
		std::cin >> x >> y;
		
		std::cout << lcs(x, y) << std::endl;
	}
	return 0;
}


Measured memory_bytes: 6816
import java.util.Scanner;


public class Main{
    public static void main (String[]args){
    try(Scanner sc = new Scanner(System.in)){
        while (true) {

            int n = sc.nextInt();
            if (n==0)break;
            
            double ave=0;

            int[] scores = new int[n];
            for (int i = 0; i < scores.length;i++) {
                scores[i] = sc.nextInt();
                ave=ave+scores[i];
            }       
            ave=ave/n;
            double var=0;

            for (int i = 0; i < scores.length;i++) {
                var=var+(scores[i]-ave)*(scores[i]-ave);
            
            }
             var=var/n;
             var =Math.sqrt(var);

             System.out.println(var);
        }  
    }

}}


Measured memory_bytes: 31836
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main() 
{
	int N; cin >> N;
	map<string, ll> M;
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		sort(S.begin(), S.end());
		M[S]++;
		ans += M[S] - 1;
	}
	cout << ans << endl;
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define repS(s,n) for(int (s) = 0; s < 1 << (n); ++(s))
#define repV(i,v) for(auto (i) = begin(v); (i) < end(v); ++(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define divceil(n,d) ((n)/(d) + ((n)%(d) > 0))
#define parity(a,b) (((a) & 1LL)^((b) & 1LL)^1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF = -1 + (1 << 30);
const int MOD = (int)1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}


int N,K;

void solve(){
	
	ll cnt = 0;
	
	repU(d,K + 1,N){
		int q = N / d;
		int r = N % d;
		cnt += q * (d - K) + max(0,r + 1 - K);
		if(!K) --cnt;   
	}
	
	cout<<cnt<<endl;
	
	return;
}

void input(){
	
	cin>>N>>K;
	
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	input();
	solve();
	
	return 0;
}





Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0 ; i < N; i++) {
			A[i] = sc.nextInt();
		}
		int eatNum = 0;
		for(int i = 0; i < N; i++) {
			int tmp = A[i];
			for(int j = 1; j <= 100; j++) {
				if(j == 1) {
					eatNum++;
				} else if((j-1)*tmp+1 <= D) {
					eatNum++;
				} else {
					break;
				}
			}
		}
		System.out.println(X+eatNum);
	}
}

Measured memory_bytes: 25300
#include<stdio.h>
int main(void){
  long long int n,a,b,rem,ans;
  scanf("%lld%lld%lld",&n,&a,&b);
  ans=n/(a+b)*a;
  rem=n%(a+b);
  ans+=a<rem?a:rem;
  printf("%lld",ans);
  return 0;
}

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

using namespace std;

#define INFTY 2000000000
#define MAX 500000

int count = 0, L[MAX/2 + 2], R[MAX/2 + 2];

void merge(int A[], int left, int mid, int right){
    int n1 = mid - left, n2 = right - mid;
    
    for(int i = 0; i < n1; i++){
        L[i] = A[left + i];
    }
    for(int i = 0; i < n2; i++){
        R[i] = A[mid + i];
    }
    L[n1] = INFTY;
    R[n2] = INFTY;
    int i = 0;
    int j = 0;
    for(int K = left; K < right; K++){
        if(L[i] <= R[j]){
            A[K] = L[i];
            i++;
            count++;
        }
        else{
            A[K] = R[j];
            j++;
            count++;
        }
    }
}
void mergeSort(int A[], int left, int right){
    if(left + 1 < right){
        int mid = (left + right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}
int main(void){
    // Your code her
    int n, A[MAX];
    scanf("%d", &n);
    
    for(int i = 0; i < n; i++)scanf("%d", &A[i]);
    
    mergeSort(A, 0, n);
    
    for(int i = 0; i < n; i++){
        if(i > 0) printf(" ");
        printf("%d", A[i]);
    }
    
    printf("\n%d",count);
    printf("\n");
}


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

int main() {

	int h, w;

	while (true) {

		cin >> h >> w;

		if (h == 0 && w == 0)break;

		for (int i = 0; i + 1 <= h;i++) {

			for (int j = 0; j + 1 <= w;j++) {

				cout << "#";
			}
			cout << endl;
		}

		cout << endl;

	}

	//cin >> /*変数他*/;
	//cout << /*文字列*/ << endl;
}


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

public static partial class Program
{
    public static void Main()
    {
        var n = CRL().ToLong();

        var divi = new List<long>();
        for (int i = 1; i <= Math.Sqrt(n); i++)
        {
            if (n % i == 0)
            {
                divi.Add(i);
                divi.Add(n / i);
            }
        }

        long sum = 0;
        foreach (var d in divi)
        {
            var a = n / d - 1;
            if (a != 0 && n % a == d)
            {
                sum += a;
            }
        }
        
        CWL(sum);
    }
}

public static partial class Program
{
    //テンプレここから
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int LCM(int a, int b) => a * b / GCD(a, b);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static string RL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static void WL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static int[] dx = new[] {0, -1, 0, 1};
    public static int[] dy = new[] {-1, 0, 1, 0};
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);

    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    //テンプレここまで
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(void){
 int N,K,R,S,P;
 string T;
 cin >> N >> K >> R >> S >> P >> T;
 int res = 0;
 vector<char> t(N);
 for (int i = 0; i < N; i++){
  if (i<K){
   if (T[i]=='r'){
    res+=P;
    t[i]='p';
   } else if (T[i]=='s'){
    res+=R;
    t[i]='r';
   } else {
    res+=S;
    t[i]='s';
   }
  } else {
   if (T[i]=='r'){
    if (t[i-K]!='p'){
     res+=P;
     t[i]='p';
    } else {
     t[i]='n';
    }
   } else if (T[i]=='s'){
    if (t[i-K]!='r'){
     res+=R;
     t[i]='r';
    } else {
     t[i]='n';
    }
   } else {
    if (t[i-K]!='s'){
     res+=S;
     t[i]='s';
    } else {
     t[i]='n';
    }
   }
  }
 }
 cout << res;
}


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

const int maxn=2e5+7;
int n;
LL a[maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]),a[i]-=i;
    sort(a+1,a+1+n);
    int b;
    if(n&1)b=a[n/2+1];
    else b=(a[n/2]+a[n/2+1])/2;
    LL ans=0;
    for(int i=1;i<=n;i++){
        ans+=abs(a[i]-b);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
/* kadai3_2
   reo012 */

#include<stdio.h>

int main(void){
  int num;
  // 整数numを取得
  scanf("%d", &num);

  // numが1のときは"Yes"と出力、2以上のときは9~2で割って
  // 割り切れたとき商が1~9であるかを確認
  int i=9;
  int check=0;
  if(num==1){
    check=1;
  }else{
    while(i>=2){
      if(num%i==0 && 1<=num/i && num/i<=9){
        check=1;
        break;
      }
      i--;
    }
  }
  // check==0で"No",check==1で"Yes"を出力
  if(check==0){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 256