akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
long long p(long long a, long long b){
    long long ans = 1;
    while(b > 0){
        if((b&1) == 1) ans = ans*a%mod;
        a = a*a%mod;
        b/=2;
    }
    return ans;
}
long long cal(int a, int b){
    long long ans = 1;
    for(int i=a;i>=a-b+1;i--) ans = ans*i%mod;
    for(int i=1;i<=b;i++) ans = ans*p(i, mod-2)%mod;
    return ans;
}
int main(){
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    long long ans = p(2, n);
    ans = (ans + mod - 1)%mod;
    ans = (ans - cal(n, a) + mod)%mod;
    ans = (ans - cal(n, b) + mod)%mod;
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {

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

		int n = Integer.parseInt(br.readLine());

		System.out.println("0.00000 0.00000");
		koch(0,0,100,0,n);
		System.out.println("100.00000 0.00000");

		br.close();
	}

	static void koch(double x1,double y1,double x2,double y2,int n) {

		if (n == 0)
			return;

		double d = Math.pow(Math.pow(x1-x2,2)+Math.pow(y1-y2,2),0.5)/3;
		double rad = Math.atan2(y2-y1,x2-x1);

		double sx = x1 + Math.cos(rad) * d;
		double sy = y1 + Math.sin(rad) * d;
		double tx = sx + Math.cos(rad) * d;
		double ty = sy + Math.sin(rad) * d;
		double ux = sx + Math.cos(rad + Math.PI/3) * d;
		double uy = sy + Math.sin(rad + Math.PI/3) * d;

		koch(x1,y1,sx,sy,n-1);
		System.out.printf("%.5f %.5f\n",sx,sy);
		koch(sx,sy,ux,uy,n-1);
		System.out.printf("%.5f %.5f\n",ux,uy);
		koch(ux,uy,tx,ty,n-1);
		System.out.printf("%.5f %.5f\n",tx,ty);
		koch(tx,ty,x2,y2,n-1);
	}
}

Measured memory_bytes: 36476
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)



Q = int(input())
B_C = [list(map(int,input().split())) for _ in range(Q)]

tot = sum(A)
cnt = [0] * 100001
for i in A:
    cnt[i] += 1

# print(cnt[:6])

for l in B_C:
    cnt[l[1]] += cnt[l[0]]
    tot += cnt[l[0]] * (l[1] - l[0])
    cnt[l[0]] = 0
    print(tot)


Measured memory_bytes: 32200
from collections import*
h,*t=open(0)
h,w=map(int,h.split())
f,o=1,0
for i in Counter(''.join(t)).values():
    f+=i//4
    o+=i&1
print('YNeos'[o-h%2>h%2*w%2or f-h//4<=h//2*(w//2)::2])

Measured memory_bytes: 3316
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)

typedef long long ll;

void Main()
{
	string s; cin >> s;
	int n = s.size() - 1;
	ll res = 0;
	for (int bit = 0; bit < (1<<n); ++bit) {
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) {
                S.push_back(i + 1);
            }
        }
		int itr = 0;
		S.push_back(n + 1);
		rep(i, S.size())
		{
			string str_num = s.substr(itr, S[i] - itr);
			res += atol(str_num.c_str());
			itr = S[i];
		}
    }
	cout << res << endl;
}

int main()
{
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
}


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

