akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

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

    string s;
    cin >> s;

    rep(i, 1 << 3){
        int ans = s.at(0) - '0';
        rep(j, 3){
            if (i & (1 << j)) {
                ans = ans + (s.at(j+1) - '0');
            } else {
                ans = ans - (s.at(j+1) - '0');
            }
        }
//        cout << ans << endl;
        if (ans == 7) {
            cout << s[0];
            rep(j, 3){
                if (i & (1 << j)){
                    cout << '+';
                } else {
                    cout << '-';
                }
                cout << s[j+1];
            }
            cout << "=7" << endl;
            break;
        }

    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)

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

int main(){
    int N;
    cin >> N;
    vector<vector<long long>> a(N, vector<long long>(N));
    REP(i, N) REP(j, N)
        cin >> a[i][j];
    vector<long long> dp(1<<N);
    REP(i, 1<<N) REP(j, N) REP(k, j+1, N)
        if((i & (1<<j)) && (i & (1<<k)))
            dp[i] += a[j][k];

    REP(i, 1<<N){
        for(int j=i; j>0; j=(j-1)&i){
            int k = i ^ j;
            dp[i] = max(dp[i], dp[j] + dp[k]);
        }
    }
    cout << dp[(1<<N)-1] << endl;
    return 0;
}


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

#define pb push_back
#define fi first
#define se second
#define mem(x,n) memset(x,n,sizeof(x))
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define foreach(it,l) for(auto it=(l).begin();it!=(l).end();it++)
#define pnl printf("\n")
#define endl '\n'
#define len(x) (x).length()

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<int> VI;
const double EPS=1e-10;
//const double PI=acos(-1.0);
const int INF=1<<30;
const LL LLINF=1ll<<60;
const int MOD=1e9+7;
const int xx[8]={1,0,-1,0,1,-1,1,-1};
const int yy[8]={0,1,0,-1,-1,1,1,-1};

void fastio(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); }

/***********************************\
     _____ _             _
    /  __ \ |           (_)
    | /  \/ | __ _ _ __  _  ___
    | |   | |/ _` | '_ \| |/ _ \
    | \__/\ | (_| | |_) | |  __/
     \____/_|\__,_| .__/|_|\___|
                  | |
                  |_|
\***********************************/

