akhauriyash/Code-Regression huggingface dataset:
n, m, c = map(int, input().split())
b = [int(_) for _ in input().split()]

res = 0
for i in range(n):
  a = [int(_) for _ in input().split()]
  if c + sum([j * k for j, k in zip(a, b)]) > 0:
    res += 1
print(res)

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

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))


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

template <class T> inline T gcd(T a, T b) { while (b) { a = a%b; swap(a, b); } return a; }

using namespace std;


int main()
{
	string  n;
	cin >> n;

	int bit = 1;
	int res = 0;
	for (int i = 0; i < n.size(); i++)
	{
		if (n[i] - '0' != bit) {
			res++;
		}

		bit = bit ^ 1;
	}

    bit = 0;
	int res2 = 0;
	for (int i = 0; i < n.size(); i++)
	{
		if (n[i] - '0' != bit) {
			res2++;
		}

		bit = bit ^ 1;
	}

	cout << min(res, res2) << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define ppll pair <pll, pll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
// yesterday was a series of blunders.
// first failed to properly implement E (which was just really basic dp/brute force), 
// then failed to realize that F is just basic centroid decomposition + dsu.
// (if I could just decently implement that in contest time... 2100 is within reach...)
// such mistakes cannot repeat again.
ll mod = 998244353;
ll fact[300005];
ll binpow(ll a, ll b) {
	if (b == 0) return 1;
	ll x = binpow(a, b/2);
	x *= x; x %= mod;
	if (b % 2) return (x * a) % mod;
	else return x;
}
ll bindiv(ll a, ll b) {
	ll inv = binpow(b, mod - 2);
	return (a * inv) % mod;
}
ll nck(ll n, ll k){
	ll x = (fact[k] * fact[n - k]) % mod;
	return bindiv(fact[n], x);
}
int main(){
	fastio;
	fact[0] = 1; for (ll i = 1; i<300005; i++) fact[i] = (fact[i-1] * i) % mod;
	ll n, a, b, k; cin >> n >> a >> b >> k;
	ll ans = 0;
	for (ll i = 0; i<=n; i++){
		ll j = k - a * i; j /= b;
		if (j <= n && j >= 0 && a * i + b * j == k) (ans += nck(n, i) * nck(n, j)) %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#define rep(i, s, t) for(i = s; i <= t; ++i)
 
const int P = 1e9 + 7;
 
typedef long long LL;
int n, ans;
 
inline int calc(int x) {
	if(x < 10) return 1;
	if(x < 100) return 2;
	if(x < 1000) return 3;
	if(x < 10000) return 4;
	if(x < 100000) return 5;
	if(x < 1000000) return 6;
	if(x < 10000000) return 7;
	return 8;
}
 
int lp(int a, int b) {
	int ret = 1;
	for(; b; b >>= 1, a = (LL)a * a % P)
		if(b & 1) ret = (LL)ret * a % P;
	return ret;
}
 
int main() {
	int i, l, r, t;
	scanf("%d", &n);
	rep(i, 1, n / 8) {
		if(!(n%i)) ans = (ans + 9ll*lp(10,n/i-1)%P - i + 1 + P) % P;
		else ++ans;
	}
	t = 0;
	for(l = 1, r = 1; calc(l) <= 7; ++l) {
		for(; t < n; ++r) t = t + calc(r);
		if(t == n) ++ans;
		t -= calc(l);
	}
	printf("%d\n", ans % P);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A=sc.nextInt(),B=sc.nextInt(),C=sc.nextInt(),D=sc.nextInt();
        System.out.println((C-1)/B<=(A-1)/D?"Yes":"No");
    }
}

Measured memory_bytes: 35784
N,K=map(int,input().split())
A=list(map(int,input().split()))

cnt=0
for i in range(len(A)-1):
	for j in range(i+1,len(A)):
		if A[i]>A[j]:cnt+=1

d={}
B=sorted(A)
for a in B:
	if a not in d:d[a]=1
	else:d[a]+=1

PP=10**9+7
y=0
t=0
for a in d:
	y+=(t*d[a])%PP
	t+=d[a]
print((((cnt*K)%PP+(y*(K*(K-1)//2))%PP))%PP)


Measured memory_bytes: 3316
import sys
sys.setrecursionlimit(100000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():  
    A,B,C,K = map(int,input().split())
    if K <= A:
        ans = K
    elif K <= A + B:
        ans = A
    else:
        ans = A - (K - A - B)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
    int n,i;
    cin>>n;
    map<ll,ll> mp;
    ll a[n];
    ll ans=0;
    for(i=0;i<n;i++)
    {cin>>a[i];
        mp[a[i]]++;
    }
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        ll p=it->ss;
        ans+=(p*(p-1))/2;
    }
    ll ans1=0;
    for(i=0;i<n;i++)
    {
        ll p=mp[a[i]];
        ans1=ans-max(0LL,(p*(p-1))/2);
        p--;
        ans1=ans1+max(0LL,(p*(p-1))/2);
        cout<<ans1<<e;
    }
}


Measured memory_bytes: 11136
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
    unsigned short *A, *B;

    int C[VMAX + 1];
    int n, i, j;
    scanf("%d", &n);

    A = (unsigned short *)malloc(sizeof(short) * n + 1);
    B = (unsigned short *)malloc(sizeof(short) * n + 1);

    for(i=0; i<=VMAX; i++) C[i] = 0; //カウンタ配列の初期化

    for(i=0; i<n; i++){
        scanf("%hu", &A[i+1]);
        C[A[i + 1]]++;
    }

    for(i=1; i<=VMAX; i++) C[i] = C[i] + C[i-1];

    for(j=1; j<=n; j++){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }

    for(i=1; i<=n; i++){
        if(i>1) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 10540
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main()
{
    int n,m;
    cin >> n >> m;
    map<int,int> mp;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        mp[a]++;mp[b]++;
    }
    bool ok = true;
    rep(i,n){
        if(mp[i]%2){
            ok = false;
            break;
        }

    }
    if(ok)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()

bool isprime(int t) {
  for(int j = 2; j < sqrt(t); j++) {
    if(t % j == 0)
      return false;
  }
  return true;
}

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

  int x;
  cin >> x;
  
  for(int i = x; ; i++) {
    if(isprime(i)) {
      cout << i << "\n";
      return 0;
    }
  }
}

Measured memory_bytes: 256
const M: i64 = 1000_000_007;

fn main() {
    proconio::input! {
        n: usize,
        mut k: usize,
        mut a: [i64; n],
    }

    let mut r = 1;
    if k == n {
        let mut m = false;
        for i in 0..k {
            m ^= a[i] < 0;
            r = r * a[i].abs() % M;
        }
        if m {
            r = M - r;
        }
    } else {
        let mut p = Vec::new();
        let mut z = 0;
        let mut m = Vec::new();

        a.sort();
        for i in 0..n {
            if a[i] > 0 {
                p.push(a[i]);
            } else if a[i] == 0 {
                z += 1;
            } else {
                m.push(a[i].abs());
            }
        }

        let plen = p.len();
        let mlen = m.len();
        if k > plen + mlen {
            r = 0;
        } else {
            if plen == 0 {
                if k > mlen {
                    r = 0;
                } else {
                    if k % 2 == 1 {
                        if z > 0 {
                            r = 0;
                        } else {
                            for i in 0..k {
                                r = r * m[mlen - 1 - i] % M;
                            }
                            r = M - r;
                        }
                    } else {
                        for i in 0..k {
                            r = r * m[i] % M;
                        }
                    }
                }
            } else {
                let plen = if k % 2 == 1 {
                    r = r * p[plen - 1] % M;
                    k -= 1;
                    plen - 1
                } else {
                    plen
                };

                if plen > 0 {
                    let mut pi = plen;
                    if mlen >= 2 {
                        let mut mi = 0;
                        while k >= 2 && pi >= 2 && mi <= mlen - 2 {
                            if m[mi] * m[mi + 1] >= p[pi - 1] * p[pi - 2] {
                                r = r * (m[mi] * m[mi + 1] % M) % M;
                                mi += 2;
                                k -= 2;
                            } else {
                                r = r * p[pi - 1] % M;
                                pi -= 1;
                                k -= 1;
                            }
                        }
                        while k >= 2 && mi <= mlen - 2 {
                            r = r * (m[mi] * m[mi + 1] % M) % M;
                            mi += 2;
                            k -= 2;
                        }
                    }
                    while k > 0 {
                        r = r * p[pi - 1] % M;
                        pi -= 1;
                        k -= 1;
                    }
                } else {
                    for i in 0..k {
                        r = r * m[i] % M;
                    }
                }
            }
        }
    }
    println!("{}", r);
}


Measured memory_bytes: 8104
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			for(;;) {
				int h = sc.nextInt();
				int w = sc.nextInt();
				if(h==0&&w==0) break;
				for(int i=0; i<h; i++) {
					for(int j=0; j<w; j++) {
						System.out.print((i+j)%2==0?"#":".");
					}
					System.out.println();
				}
				System.out.println();
			}
		}
	}
}


Measured memory_bytes: 35524
/*
[agc025] C - Interval Game
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 100000;
const int C = MAX_N;

int N;
int l[MAX_N], r[MAX_N];
int sl[2 * MAX_N + 1], sr[2 * MAX_N + 1];

ll solve() {
    sl[C]++;
    sr[C]++;
    for (int i = 0; i < N; i++) {
        sl[C + r[i]]++;
        sr[C + l[i]]++;
    }
    for (int i = 1; i <= 2 * C; i++) {
        sl[i] += sl[i - 1];
    }
    for (int i = 2 * C - 1; i >= 0; i--) {
        sr[i] += sr[i + 1];
    }

    ll ans = 0;
    for (int i = 0; i < 2 * C; i++) {
        ans += min(sl[i], sr[i + 1]) * 2;
    }

    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 2560
import sys
readline = sys.stdin.readline
write = sys.stdout.write

n = int(input())
G = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(n):
    temp = list(map(int, readline().split()))
    for j in range(temp[1]):
        G[temp[0]][temp[j+2]] = 1

for i in range(1, n+1):
    for j in range(1, n):
        write(str(G[i][j]) + " ")
    write(str(G[i][n]) + "\n")


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

using namespace std;

int main(){
    int N, T;
    int tm, cost;
    int min;
    int sw = 0;
    scanf("%d %d", &N, &T);

    for(int i = 0; i < N; i++){
        scanf("%d %d", &cost, &tm);
        if(tm <= T && sw == 0){
            min = cost;
            sw = 1;
        }else if(tm <= T && cost < min){
            min = cost;
        }
    }
    if(sw == 0){
        printf("TLE\n");
    }else{
        printf("%d\n", min);
    }

    return 0;
}

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

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using VVI = vector<vector<int>>;
using VVL = vector<vector<long>>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}

template <class T>
void PrintVector(const vector<T> & v, I n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}

int main(int argc, char const *argv[]) {
  I n;
  I ans = 0;
  cin >> n;
  VI a(n, 0);
  rep(i, 0, n - 1) {
    cin >> a[i];
  }
  if (n % 2 == 1) a.pb(0);
  sort(a.begin(), a.end(), greater<int>());
  rep(i, 0, (n - 1) / 2) {
    ans += a[i * 2];
    ans -= a[i * 2 + 1];
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n;
  in(n);
  out(3 * n * n);
  memi;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<sstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<numeric>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
typedef map<string,int> dict;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
double eps = 1e-10 ;

template <typename T>
void out(vector < T > v)
{
  for(size_t i = 0; i < v.size(); i++)
  {
    debug(v[i]);
  }
}

template<typename T>
string ntos( T i ) {
  ostringstream s ;
  s << i ;
  return s.str() ;
}

template<typename T>
T ston(string str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double x,h;
  while(1){
    cin >> x >> h;
    if(x + h == 0){
      break ;
    }
    cout << fixed << setprecision(6) << x * x + 2 * x * sqrt((x/2)*(x/2) + h* h) << endl;
  }
  return 0;
}

Measured memory_bytes: 3292
def main():
    import sys
    readline = sys.stdin.readline

    inf = 10 ** 9

    n = int(readline())
    *h, = map(int, readline().split())
    h = [inf] + h + [inf]  # 1-indexed化

    dp = [inf] * (n + 2)
    dp[0] = 0
    dp[1] = 0

    for i in range(1, n):  # ジャンプ元,1-indexed
        dp[i + 2] = min(
            dp[i + 2],
            dp[i] + abs(h[i + 2] - h[i]))

        dp[i + 1] = min(
            dp[i + 1],
            dp[i] + abs(h[i + 1] - h[i]))

    print(dp[n])


if __name__ == '__main__':
    main()


Measured memory_bytes: 13884
import sys
def input(): return sys.stdin.readline().rstrip()
import math
def main():
    a,b,x=map(int,input().split())
    if x==a**2*b:
        print(0)
        sys.exit()
    if x<=a**2*b/2:
        print(90.0-math.degrees(math.atan((2*x)/(a*b**2))))
    else:
        z=2*x/a**2-b
        print(90.0-math.degrees(math.atan(a/(b-z))))

if __name__=='__main__':
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,c;
    cin >> n >> m >> c;
    vi lm(c);
    rep(i,c){
        cin >> lm[i];
    }
    vvi vec(c);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        vec[a-1].pb(b);
    }
    vi res;
    rep(i,c){
        sort(all(vec[i]),greater<int>());
        rep(j,min(len(vec[i]),lm[i])){
            res.pb(vec[i][j]);
        }
    }
    sort(all(res),greater<int>());
    int ans = 0;
    rep(i,m){
        ans += res[i];
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 7892
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

template<Int Mod = 1000000007> class modint{
public:
	Int val;
	constexpr modint(const Int x = 0) : val(x % Mod) {if(val < 0) val += Mod;}
	constexpr modint operator+(const modint rhs) const {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const {
		return modint(*this) /= rhs;
	}
	constexpr modint operator-() const {
		return modint(Mod - val);
	}
	constexpr modint &operator+=(const modint rhs){
		val += rhs.val;
		if(val >= Mod) val -= Mod;
		return *this;
	}
	constexpr modint &operator-=(const modint rhs){
		if(val < rhs.val) val += Mod;
		val -= rhs.val;
		return *this;
	}
	constexpr modint &operator*=(const modint rhs){
		val *= rhs.val;
		val %= Mod;
		return *this;
	}
	constexpr modint &operator/=(const modint rhs){
		return *this *= inv(rhs);
	}
	constexpr modint &operator++(){
		++val;
		if(val == Mod) val = 0;
		return *this;
	}
	constexpr modint &operator--(){
		--val;
		if(val == -1) val = Mod - 1;
		return *this;
	}
	constexpr modint operator<<(const Int rhs) const {
		return modint(*this) << rhs;
	}
	constexpr modint operator>>(const Int rhs) const {
		return modint(*this) >> rhs;
	}
	constexpr modint &operator<<=(const Int rhs){
		val <<= rhs;
		val %= Mod;
		return *this;
	}
	constexpr modint &operator>>=(const Int rhs){
		val >>= rhs;
		val %= Mod;
		return *this;
	}
	constexpr bool operator==(const modint rhs) const {
		return val == rhs.val;
	}
	constexpr bool operator!=(const modint rhs) const {
		return val != rhs.val;
	}
	constexpr bool operator<(const modint rhs) const {
		return val < rhs.val;
	}
	constexpr bool operator>(const modint rhs) const {
		return val > rhs.val;
	}
	constexpr bool operator<=(const modint rhs) const {
		return val <= rhs.val;
	}
	constexpr bool operator>=(const modint rhs) const {
		return val >= rhs.val;
	}
	friend ostream& operator<<(ostream& os, const modint<Mod>& m){
		return os << m.val;
	}
	friend istream& operator>>(istream& is, modint<Mod>& m){
		return is >> m.val;
	}
	static constexpr modint inv(modint m){
		Int a = m.val, b = Mod, u = 1, v = 0;
		while(b){
			Int t = a / b;
			a -= t * b;
			swap(a, b);
			u -= t * v;
			swap(u, v);
		}
		u %= Mod;
		if(u < 0) u += Mod;
		return modint(u);
	}
	constexpr operator Int() const {
		return val;
	}
};
using mint = modint<>;
mint pow(mint a, Int m){
	mint res = 1;
	while(m > 0){
		if(m & 1) res *= a;
		a *= a;
		m >>= 1;
	}
	return res;
}
using mint = modint<>;
vector<mint> fact(1, 1);
mint comb(Int n, Int r){
	mint res = 1;
	for(int i=0; i<r; ++i){
		res *= mint(n-i);
		res /= mint(i+1);
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, a, b; cin >> n >> a >> b;
	mint ans = pow(mint(2), n) - mint(1);
	ans -= comb(n, a);
	ans -= comb(n, b);
	cout << ans << "\n";
}

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

int main(void){
    int a,b;
    cin >> a;
    cin >> b;
    int d = a/b ;
    int r = a%b ;
    double f = double(a)/ double(b) ;
    cout << d ;
    cout << " " ;
    cout << r ;
    cout << " " ;
    cout << fixed << setprecision(5) << f ;
    cout << endl;
    
    
}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    vector<string> two = {"SS", "SW", "WS", "WW"};
    string ans = "";
    rep(i,4){
        string tmp = two[i];
        bool isOK = false;
        for(int i = 1; i < n; ++i){
            if(s[i]=='o'){
                if(tmp[i]=='S') tmp += (tmp[i-1] == 'S' ? 'S' : 'W');
                else tmp += (tmp[i-1] == 'S' ? 'W' : 'S');
            }else{
                if(tmp[i]=='S') tmp += (tmp[i-1] == 'S' ? 'W' : 'S');
                else tmp += (tmp[i-1] == 'S' ? 'S' : 'W');
            }
        }
        if(tmp[n] == tmp[0]){
            if(s[0] == 'o'){
                if(tmp[0]=='S' && tmp[n-1] == tmp[1]) isOK = true;
                else if (tmp[0]=='W' && tmp[n-1] != tmp[1]) isOK = true;
            }else{
                if(tmp[0]=='S' && tmp[n-1] != tmp[1]) isOK = true;
                else if (tmp[0]=='W' && tmp[n-1] == tmp[1]) isOK = true;
            }
        }
        /*
        if(s[0] == 'o'){
            if(tmp[0]=='S' && tmp[n-1] == tmp[1]) isOK = true;
            else if (tmp[0]=='W' && tmp[n-1] != tmp[1]) isOK = true;
        }else{
            if(tmp[0]=='S' && tmp[n-1] != tmp[1]) isOK = true;
            else if (tmp[0]=='W' && tmp[n-1] == tmp[1]) isOK = true;
        }
        */
        if(isOK) {
            tmp.pop_back();
            ans = tmp;
            cout << ans << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 776
n = int(input())
F = [[*map(int, input().split())] for _ in range(n)]
P = [[*map(int, input().split())] for _ in range(n)]
ans = -10000000*100
for i in range(1, 1<<10): # my shop open pattern 10bit, i:[0~1,1~1]
    s = 0
    for j in range(n): # the other shop
        cj = 0
        for k in range(10):
            if i>>k & 1 and F[j][k]: cj += 1
        s += P[j][cj]
    ans = max(ans ,s)
print(ans)


Measured memory_bytes: 9236
N = gets.chomp.to_i
S = gets.chomp.codepoints

A = 'RGB'.codepoints

cnts = { A[0] => 0, A[1] => 0, A[2] => 0 }

S.each { |n| cnts[n] += 1 }

cnt = cnts[A[0]] * cnts[A[1]] * cnts[A[2]]

0.upto(N - 3) do |i|
  (i + 1).upto(N - 2) do |j|
    next if S[i] == S[j]

    c = (A - [S[i], S[j]]).first

    d = j - i

    cnt -= 1 if S[j + d] == c
  end
end

puts cnt


Measured memory_bytes: 14320
#include<iostream>
#include<algorithm>
using namespace std;
int array[]={2,3,25,30,60,120,240,480,960,1920};
int main(){
  int n;
  cin>>n;
  if(n<=10){
    for(int i=0;i<n-1;i++) cout<<array[i]<<" ";
    cout<<array[n-1]<<endl;
    return 0;
  }
  else if(n==19999){
    for(int i=1;i<=2500;i++) cout<<i*12-9<<" "<<i*12-3<<" ";
    for(int i=1;i<=14998;i++) cout<<i*2<<" ";
    cout<<29998<<endl;
    return 0;
  }
  int ncnt=1,mcnt=1;
  n-=5;
  int lasn,lasm;
  while(n>0&&mcnt<2500){
    n-=2;
    mcnt++;
    if(n%3==0){
      lasn=n/3;
      lasm=mcnt;
    }
  }
  ncnt+=lasn;
  mcnt=lasm;

//  cout<<ncnt<<" "<<mcnt<<endl;
  for(int i=1;i<=3*ncnt;i++) cout<<2*i<<" ";
  for(int i=1;i<mcnt;i++) cout<<12*i-9<<" "<<12*i-3<<" ";
  cout<<mcnt*12-9<<" "<<mcnt*12-3<<endl;
  return 0;

}


Measured memory_bytes: 384
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

def prime_factor(n):
    factors = []
    for i in range(2, int(n**0.5)+1):
        count = 0
        while n % i == 0:
            count += 1
            n //= i
        if count != 0:
            factors.append((i, count))
    if n != 1:
        factors.append((n, 1))
    return factors

seen = set()
flag = True
ans = 0
while flag:
    flag = False
    div = make_divisors(n)
    for i in div:
        if len(prime_factor(i)) == 1 and i not in seen:
            seen.add(i)
            n /= i
            ans += 1
            flag = True
            break
print(ans)


Measured memory_bytes: 73884
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



int main(void) {
    
    int n;
    cin>>n;
    vll a(n);
    rep(i,n)cin>>a[i];
    vll one(n+1),two(n);

    one[0]=0;

    for(int i=1;i<n+1;i++){
        one[i]=a[i-1]-one[i-1];
    }
    // rep(i,n){
    //     if(i==0)cout<<one[i]*2;
    //     else cout<<" "<<one[i]*2;
    // }
    // fin('\n');

    two[0]=one[n]/2;
    for(int i=1;i<n;i++){
        two[i]=a[i-1]-two[i-1];
    }
    rep(i,n){
        if(i==0)cout<<two[i]*2;
        else cout<<" "<<two[i]*2;
    }
    fin('\n');
}


Measured memory_bytes: 3712
from collections import defaultdict

class UnionFind():
    def __init__(self, n=0):
        self.d = [-1]*n
    
    def find(self, x):
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x,y=self.find(x),self.find(y)
        if x==y:return False
        if self.d[x] > self.d[y]: x,y=y,x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x,y): return self.find(x)==self.find(y)
    def size(self,x): return -self.d[self.find(x)]
    
N,M,K=map(int,input().split())
uf=UnionFind(N+1)
n_friends=defaultdict(int)
for i in range(M):
  a,b=map(int,input().split())
  uf.unite(a,b)
  n_friends[a] += 1
  n_friends[b] += 1
  
ans = [uf.size(i)-n_friends[i]-1 for i in range(N+1)]

for i in range(K):
  c,d=map(int,input().split())
  if uf.same(c,d):
    ans[c] -= 1
    ans[d] -= 1
  
print(*ans[1:])

Measured memory_bytes: 26800
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def same(self, x, y):
        if self.find(x) == self.find(y):
            return True
        else:
            return False


n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ans = [0] * m
ans[m-1] = n * (n-1) // 2
UF = UnionFind(n)
for i in range(m-1, 0, -1):
    a, b = ab[i]
    if UF.same(a-1, b-1):
        ans[i-1] = ans[i]
    else:
        ans[i-1] = ans[i] - UF.size[UF.find(a-1)] * UF.size[UF.find(b-1)]
        UF.unite(a-1, b-1)

for a in ans:
    print(a)


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


int main (){
    vector<int> ans ;
    while(1){
        int n, x ;
        cin >> n >> x ;
        if(n == 0 && x == 0){
            break ;
        }
        int num = 0;
        for(int i = 1; i <= n ; i ++){
            for(int j = i + 1 ; j <=n ; j++){
                for(int k = j + 1 ; k<= n ;k++){
                    if(i + j + k == x){
                        num++ ;
                    }
                }
            }
        }
        ans.push_back(num) ;
    }
    rep(i, ans.size()){
        cout << ans[i] << endl ;
    }
}



Measured memory_bytes: 3148
#各pは、自分の今いるインデックスがindex p-1と繋がっていればそこに移動する
import sys
sys.setrecursionlimit(200000)

class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents = [i for i in range(n+1)]
        self.size = [1]*(n+1)
    def find(self,x):
        if self.parents[x]==x:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        xRoot = self.find(x)
        yRoot = self.find(y)
        if xRoot == yRoot:
            return
        if self.size[xRoot]>self.size[yRoot]:
            self.parents[yRoot] = xRoot
        else:
            self.parents[xRoot] = yRoot
            if self.size[xRoot] == self.size[yRoot]:
                self.size[yRoot]+=1
N,M = map(int,input().split())
P = list(map(int,input().split()))
tree = UnionFind(N)
for _ in range(M):
    x,y = map(int,input().split())
    tree.unite(x,y)

count = 0
for i in range(N):
    if tree.find(i+1) == tree.find(P[i]):
        count += 1

print(count)

Measured memory_bytes: 93932
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include <string.h>
#include <iomanip>
using namespace std;

#define PI 3.14159265358979323846264338327950L

#define MAX 12
#define SUM_INIT 10000000000

int main() {
	int N, M, X;
	int C[MAX];
	int A[MAX][MAX];

	cin >> N >> M >> X;

	for (int ii = 0; ii < N; ii++) {
		cin >> C[ii];
		for (int jj = 0; jj < M; jj++) {
			cin >> A[ii][jj];
		}
	}

	long long sum = SUM_INIT, tmp = 0;
	int U[MAX];
	for (int ii = 0; ii < 1 << N; ii++) {
		memset(U, 0x00, sizeof(U));
		tmp = 0;
		for (int jj = 0; jj < N; jj++) {
			if (((ii >> jj) & 1) == 0) {
				continue;
			}
			for (int kk = 0; kk < M; kk++) {
				U[kk] += A[jj][kk];
			}
			tmp += C[jj];
		}
		for (int jj = 0; jj < M; jj++) {
			if (U[jj] < X) {
				break;
			}
			if (jj == M - 1) {
				if (tmp < sum) {
					sum = tmp;
				}
			}
		}
	}
	if (sum == SUM_INIT) {
		cout << -1 << endl;
	}
	else {
		cout << sum << endl;
	}
	
	return 0;

}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<ctime>

using namespace std;

//math
//------------------------
template<class T>inline T sqr(T x){ return x*x; };



int a, b, c;




void solve(int a, int b, int c){
	if (a < b && b < c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
}
	


int main(){
	//std::clock_t start = clock();
	scanf("%d %d %d", &a, &b, &c);
	solve(a, b,c);
	//printf("time is %d",(clock()-static_cast<double>(start)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 1172
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
//#include <boost/math/common_factor_rt.hpp>

#define ll long long
using namespace std;
ll l = 1000000007;

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

	char c = s[5];
	int i = c - '0';
	if (i == 1) {
		cout << "TBD" << endl;
		return 0;
	}

	char h = s[6];
	int n = h - '0';

	if (n > 4) {
		cout << "TBD" << endl;
		return 0;
	}
	else {
		cout << "Heisei" << endl;
		return 0;
	}


}



Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
ll a[100000];
ll dom[100001];

int main(){
  int n,cnt=1;
  cin>>n;
  string s;
  cin>>s;
  for(int i=1;i<n;i++){
    if(s[i-1]!=s[i]) cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 512
input()
X_vec = map(float, input().split())
Y_vec = map(float, input().split())
pair = list(zip(X_vec, Y_vec))
D1 = sum(abs(x-y) for x,y in pair)
D2 = (sum((x-y)**2 for x,y in pair)) ** .5
D3 = (sum(abs(x-y)**3 for x,y in pair)) ** (1/3)
Dinf = max(abs(x-y) for x,y in pair)
print("{0:.6f}\n{1:.6f}\n{2:.6f}\n{3:.6f}\n".format(D1,D2,D3,Dinf))

Measured memory_bytes: 7692
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll C[100005]={};

vector<P> v;
vector<ll> ma2;

int n,m;
string a[3];
int main() {
	cin>>n>>a[0]>>a[1]>>a[2];
	ll ans=0;
	rep(i,0,n){
		int k=0;
		rep(j,0,3){
			if(a[j][i]==a[(j+1)%3][i])k++;
		}
		if(k==1)ans++;
		if(k==0)ans+=2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a;
int main(){
	ios::sync_with_stdio(false);
	cin>>a;
	if(a==0){
		cout<<0<<endl;
	}
	if(a>0&&a<=1){
		cout<<1<<endl;
	}
	if(a>1&&a<=3){
		cout<<2<<endl;
	}if(a>3&&a<=7){
		cout<<4<<endl;
	}if(a>7&&a<=15){
		cout<<8<<endl;
	}if(a>15&&a<=31){
		cout<<16<<endl;
	}if(a>31&&a<=63){
		cout<<32<<endl;
	}if(a>63&&a<=100){
		cout<<64<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
s = input()
t = input()

def check(a,b):
    s = 0
    for i,j in zip(a,b):
        s += i!=j
    return s
ans = 10**6
for i in range(len(s)):
    a = s[i:]
    if len(a) >= len(t):
        ans = min(ans,check(t,a[:len(t)]))
print(ans)

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

int main() {
	// your code goes here
	long long w,h,x,y;
	cin >> w >> h >> x >> y;
	cout << (w*h-(w%2)*(h%2))/2;
	if((w%2)*(h%2)==1) cout << ".5";
	cout << " ";
	if(2*x==w&&2*y==h) cout << "1" << endl;
	else cout << "0" << endl;
	return 0;
}

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

int main(int argc, char const *argv[]) {
  int n, x;
  scanf("%d", &n);
  std::vector<int> b;
  scanf(" %d", &x);
  b.push_back(x);
  for (int i = 1; i < n; i++) {
    scanf(" %d", &x);
    if (i%2 == 0) {
      b.insert(b.begin(), x);
    }else{
      b.push_back(x);
    }
  }

  if(n%2 == 0){
    for (int i = n-1; i >= 0; i--) {
      printf("%d ", b[i]);
    }
  }else{
    for (int i = 0; i < n; i++) {
      printf("%d ", b[i]);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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 = 1e9;

int main() {
    IOS
    int n;
    cin >> n;
    int h[n], dp[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    for (int i = 0; i < n; i++) dp[i] = INF;
    dp[0] = 0, dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    x_sum = sum(a) // 2
    x = [0] * n
    tmp = x_sum
    idx = 1
    for _ in range((n - 1) // 2):
        tmp -= a[idx]
        idx += 2
        idx %= n
    x[0] = 2 * tmp
    for i in range(n - 1):
        x[i + 1] = 2 * (a[i] - x[i] // 2)
    print(*x)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 58224
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

string S;
int main(){
    cin>>S;
    int a=stoi(S.substr(0,2));
    int b=stoi(S.substr(2,2));
    bool YM,MY;
    MY=(1<=a && a<=12);
    YM=(1<=b && b<=12);
    if(YM&&MY){
        cout<<"AMBIGUOUS";
    }else if(YM){
        cout<<"YYMM";
    }else if(MY){
        cout<<"MMYY";
    }else{
        cout<<"NA";
    }
    return 0;
}

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

int main() {
	int n; cin >> n;
	vector<int>w(n);
	for (int i = 0; i < n; i++) cin >> w[i];

	int ans = 1e9;
	int l = 0;
	for (int i = 0; i < n; i++) {
		l += w[i];
		int r = 0;
		for (int j = i + 1; j < n; j++) {
			r += w[j];
		}
		ans = min(ans, abs(l - r));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector< string > s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s.begin(), s.end());
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        long long tmp = 0;
        while (i < n - 1 && s[i] == s[i + 1]) {
            tmp++;
            i++;
        }
        ans = (ans + (tmp * (tmp + 1)) / 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>
int main(void){
  
  int i,j;
  
  for(i=1;i<10;i++)
    {
      for(j=1;j<10;j++)
	{
	  printf("%dx%d=%d\n",i,j,i*j);
	}
    }
  return 0;
}

Measured memory_bytes: 0
n,m=[int(s)for s in input().split()]
pref={}
yn={}
res=[-1 for _ in range(m)]
for i in range(m):
    p,y=[int(s)for s in input().split()]
    if p not in pref:pref[p]=[]
    pref[p].append(y)
    yn[y]=i
for p in pref:
    pref[p]=sorted(pref[p])
    for i in range(len(pref[p])):
        num="%06d%06d"%(p,i+1)
        res[yn[pref[p][i]]]=num
for s in res:print(s)

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

using namespace std;

typedef long long ll;

const int N = 1e8;
const int INF = 1e9;
const int MOD = 998244353;



int main() {
    int n, t;
    cin >> n >> t;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int mn = a[0], mx = 0;
    for (int i = 0; i < n; i++) {
        mn = min(mn, a[i]);
        mx = max(mx, a[i] - mn);
    }
    int cnt = 0;
    set<int> st;
    for (int i = 0; i < n; i++) {
        if (st.count(a[i] - mx))
            cnt++;
        st.insert(a[i]);
    }
    cout << cnt;
}

Measured memory_bytes: 5376
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(LLI i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(LLI i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// LLI 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	LLI n;
	string s;
	cin >> n >> s;
	LLI rc = 0;
	LLI gc = 0;
	LLI bc = 0;
	REP(i, n)
	{
		if (s[i] == 'R')rc++;
		if (s[i] == 'G')gc++;
		if (s[i] == 'B')bc++;
	}
	LLI ans = rc * gc * bc;

	FOR(w, 1, n / 2 + 1)
	{
		for (LLI i = w; i + w < n; i++)
		{
			if (s[i - w] != s[i] && s[i] != s[i + w] && s[i - w] != s[i + w])ans--;
		}
	}
	cout << ans;


	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const ll maxn=1e9+7;

int main(){
    int r,g,b;
    cin>>r>>g>>b;
    int x=r*100+g*10+b;
    if(x%4) cout<<"NO\n";
    else cout<<"YES\n";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
    
    while(cin >> s, s != "-"){
        int m;
        
        scanf("%d", &m);
        
        for(int i = 0; i < m; ++i){
            int h;
            string t, b;
            
            scanf("%d", &h);
            
            t = s.substr(0, h);
            b = s.substr(h);
            
            s = b + t;
        }
        
        cout << s << endl;
    }
    
    return 0;
}




Measured memory_bytes: 3240
#include <iostream>
#include <cstdio>
#include <algorithm>

void print_array(int N, int *array)
{
    for (int i = 0; i < N - 1; i++)
        printf("%d ", array[i]);
    printf("%d\n", array[N - 1]);
}

int selection_sort(int N, int *array)
{
    int counter = 0;
    for (int i = 0; i < N; i++)
    {
        int minj = i;
        for (int j = i; j < N; j++)
        {
            if (array[j] < array[minj])
                minj = j;
        }
        if(i != minj)
        {
            std::swap(array[i], array[minj]);
            counter++;
        }
    }
    return counter;
}

int main()
{
    /* input process */
    int N;
    scanf("%d", &N);
    int *array = new int[N];
    for (int i = 0; i < N; i++)
        scanf("%d", &array[i]);

    /* sort */
    int counter = selection_sort(N, array);

    /* print */
    print_array(N, array);
    printf("%d\n", counter);
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  
  ll a;
  cin >> a;
  string b;
  cin >> b;
  ll c = 100*(int)(b[0]-'0')+
    10*(int)(b[2]-'0') + (int)(b[3]-'0');
  cout << (a*c)/100 << endl;
  
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
 
typedef long long LL;
typedef pair<int, int> PII;
 
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	LL x, y;
	cin >> x >> y;
	cout << (abs(x - y) > 1 ? "Alice" : "Brown");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#define llong long long
#define pb(a) push_back(a)
#define strVecSORT(strVec) sort(strVec.begin(), strVec.end());
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int ab =a+b;
  int bc =b+c;
  int ca =c+a;
  if(ab<=bc && ab<=ca){
    cout<<ab<<endl;
    exit(0);
  }
  if(bc<=ab && bc<=ca){
    cout<<bc<<endl;
    exit(0);
  }
  if(ca<=ab && ca<<bc){
    cout<<ca<<endl;
    exit(0);
  }
}

Measured memory_bytes: 256