int main() {
  int N, M, a[51], b[51], c[51], d[51];
  cin >> N >> M;
  for (int i = 1; i <= N; i++) cin >> a[i] >> b[i];
  for (int i = 1; i <= M; i++) cin >> c[i] >> d[i];

  for (int i = 1; i <= N; i++) {
    int min = 400000001, ans = 0;

    for (int j = 1; j <= M; j++) {
      int dis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (dis < min) {
        min = dis;
        ans = j;
      }
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 n, m;
        cin >> n >> m;
        vector<int> a(n);
        rep(i, n)cin >> a[i];
        int cnt = 0;
        int th = (accumulate(a.begin(), a.end(), 0)+4*m-1)/(4*m);
        rep(i, n){
                if(a[i]>=th)cnt++;
                if(cnt>=m){
                        cout << "Yes" << endl;
                        return 0;
                }
        }
        cout << "No" << endl;
        return 0;
}

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

ll solve() {
    string S;
    cin >> S;
    int n = S.size();
    if ( S[n-1] != '0' ) return -1;
    if ( S[0] != '1' ) return -1;
    for ( int i = 0; i < (n-1)/2; i++ ) {
        if ( S[i] != S[n-2-i] ) return -1;
    }
    int p = 0;
    for ( int i = 0; i < n-1; i++ ) {
        cout << p+1 << " " << i+2 << "\n";
        if ( S[i] == '1' ) p = i+1;
    }
    return 0;
}

int main() {
    auto ans = solve();
    if ( ans < 0 ) {
        cout << ans << "\n";
    }
    return 0;
}

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

int main()
{
    int n,k,i,temp,temp0 = 0;
    string s;
    cin >> n >> k >> s;
    vector<pair<int,int>> info;
    for(i = 0;i < n;++i){
        if(i == 0){
            temp = s.at(i)-'0';
            info.emplace_back(temp,1);
            if(temp == 0){
                ++temp0;
            }
            continue;
        }
        if(s.at(i)-'0' == temp){
            ++info.at(info.size()-1).second;
        }else{
            info.emplace_back(s.at(i)-'0',1);
            temp = s.at(i)-'0';
            if(temp == 0){
                ++temp0;
            } 
        }
    }
    if(temp0 <= k){
        cout << n << endl;
        return 0;
    }
    vector<int> sum;
    if(info.at(0).first == 0){
        sum.push_back(info.at(0).second+info.at(1).second);
    }else{
        sum.push_back(info.at(0).second+info.at(1).second+info.at(2).second);
    }
    for(i = 2;i < info.size();++i){
        if(info.at(i).first == 1){
            continue;
        }else if(i == (info.size()-1)){
            sum.push_back(sum.at(sum.size()-1)+info.at(i).second);
        }else{
            sum.push_back(sum.at(sum.size()-1)+info.at(i).second+info.at(i+1).second);
        }
    }
    vector<int> anstemp(1,sum.at(k-1));
    for(i = k;i < sum.size();++i){
        if(info.at(((i-k)+1)*2).first == 1){
            anstemp.push_back(sum.at(i)-sum.at(i-k)+info.at(((i-k)+1)*2).second);
        }else{
            anstemp.push_back(sum.at(i)-sum.at(i-k)+info.at(((i-k)+1)*2-1).second);
        }
    }
    int max = 0;
    for(i = 0;i < anstemp.size();++i){
        if(max < anstemp.at(i)){
            max = anstemp.at(i);
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 1908
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){

    int K;
    string S;
    
    cin >> K;
    cin >> S;
    
    if(K>=S.size()) cout << S;
    if(K<S.size()) {
        S = S.substr(0,K) + "...";
        cout << S;
    }
}

Measured memory_bytes: 3620
N=int(input())
R = [ [0,0] for _ in range(N) ]
B = [ [0,0,0] for _ in range(N) ]
for i in range(N):
  R[i][0], R[i][1] = map(int, input().split())
for i in range(N):
  B[i][0], B[i][1] = map(int, input().split())

R.sort(reverse=True)

ans = 0
for i in range(N):
  bmin = 3 * N
  tgtb = -1
  for j in range(N):
    if (B[j][2] == 0) and (R[i][0] < B[j][0]) and (R[i][1] < B[j][1]):
      if bmin > B[j][1]:
        bmin = B[j][1]
        tgtb = j
  if tgtb != -1:
    ans += 1
    B[tgtb][2] = 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=3e3+5;
const int MD=998244353;
int a[N],f[N];
void add(int &x,int y) {
    x+=y;
    if(x>=MD) x-=MD;
}
int main() {
    //freopen("in.txt","r",stdin);
    int n,s;
    scanf("%d%d",&n,&s);
    for(int i=0;i<n;i++) {
        scanf("%d",&a[i]);
    }
    int ans=0;
    for(int i=0;i<n;i++) {
        add(f[0],1);
        for(int j=s;j>=a[i];j--) {
            add(f[j],f[j-a[i]]);
        }
        add(ans,f[s]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
/*input
3 4 240
60 90 120
80 150 80 150
*/
 
 
 
#include <bits/stdc++.h>
using namespace std;
 
 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))
#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
#define F first
#define S second  
#define pb push_back  
#define INF 3e18
#ifdef gaviria
#define TRACE
#endif
#ifdef TRACE
#define trace(...) _f(#VA_ARGS, __VA_ARGS_)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< ll, ll > ii;
typedef unordered_set<int> usi;
 


ll n,i,j,k,m,x;


void solve()
{
    cin>>n>>m>>k;
    int a[n],pre[n+1];
    int b[m];
    vi por(m+1);
pre[0]=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        pre[i+1]=a[i]+pre[i];
    }
    por[0]=0;
    for(i=0;i<m;i++)
    {
        cin>>b[i];
        por[i+1]=b[i]+por[i];
    }


int count=0;
int l=0,r=m;int ans=0;

    for(l=0;l<=n;l++)
    {
        if(pre[l]>k)
            break;

        while(k-pre[l]<por[r])
            r--;
     
      
     ans=max(ans,l+r);
      
       
    }

cout<<ans;


}


 
 
 
signed main()
{
 
    // inputFile;
    // outputFile;
    fast;
    int T = 1;
    // cin >> T;
    // ll h=T;
    while(T--){
 
        solve();
        cout<<endl;
 
     
        
        
 
    }
    
    
    return 0;
 
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    double A, B, H, M;
    cin>> A >> B >> H >> M;
    const double PI=3.14159265358979323846;
    double sita = H * 30+ M * 0.5 - M * 6;
    if(sita < 0) sita += 360;
    double c_2 = A*A + B*B - 2 * A * B * cos(sita/180*PI);
    cout << setprecision(12) << pow(c_2, 0.5) << endl;

}

Measured memory_bytes: 4388
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")

N, M = LI()
A = RI(M)

dp = [0] * (N+10)
dp[0] = 1
j = 0
for i in range(N):
    if j < M and i == A[j]:
        j += 1
        continue

    dp[i+1] = ((dp[i] % MOD) + (dp[i+1] % MOD)) % MOD
    dp[i+2] = ((dp[i] % MOD) + (dp[i+2] % MOD)) % MOD

print(dp[N])


Measured memory_bytes: 44508
#include<iostream>
using namespace std;
int main(){
    int x,a,b;
    cin>>x>>a>>b;
    int s=b-a;
    if(a-b>=0) cout<<"delicious"<<endl;
    else if(abs(a-b)<=x)cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
    return 0;
}
/*
4 3 6
33
6 5 1
-4
3 7 12
5
*/


Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
//In the name of Allah the Most Merciful
//Astagfirullahil laji Rabbi Minkulli Jamio
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
int i,j,k;
 main()
 {
     map<string ,int> m;
     int n;cin>>n;
     for(i=0;i<n;i++)
     {
         string s;cin>>s;
         m[s]++;
     }
     cout<<"AC x "<<m["AC"]<<endl;
     cout<<"WA x "<<m["WA"]<<endl;
     cout<<"TLE x "<<m["TLE"]<<endl;
     cout<<"RE x "<<m["RE"]<<endl;

 }


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

int f(int n) {
    if (n % 2 == 0) return n / 2;
    else return 3 * n + 1;
}

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

    set<int> S;
    S.insert(s);

    for (int i = 1; i <= 1e6; i++) {
        s = f(s);
        if (S.count(s)) {
            cout << i + 1 << endl;
            return 0;
        } else {
            S.insert(s);
        }
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll S,xa=1e9,xb=1,ya=1,yb=1;
  cin >> S;
  xb = (xa-S%xa)%xa;
  yb = (S+xb)/xa;
  cout << "0 0 1 1000000000 " << yb << " " << xb << endl; 
}

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

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;i++)

void dfs(int index);

int r, c, maxsnb;
int snb[10][10000];

int main() {

	while(true) {

		scanf("%d %d", &r, &c);

		if (r==0 && c==0) break;

		REP(i,r)REP(j,c) {
			scanf(" %d", &snb[i][j]);
		}

		maxsnb = 0;

		dfs(0);

		printf("%d\n", maxsnb);

	}

	return 0;
}

void dfs(int index) {
	if (index<r) {
		dfs(index+1);
		REP(i,c) {
			snb[index][i] = (snb[index][i]+1)%2;
		}
		dfs(index+1);
	} else {
		int total = 0;
		REP(i,c) {
			int total_ = 0;
			REP(j,r) {
				total_ += snb[j][i];
			}
			total += max(total_, r-total_);
		}
		maxsnb = max(maxsnb, total);
	}
}

Measured memory_bytes: 1576
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  vector<ll> s(n+1);
  vector<ll> m(n+1);
  s[0]=0;
  m[0]=0;
  rep(i,n) cin>>a[i];
  rep1(i,n){
    s[i]=a[i-1]+s[i-1];
    m[i]=(s[i]-i)%k;
  }
  /*
  for(auto x:s) cout << x << " ";
  cout << endl;
  for(auto x:m) cout << x << " ";
  cout << endl;
  */

  ll ans=0;
  unordered_map<ll,ll > um;
  for( ll i=0;i<=n;i++ ){

    ll x=m[i];
    //cout << x << endl;
    if(i>=k){
      ll de=m[i-k];
      um[de]--;
    }
    if(um.find(x)!=end(um)) ans+=um[x];

    um[x]++;
    

  }

  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

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

int main() {
	int n; cin >> n;
	vector<int> p(n, 0);
	for(int i = 0; i < n; i++) cin >> p[i];
	sort(p.begin(), p.end());
	int sum = 0;
	for(int i = 0; i < n-1; i++) sum += p[i];
	sum += (p[n-1] / 2);
	cout << sum << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int f(int b, int n) {
  int ret = 0;
  while (n) {
    ret += n % b;
    n /= b;
  }
  return ret;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, s;
  cin >> n >> s;
  if (s == n) {
    cout << n + 1 << endl;
    return 0;
  } else {
    rep(b, 2, 1+sqrt(n + 1)) {
      if (f(b, n) == s) {
        cout << b << endl;
        return 0;
      }
    }
    int ans = INF;
    rep(p, 1, 1+sqrt(n)) {
      if ((n - s) % p == 0) {
        int b = 1 + (n - s) / p;
        if(b==1||b==0)continue;
        if (f(b, n) == s) {
          chmin(ans, b);
        }
      }
    }
    if (ans == INF)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }

  return 0;
}


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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> L(N);
  
  for (int i=0;i<N;i++) {
    cin >> L.at(i);
  }
  
  int MAX=0,sum=0;
  for (int i=0;i<N;i++) {
    MAX = max(MAX,L.at(i));
    sum += L.at(i);
  }
  
  if (MAX < sum - MAX)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
  

Measured memory_bytes: 256
n, m = map(int, input().split())
s = [list(map(int, input().split()))[1:] for i in range(m)]
p = list(map(int, input().split()))


count = 0
for i in range(2**n):
    for j in range(m):
        swich_on = 0
        for k in range(len(s[j])):
            swich_on += (i >> (s[j][k] - 1)) & 1
        if swich_on % 2 != p[j]:
            break
    else:
        count += 1
print(count)

Measured memory_bytes: 39920
n = int(input())
#a, b = map(int,input().split())
al = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

dic = {}
for a in al:
    dic[a] = dic.get(a, 0)+1

mx = max(al)
mn = min(al)
ans = 0
for x in range(mn, mx+1):
    ans = max(ans, dic.get(x+1, 0)+dic.get(x, 0)+dic.get(x-1, 0))
print(ans)


Measured memory_bytes: 20892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
const double PI = acos(-1.0);
double a, b, x;
double ans;

int main() {
	scanf("%lf %lf %lf", &a, &b, &x);
	double vh = a * a * b * 0.5;
	if(x == vh) ans = atan(b / a);
	else if(x < vh) {
		double c = x * 2 / (a * b);
		ans = atan(b / c);
	}
	else {
		double v = a * a * b - x;
		double l = v * 2 / (a * a);
		ans = atan(l / a);
	}
	printf("%.10lf\n", ans * 180 / PI);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define ld          long double


void solve() 
{
    ll m, d; cin>>m>>d;
    ll ans=0;
    for(ll i=4; i<=m; i++)
    {
        for(ll j=22; j<=d; j++)
        {
            ll d0=j%10, d1=j/10;
            if(d0>=2 and d1>=2 and d0*d1==i) ans++;
        }
    }
    cout<<ans<<endl;
} 
 
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);  
	ll T = 1; 
	//cin>>T;   
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

using R = double;
vector<R> dp1, dp2;
vector<vi> graph;

R dfs1(int v, int pv){
    R& cur = dp1[v];
    cur = (R)0;

    int cnt = 0;
    for(auto& nv : graph[v]){
        if(nv == pv) continue;

        cur += (dfs1(nv, v) + 1);
        cnt++;
    }
    if(cnt > 0) cur /= (graph[v].size() - 1);

    return cur;
}

R dfs2(int v, int pv, R par_val){
    R& cur = dp2[v];
    cur = par_val + (pv != -1 ? 1:0);

    int cnt = (pv != -1 ? 1:0);
    for(auto& nv : graph[v]){
        if(nv == pv) continue;
        cur += (dp1[nv] + 1);
        cnt++;
    }
    cur /= cnt;

    for(auto& nv : graph[v]){
        if(nv == pv) continue;
        R nval = cur * cnt;
        nval -= (dp1[nv] + 1);
        if(cnt - 1 > 0) nval /= (cnt - 1);
        dfs2(nv, v, nval);
    }

    return cur;
}

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

    int n; cin >> n;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }

    dp1 = dp2 = vector<R>(n, -1);
    graph = vector<vi>(n);
    rep(loop, n - 1){
        int u, v; cin >> u >> v;
        u--, v--;
        graph[u].emplace_back(v);
        graph[v].emplace_back(u);
    }

    dfs1(0, -1);
    dfs2(0, -1, 0.0);

    cout.precision(20);
    rep(i, n){
        cout << fixed << dp2[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 20096
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define mx 100005
#define ll long long
#define mod 1000000007

int ar[mx];
char ch[mx];

int n,m;

void solve()
{
   string s;
   cin>>s;
   (s=="ABC")?cout<<"ARC\n":cout<<"ABC\n";
}

int main()
{
    int t=1;
   // scanf("%d",&t);
    while(t--)solve();
    return 0;
}



Measured memory_bytes: 3628
#include <stdio.h>
int main(void){
    int r,c,i,j;
    scanf("%d %d",&r,&c);
    int a[100+1][100+1]={};
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            printf("%d ",a[i][j]);
            a[i][c]=a[i][c]+a[i][j];
        }
        printf("%d",a[i][c]);
        putchar('\n');
        a[i][c]=0;
    }
    for(j=0;j<c;j++){
        for(i=0;i<r;i++){
            a[r][j]=a[r][j]+a[i][j];
            a[r][c]=a[r][c]+a[i][j];
        }
        printf("%d ",a[r][j]);
        a[r][j]=0;
    }
    printf("%d\n",a[r][c]);
    return 0;
}



Measured memory_bytes: 2112
#include<stdio.h>

int n, A[50];

int solve(int i, int m)
{
    if (m == 0) return 1;
    if (i >= n) return 0;
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main()
{
    int q, M, i;

    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i = 0; i < q; i++)
    {
        scanf("%d", &M);
        if (solve(0, M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define f first
#define s second
#define m 1000000007

signed main()
{

   int n,k,ans=0;
   cin>>n>>k;

    for(int i=k;i<=n+1;i++)
    {
     int p=((i-1)*i/2)%m;
     int k1=n-i;
     int q=((n*(n+1)/2)%m-((k1*(k1+1))/2)%m+m)%m;
     ans=(ans%m+(q%m-p%m+m+1)%m)%m;
     //cout<<p<<" "<<q<<" "<<ans<<endl;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  rep(i, 4) {
    if (S[i] == '+')
      ans++;
    else
      ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int ans,h,w,n;
  scanf("%d\n%d\n%d\n",&h,&w,&n);
  if(h>w && n%h==0){
    ans=n/h;
  }
  else if(h>w){
    ans=n/h+1;
  }
  else if(w>=h && n%w==0){
    ans=n/w;
  }
  else{
    ans=n/w+1;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define CAT(a,b)a b
#define VASIZE(a,b,N,...)N
template<class T>auto size(T&&a)->decltype(a.size(), int()) { return a.size(); }
template<class T>typename make_signed<decltype(T() % 0)>::type size(T a) { return a; }
#define REP(t,a,N)for(decltype(size(N))t=size(a),_l##t=size(N);t<_l##t;t++)
#define RREP(t,a,N)for(decltype(size(N))t=size(N)-1,_l##t=size(a);t>=_l##t;t--)
#define rep(t,...)CAT(REP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define rrep(t,...)CAT(RREP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define all(a)begin(a),end(a)

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

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

void Calc() {
  map<char, int> m;
  string s = in;
  for (auto& i : s) {
    m[i]++;
  }

  bool ok = true;
  if (m['N'] != 0 && m['S'] != 0 || m['N'] == 0 && m['S'] == 0) {
  } else {
    ok = false;
  }
  if (m['W'] != 0 && m['E'] != 0 || m['W'] == 0 && m['E'] == 0) {
  } else {
    ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
}


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

typedef long long ll;

int main(){
    char s;
    cin >> s;

    if(s == 'a'||s=='i'||s=='o'||s=='u'||s=='e'){
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int h=n/3600;
        int m=(n%3600)/60;
        int s=(n%3600)%60;
        
        System.out.println(h+":"+m+":"+s);
        
    }
}


Measured memory_bytes: 26232
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;
int mod = 1e9+7;
int inf = 1e18;
const int N = 5e5+999;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int ncr(int n,int r)
{
    int ans=1;
    for(int i=1;i<=r;++i)
    {
        ans = (((ans*n)%mod)*(powmod(i,mod-2)))%mod;
        n--;
    }
    return ans;

}
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
      int n,a,b;
      cin>>n>>a>>b;
      int x = powmod(2,n);
      x-=1;
      x = (x-ncr(n,a)+mod)%mod;
      x = (x-ncr(n,b)+mod)%mod;
      cout<<x<<el;

    }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n; string s;
	cin >> n;
	cin >> s;
	int ans = 0;
	for (int i = 1; i < n; i++) {
		int len = 0;
		for (int j = 0; j < n - i; j++) {
			if (s[j] == s[j + i]) {
				len++;
				len = min(i, len);
				ans = max(ans, len);
			}
			else {
				len = 0;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
n, a, b = gets.chomp.split.map(&:to_i)
arr = []
n.times{arr << gets.to_i}

l, r = 0, 10**9 # 10**9+1ってやってたけど、取り得る最大値でいいのか...
while r-l >= 1 do # r-l>1にしてたんだけどダメなのか
  mid = (l+r)/2
  # mid回と仮定して計算
  count = 0
  temp_arr = arr.map{|x|x-mid*b}
  # 体力が残っているやつをA-Bで何回で倒せるかカウント
  # （A>BかつBで叩き済みなので差で殴る）
  temp_arr.each do |x|
    next if x<=0  # 死んでいる
    count += x%(a-b)>0 ? x/(a-b) + 1 : x/(a-b)
    # count += x/(a-b)
  end
  if mid < count
    # まだ叩けるので増やす
    l = mid +1
  else
    # 叩きすぎたので減らす
    r = mid
  end
end
puts (r+l)/2

Measured memory_bytes: 26548
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  char a[2];
  int x[2];
  cin>>a[0]>>a[1];
  rep(i,2){
    if('A'<=a[i] && a[i]<='F')x[i]=a[i]-'A'+10;
    else x[i]=a[i]-'0';
  }
  if(x[0]<x[1])cout<<"<"<<endl;
  else if(x[0]>x[1])cout<<">"<<endl;
  else cout<<"="<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
double cal_estimate(int a)
{
  double b=0.0;
  for(int j=1;j<=a;j++) b+=(double)j;
  b/=(double)a;
  return b;
}
int main(void)
{
  int n,k;
  scanf("%d%d",&n,&k);
  double estimate[n+1],ruiseki[n+1];
  for(int i=1;i<=n;i++){
    int tmp;
    scanf("%d",&tmp);
    estimate[i]=cal_estimate(tmp);
  }
  double tmp_k,ans=0.0;
  estimate[0]=ruiseki[0]=0;
  for(int i=1;i<=n;i++) ruiseki[i]=ruiseki[i-1]+estimate[i];
  for(int i=k;i<=n;i++){
    tmp_k=ruiseki[i]-ruiseki[i-k];
    if(tmp_k>=ans) ans=tmp_k;
  }
  //for(int i=1;i<=n;i++) printf("%lf\n",estimate[i]);
  printf("%lf",ans);
  return 0;
}

Measured memory_bytes: 3328
n,x=int(input()),input()
o=x.count("1")
if o==1:
    for i,v in enumerate(x):
        if v=="1":print(0)
        else:
            if i!=n-1:
                if x[-1]=="0":print(1)
                else:print(2)
            else:print(2)

else:
    m=o-1
    M=o+1
    mp,mm={0:1},{0:1}
    for i in range(1,n):
        mp[i]=mp[i-1]*2%M
        mm[i]=mm[i-1]*2%m
    A=int(x,2)
    a=A%m
    b=A%M
    rest={0:0}
    for i in range(1,o+1):
        rest[i]=1+rest[i%bin(i).count("1")]
    for i,v in enumerate(x):
        if v=="1":
            print(1+rest[(a-mm[n-i-1])%m])
        else:
            print(1+rest[(b+mp[n-i-1])%M])


Measured memory_bytes: 61952
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    int n,k,ans=0,sum=0;
    int l[100];
    //bool flag=false;

    cin >> n >> k;

    for(int i=0;i<n;i++){
        cin >> l[i];
    }

    sort(l,l+n,greater<int>());

    for(int i=0;i<k;i++){
        ans+=l[i];
    }

    //cout << (flag ? "Yes" : "No") << endl;
    cout << ans << endl;
    //printf("%.10f",ans_d);cout<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef pair<int,int> P;
typedef vector<P> VP;

int dx[] = {+0,-1,-1,+0,+1,+1};
int dy[] = {-1,-1,+0,+1,+1,+0};
int N,C;

void dfs(VVI &G,VVB &used,int x,int y,int c)
{
  if(used[y][x])return;
  used[y][x] = true;

  rep(i,8)
    {
      int nx = x+dx[i];
      int ny = y+dy[i];
      if(!(0 <= ny && ny < N && 0 <= nx && nx < G[ny].size()))continue;
      if(used[ny][nx])continue;
      if(G[ny][nx] != c)continue;
      dfs(G,used,nx,ny,c);		      
    }

}

int Count(VVI &G,VVB &used)
{
  int ret = 0;
  rep(i,N)
    {
      rep(j,i+1)
	{
	  if(used[i][j])continue;
	  if(G[i][j] == 0)continue;
	  //cout << "yes " << j << " " << i << endl; 
	  if(G[i][j] == C)ret--;
	  else            ret++;
	}
    }
  return ret;
}


int main()
{
  while(cin >> N >> C,N|C)
    {
      VP zero;
      VVI G(N);
      rep(i,N)
	{
	  G[i].resize(i+1);
	  rep(j,i+1)
	    {
	      cin >> G[i][j];
	      if(G[i][j] == 0)
		zero.push_back(P(j,i));
	    }
	}

      int ans = -(1<<29);
      rep(i,N)
	{
	  rep(j,i+1)
	    {
	      if(G[i][j] != 0)continue;	 
	      G[i][j] = C;
	      VVB used(N);
	      rep(k,N)
		{//init
		  used[k].resize(k+1);
		  rep(l,k+1)
		    used[k][l] = false;
		}//init

	      int zeroSize = zero.size();
	      rep(k,zeroSize)
		{
		  P p = zero[k];
		  if(p.F == j && p.S == i)continue;
		  rep(l,6)
		    {
		      int nx = p.F+dx[l];
		      int ny = p.S+dy[l];
		      if(!(0 <= ny && ny < N && 0 <= nx && nx < G[ny].size()))continue;
		      dfs(G,used,nx,ny,G[ny][nx]);
		    }
		}

	      int cnt = Count(G,used);
	      //cout << "cnt = " << cnt << endl;
	      ans = max(ans,cnt);

	      G[i][j] = 0;
	    }
	}

      cout << ans << endl;

    }
  return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>
#include <string.h>
long long int d = 1000000007ll;

long long int pow(long long int m, long long int n){
	long long int res;
	if(n == 0) return 1;
	res = pow((m*m)%d, n/2);
	if(n % 2){
		res = (res*m)%d;
	}
	return res;
}

int main(void) {
	long long int n;
	int m;
	
	scanf("%d%lld", &m, &n);
	
	printf("%lld\n", pow(m, n));
	
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    vector<vector<int> > t;
    t.resize(n);
    REP(i,n) t[i].resize(n+1);
    REP(i,n) REP(j,n+1) cin >> t[i][j];
    vector<int> dp;
    dp.assign(1<<n,33554432);
    dp[0]=0;
    REP(bi,1<<n){
      REP(ne,n){
	if((1<<ne)&bi) continue;
	int nebi=((1<<ne)|bi);
	int cost=t[ne][0];
	REP(wep,n) if((1<<wep)&bi) cost=min(cost,t[ne][wep+1]);
	dp[nebi]=min(dp[nebi],dp[bi]+cost);
      }
    }
    cout << dp[(1<<n)-1] << endl;
  }
}

Measured memory_bytes: 1460
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int N;
  std::cin >> N;
  vt<std::string> s(N);
  vt<ll> tl(N);

  rep(i,N){
    std::string moji;
    std::cin >> moji;
    sort(moji.begin(),moji.end());
    s[i] = moji;
  }
  sort(s.begin(),s.end());

  int k = 0;
  for (int i = 0; i < N-1; i = k) {
    for(int j = i+1; j < N; j++){
      if(s[i] == s[j]) {
        tl[i]++;
        k = j;
      }
      else{
        ++k;
        break;
      }
    }
  }

  ll ans = 0;
  rep(i,N) {
    if(tl[i] != 0)
      ans += (tl[i]+1)*tl[i]/2;
  }

  std::cout << ans << '\n';
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  set<int> a;
  bool ok = true;
  rep(i, n) {
    int at;
    cin >> at;
    if(a.count(at) == 0) a.insert(at);
    else ok = false;
  }
    
  if(ok) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 12956
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;

int main(){
  ll n;cin>>n;
  string s;cin>>s;
  ll w=0,b=0,ans=MOD,lb=0,lw=0;
  rep(i,0,n){
    if(s[i]=='#')b++;
    else w++;
  }
  ans=w;
  rep(i,0,n){
    if(s[i]=='#'){
      lb++;
      
    }
    else lw++;
    ans=min(ans,lb+w-lw);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3756
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define REPR(i, n) for(int i = n - 1; 0 <= i; i--)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define FORR(i, s, e) for(int i = s; e <= i; i--)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    int r, D, x;
    cin >> r >> D >> x;
    REP(i, 10) {
        x = r * x - D;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;
namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var asc = ReadStringArray();
            Console.WriteLine($"A{asc[1][0]}C");
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }

}


Measured memory_bytes: 11092
#!/usr/bin/env python3
import sys


def solve(N: int, X: int, L: "List[int]"):
    d = 0
    ret = 1
    for l in L:
        d += l
        if d <= X:
            ret += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    L = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, X, L)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MOD(x) ((x)%mod)
int n,m;
long long a[300005];
long long b[300005];
long long c[300005];
long long sum1,sum2;
long long ans;
priority_queue<long long , vector<long long> , greater<int> >q1;
priority_queue<long long , vector<long long> , less<int> >q2;
int main()
{
	scanf("%d",&n);
	m=3*n;
	for(int i=1;i<=m;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=m;i++)
	{
		if(q1.size()<n)
		{
			q1.push(a[i]);
			b[i]=b[i-1]+a[i];
		}
		else
		{
			if(a[i]>q1.top())
			{
				b[i]=b[i-1]-q1.top()+a[i];
				q1.pop();
				q1.push(a[i]);
			}
			else b[i]=b[i-1];			
		}
	}
	for(int i=m;i>=1;i--)
	{
		if(q2.size()<n)
		{
			q2.push(a[i]);
			c[i]=c[i+1]+a[i];
		}
		else
		{
			if(a[i]<q2.top())
			{
				c[i]=c[i+1]-q2.top()+a[i];
				q2.pop();
				q2.push(a[i]);
			}
			else c[i]=c[i+1];
		}
	}
	bool sign=0;
	for(int i=n;i<=2*n;i++)
	{
		if(sign==0)
		{
			ans=b[i]-c[i+1];
			sign=1;
		}
		else ans=max(ans,b[i]-c[i+1]);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 8948
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    int a,b,c; 
    cin >> a >> b >> c;

    cout << min(b/a,c) << endl;; 

    return 0;
}




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


using namespace std;
typedef long long ll;

int N, M, C = 0;

int main(){

    cin >> N >> M >> C;

    vector<int > B;

    int t = 0;
    for(int i = 0; i < M; i++){
        cin >> t;
        B.push_back(t);
    } 


    int total = 0;
    int num = 0;

    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> t;
            total += B[j] * t;
        } 
        if(total + C > 0){
            num++;
        }
        total = 0;
    } 

    cout << num << endl;
    
}

Measured memory_bytes: 256
class NormalInput{
  input: string[];
  pointer: number;
  constructor(raw:string){
    this.input=raw.split(/ |\n/);
    this.pointer=0;
  }
  int():number{
    const ret= parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  }
  str():string{
    const ret= this.input[this.pointer];
    this.pointer++;
    return ret;
  }
  strs(length:number):string[]{
    let ret:string[]=[];
    for(let i=0;i<length;i++){
      ret.push(this.str());
    }
    return ret;
  }
  ints(length:number):number[]{
    let ret:number[]=[];
    for(let i=0;i<length;i++){
      ret.push(this.int());
    }
    return ret;
  }
}
function Main(_: NormalInput) {
  const [A,B]=[_.int(),_.int()];
  console.log(Math.max(A+B,A-B,A*B));
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
X=int(input())
five=[i**5 for i in range(1000) ]
flg=0
for i in range(len(five)):
    for j in range(len(five)):
        if five[i]+five[j]==X:
            flg=1
            ans_1=i
            ans_2=-j
        if five[i]-five[j]==X:
            ans_1=i
            ans_2=j
print(ans_1,ans_2)

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class a, int N, class T>
void fillArray(a(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


long double a, b, c;
void solve() {
    cin >> a >> b >> c;
    if (a + b + 2 * sqrt(a * b) < c) cout << "Yes" << endn;
    else cout << "No" << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
all_set = set([chr(97+i) for i in range(26)])

if len(S)<26:
    raw_set = set(S)
    lis = list(all_set - raw_set)
    lis.sort()
    S.append(lis[0])
    print(''.join(S))
else:
    can_use = set()
    p = S[-1]
    can_use.add(p)
    for i in range(24, -1, -1):
        nx = S[i]
        if ord(nx)<ord(p):
            for c in sorted(list(can_use)):
                if ord(nx)<ord(c):
                    break
            S = S[:i]+[c]
            print(''.join(S))
            break
        else:
            can_use.add(nx)
            p = nx
    else:
        print(-1)

Measured memory_bytes: 61872