int main(){
	LL a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	bool fl=true;
	int cnt=0,asd=10000000;
	
	while(asd--){
		if(a%2!=0||b%2!=0||c%2!=0){
			 fl=false;
			 break;
		}
		
		int tempa = a/2; 
		int tempb = b/2; 
		int tempc = c/2;
		a=tempa+tempb;
		b=tempb+tempc;
		c=tempc+tempa;
		cnt++;	
	}
	
	if(!fl) printf("%d\n",cnt);
	else printf("-1\n");
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")  
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define mem(z,i) memset(z,i,sizeof(z))
#define eps 1e-7
#define I (int)
const int mod=(int)1e9+7;
const long long INF = 1000000000000000000LL;
//const int WASTE=∞;
//#define int long long
int power(int a,int b,int m){
	int i=1;
	while(b){
		if(b%2)
			i=(i*a)%mod;
		b/=2;
		a=(a*a)%mod;
	}
	return i;	
}
const int N=1e5+5;
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll n,k,ans=0;
    cin>>n>>k;
    priority_queue<int>q;
    for(int x=0;x<n;x++){
    	int i;
    	cin>>i; ans+=i;
    	q.push(i);
    }
    while(k--&&!q.empty()){
    	ans-=q.top();
    	q.pop();
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 1400
from collections import deque
n = int(input())
p_que = deque(map(int, input().split()))
q_que = deque(map(int, input().split()))

que = deque(i for i in range(1, n+1))
cnt = 0
a = 0
b = 0

def dfs(d, q):
  # print('-'*10, q)
  # sorted(q)
  for i in list(q):
    # print(i, d, q)
    d.append(i)
    q.remove(i)
    # print('>', d, q)
    if q == deque([]):
      global cnt
      cnt += 1
      # print('>>>', cnt, d, q)
      if d == p_que:
        global a
        a = cnt
      if d == q_que:
        global b
        b = cnt
      # print('return')
      d.remove(i)
      q.appendleft(i)
      return
    # print('tansaku')
    dfs(d, q)
    # print('>returned')
    # print('---', i, d, q)
    d.remove(i)
    if i > q[0]:
      q.append(i)
    else:
      q.appendleft(i)
    q = deque(sorted(q))

dfs(deque(), que)
# print(a, b)
print(abs(a-b))

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <deque>
using namespace std;
#define rep(i,n) for (ll i=0;i<n;i++)
typedef long long ll;

string S;
ll Q;
ll F[210000];
char C[210000];
ll q[210000];

int main() {
	cin >> S;
	cin >> Q;
	ll nobi = 0;
	rep(i, Q) {
		cin >> q[i];
		if (q[i] == 2) {
			cin >> F[i] >> C[i];
			nobi++;
		}
		else F[i] = 0;
	}
	deque<char> dq(S.size());
	rep(i, S.size()) dq[i] = S[i];
	bool now = true;
	rep(i, Q) {
		if (now) {
			if (F[i]==0) {
				now = false;
			}
			else if (F[i] ==1) dq.insert(dq.begin(), C[i]);
			else dq.insert(dq.end(), C[i]);
		}
		else {
			if (F[i] == 0) {
				now = true;
			}
			else if (F[i] == 1) {
				dq.insert(dq.end(), C[i]);
			}
			else {
				dq.insert(dq.begin(), C[i]);
			}
		}
	}
	if (!now) reverse(dq.begin(), dq.end());
	rep(i, dq.size()) cout << dq[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 55;
const int INF = 1e9;
const lli MOD = 1e9+7;


vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}
lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}
int dx[4]={-1,0,0,1}, dy[4]={0,1,-1,0};

// ---- コーディングはここから！ ('-')7



void solve(){
	int n; cin>>n; vl v(n); fore(i,0,n)cin>>v[i];
	vl pre(n,0);
	pre[0]=v[0];
	fore(i,1,n)pre[i]+=pre[i-1]+v[i];
	lli prod = 0;
	fore(i,0,n-1){
	//	cout<<v[n-i-2]<<" "<<pre[n-i-1]<<ENDL;
		prod = SUM(prod,PROD(v[n-i-1],pre[n-i-2]));
	}
	cout<<prod<<ENDL;
}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


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

int main()
{
  string a, b, c;
  cin >> a >> b >> c;
  
  char dif = 'A' - 'a';
  a.at(0) += dif;
  b.at(0) += dif;
  c.at(0) += dif;
  cout << a.at(0) << b.at(0) << c.at(0) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int a, b; ll p;
int ten[10];
ll solve(){
	if(p==1) return 0;
	if(a==b) return 1;
	ll dp[100002];
	fill(dp+1, dp+(b-a)+2, 1);
	ll s[100002];
	s[0]=0; s[1]=1;
	int ind[100002]; ind[1]=1;
	for(int i=2; i<=b-a+1; i++){
		int t=lower_bound(ten, ten+10, a-1+i)-ten;
		if(t<10 && ten[t]==a-1+i){
			ind[i]=i;
		}else{
			ind[i]=ind[i-1];
		}
		int x=a-1+i;
		dp[i]+=(s[i-1]-s[ind[i]-1]+p); dp[i]%=p;
		while(1){
			x/=10;
			if(x<a) break;
			dp[i]+=(s[x-a+1]-s[ind[x-a+1]-1]+p); dp[i]%=p;
		}
		s[i]=(s[i-1]+dp[i])%p;
	}
	return s[b-a+1];
}
int main()
{
	ten[0]=1; for(int i=1; i<10; i++) ten[i]=ten[i-1]*10;
	while(1){
		cin>>a>>b>>p;
		if(a==0) return 0;
		cout<<solve()<<endl;
	}
	return 0;
}


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

int main() {
	int n,sum=0,t,i,l=-1,ans;
	cin >> n;
	for (i=1;i<=n;i++){
		t=i;
		while (t%2==0){
			sum++;
			t=t/2;
		}
		if (sum>l){
			l=sum;
			ans=i;
		}
		sum=0;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 41
int recont(int,int,int);
void postorder(int,int);
typedef struct node{
	int L_id;
	int R_id;
}node;

node c[N];
int a[N];
int b[N];
int cnt=0;

int main(){
  int n,i;
  int root;
	
  scanf("%d",&n);
	
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
  }
  for(i=1;i<=n;i++){
    scanf("%d",&b[i]);
  }
  for(i=1;i<=n;i++){
    c[i].L_id=-1;
    c[i].R_id=-1;
	}	
  root=reconst(1,n,n);	
  postorder(root,n);
	
  return 0;	
}

int reconst(int start,int last,int n){
	
  if(start==last)
    return b[start];
		
  else if(start > last)
    return -1;
	
  else {
    for(int i=1;i<=n;i++){
      for(int j=start;j<=last;j++){
	if(a[i]==b[j]){
	  c[a[i]].L_id=reconst(start,j-1,n);
	  c[a[i]].R_id=reconst(j+1,last,n);
	  return a[i];
	}
      }
    }
  }
  
}
void postorder(int root,int n){
	
  if(c[root].L_id!=-1)
    postorder(c[root].L_id,n);
	
  if(c[root].R_id!=-1)
    postorder(c[root].R_id,n);
  
  if(cnt<n-1)
    printf("%d ",root);
  else 
    printf("%d\n",root);	
  cnt++;
  return;
}



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

int a[100005],ans,n,f[100005][2];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	for(int k=1<<29;k;k>>=1){
		for(int i=0,j=0;i<n;i=j){
			if(a[i]<=k){j=i+1;continue;}
			a[i]=k;
			for(j++;j<n&&a[j]==k<<1;j++)a[j]=k;
			if(j<n&&a[j]>k)a[j++]=k;
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 768
import sys
input = sys.stdin.readline
h,w=map(int, input().split())
a=[list(map(int, input().split())) for i in range(h)]
ans=[]


for i in range(h):
    for j in range(w):
        if i==h-1 and j==w-1:
            continue
        
        if a[i][j]%2==0:
            continue
        
        if j!=w-1:
            ans.append([i+1,j+1,i+1,j+2])
            a[i][j+1]+=1
        else:
            ans.append([i+1,j+1,i+2,j+1])
            a[i+1][j]+=1
            
print(len(ans))
for i in range(len(ans)):
    print(*ans[i])


Measured memory_bytes: 72028
// Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
bool flg = false;
while(true){
	int n;
	cin >> n;
if(n==0)
break;
	string T[10];
	int P[10];
	int I[10];
	for(int i=0; i<n; i++){
		cin >> T[i];

		int w, l, d;
		cin >> w >> l >> d;
		P[i] = w*3+d;

		I[i] = i;
	}

	for(int i=0; i<n-1; i++){
		for(int j=i+1; j<n; j++){
			if(P[i]<P[j]||(P[i]==P[j]&&I[i]>I[j])){
				string s_tmp = T[i];
				T[i] = T[j];
				T[j] = s_tmp;

				int tmp = P[i];
				P[i] = P[j];
				P[j] = tmp;

				tmp = I[i];
				I[i] = I[j];
				I[j] = tmp;
			}
		}
	}
if(flg)
cout << endl;
	for(int i=0; i<n; i++){
		cout << T[i] << ',' << P[i] << '\n';
	}
flg = true;
}
	return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef long long ll;

void solve() {
  string S;
  ll K;
  cin >> S >> K;
  ll N = S.size();
  if (S.find_first_not_of(S[0]) == string::npos) {
    cout << (N * K) / 2 << endl;
  } else {
    ll cnt = 1, a = 0, d = 0;
    for (int i = 0; i < N - 1; i++) {
      if (S[i] == S[i + 1]) {
        cnt++;
      } else {
        a += cnt / 2;
        cnt = 1;
      }
    }
    a += cnt / 2;
    cnt = 1;
    S = S + S;
    for (int i = 0; i < N * 2 - 1; i++) {
      if (S[i] == S[i + 1]) {
        cnt++;
      } else {
        d += cnt / 2;
        cnt = 1;
      }
    }
    d += cnt / 2;
    cout << a + (K - 1) * (d - a) << endl;
  }
}

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

  solve();

  return 0;
}


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

int main() {
  int N, p;
  cin >> N;
  for(int Y = N; Y > 0; Y/=10) {
    p += Y % 10;
  }
  bool n = false;
  if (N % p == 0) {
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
MOD=10**9+7
N,M=map(int,input().split())
a=[-1]

for i in range(M):
  a.append(int(input()))
s=[1]
b=0 if 1 in a else 1
s.append(b)
p,q=-1,-1
j=-1
for i in range(2,N+1):
  while j<M:
    if a[j+1]<=i:
      j+=1
    else:
      break
  v=s[i-2]+s[i-1]
  if a[j]==i:
    v=0
  s.append(v%MOD)
print(s[N])

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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 int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; string s;
    cin >> n >> s;
    bool ans = true;
    if(n%2 != 0) ans = false;
    else {
        for(int i = 0; i < n/2; i++){
            if(s[i] != s[i+n/2]){
                ans = false;
                break;
            }
        }
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace arc091_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long ret = 0;
            for (int i = x[1] + 1; i <= x[0]; i++)
            {
                int a = (x[0] - (i - 1)) / i + 1;
                ret += a * (i - x[1]);
                if ((x[0] - (i - 1)) / i != (x[0] - x[1]) / i)
                {
                    ret += (x[0] - x[1]) % i + 1;
                }
            }
            if (x[1] == 0) ret -= x[0];
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>N;
    ll ans = 50;
    rep(i,N){
        cin>>A;
        ll temp = 0;
        while(A%2 == 0){
            A >>= 1;
            ++temp;
        }
        ans = min(ans, temp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[2000000];
long long b[2000000];
long long d[2000000];
long long n;
long long m,p,v;
bool pos(long long t) {
    for(long long i=0;i<n;i++) {
        b[i]=a[i];
        d[i]=0;
    }
    b[t]+=m;
    long long lj=v-1;
    if(t>=lj) {
        long long r=0;
        for(long long i=0;i<n;i++) {
            if(b[i]>b[t]) r++;
        }
        if(r>=p) return false;
        return true;
    }
    lj-=t;
    for(long long i=0;i<t;i++) b[i]+=m;
    long long c=0;
    while(t+c+1<n && a[t+c+1]==a[t]) c++;
    if(c>=lj) {
        long long r=0;
        for(long long i=0;i<n;i++) {
            if(b[i]>b[t]) r++;
        }
        if(r>=p) return false;
        return true;
    }
    lj-=c;
    for(long long i=t+1;i<=t+c;i++) b[i]+=m;
    long long rem=lj*m;
    for(long long i=t+c+1;i<n && rem>0;i++) {
        if(b[i]>b[t]) break;
        d[i]=min(rem,b[t]-b[i]);
        rem-=d[i];
        b[i]=b[t];
    }
    if(rem>0) {
        for(long long i=n-1;i>t+c && rem>0;i--) {
            b[i]+=min(rem,m-d[i]);
            rem-=min(rem,m-d[i]);
        }
    }
    long long r=0;
    for(long long i=0;i<n;i++) {
        if(b[i]>b[t]) r++;
    }
    if(r>=p) return false;
    return true;
}
int main() {
    scanf("%lld %lld %lld %lld",&n,&m,&v,&p);
    for(long long i=0;i<n;i++) scanf("%lld",&a[i]);
    sort(a,a+n);
    long long l=0,r=n-1;
    while(l<r) {
        long long mid=(l+r)>>1ll;
        if(pos(mid)) r=mid;
        else l=mid+1;
    }
    printf("%lld",n-l);
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using ii = pair<int, int>;
 
void solve();
 
clock_t start_time;
double get_current_time() {
	return (double)(clock() - start_time) / CLOCKS_PER_SEC;
}
 
int main() {
	// freopen("substring.in", "r", stdin);
	// freopen("substring.out", "w", stdout);
 
	ios_base::sync_with_stdio(false);
	solve();
}
 
/* ========== actual code starts here ========== */
 
#define fi first
#define re return
#define se second
#define in insert
#define pb push_back
#define eb emplace_back
#define y1 y123123123123
#define all(x) x.begin(), x.end()
#define hash hash123s
#define index ind123
 
#define repx(i, x, n) for (int i = x; i < (n); i++)
#define repd(i, n, d) for (int i = 0; i < (n); i += d)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepd(i, n, d) for (int i = (n) - 1; i >= 0; i -= d)
#define rep(i, n) for (int i = 0; i < (n); i++)
 
template<class t>
void print(t x, int end = 1) {
	cout << x << (end == 1 ? "\n" : " ");
}
 
template<class T>
void print(const vector<T> &v, int end = 1) {
	rep(i, (int) v.size()) {
		print(v[ i ], 0);
	}
	cout << endl;
}

template<class T>
void print(const int *a, int sz, int end = 1) {
	rep(i, sz) {
		print(a[ i ], 0);
	}
	cout << endl;
}
 
template<class T>
void print(const set<T> &v, int end = 1) {
	for(auto to = v.begin(); to != v.end(); to++) {
		print(*to);
	}
	cout << endl;
}
 
template<class T>
void print(const map<T, T> &v, int end = 1) {
	for(auto to : v) {
		print(to.fi, 0);
		cout << ": ";
		print(to.se);
	}
}
 
template<class t>
void errprint(t x, int end = 1) {
	cerr << x << (end == 1 ? "\n" : " ");
}
 
#ifdef artem
	#define debug(x) x
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define debug(x)
#endif

int w, h;
vector<int> p, q;
ll ans = 0;

void solve() {
	cin >> w >> h;
	p = vector<int>(w);
	q = vector<int>(h);

	rep(i, w) cin >> p[ i ];
	rep(i, h) cin >> q[ i ];
	sort(all(p));
	sort(all(q));

	// print("it's P:\n");
	rep(i, w) {
		int v = p[ i ];
		auto it = lower_bound(all(q), v) - q.begin();
		int cnt = h - it + 1;
		ans += (ll)cnt * v;

		// cout << "for v = " << v << ", cnt = " << cnt << endl;
	}
	// print("it's Q:\n");
	rep(i, h) {
		int v = q[ i ];
		auto it = upper_bound(all(p), v) - p.begin();
		int cnt = w - it + 1;
		ans += (ll)cnt * v;

		// cout << "for v = " << v << ", cnt = " << cnt << endl;
	}
	print(ans);
}

Measured memory_bytes: 4028
N=int(input())
zorome=[]

for i in range(N):
  saikoro=input().split()
  zorome.append(saikoro[0]==saikoro[1])

ret=False
for i in range(N-2):
  if zorome[i] and zorome[i+1] and zorome[i+2]:
    ret=True
    break
print('Yes') if ret else print('No')
  
  



Measured memory_bytes: 9112
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int n,k;
	int d[10] ={};
	int buf,flag = 0;
	cin >> n >> k;
	buf = 1;
	
	for(int i =0; i <k;i++){
		int a;
		cin >> a;
		d[a] = 1;
	}

	if(n == 0){
		for(int i =0; i <k;i++){
			if(d[i] == 0){
				n =i;
				break;
			} 
		}
	}else{
		while(buf <= n){
			buf*=10;
		}
		buf/=10;
		
		int f = 0;
		while(1){
		
			int t=(n / buf)%10;
		
		//	cout << t << " " << n << " " << flag << endl;
			if(flag == 0){
				int i;
				if(d[t] == 0){
				//	cout <<t;
					if(f == 1)flag =1;
					
				}else{
					for(i =t; i <10;i++){
						if(d[i] == 0){
						//	cout << i;
							break;
						}	
					} 
					if(i >= 10){
						n += buf*10;
						n-= t*buf;
						buf*=100;
						f = 1;
					}else{
						n-= t*buf;
						n+= i*buf;
						flag =1;
					}
				}
			}else{
				for(int i =0; i <10;i++){
					if(d[i] == 0){
						n-=t*buf;
						n+=i*buf;
						break;
					}	
				} 
			}			
		
			if(buf == 1)break;
			buf/=10;
		}
	}
	cout << n <<endl;
	
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO [()]
main = do
    -- スペース区切り整数の入力
    [n, l] <- map strToInt . words <$> getLine
    cs <- sort <$> replicateM n getLine
    -- 出力
    forM cs putStr


Measured memory_bytes: 1276
/*
h s, d't skp th si tll i's sved
 * ABC141 E
 * ABC145 D
 * ABC147 F
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
string s;
cin>>s;
int n=s.length();
for(int i=0;i<n;i++)
{
cout<<"x";
}
}

Measured memory_bytes: 3568
N,K = map(int,input().split())
A = list(map(int,input().split()))
town = 1
record = [1]
record2 = [0]*N
for i in range(N):
    town = A[town-1]
    if record2[town-1]==1:
        break
    record.append(town)
    record2[town-1] += 1
    
newrecord = record[record.index(town):]
roop = len(newrecord)
newK = K-(len(record)-roop)
if newK>=0:
    answer = newrecord[newK%roop]
else:
    answer = record[K]

print(answer)

Measured memory_bytes: 95548
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int count = 0;
    for(int i = 0; i < 6; i++) {
      if(s.charAt(i) == '1')count++;
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 21972
#include<stdio.h>

int main(void)
{
	int n,i,g;
	int s[13],h[13],c[13],d[13];
	char j;
	for(i = 0;i < 13;i++)
	{
		s[i] = 0;
		h[i] = 0;
		c[i] = 0;
		d[i] = 0;
	}
	scanf("%d",&n);
	for(i = 0;i < n*2;i++)
	{
		scanf("%c",&j);
		if(j == 'S')
		{
			scanf("%d",&g);
			s[g-1] = g;
		}
		else if(j == 'H')
		{
			scanf("%d",&g);
			h[g-1] = g;
		}
		else if(j == 'C')
		{
			scanf("%d",&g);
			c[g-1] = g;
		}
		else if(j == 'D')
		{
			scanf("%d",&g);
			d[g-1] = g;
		}
		else
		{
		}
	}
	for(i = 0;i < 4;i++)
	{
		for(n = 0;n < 13;n++)
		{
			switch(i)
			{
			case 0:
				if(s[n] == 0)
				{
					printf("S %d\n",n+1);
				}
				break;
			case 1:
				if(h[n] == 0)
				{
					printf("H %d\n",n+1);
				}
				break;
			case 2:
				if(c[n] == 0)
				{
					printf("C %d\n",n+1);
				}
				break;
			default :
				if(d[n] == 0)
				{
					printf("D %d\n",n+1);
				}
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
main :: IO ()
main = do
  n <- readLn
  if n == 0
    then return ()
    else do
      putStrLn (show (func' n))
      main
 
func :: [Int] -> [Int]
func (x:y:z:r) = ((x+y+z):x:y:z:r)

funcn :: Int -> [Int] -> [Int]
funcn 0 ls = ls
funcn n ls = funcn (n-1) (func ls)

func2 :: Int -> Int
func2 0 = 1
func2 1 = 1
func2 n = head (funcn (n-2) [2,1,1])


func' :: Int -> Int
func' n = (days `div` 365) + (min (days `mod` 365) 1)
  where num = func2 n
        days = (num `div` 10) + (min (num `mod` 10) 1)

Measured memory_bytes: 3872
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC144_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(ab[0] < 10 && ab[1] < 10 ? ab[0] * ab[1] : -1);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
	int n, ans = 0;
  	string s;
  	cin >> n >> s;
  	for(int i = 0; i <= n-3; i++) {
    	if (s.substr(i, 3) == "ABC")
          ans += 1;
    }
  	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
N = int(input())
W = []

for i in range(N):
    W.append(input())

h = []
for i in range(1,N):
    h.append(W[i][0])
t = []
for i in range(N-1):
    t.append(W[i][-1])    

flg = 1
for i in range(N-1):
    if h[i] != t[i]: flg = 0
W.sort()
for i in range(N-1):
    if W[i] == W[i+1]: flg = 0

if flg==1: print("Yes")
else: print("No")

Measured memory_bytes: 3064
h, w = map(int, input().split())
filed = [list(input()) for _ in range(h)]

MOD = 10**9 + 7

dp = [[0]*w for _ in range(h)]

# 一番上のマスは左から、一番左のマスは上からしか移動できない
for i in range(w):
    if filed[0][i] == '#':
        break
    dp[0][i] = 1
for i in range(h):
    if filed[i][0] == '#':
        break
    dp[i][0] = 1
    
# 残りのマスは、壁がなければ、左と上から移動できる
# dp[i][j] = dp[i-1][j] + dp[i][j-1]
for i in range(1, h):
    for j in range(1, w):
        if filed[i][j] == '#':
            continue
        dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD

print(dp[-1][-1])

Measured memory_bytes: 51540
n, k = map(int, input().split())
d = set(input().split())

nums = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}
dd = d ^ nums

i = n
while True:
        if dd >= set(list(str(i))):
            print(i)
            exit()
        else:
            i += 1


Measured memory_bytes: 40812
def calculate_grade(m,f,r):
    grade = ''
    if m+f+r == -3:
        return None
    else:
        total = m+f
        if  m == -1 or f == -1:
            grade = 'F'
        elif   total >= 80:
            grade = 'A'
        elif 65 <= total < 80:
            grade = 'B'
        elif 50 <= total < 65:
            grade = 'C'
        elif 30 <= total < 50:
            if r >= 50:
                grade = 'C'
            else:
                grade = 'D'
        elif total < 30:
            grade = 'F'
    return grade


while True:
    m,f,r = map(int,input().split())
    ans = calculate_grade(m,f,r)
    if ans:
        print(ans)
    else:
        break




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

int main(){
   string a,b;
   cin>>a>>b;
   string ss = a+b;
   int s = stoi(ss);
   
   for(int i=0;i<100100;i++){
       if(i*i==s){
           cout<<"Yes";
           return 0;
       }
   }
   cout<<"No";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            int iN = int.Parse(Console.ReadLine().Trim());

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iSum = 0;
            int iTmp = iN;
            while (iTmp > 0)
            {
                iSum += iTmp % 10;
                iTmp /= 10;
            }
            string sOut = "No";
            if (iN % iSum == 0) { sOut = "Yes"; }
            
            // 出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
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



T, S = sys.stdin.buffer.readline().decode().rstrip().split()
print(S+T)


Measured memory_bytes: 23752
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import defaultdict
from itertools import accumulate

n, *a = map(int, read().split())
dict = defaultdict(int)
ans = 0
for aa in list(accumulate([0] + a)):
    dict[aa] += 1
for v in dict.values():
    ans += v * (v - 1) // 2
print(ans)


Measured memory_bytes: 42852
#include <iostream>

using namespace std;

int main () {
    int P, Q, R;
    cin >> P >> Q >> R;
    int abc = P + Q;
    int acb = R + Q;
    int bac = P + R;
    
    int min_root = min(abc, acb);
    min_root = min(min_root, bac);
    cout << min_root << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int D;
  cin >> D;
  vector<ll> C(26);
  rep(i, 26) cin >> C[i];
  vector<vector<ll>> S(D, vector<ll>(26));
  rep(i, D) rep(j, 26) {
    cin >> S[i][j];
  }
  vector<int> L(26, 0);
  vector<int> T(D);
  vector<ll> ans(D);
  ll sum = 0;
  rep(i, D) {
    cin >> T[i];
    sum += S[i][T[i]-1];
    L[T[i]-1] = i+1;
    rep(j, 26) {
      sum -= C[j] * (i+1 - L[j]);
    }
    ans[i] = sum;
  }
  rep(i, D) cout << ans[i] << "\n";
  return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second
#define pb push_back
#define all(x) x.begin(), x.end()
#define inputSpeed() ios_base::sync_with_stdio(0),cin.tie(0)

#define MAXN (ll)(1e6+10)
// only one prime factor will be larger than 10^6
// Also, there are at most 40 prime factors.
bool composite[MAXN];
vector<pii> prime_factorise(ll N) {
	vector<pii> prime_factors;
	for (ll i = 2; i < MAXN; i++)  {
		if (!composite[i]) {
			// Found prime
			ll power = 0;
			while (N % (ll)i == 0) {
				N /= (ll)i;
				power++;
			}
			if (power) {
				prime_factors.pb({i, power});
			}
			// Update rest
			for (ll j = i*i; j <= MAXN; j += i) {
				composite[j] = true;
			}
		}
	}
	if (N > 1) {
		prime_factors.pb({N, 1});
	}
	return prime_factors;
}

int main () {
	inputSpeed();

	ll N;
	cin >> N;
	vector<pii> prime_factors = prime_factorise(N);

	// printf("N = 1\n");
	// for (auto f : prime_factors) {
	// 	printf("* %d ^ %d\n", f.x, f.y);
	// }

	int ans = 0;
	for (auto f : prime_factors) {
		// find out which triangular number it is
		for (int j = 1; j < 100; j++) {
			if (f.y - j >= 0) {
				f.y -= j;
				ans++;
			}
		}
	}
	printf("%d\n", ans);
}


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

int main()
{
	int i, N, A[100002] = {};
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));

	int dif[100001], sum = abs(A[1]);
	for (i = 1; i <= N; i++) {
		sum += abs(A[i+1] - A[i]);
		dif[i] = abs(A[i] - A[i-1]) + abs(A[i+1] - A[i]) - abs(A[i+1] - A[i-1]);
	}
	for (i = 1; i <= N; i++) printf("%d\n", sum - dif[i]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1920
/** @Date    : 2017-07-09 11:36:17
  * @FileName: C 构造.cpp
  * @Platform: Windows
  * @Author  : Lweleth (SoungEarlf@gmail.com)
  * @Link    : https://github.com/
  * @Version : $Id$
  */
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8;


int a[600][600];
int main()
{	
	int n, m;
	int x, y;
	while(cin >> n >> m >> x >> y)
	{
		if(n % x == 0 && m % y == 0)
		{
			printf("No\n");
			continue;
		}
		printf("Yes\n");
		if(n % x == 0)
		for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= m; j++)
			{
				if(j % y == 1)
					a[i][j] = (y - 1) * 2000 - 1;
				else a[i][j] = -2000;
			}
		}
		else
		for(int j = 1; j <= m; j++)
		{
			for(int i = 1; i <= n; i++)
				if(i % x == 1)
					a[i][j] = (x - 1) * 2000 - 1;
				else a[i][j] = -2000;
		}
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= m; j++)
				printf("%d%s", a[i][j], j==m?"\n":" ");
	}

    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int Nmax = 2010;

vector<vector<ll>> C(Nmax, vector<ll>(Nmax));

void PascalTriangle() {

    rep(i, Nmax) {
        C[i][0] = C[i][i] = 1;
    }
    
    for(int i = 2; i < Nmax; i++) {
        for(int j = 1; j < i; j++) {
            C[i][j] = C[i-1][j] + C[i-1][j-1];
            C[i][j] %= mod;
        }
    }
}

int main() {
    int n, k;
    cin >> n >> k;
 
    PascalTriangle();
    
    for(int i = 1; i <= k; i++) {
        ll ans = C[n-k+1][i] * C[k-1][i-1] % mod;
        cout << ans << "\n";
    }
    
    return 0;
}

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

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*b / gcd(a, b);
}

int main(){
	long long a, b;
	while(cin >> a >> b){
		cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
}


Measured memory_bytes: 3092
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int s = 0;
		String n = sc.next();
		for( char ch : n.toCharArray()) {
			s += ch - '0';
			s %= 9;
		}
		
		if( s == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 41020
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let w:f64 = read();
    let h:f64 = read();
    let x:f64 = read();
    let y:f64 = read();

    let area = w * h / 2.0;

    if w / 2.0 == x && h / 2.0 == y {
        println!("{:.012} {}",area, 1);
    }else{
        println!("{:.012} {}",area, 0);
    }

}


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

signed main(void)
{
	int n, i, j;
	cin >> n;
	i = 1;
	j = 0;
	while(i <= n)
	{
		if ((i + 1) * i / 2 >= n)
		{
			j = (i + 1) * i / 2 - n;	
			break;
		}
		i++;
	}
	for(int k = 1; k <= i; k++)
	{
		if (k == j) continue;
		cout << k << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
 
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl
#define DEV_VAL (1000000000 + 7)
 
int main()
{
  string a, b;
  cin >> a >> b;
  ll ans = 0;
  
  rep(i, a.length())
  {
    if(a[i] != b[i])
    {
      ans++;
    }
  }
  cout << ans << endl;
 
 
  return 0;
}

Measured memory_bytes: 3856
#include <iostream>
#include <bits/stdc++.h>
typedef long long ll;
#define lp(i,n) for(ll i = 0;i < ll(n);i++)
#define rlp(i,n) for(ll i = ll(n);i >= 0;i--)
#define rg(i,a,b) for(ll i = ll(a);i <= ll(b);i++)
#define wh(t) while(t)
#define re return
#define pb push_back
#define sz(s) (ll)(s.size())
#define fx(n) fixed<<setprecision(n)
#define NeverGiveUp ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
/*freopen("input.txt","r", stdin);
	freopen("output.txt","w", stdout);*/
using namespace std;
/*ll mx = INT_MIN;
ll mn = INT_MAX;*/
/*ll xd,dx[4]={1,0,-1,0};
ll yd,dy[4]={0,1,0,-1};
bool valid(ll xd,ll yd,ll n,ll m){return xd>-1&&xd<n&&yd>-1&&yd<m;}*/
const int sz = 2e6+5;
const ll md = 1e9+7;
//ll lcm(ll a,ll b){return a*b/__gcd(a,b);}
ll a,b,g,ans=1;
int main()
{
    NeverGiveUp
    cin>>a>>b;
    g=__gcd(a,b);
     if(!(g%2)){
        while(!(g%2))g/=2;
        ans++;
    }
    for(ll j=3;j*j<=g;j+=2){
        if(!(g%j)){
            ans++;
            while(!(g%j))g/=j;
        }
    }
    if(g>1)ans++;
    cout<<ans;
    re 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,m;
  cin >> n >> m;
  if(n==1||m==1){
    if(n==1&&m==1){
      cout << 1 << endl;
    }
    else{
      cout << max(n,m)-2 <<endl;
    }
  }
  else{
    cout << (n-2)*(m-2) << endl;
  }
}

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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;

const long double PI  = 3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

map<vector<int>, ll> mp;

void solve()
{
	ll n;
	cin>>n;
	ll ans = 0;
	rep(i, 0, n)
	{
		string s;
		cin>>s;
		vector<int> v(26, 0);
		for(char x: s)
		{
			ll k = x - 'a';
			v[k]++;
		}
		ans += mp[v];
		mp[v]++;
	}
	cout<<ans<<endl;
}


int main()
{
	ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
    	solve();
    }
    return 0;
}

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

int main(){
  long long N, M;
  cin >> N >> M;
  //ここまで入力

  long long count = 0;
  //c型が不足しているとき
  if(M < 2*N){
    //c型の数に合わせて"scc"を作れる
    cout << M/2 << endl;
    return 0;
  }
  //s型の方が不足しているとき
  else{
    //s型の分を使い切る
    count += N;
    //s型で使った分c型も使う
    M = M - 2*N;
    //c型のみで"scc"を作るには4つ必要
    count += M/4;
  }

  //解答
  cout << count << endl;

  return 0;
}


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

int main(){
  ull n;
  cin >> n;
  ull ans = n-1;
  for(ull i=2;i<=1000000;i++){
    if( i >= n/2 ) break;
    ull num;
    if( n%i == 0 ){
      num = (i-1) + (n/i - 1);
      ans = min(num,ans);
    }
  }
  
  cout << ans << endl;
  return 0;
}


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

int main() {
	multiset<pair<int, int>> W;
	priority_queue<int> B;
	int N, M, a, b;
	cin >> N >> M;
	for (int i = 0;i < N;i++) {
		cin >> a >> b;
		W.insert({ a,b });
	}
	int ans = 0;
	auto it = W.begin();
	for (int i = 0;i < M;i++) {
		while (it != W.end()) {
			if ((*it).first > i + 1)
				break;
			B.push((*it).second);
			it++;
		}
		if (!B.empty()) {
			ans += B.top();
			//cout << i<<" "<<B.top() << endl;
			B.pop();
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5628
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> c(m);
    for (int i = 0; i < m; i++) {
        cin >> c[i];
    }
    // d[i]:i円を作るのに必要な最小枚数
    vector<int> d(n + 1, -1);
    d[0] = 0;
    queue<int> bfs;
    bfs.push(0);
    while (d[n] == -1) {
        int now = bfs.front();
        bfs.pop();
        for (int i = 0; i < m; i++) {
            if (now + c[i] <= n && d[now + c[i]] == -1) {
                d[now + c[i]] = d[now] + 1;
                bfs.push(now + c[i]);
            }
        }
    }
    cout << d[n] << endl;
}


Measured memory_bytes: 3220
# https://atcoder.jp/contests/abc114/tasks/abc114_d

import itertools
from collections import Counter
from collections import defaultdict
import bisect

def solve(primes, index, target):
    if index == len(primes):
        if target == 1:
            return 1
        else:
            return 0
    ans = 0
    for i in range(primes[index] + 1):
        if target % (i + 1) != 0:
            continue
        ans += solve(primes, index + 1, target // (i + 1))

    return ans



def main():
    N = int(input())
    primes = [0] * (N + 1)

    for i in range(N + 1):
        cur = i
        for j in range(2, i + 1):
            while cur % j == 0:
                primes[j] += 1
                cur //= j

    # print(primes)
    print(solve(primes, 0, 75))


if __name__ == '__main__':
    main()


Measured memory_bytes: 55128
#include <iostream>

const int MAXN = (int)2e5;

int a[MAXN];

int main() {
  int n;
  std::cin >> n;
  int xor_sum = 0;
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
    xor_sum ^= a[i];
  }
  for (int i = 0; i < n; ++i) {
    std::cout << (xor_sum ^ a[i]) << " ";
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200005;
const int mod = 1000000007;
int sub[N];
int p[N];
vector<int> adjlist[N];
ll two[N];
int n;
ll exp(int a, int x){
    if (x == 0) return 1;
    ll p = exp(a,x/2);
    p *= p; p %= mod;
    if (x & 1){
        p *= a;
        p %= mod;
    }
    return p;
}
ll ans = 0;
ll f(int x){
    return two[x]-1;
}
void dfs(int u){
    sub[u] = 1;
    //printf("dfs to %d\n",u);
    for (auto v : adjlist[u]){
        if (p[v] == 0) {
            p[v] = u;
            dfs(v);
            sub[u] += sub[v];
        }
    }
   // printf("subtree at %d is size %d\n",u,sub[u]);
    int cur = n-sub[u];
    for (auto v : adjlist[u]){
        if (v == p[u]) continue;
        //printf("%d -> %d: %d %d\n",u,v,sub[v],cur);
        ans += f(sub[v])*f(cur);
        ans %= mod;
        cur += sub[v];
    }
}
int main(){
    scanf("%d",&n);
    two[0] = 1;
    for (int i = 1; i <= n; i++){
        two[i] = (two[i-1]*2)%mod;
    }
    for (int i =0 ; i < n-1; i++){
        int a,b;
        scanf("%d%d",&a,&b);
        adjlist[a].push_back(b);
        adjlist[b].push_back(a);
    }
    p[1] = 1;
    dfs(1);
    //printf("%lld %lld\n",ans,two[n]);
    printf("%lld",(ans*exp(two[n],mod-2))%mod);
}


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

const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

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

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

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

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

const int D = 80 * 160 + 10;
const int D2 = D*2;
typedef bitset<D2> bs;
int a[100][100];
bs dp[90][90];



const int N = 20;
int h;
int w;
vector<vector<char>> maze(N, vector<char>(N,'#'));

const int MAX_WH = 21;
int d[MAX_WH][MAX_WH];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
const int INF = 100000;
int bfs(int x, int y) {
    queue<P> que;
    rep(i,MAX_WH) {
        rep(j,MAX_WH) {
            d[j][i] = INF;
        }
    }
    que.push(P(x,y));
    d[x][y] = 0;

    while (que.size()) {
        P p = que.front(); que.pop();
        for (int i=0; i< 4; i++) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if (0 <= nx && nx < w && 0 <= ny && ny < h && maze[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    int mx = 0;
    rep(i,h) rep(j,w) {
            if (d[j][i] == INF) continue;
            mx = max(mx, d[j][i]);
        }
    return mx;
}

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}
void dfs(){

}
const int MX = 100000;
vector<int> G[MX];

int main(){
    ll h; cin >> h;
    ll ans = 1;
    ll count = 0;
    ll tmp = 1;
    while (tmp <= h) {
        tmp *= 2;
        count++;
    }
    rep(i,count-1){
        ans += pow(2, (i+1));
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4352