akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

int N, A, B, C, D;
string S;

// 岩が 2 連続で置かれていなければゴールできる true を返す
bool chain2(int start, int goal){
    if(goal - start < 3) return true;

    for(int i = start+1; i < goal-1; i++){
        if(S[i] == '#' && S[i-1] == '#') return false;
    }

    return true;
}

// fnukeが移動する区間+左右両端一個ずつ含めた区間に . が３つ以上連続する場所がなければ
// snukeはゴールできない false を返す
bool chain3(int start, int goal){
    for(int i = start; i <= goal; i++){
        if(S[i] == '.' && S[i-1] == '.' && S[i-2] == '.') return true;
    }

    return false;
}

int main(){
    cin >> N >> A >> B >> C >> D;
    cin >> S;

    bool ans = true;

    ans = chain2(A, C) && chain2(B, D);

    if(C > D)  ans =  ans && chain3(B, D);

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

    return 0;
}

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

using namespace std;

int main(){
    int n;cin>>n;
    int ans=0;
    for (int i = 0; i < 4; ++i) {
        if(n%10==2)++ans;
        n/=10;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = set()
b = set()
for _ in range(m):
    af, bf = map(int, input().split())
    if af == 1:
        a.add(bf)
    if bf == n:
        b.add(af)
        
if len(a&b) == 0:
    print("IMPOSSIBLE")
else:
    print('POSSIBLE')

Measured memory_bytes: 19024
while True:
    H,W=map(int,input().split())
    if(H==0 and W==0):
        break
    for i in range(H):
        for j in range(W):
            if(((i+j)%2)==0):
                    print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7000
#include <cstdio>

int main(void)
{
    int N,i;
    int curr,count,x;
    scanf("%d",&N);

    count=0;
    curr=1;
    for(i=0;i<N;i++)
    {
        scanf("%d",&x);
        if(x==curr)
        {
            count+=1;
            curr+=1;
        }
    }
    if(curr==1)
    {
        printf("-1\n");
    }
    else
    {
        printf("%d\n",N-count);
    }
    return 0;

}



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

typedef struct UnionFind{
  int *parent;
  int n;
} UnionFind;

UnionFind* newUnionFind(int n){
  UnionFind *u=(UnionFind *)calloc(1,sizeof(UnionFind));
  u->parent=(int *)calloc(n,sizeof(int));
  u->n=n;
  for(int i=0;i<n;i++) u->parent[i]=-1;
  return u;
}

void freeUnionFind(UnionFind *u){
  free(u->parent);
  free(u);
}

void initUnionFind(UnionFind *u){
  for(int i=0;i<u->n;i++) u->parent[i]=-1;
}

int root(UnionFind *u,int x){
  if(u->parent[x]<0) return x;
  return u->parent[x]=root(u,u->parent[x]);
}

int same(UnionFind *u,int x,int y){
  return root(u,x)==root(u,y);
}

int getSize(UnionFind *u,int x){
  return -u->parent[root(u,x)];
}

void unite(UnionFind *u,int x,int y){
  x=root(u,x);
  y=root(u,y);
  if(x==y) return;
  if(u->parent[x]>u->parent[y]){
    int swap=x;
    x=y;
    y=swap;
  }
  u->parent[x]+=u->parent[y];
  u->parent[y]=x;
}

typedef struct node{
  int x,y;
  int index;
} node;

int cmp(const void *a,const void *b){
  node *p=(node *)a;
  node *q=(node *)b;
  if(p->x!=q->x) return p->x-q->x;
  return p->y-q->y;
}

void run(void){
  int n,k,l;
  scanf("%d%d%d",&n,&k,&l);
  UnionFind *a=newUnionFind(n);
  while(k--){
    int p,q;
    scanf("%d%d",&p,&q);
    unite(a,p-1,q-1);
  }
  UnionFind *b=newUnionFind(n);
  while(l--){
    int r,s;
    scanf("%d%d",&r,&s);
    unite(b,r-1,s-1);
  }
  node *p=(node *)calloc(n,sizeof(node));
  int i;
  for(i=0;i<n;i++) p[i]=(node){root(a,i),root(b,i),i};
  qsort(p,n,sizeof(node),cmp);
  int *ans=(int *)calloc(n,sizeof(int));
  i=0;
  int j=0;
  while(i<n){
    while(j<n && cmp(p+i,p+j)==0) j++;
    for(int x=i;x<j;x++) ans[p[x].index]=j-i;
    i=j;
  }
  for(i=0;i<n;i++) printf("%d%c",ans[i]," \n"[i==n-1]);
}

int main(void){
  run();
  return 0;
}


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

long long N, P;

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

    long long d = 2, ans = 1;
    bool over = false;
    
    int cnt = 0;
    while(P % d == 0) {
        P /= d;
        cnt++;
    }
    for (int i = 0; i < cnt / N; i++) {
        ans *= d;
    }
    d++;
    
    while(!over) {
        int cnt = 0;
        while(P % d == 0) {
            P /= d;
            cnt++;
        }
        for (int i = 0; i < cnt / N; i++) {
            ans *= d;
        }
        d += 2;

        if (d * d > P ) {
            over = true;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import collections as cl


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N, X, M = MI()
    rep = []
    rep_set = set([])
    i = 1

    rep.append(X)
    rep_set.add(X)
    flag = True

    while flag and i < N:
        x = rep[i-1] ** 2 % M
        if x in rep_set:
            rep.append(x)
            break
        rep.append(x)
        rep_set.add(x)
        i += 1

    if i == N:
        print(sum(rep))
    else:
        l = rep.index(rep[-1])
        rep_leng = i - l
        rep_sum = sum(rep[l:i])
        ans = 0
        ans += sum(rep[:l])
        N -= l
        rep_num = N // rep_leng
        rep_amari = N % rep_leng
        ans += rep_sum * rep_num
        ans += sum(rep[l:l+rep_amari])
        print(ans)


main()


Measured memory_bytes: 78792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(void)
{
    ll n;
    cin >> n;
    int k=0;
    ll i=1;
    ll c;
    while(n / i != 0)
    {
        k++;
        c = n / i;
        i *= 10; 
    }
    i /= 10;
    if((n+1)%i == 0)
    {
        cout << c + 9 * (k-1) << endl;
    }
    else
    {
        cout << c + 9 * (k-1) -1 << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
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() {
ll ans = 0;
	int N,W; cin >> N >> W;
	ll dp[N+1][W+1] = {};
	ll w[N];
	ll v[N];
	rep(i,N){cin >> w[i] >> v[i];}

	rep(i,N)
	{

		FORq(j,0,W)
		{
			if(i == 0)
				{
					dp[0][0] = 0;
					dp[0][w[0]] = v[0];continue;
				}
			if(j-w[i] < 0){dp[i][j] = dp[i-1][j];continue;}
			dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]] + v[i]);
			// cout << "dp(" << i << ',' << j << ") = " << dp[i][j] << endl;
		}
	}
	rep(i,W+1)
	{
		ans = max(dp[N-1][i],ans);
	}

	cout << ans << endl;
}

Measured memory_bytes: 79104
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<ll> cnt(n + 1);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  ll all = 0;
  for (int i = 1; i <= n; ++i) {
    all += cnt[i] * (cnt[i] - 1) / 2;
  }
  for (int i = 0; i < n; ++i) {
    ll ans = all;
    ll hoge = cnt[a[i]];
    ans -= hoge * (hoge - 1) / 2;
    ans += (hoge - 1) * (hoge - 2) / 2;
    cout << ans << endl;
  }
  return 0;
}

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

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

    ll n;
    cin >> n;

    ll tmp = n;
    ll res = 1;
    ll base = 2;
    while(tmp>1){
        res += base;
        base *= 2;
        tmp /= 2;
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int a,b,c,k = 0;
    cin >> a >> b >> c >> k;
    for(int i = 0;i < k;i++){
        if(c > b && b > a){
            cout << "Yes" << endl;
            return 0;
        }
        if(a >= b){
            b *= 2;
            continue;
        }
        if(b >= c){
            c *= 2;
            continue;
        }
    }
    if(c > b && b > a){
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
        return 0;
    }

}

Measured memory_bytes: 3628
#include <stdio.h>

int main(){
	int i,n,a,cnt=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d", &a);
		if(i%2==1&&a%2==1){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int maxn=0x7fffff;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	n-=k;
	cout<<n/(m+k);
	return 0;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
A = getList()

list_a = [0] * (10 ** 6 + 1)
list_b = [0] * (10 ** 6 + 1)

for i in A:
    list_a[i] += 1

ans = 0
for i in range(1, 10 ** 6 + 1):
    if not list_a[i]:
        continue
    if list_a[i] == 1 and not list_b[i]:
        ans += 1
    for j in range(1, 10 ** 6 + 1):
        if i * j >= 10 ** 6 + 1:
            break
        list_b[i * j] = 1
print(ans)

Measured memory_bytes: 130112
/*
 * 2676.cc: Typing Game
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

string ss[MAX_N];
int ts[MAX_N];

/* subroutines */

inline char uc(char c) {
  return ((c >= 'A' && c <= 'Z') ? c : c - 'a' + 'A');
}

/* main */

int main() {
  int n, h;
  cin >> n >> h;

  for (int i = 0; i < n; i++) cin >> ss[i] >> ts[i];
  
  int an = 0, tn = 0;

  for (int i = 0; i < n; i++) {
    string &si = ss[i];
    int k = 0, sn = si.size(), m = ts[i];

    while (k < sn && m >= 0) {
      //printf("sn=%d, k=%d, m=%d\n", sn, k, m);
      putchar('?'); putchar(' ');
      for (int j = 0; j < sn; j++) putchar(j < k ? '_' : si[j]);
      putchar('\n');
      cout.flush();

      string s;
      cin >> s;
      tn++;

      if (uc(s[0]) == uc(si[k])) k++, an++;
      else m--;
    }

    if (m < 0 && --h <= 0) {
      puts("! Game Over"); cout.flush();
      return 0;
    }
  }

  printf("! Game Clear %.1lf\n", floor((double)an / tn * 1000) / 10);
  return 0;
}

Measured memory_bytes: 1300
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
#define inf 1e12+7
typedef long long ll;

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

    if(n % 2 == 1){
        cout << "No" << endl;
        return 0;
    }
    if(s.substr(0, n/2) == s.substr(n/2, n/2)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from math import gcd

n = int(input())
MOD = 10**9+7
p_map = {}
n_map = {}

p_zero_map = 0
n_zero_map = 0
z_map = 0
for _ in range(n):
    ab = list(map(int, input().split()))
    ab_gcd = gcd(ab[0], ab[1])
    if ab_gcd == 0:
        ab_gcd = 1
    a = ab[0]//ab_gcd
    b = ab[1]//ab_gcd

    if (a > 0 and b > 0) or (a < 0 and b < 0):
        if a < 0:
            a = -a
            b = -b
        key = "{}_{}".format(a, b)
        if key not in p_map:
            p_map[key] = 1
        else:
            p_map[key] += 1
    elif a == 0 and b == 0:
        z_map += 1
    elif a == 0 and b != 0:
        n_zero_map += 1
    elif b == 0 and a != 0:
        p_zero_map += 1
    else:
        if b < 0:
            a = -a
            b = -b
        key = "{}_{}".format(a, b)
        if key not in n_map:
            n_map[key] = 1
        else:
            n_map[key] += 1

ans = 1
for k, v in p_map.items():
    a = int(k.split("_")[0])
    b = int(k.split("_")[1])
    n_num = 0
    key_a = "{}_{}".format(-b, a)
    if key_a in n_map:
        n_num += n_map.pop(key_a)
    res = 0
    res += pow(2, v, MOD)-1
    if n_num > 0:
        res += pow(2, n_num, MOD)-1
    res += 1
    ans *= res
    ans %= MOD

n_num = sum(n_map.values())
if n_num > 0:
    ans *= pow(2, n_num, MOD)
    ans %= MOD

res = 0
if p_zero_map > 0 and n_zero_map > 0:
    res = pow(2, p_zero_map, MOD)-1 + pow(2, n_zero_map, MOD)-1
    res += 1
    res %= MOD
elif p_zero_map > 0 and n_zero_map == 0:
    res = pow(2, p_zero_map, MOD)
elif p_zero_map == 0 and n_zero_map > 0:
    res = pow(2, n_zero_map, MOD)
if res > 0:
    ans *= res
    ans %= MOD


if z_map > 0:
    ans += z_map
ans -= 1
ans %= MOD
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int a[1000006];
int main()
{
    long long n, i, j, s =0,s1=0;
    cin >> n;
    //cout<<s<<endl;
     for (i = 1;i<=n; i++)
    {
      if(i%3==0)
      {
        a[i]=1;
      }else if(i%5==0)
      {
        a[i]=1;
      }
    }
    for(i=1;i<=n;i++)
    {
        if(a[i]==0)
        {
            s=s+i;
        }
    }
    cout<<s<<endl;
    return 0;

}

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

using namespace std;
#define ll long long

#define MOD 1000000007

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif


void init();
void solve();

signed main()
{
	init();
	solve();
}

string s, t, x;
ll n, m, l;

ll gcd(ll x, ll y)
{
	if (x < y) return gcd(y, x);
	if (x % y == 0) return y;
	return gcd(y, x % y);
}

void init()
{
	cin >> n >> m >> s >> t;
	l = n * m / gcd(n, m);	
}

void solve()
{
	vector<pair<int, char> > v;
	rep(i, n) {
		v.PB(MP(i * (l / n), s[i]));
	}
	rep(i, m) {
		v.PB(MP(i * (l / m), t[i]));
	}
	sort(all(v));
	reps(i, 1, n+m) {
		auto x = v[i];
		auto y = v[i-1];
		if (x.first == y.first && x.second != y.second) {
			cout << -1 << endl;
			return;
		}
	}
	cout << l << endl;
}

Measured memory_bytes: 2744
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	rep(i,n)cin>>v[i];
	
	int mini = INF;
	for(int i=-100;i<=100;i++){
		int t = 0;
		rep(j,n){
			t+=abs(v[j]-i)*abs(v[j]-i);
		}
		mini = min(mini,t);
	}
	cout<<mini<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <string.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define INF 100000000
using namespace std;

int path[101][101];

int dijkstra(int s,int g,int n){
	long long d[101];
	bool used[101];
	memset(d,0x3f,sizeof(d));
	memset(used,0,sizeof(used));
	d[s]=0;
	while(1){
		int v=-1;
		for(int u=1;u<=n;u++){
			if(!used[u]&&(v==-1||d[u]<d[v])) v=u;
		}
		if(v==-1) break;
		used[v]=true;
		for(int u=1;u<=n;u++){
			d[u]=min(d[u],d[v]+path[v][u]);
		}
	}
	return d[g];
}

int main(){
	int n,k;
	while(1){
		cin>>n>>k;
		if(n==0&&k==0) return 0;
		memset(path,0x3f,sizeof(path));
		for(int i=0;i<k;i++){
			int tmp;
			cin>>tmp;
			if(tmp){
				int c,d,e;
				cin>>c>>d>>e;
				path[c][d]=path[d][c]=min(e,path[c][d]);
			}
			else{
				int a,b;
				long long res=0;
				cin>>a>>b;
				res=dijkstra(a,b,n);
				if(res>INF) cout<<"-1"<<endl;
				else cout<<res<<endl;
			}
		}
	}
	return 0;
}

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

#define int long long int
#define float long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX
int exp(int x,int y,int mod){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int modinv(int x,int mod){return exp(x,mod-2,mod);}


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

	int n,mx=-inf,mn=inf,mxx=-inf,mnn=inf;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		mx=max(mx,x+y);
		mn=min(mn,x+y);
		mxx=max(mxx,x-y);
		mnn=min(mnn,x-y);
	}
	cout<<max(abs(mx-mn),abs(mxx-mnn));
	return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


ll N;
int main(){
    cin >> N;
    ll sum = 0;
    rep1(i,sqrt(N)*10){
        ll m = N/i - 1;
        if(m > 1 && N % m != 0 && m > i && N % i == 0) sum += m; 
    }
    cout << sum << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll K = 38, N = K*(K-1) + 1;
  //ll K = 4, N = 13;
  std::cout << N << " " << K << '\n';

  vvl ans;

  //NK
  // las = N
  // (N-1)K + K

  // shift 0 ~ K-1
  for(int d=0;d<(K-1);d++){
    for(int i=0;i<K-1;i++){ //x
      vll ad;
      ll amari = i;
      for(int j=0;j<(K-1);j++){//y
        ad.push_back(j*(K-1) + amari);
        amari = (amari + d)%(K-1);
      }
      ad.push_back((K-1)*(K-1)+d);
      ans.push_back(ad);
    }
  }

  for(int i=0;i<K;i++){
    vll ad;
    for(int j=0;j<K-1;j++) ad.push_back((i*(K-1)) + j);
    ad.push_back(N-1);
    ans.push_back(ad);
  }

  for(int i=0;i<N;i++){
    for(int j=0;j<K;j++) {
      std::cout << ans[i][j]+1 << (j==K-1?"\n":" ");
    }
  }

  return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n);
    vector<ll> b(n);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
        ans += b[i];
    }
    for (int k = 1; k < n; k++) {
        ll tmp = k * x;
        for (int i = 0; i < n; i++) {
            b[i] = min(b[i], a[(i - k + n) % n]);
            tmp += b[i];
        }
        ans = min(ans, tmp);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;


Node root;

Node tSearch(Node u, int v);

void insert(int u);

void inorder(Node u);

void preorder(Node u);

int main(){
  int b,n,i;
  char a[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", a);
    if ( a[0] == 'i' ){
      scanf("%d", &b);
      insert(b);
    } else if ( a[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( a[0] == 'f' ){
      scanf("%d", &b);
      Node t = tSearch(root,b);
      if ( t != N ) printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}



Node tSearch(Node u, int v){
    if(u == N || v == u->key)return u;

    if(v < u->key)return tSearch(u->left,v);

    else return tSearch(u->right,v);
    
}

void insert(int u){
  Node y = N;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = u;
  z->left = N;
  z->right = N;

  while(x != N){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;

  if(y == N)root = z;

  else if(z->key < y->key)y->left = z;

  else y->right = z;
}

void inorder(Node u){
  if(u != N){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }

}
void preorder(Node u){
  if(u==NULL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}




Measured memory_bytes: 20524
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll 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;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, e , m, n, k, x, y, l,r,t, h, w;
    string s;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";
    vector<ll> ar;
    vector<string> sr;
    vector<vector<char>> arr;

    cin >> n;
    sans = "No";

    rep(cake,n){
        rep(donut, n){
            if(cake*4 + donut*7 == n){
                std::cout << "Yes" << endl;
                return;
            }

            if(cake*4 + donut*7 >= n) break;
        }
    }


    // std::cout << ans << endl;

    std::cout << sans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int nums = 1;
		int num = 1;
		for(int i = 0; nums != 0 ; ++i,num++) {
			nums = scan.nextInt();
			if(nums == 0) break;
			System.out.println("Case " + num + ": " + nums);
		}

 }
}

Measured memory_bytes: 33032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc148_e.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N;
  cin >> N;

  if (N % 2 != 0) {
    cout << 0 << endl;
    return 0;
  }

  ll prime = 5 * 2;
  ll ans = 0;
  while (prime <= N) {
    ans += N / prime;
    prime *= 5;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
    int N; cin>>N;
    vi A(N);
    rep(i,0,N) cin>>A[i];
    vii dp(N+1,vi(N));
    REP(i,1,N){
        REP(j,0,N-i){
            dp[i][j]=max(A[j+i-1]-dp[i-1][j],A[j]-dp[i-1][j+1]);
        }
    }
    cout<<dp[N][0]<<endl;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
typedef long long ll;

int main(){
	ll A, B, C;
	cin >> A >> B >> C;
	if( A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
		cout << 0 << endl;
		return 0;
	}
	cout << min(min(A * B, B * C), C * A) << endl;
	return 0;
}


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


int main()
{
	int N = 0, L = 0, M = 0, ans = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0;
	cin >> N;

	for (int i = 0; i < 8; i++) {
		a = N % 10;
		b = N % 100 / 10;
		c = N % 1000 / 100;
		d = N % 10000 / 1000;
		e = N % 100000 / 10000;
		f = N % 1000000 / 100000;
		g = N % 10000000 / 1000000;
		h = N % 100000000 / 10000000;
		M = a + b + c + d + e + f + g + h;
		L = N % M;
	}

	if (0 < L) {
		cout << "No" << endl;
	}

	else
		cout << "Yes" << endl;
    
}

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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    vector<int> arr = {
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    };
    int k; cin >> k;
    cout << arr[k - 1] << endl;

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
//Loopで使う文字列の長さは固定！
//intで大丈夫？オーバーフローしない？
//Loop回数は本当に10⁹以内になってる？Loopは回る？？
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int x=sc.nextInt();
        int[] a=new int[n];
        for (int i = 0; i < n; i++) {
            a[i]=sc.nextInt();
        }
        int temp=a[0];
        long ans=0;
        for (int i = 1; i < n; i++) {
            temp=a[i]+a[i-1];
            if(temp>x){
                ans+=temp-x;
                if(a[i]>=temp-x){
                    a[i]-=temp-x;
                }else{
                    a[i-1]-=temp-x-a[i];
                    a[i]=0;
                }
            }
            temp=0;
        }
        out.println(ans);
    }
}


Measured memory_bytes: 49888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

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

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include <iomanip>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (ll)1e9+7
#define LLINF (ll)1e30
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    ll W,H,x,y,res2=0;
    cin>>W>>H>>x>>y;
    double res=(double)(H*W)/2;
    if((y*H==x*W && x*2==W) ||(y*H==x*W &&y*2==H) ||(x*2==W &&y*2==H)){
        res2=1;
    }
    else if(W*(H-y)==H*x && x*2==W) res2=1;
    else if(W*(H-y)==H*x && y*2==H) res2=1;
    else if(W*(H-y)==H*x && y*H==x*W) res2=1;
    cout<<fixed<<setprecision(10)<<res<<" "<<res2<<endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 行ごとのiterが取れる
    let mut iter = buf.split_whitespace();
    let steps: usize = iter.next().unwrap().parse().unwrap();
    let costs: Vec<i32> = (0..steps)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect();
    let mut dp = vec![0; steps];

    for step in 1..steps {
        if step == 1 {
            dp[step] = i32::abs(costs[step - 1] - costs[step]);
            continue;
        }
        if step > 1 {
            let one_step_cost = dp[step - 1] + i32::abs(costs[step - 1] - costs[step]);
            let tow_step_cost = dp[step - 2] + i32::abs(costs[step - 2] - costs[step]);
            dp[step] = if one_step_cost < tow_step_cost {
                one_step_cost
            } else {
                tow_step_cost
            }
        }
    }
    println!("{:?}", dp[steps - 1]);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>

    using namespace __gnu_pbds;
    using namespace std;
    #define INF 10000000000000LL
    #define DIM 100007
    #define pll pair<long long, long long>
    #define ll long long
    #define ld long double
    #define fi first
    #define se second
    #define pb push_back

    typedef tree<
    int,
    null_type,
    less<int>,
    rb_tree_tag,
    tree_order_statistics_node_update> myset;
    typedef  pair< long long, pair<long long, long long> > ppll;
    ll n,m,c,x,x2,y2,e,h,k,res1,a1,a2,w,a3,y,z,a4,a5,a6,last,LL,timer,start,finish,maxmask,newmax,reslast,tests,police,brothers;
    string s,s1;
    ll al,ar;
    ll mas[100007][107],sum[100007][107],mas1[107],zin[107];

    int main(){

        cin>>n>>w;
        for(int i=1;i<=n;i++){
            //mas[0][i]=1;
            cin>>mas1[i]>>zin[i];
        }
        mas[0][0]=1;
        for(int i=1;i<=n;i++){
            for(int j=0;j<=w;j++){
                if(mas[j][i-1]==1&&j<=w-mas1[i]){
                    //cout<<i<<' '<<j<<' '<<mas[j][i]<<endl;
                    mas[j+mas1[i]][i]=1;
                    sum[j+mas1[i]][i]=max(sum[j+mas1[i]][i],sum[j][i-1]+zin[i]);
                    res1=max(res1,sum[j+mas1[i]][i]);
                }
                if(mas[j][i-1]==1){
                    mas[j][i]=1;
                    sum[j][i]=max(sum[j][i],sum[j][i-1]);
                }
            }
        }
        /*for(int i=1;i<=3;i++){
            for(int j=0;j<=15;j++){
                cout<<mas[j][i]<<' ';
            }cout<<endl;
        }
        cout<<endl;
        for(int i=1;i<=3;i++){
            for(int j=0;j<=15;j++){
                cout<<sum[j][i]<<' ';
            }cout<<endl;
        }*/
        cout<<res1<<endl;
    }


Measured memory_bytes: 167168
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

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

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll N,K;
  cin >> N >> K;
  vector<ll> A(N), F(N);
  REP(i,N){ cin >> A[i]; }
  REP(i,N){ cin >> F[i]; }

  sort(A.begin(), A.end(), greater<ll>());
  sort(F.begin(), F.end());

  ll l = -1;
  ll r = 1e12+1;
  while(l+1<r){
    ll c = (l+r)/2;
    // check
    ll hp = K;
    REP(i,N){
      if (A[i]*F[i]>c){
        hp -= A[i] - c/F[i];
      }
    }
    // update
    if (hp<0){
      l = c;
    } else {
      r = c;
    }
  }

  cout << r << "\n";
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;


int main() {
    ios_base::sync_with_stdio(false);

    int a,b;
    cin >> a >> b;
    cout << (a+b)%24 << endl;

    return 0;   
}


Measured memory_bytes: 256
#include<stdio.h>

long long xh(long long a,long long b)
{
if(b==0) return a;
return xh(b,a%b);
}

long long lcm(long long a,long long b)
{
return a/xh(a,b)*b;
}

main()
{
    long long n, i, m=1, a, b, r;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
	scanf("%lld",&a);
	if(m>a) {r=a;a=m;m=r;}
	if(a%m==0)
	m=a;
	else
	m=lcm(a,m);
	}
	printf("%lld\n",m);
}

Measured memory_bytes: 128
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        double w=sc.nextDouble();
        double h=sc.nextDouble();
		double x=sc.nextDouble();
		double y=sc.nextDouble();
  		
		
  		double ans=w*h/2;
  		System.out.println(ans);
    
 	if(x==w/2&&y==h/2){
    		System.out.println(1);
    	}else{
     		System.out.println(0);
   	 }

    	
    }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;


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

    ll n; cin >> n;
    string s;
    map<string, ll> dic;
    REP(i,n){
        cin >> s;
        sort(s.begin(), s.end());
        dic[s]++;
    }
    ll ans = 0;
    for(auto p:dic){
        ans += p.second * (p.second-1) / 2;
    }
    cout << ans;
    return 0;
    
}



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

vector <vector <int> > GT;
vector <int> Stopnie;
int main(){
    ios_base::sync_with_stdio(0);
    int N, M;
    cin >> N >> M;
    GT.resize(N);
    Stopnie.resize(N, 0);
    for (int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        GT[b].push_back(a);
        Stopnie[a]++;
    }
    queue <int> Q;
    for (int i = 0; i < N; i++){
        if (Stopnie[i] == 0){
            Q.push(i);
        }
    }
    vector <int> DP;
    DP.resize(N);
    while (!Q.empty()){
        int W = Q.front();
        Q.pop();
        DP[W]++;
        cerr << DP[W] << "\n";
        for (auto sas : GT[W]){
            Stopnie[sas]--;
            DP[sas] = max(DP[sas], DP[W]);
            if (Stopnie[sas] == 0){
                Q.push(sas);
            }
        }
    }
    int Res = 0;
    for (int i = 0; i < N; i++){
        Res = max(DP[i], Res);
    }
    Res--;
    cout << Res << "\n";
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n;
int x,y;
int fir[100005],nxt[200005],to[200005],cnt=0;
int dp[100005][2];

void dfs(int x,int f){
	dp[x][0]=1;
	dp[x][1]=1;
	for(int i=fir[x];i;i=nxt[i]){
		if(to[i]==f) continue;
		dfs(to[i],x);
		dp[x][0]=1LL*dp[x][0]*(dp[to[i]][0]+dp[to[i]][1])%mod;
		dp[x][1]=1LL*dp[x][1]*dp[to[i]][0]%mod;
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d %d",&x,&y);
		to[++cnt]=y,nxt[cnt]=fir[x],fir[x]=cnt;
		to[++cnt]=x,nxt[cnt]=fir[y],fir[y]=cnt;
	}
	dfs(1,0);
	printf("%d\n",(dp[1][1]+dp[1][0])%mod);
	
	return 0;
}

Measured memory_bytes: 7168
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<string,int> P;
int main(){
  	int A, B, C, X;
    cin >> A >> B >> C >> X;

    int cnt = 0;

    for(int i=0;i<=A;i++){
      for(int j=0;j<=B;j++){
        for(int k=0;k<=C;k++){
          if(500*i+100*j+50*k==X) cnt++;
        }
      }
    }
    cout << cnt <<endl;


  return 0;
}






Measured memory_bytes: 256
(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))
(defun f(k x)
  (<= x (* 500 k)))
(let* ((line (mapcar #'parse-integer (splitat #\space (read-line nil nil)))))
  (format t "~A~%" (if (f (car line) (cadr line)) "Yes" "No")))


Measured memory_bytes: 13800
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll inf = 1e14;
const int mxn = 1e3 + 3;
int n, w, W[102], V[102];
ll dp[102][mxn * 102];

ll dfs( int i, int j ) {
	if( j == 0 ) return 0;
	if( i == 0 ) return (j == 0) ? 0 : inf;
	ll& ret = dp[i][j];
	if( ~ret ) return ret;

	ret = inf;
	ret = min(ret, dfs( i - 1, j ));
	if( j >= V[i] ) { 
		ret = min(ret, W[i] + dfs( i - 1, j - V[i] ));
	}
	return ret;
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n >> w;
	int sm = 0;
	for(int i = 1; i <= n; i++) {
		cin >> W[i] >> V[i];
		sm += V[i];
	}
	memset(dp, -1, sizeof dp);
	dfs( n, sm );
	for(int j = sm; j > 0; j--) {
		for(int i = 1; i <= n; i++) {
			dfs( i, j );
			if( dp[i][j] > 0 and dp[i][j] <= w ) {
				cout << j << "\n";
				exit(0);
			}
		}
	}
} 

Measured memory_bytes: 81792
#include <iostream>
using namespace std;
int main() {
 int a;
  int b;
  int c;
  
  cin >> a;
  cin >> b;
  
  c = (a*b)/2;
  c = c*2;
  
  if (a*b!=c) cout << "Yes";
  else cout << "No";
  cout <<endl;
}


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

int n,p[100010],cnt,vis[100010];
long long a[100010],l[100010],r[100010],ans;//l为原数，r为与l乘积为完全立方数的数 
map<long long,int> mp;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	scanf("%lld",&a[i]);
	vis[1]=1;
	for(int i=2;i<=2200;++i)
	{
		if(!vis[i])
		p[++cnt]=i;
		for(int j=1;j<=cnt&&p[j]*i<=2200;++j)
		{
			vis[p[j]*i]=1;
			if(i%p[j]==0)
			break;
		}
	}
	for(int i=1;i<=n;++i)
	{
		long long ji=a[i],qwq=1,ovo=1;
		for(int j=1;j<=cnt;++j)
		{
			int gg=0;
			while(ji%p[j]==0)
			{
				++gg;
				ji/=p[j];
			}
			gg%=3;
			if(gg)
			{
				for(int k=gg;k<3;++k)
				{
					qwq*=p[j];
					if(qwq>1e10)
					qwq=0;
				}
				while(gg)
				{
					ovo*=p[j];
					--gg;
				}
			}
		}
		l[i]=ovo*ji;
		mp[l[i]]++;
		r[i]=qwq;
		long long qaq=(long long)sqrt(ji);
		if(qaq*qaq!=ji)
		{
			if(ji*r[i]<=1e10)
			r[i]*=ji;
			else
			r[i]=0;
			if(ji*r[i]<=1e10)
			r[i]*=ji;
			else
			r[i]=0;
		}
		else
		{
			if(qaq*r[i]<=1e10)
			r[i]*=qaq;
			else
			r[i]=0;
		}
	}
	for(int i=1;i<=n;++i)
	{
		if(l[i]==1)
		continue;
		ans+=max(mp[l[i]],mp[r[i]]);
		mp[l[i]]=0;
		mp[r[i]]=0;
	}
	if(mp[1])
	ans++;
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    ll now = 0;
    ll res = 0;
    for (int i = 0; i < n; i++) {
        if(a[i]!=now+1){
            res++;
        }else{
            now++;
        }
    }
    if(res==n){
        std::cout << -1 << std::endl;
    }else{
        std::cout << res << std::endl;
    }
    
}


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

int32_t main()
{
    int n;
    cin>>n;
    int sum=0;

    int a[n];
    int ans=INT_MAX;
    
    for(int i=0;i<n;i++)
{    cin>>a[i];sum+=a[i];if(a[i]%10!=0)ans=min(ans,a[i]);
}



    if(sum%10!=0)
    cout<<sum<<endl;
    else if(sum%10==0 && ans==INT_MAX)
    cout<<0<<endl;
    else
    cout<<sum-ans<<endl;
   
}

Measured memory_bytes: 3644
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var t1 = int.Parse(line[0]);
        var t2 = int.Parse(line[1]);
        var r1 = int.Parse(line[2]);
        var r2 = int.Parse(line[3]);
        Console.WriteLine(getAns(t1, t2, r1, r2));
    }
    static string getAns(int t1, int t2, int r1, int r2)
    {
        if (r1 == -1 | r2 == -1)
        {
            if (t1 < t2) return "Alice";
            else if (t1 == t2) return "Draw";
            else return "Bob";
        }
        else
        {
            if (r1 > r2) return "Alice";
            else if (r1 == r2) return "Draw";
            else return "Bob";
        }
    }
}



Measured memory_bytes: 17960
function main(arg) {
    var xzahyo = [];
    var yzahyo = [];
    for(i=1;i<(arg.split(/\s|\r/g).length)/2;i++){
        xzahyo.push(arg.split(/\s|\r/g)[2*i-1]);
        yzahyo.push(arg.split(/\s|\r/g)[2*i]);
    }
    var nagasanowa = 0;
    for(j=0;j<xzahyo.length-1;j++){
        for(k=j+1;k<xzahyo.length;k++){
            nagasanowa += Math.sqrt( Math.pow(xzahyo[k]-xzahyo[j],2)+Math.pow(yzahyo[k]-yzahyo[j],2) );
        }
    }
    console.log(nagasanowa*2/arg.split(/\s|\r/g)[0]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21320
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();

		int pos = 0, ans = 0;

		for (int i=0; i<200; i++) {
			if (i%2 == 0) {

				if (pos + a >= 60 && pos <= c) {
					out.println((ans + (c - pos)));
					return;
				} else if (pos + a >= 60 && c <= (pos + a)%60) {
					out.println((ans + (60 - pos) + c));
					return;
				} else if (pos <= c && c <= pos + a) {
					out.println((ans + (c - pos)));
					return;
				}

				pos = (pos + a)%60;
				ans += a;

			} else {
				pos = (pos + b)%60;
				ans += b;
			}
		}

		out.println("-1");
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 26268
s = input()
len_s = len(s)
alp =  [0]*26
for i,j in enumerate(s):
  alp_index = ord(j) - ord("a")
  if alp[alp_index] == 0:
    alp[alp_index] = [i]
  else:
    alp[alp_index].append(i)
max_k = []
for i in alp:
  if i != 0:
    i.append(len_s)
    k = [i[0]]
    for j,l in enumerate(i[1:]):
      k.append(i[j+1]-i[j]-1)
    max_k.append(max(k))
     
print(min(max_k)) 

Measured memory_bytes: 3064