akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

const int MAX = 510000;
const int MOD = 1000000007;

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

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

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

Int pow_f(Int x, Int n) {
    Int ret = 1;
    while (n > 0) {
        if (n % 2 == 0) {
            x *= x;
            x %= mod;
            n >>= 1LL;
        }
        else {
            ret *= x;
            ret %= mod;
            n--;
        }
    }
    return ret;
}

int main() {
    COMinit();
    Int n, a, b;
    cin >> n >> a >> b;
    Int res = pow_f(2LL, n) - 1;
    Int nCa = 1;
    for (Int k = 0; k < a; k++) {
        nCa = nCa * (n - k) % mod * pow_f(k + 1, mod - 2) % mod;
        nCa %= mod;
    }
    Int nCb = 1;
    for (Int k = 0; k < b; k++) {
        nCb = nCb * (n - k) % mod * pow_f(k + 1, mod - 2) % mod;
        nCb %= mod;
    }
    //cout << nCa << " " << nCb << endl;
    //dump((res - nCa - nCb + 2 * mod) % mod);
    dump(((res - nCa + mod) % mod - nCb + mod) % mod);
    return 0;
}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
static const int MAX=100000;
static const int INFTY=(1<<30);

class Edge{
public:
	int t,w;
	Edge(){}
	Edge(int t,int w):t(t),w(w){}
};

vector<Edge> G[MAX];
int n,d[MAX];

bool vis[MAX];
int cnt;

void bfs(int s){
	for (int i = 0; i < n; ++i) {d[i]=INFTY;}
	queue<int> Q;
	Q.push(s);
	d[s]=0;
	int u;
	while(!Q.empty()){
	u=Q.front();Q.pop();
	for(int i=0;i<G[u].size();i++){
		Edge e=G[u][i];
		if(d[e.t]==INFTY){
			d[e.t]=d[u]+e.w;
			Q.push(e.t);
			}
		}
	}
}

void solve(){
	//???????????????s????????????????????????tgt????±??????????
	bfs(0);
	int maxv=0;
	int tgt=0;
	for (int i = 0; i < n; ++i) {
		if(d[i]==INFTY)continue;
		if(maxv<d[i]){
			maxv=d[i];
			tgt=i;
		}
	}
	//tgt????????????????????????????????¢maxv????±???????
	bfs(tgt);
	maxv=0;
	for (int i = 0; i < n; ++i) {
		if(d[i]==INFTY)continue;
		maxv=max(maxv,d[i]);
	}
	cout<<maxv<<endl;
}

int main(){
	int s,t,w;
	cin>>n;
	for (int i = 0; i < n-1; ++i) {
		cin>>s>>t>>w;
		G[s].push_back(Edge(t,w));
		G[t].push_back(Edge(s,w));
	}
	solve();
	return 0;
}

Measured memory_bytes: 9868
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>

using namespace std;
const long long P = 1000000007;
const long long INF = 1LL << 60;

int is_Prime(int x) {
  int i;
  if(x < 2) return 0;
  else if(x == 2) return 1;
  if(x % 2 == 0) return 0;
  for(int i = 3; i*i <= x ;i += 2) {
    if(x % i == 0) return 0;
  }
  return 1;
}

int main() {
  int x;
  cin >> x;
  while(true) {
    if(is_Prime(x)) {
      cout << x << endl;
      return 0;
    }
    x++;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

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

  vector<int> ans;
  if(N==0)  ans.push_back(0);
  while(N!=0){
    if(N%2!=0){
      ans.push_back(1);
      N--;
    }
    else  ans.push_back(0);
    N/=-2;
  }

  for(int i=ans.size()-1;i>=0;i--){
    cout << ans.at(i);
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()

//重み付きUnion-Find木(ランク無し)
struct UnionFind{
private:
	vector<int> parent;
	vector<long long> difference;
public:
	void init(int N){ //初期化する O(N)
		parent.clear();
		difference.clear();
		for(int i=0; i<N; i++){
			parent.push_back(i);
			difference.push_back(0);
		}
	}
	int root(int a){ //親を返す O(log N)
		if(parent[a] == a) return a;
		int r = root(parent[a]);
		difference[a] += difference[parent[a]];
		return parent[a] = r;
	}
	void unite(int a, int b, long long x){ //木を併合する x=a-b O(log N)
		int rootA = root(a);
		int rootB = root(b);
		if(rootA != rootB){
			x += weight(b);
			x -= weight(a);
			parent[rootA] = rootB;
			difference[rootA] = x;
		}
	}
	bool same(int a, int b){ //属する木が同じかを返す O(log N)
		return root(a) == root(b);
	}
	long long weight(int a){
		root(a); //経路圧縮
		return difference[a];
	}
	long long diff(int a, int b){ //重みの差を返す O(log N)
		return weight(a) - weight(b);
	}
};

int main(){
	
	int N,Q;
	cin >> N >> Q;
	UnionFind uf;
	uf.init(N);
	for(int i=0; i<Q; i++){
		int c;
		cin >> c;
		if(c == 0){
			int x,y,z;
			cin >> x >> y >> z;
			uf.unite(x,y,z);
		}
		else{
			int x,y;
			cin >> x >> y;
			if(uf.same(x,y)) cout << uf.diff(x,y) << endl;
			else cout << "?" << endl;
		}
	}

	return 0;
}




Measured memory_bytes: 4872
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int a, b, m, p[100010], q[100010];
int main() {
	scanf("%d %d %d", &a, &b, &m);
	for (int i = 0; i < a; i++)
		scanf("%d", p + i);
	for (int i = 0; i < b; i++)
		scanf("%d", q + i);
	int minp = 1e9, minq = 1e9;
	for (int i = 0; i < a; i++)
		minp = min(minp, p[i]);
	for (int i = 0; i < b; i++)
		minq = min(minq, q[i]);
	int minc = minp + minq;
	for (int i = 0; i < m; i++) {
		int x, y, c;
		scanf("%d %d %d", &x, &y, &c);
		minc = min(minc, p[x - 1] + q[y - 1] - c);
	}
	printf("%d\n", minc);
}

Measured memory_bytes: 896
# coding: utf-8
n, k = map(int, input().split())
l = []
ll = []
for i in range(n):
    a, b = map(int, input().split())
    l.append(b)
    ll.append([a, b])
ll.sort(key=lambda x: x[0])
for i in range(n):
    if k <= ll[i][1]:
        print(ll[i][0])
        break
    k -= ll[i][1]

Measured memory_bytes: 22144
N,M = map(int, input().split())
mem = [[] for i in range(N)]

p1 = []
p2 = []
def solve():
    for i in range(M):
        a,b = map(int, input().split())
        if a == 1:
            p1.append(b)
        elif b == N:
            p2.append(a)
    return len(set(p1) & set(p2)) > 0

print('POSSIBLE' if solve() else 'IMPOSSIBLE')


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int n;
	cin >> n;
	int a[n];
	rep(i, 0, n) cin >> a[i];

	ll rsl = 0;
	rep(i, 0, n) {
		if(a[i] > 0) {
			if(i > 0 and a[i - 1] == 1) {
				rsl++;
				a[i]--;
			}
			rsl += (a[i] / 2);
			if(a[i] % 2 == 0) a[i] = 0;
			else a[i] = 1;
		}
	}

	cout << rsl << endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n;
    string s;
    int cnt[26] = {};
    long long int ans = 1;


    cin >> n >> s;

    for (int i = 0; i < n; i++) {
        cnt[s[i]-'a']++;
    }

    for (int i = 0; i < 26; i++) {
        if (cnt[i]) {
            ans *= (cnt[i]+1);
        }
        ans %= 1000000007;
    }

    cout << ans-1 << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  string S; cin >> S;
  vector<int> res;
  for (int i = 0; i < N; ++i){
    int length = 1;
    while(S[i] == S[i + 1] && i + 1 < N) ++length, ++i;
    res.push_back(length);
  }
  cout << res.size() << endl;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define int 		long long
#define ull 		unsigned long long
#define vi 			vector<int>
#define vvi			vector<vi>
#define pb			push_back
#define mii  		map<int, int>
#define pii 		pair<int, int>
#define pq 			priority_queue<int>
#define pqs 		priority_queue<int, vi, greater<int>>
#define mod 		1000000007
#define inf 		1e18
#define ps(x, y) 	fixed<<setprecision(y)<<x
#define w(t)		int t; cin>>t; while(t--)
#define rep(i,a,b)	for(int i = a; i < b; i++)
#define repd(i,a,b)	for(int i = a; i>= b; i--)
/*void inout()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt","w",stdout);
	#endif
}*/
int32_t main()
{
	//inout();
	string s, t;
	cin>>s>>t;
	int dp[s.size()+1][t.size()+1];
	rep(i, 0, s.size()+1)
		dp[i][0] = 0;
	rep(i, 0, t.size()+1)
		dp[0][i] = 0;
	rep(i, 1, s.size()+1)
		rep(j, 1, t.size()+1)
			if(s[i-1] == t[j-1])
				dp[i][j] = dp[i-1][j-1] + 1;
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
	int i = s.size(), j = t.size();
	string ans = "";
	while(dp[i][j] != 0)
	{
		if(s[i-1] == t[j-1])
		{
			ans = s[i-1] + ans;
			i--;
			j--;
		}
		else if(dp[i-1][j] >= dp[i][j-1])
			i--;
		else if(dp[i-1][j] < dp[i][j-1])
			j--;
	}
	cout<<ans;
	return 0;
}

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

signed main(void)
{
	int h, w;
	cin >> h >> w;
	char a[h][w];
	rep(i, h) rep(j, w) cin >> a[i][j];
	rep(i, w + 2) cout << '#';
	cout << endl;
	rep(i, h)
	{
		cout << '#';
		rep(j, w)
		{
			cout << a[i][j];
		}
		cout << '#' << endl;
	}
	rep(i, w + 2) cout << '#';
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<math.h>


#define square(x) x*x;
#define ll long long;



using namespace std;




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

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    long long int t;
    cin >> t;
    long long int curr = 0;
    while (t--)
    {
        long long int a, b;
        cin >> a >> b;
        if (a == b)
            curr++;
        else {
            curr = 0;
        }
        if (curr >= 3)
        {
            cout << "Yes" << endl;
            break;
        }
    }
    if (curr < 3)
        cout << "No" << endl;


    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
	char c[3];
  	cin >> c[0] >> c[1] >> c[2];
  	bool w = 0;
  	w |= c[0] == 'A' && c[1] == 'B';
  	w |= c[1] == 'A' && c[0] == 'B';
	w |= c[1] == 'A' && c[2] == 'B';
  	w |= c[2] == 'A' && c[1] == 'B';
  	cout << (w ? "Yes" : "No") << endl;

}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s=sc.next();
		//String[] t=new String[4];
		int n = sc.nextInt();
		int m = sc.nextInt();
		//int k = sc.nextInt();
		long count=0;
		long count1=0;
		int[] array = new int[3];
		array[0]=n-m;
		array[1]=n*m;
		array[2]=n+m;
		Arrays.sort(array);

		/*for(int i=0;i<4;i++) {
			t[i]=s.substring(i,i+1);
			System.out.println(t[i]);
		}*/

		/*if(count>2||count1>=2) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}*/

		System.out.println(array[2]);
	}
}




Measured memory_bytes: 21844
#include <stdio.h>

#define MAX 10000
#define NIL -1

struct Node {int p, l, r;};
struct Node T[MAX];
int n;

/* 先行順巡回 */
void preParse(int u) {
  if(u == NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

/* 中間順巡回 */
void inParse(int u) {
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

/* 後方順巡回 */
void postParse(int u) {
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(void) {
  int i, v, l, r, root;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    T[i].p = NIL;
  }
  
  for(i=0; i<n; i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }
  
  for(i=0;i<n;i++) if(T[i].p == NIL) root = i;
  
  printf("Preorder\n");
  preParse(root);
  printf("\n");

  printf("Inorder\n");
  inParse(root);
  printf("\n");

  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}

/*
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1
*/



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

int main(void){
  int a, b, i; string s;
  cin >> a >> b >> s;

  if(s[a] != '-'){
    cout << "No" << endl;
    return 0;
  }

  for(i = 0; i < a+b+1; i++){
    if(i == a) continue;
    if(s[i] < '0' || s[i] > '9'){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define lld long long int 

//-4%3=-1
int x,y,mod=1e9+7;
char arr[1001][1001];
int dp[1001][1001];

int fun(int h,int w)
{
    if(h==x&&w==y)
    return 1;
    if(dp[h][w]!=-1)
    return dp[h][w];
    else
    {
        if(h+1<=x && w+1<=y)
        {   if(arr[h+1][w]=='.'&&arr[h][w+1]=='.')
            return dp[h][w]=(fun(h+1,w)%mod+fun(h,w+1)%mod)%mod;
            else if(arr[h+1][w]!='.'&&arr[h][w+1]=='.')
            return dp[h][w]=fun(h,w+1)%mod;
            else if(arr[h+1][w]=='.'&&arr[h][w+1]!='.')
            return dp[h][w]=fun(h+1,w)%mod;
            else 
            return dp[h][w]=0;
        }
        else if(h+1>x && w+1<=y)
        {   
            if(arr[h][w+1]=='.')
            return dp[h][w]=fun(h,w+1);
            else 
            return dp[h][w]=0;
        }
        else if(h+1<=x && w+1>y)
        {
            if(arr[h+1][w]=='.')
            return dp[h][w]=fun(h+1,w);
            else 
            return dp[h][w]=0;
        }
        
    }
    return dp[h][w];
    
}
int main() {
	// your code goes here
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t;
    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>x>>y;
        for(int i=1;i<=x;i++)
        for(int j=1;j<=y;j++)
        cin>>arr[i][j];
        memset(dp,-1,sizeof(dp));
        cout<<fun(1,1);
        /*for(int i=1;i<=x;i++)
        {
            for(int j=1;j<=y;j++)
            cout<<dp[i][j]<<" ";
            cout<<"\n";
        }*/
    }
    
}



Measured memory_bytes: 5248
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int M,N,Q;
int A[MAXN],a[MAXN],b[MAXN],c[MAXN],d[MAXN];
int ans;

int cal(){
    int tmp=0;
    for(int i=1;i<=Q;i++){
        if(A[b[i]]-A[a[i]]==c[i]) tmp+=d[i];
    }
    return tmp;
}

void DFS(int cur,int mi){
    if(cur==N+1){
        ans=max(ans,cal());
        return;
    }
    for(int i=mi;i<=M;i++){
        A[cur]=i;
        DFS(cur+1,i);
    }
}

void work(){
    scanf("%d%d%d",&N,&M,&Q);
    for(int i=1;i<=Q;i++){
        scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
    }
    ans=0;
    DFS(1,1);
    printf("%d\n",ans);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}








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

int main() {
	int n,d,cnt=0; cin>>n>>d;
	float a[n][d],x=0;
	for(int i=0;i<n;i++) for(int j=0;j<d;j++) cin>>a[i][j];
	for(int i=0;i<n;i++) {
		for(int j=0;j<i;j++) {
			for(int k=0;k<d;k++) 
				x+=((a[i][k]-a[j][k])*(a[i][k]-a[j][k]));
				
			x=sqrt(x);
			
			if(x==floor(x)) cnt++; x=0;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
const int N = 1000000007;

int n,m;
int dp[3005][3005] = {0};
char ch;

int main(){
	ios::sync_with_stdio(false);
	dp[1][1] = 1;
	cin >> n >> m;
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= m;j ++){
			cin >> ch;
			if(ch == '.' && (!(i == 1 && j == 1))){
				dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
				dp[i][j] %= N;
			}
		}
	}
	printf("%d\n",dp[n][m]);
	return 0;
}
//

Measured memory_bytes: 11904
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
    LL N,K;
    cin >> N >> K;
    LL ans=N*500;
    if(ans>=K){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

Measured memory_bytes: 256
import sys
from collections import deque

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())

G = [[] for _ in range(N+1)]
m = map(int, read().split())
for a,b in zip(m, m):
    G[a].append(b)
    G[b].append(a)

par = [0]*(N+1)
visited = [0] * (N+1)
root = 1
visited[root] = 1
q = deque([root])
while q:
    v = q.popleft()
    for w in G[v]:
        if visited[w]:
            continue
        visited[w]=1
        par[w] = v
        q.append(w)

print('Yes')
print(*par[2:], sep='\n')

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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;

int main(int argc, char *argv[]) {
    ll n;
    cin >> n;

    vector<ll> a(n);
    REP(i, n) {
        cin >> a[i];
    }

    ll tmp = n;
    while (tmp >= 2) {
        cout << a[tmp-1] << " ";
        if(tmp > 2) tmp -= 2;
        else tmp = 1;
    }

    while (tmp <= n) {
        cout << a[tmp-1] << " ";
        if (tmp == 1 && n % 2 == 1) tmp++;
        else tmp += 2;
    }
    cout << endl;
}


Measured memory_bytes: 3840
use io::*;

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: usize = sc.next();
    let m: usize = sc.next();
    let q: usize = sc.next();

    let ts: Vec<(usize, usize)> = (0..m)
        .map(|_| {
            let l: usize = sc.next();
            let r: usize = sc.next();
            (l - 1, r - 1)
        })
        .collect();

    let mut tbl = vec![vec![0; n]; n];

    for &(l, r) in ts.iter() {
        for rr in r..n {
            tbl[l][rr] += 1;
        }
    }

    for _ in 0..q {
        let p: usize = sc.next();
        let q: usize = sc.next();
        let p = p - 1;
        let q = q - 1;

        let mut ans = 0;
        for ll in p..n {
            ans += tbl[ll][q];
        }
        println!("{}", ans);
    }
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


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

int main(){
    
    int h,w;
    int ch,cw,dh,dw;

    cin >> h >> w;
    int INF = pow(10,6);
    vector<vector<int>> s(h,vector<int>(w));
    
    cin >> ch >> cw >> dh >> dw;

    for (int i=0;i<h;i++){
        string tmp;
        cin >> tmp;
        for (int j=0;j<w;j++){
            if (tmp.at(j) == '#') {
                s.at(i).at(j) = -1;
            } else {
                s.at(i).at(j) = INF;
            }
        }
    }
    
    int weight = 0;
    deque<pair<int,int>> checklist;
    checklist.push_front(make_pair(ch-1,cw-1));
    
    while(!checklist.empty()){
        vector<pair<int,int>> warplist;
        while(!checklist.empty()){
            int x,y;
            tie(x,y) = checklist.front();
            checklist.pop_front();
            warplist.push_back(make_pair(x,y));
            if (x-1 >= 0 && s.at(x-1).at(y) > weight){
                s.at(x-1).at(y) = weight;
                checklist.push_back(make_pair(x-1,y));
            }
            if (x+1 < h && s.at(x+1).at(y) > weight){
                s.at(x+1).at(y) = weight;
                checklist.push_back(make_pair(x+1,y));
            }
            if (y-1 >= 0 && s.at(x).at(y-1) > weight){
                s.at(x).at(y-1) = weight;
                checklist.push_back(make_pair(x,y-1));
            }
            if (y+1 < w && s.at(x).at(y+1) > weight){
                s.at(x).at(y+1) = weight;
                checklist.push_back(make_pair(x,y+1));
            }
        }
        if (s.at(dh-1).at(dw-1) != INF) break;
        weight++;
        
        for (int i=0;i<warplist.size();i++){
            int x,y;
            tie(x,y) = warplist.at(i);
            for (int j=max(0,x-2);j<min(h,x+3);j++){
                for (int k=max(0,y-2);k<min(w,y+3);k++){
                    if (s.at(j).at(k) > weight){
                        s.at(j).at(k) = weight;
                        checklist.push_back(make_pair(j,k));
                    }
                }
            }
        }
    }
    if (s.at(dh-1).at(dw-1) == INF) {
        cout << -1 << endl;
    } else {
        cout << s.at(dh-1).at(dw-1) << endl;
    }

 
}

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

using namespace std;


int total_dist(int x, vector<int> v){
  int sum=0;
  for (auto it = v.begin();it != v.end();it++) {
    sum += (*it - x)*(*it - x);
  }
  return(sum);
}

int main(){
  int n;
  int min_sum = 10000000;
  vector<int> v;
  cin >> n;
  for (int i=0;i<n;i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  
  for (int i=1;i<=100;i++) {
    int sum = total_dist(i, v);
    min_sum = sum < min_sum?sum:min_sum;
  }
  cout << min_sum << endl;
  return(0);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset> 
using namespace std;
typedef long long ll;
ll n,k;
ll a[200005];
ll b[200005]={0};
int main(void)
{
	scanf("%lld%lld",&n,&k);
	for(ll i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	ll i1=0;
	while(true)
	{
		ll now=0;
		memset(b,0,sizeof(b));
		for(ll i=0;i<n;i++)
		{
			if(i-a[i]<0) b[0]++;
			else b[i-a[i]]++;
			if(i+a[i]<n) b[i+a[i]+1]--;
		}
		for(ll i=1;i<n;i++) b[i]+=b[i-1];
		for(ll i=0;i<n;i++) if(b[i]>=n) now++;
		if(now==n) break;
		i1++;
		if(i1==k) break;
		for(ll i=0;i<n;i++) a[i]=b[i];
	}
	
	if(i1==k)
	{
		for(ll i=0;i<n;i++)
		{
			printf("%lld ",b[i]);
		}
	}
	else
	{
		for(ll i=0;i<n;i++)
		{
			printf("%lld ",n);
		}
	}
}

Measured memory_bytes: 6884
//i hate _____
#include<bits/stdc++.h>

#define ll long long int 
#define ld long double 
#define pb push_back
#define mk make_pair
#define ii pair<int,int>

using namespace std;
double pi=2*acos(0.0);

/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/

template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << " " << x;
        return os << '}'; 
}

void solve(){
    int n; cin>>n;
    int ans=n+(n*n)+(n*n*n);
    cout << ans << endl;
}

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

    int test_cases=1; 
    //cin>>test_cases;

    for (int tc=1;tc<=test_cases;tc++){
        
        solve();
        //cout << "Case " << tc << ": " << solve() <<endl;
        //printf("Case %d: %.10lf",tc,ans);
    }
    return 0;
}
/*
    problems are the sign of life
*/


Measured memory_bytes: 3588
import java.util.Arrays;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int[] a = new int[N];

        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }

        int alice = 0;
        int bob = 0;

        Arrays.sort(a);
        int index = 0;
        for (int i = N - 1; i >= 0; i--) {
            if (index % 2 == 0)
                alice += a[i];
            else
                bob += a[i];

            index++;
        }

        System.out.println(alice - bob);
        sc.close();
    }
}

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

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

    if(s[0] == s[1] && s[1] == s[2])
        cout << "Yes" << endl;
    else if(s[1] == s[2] && s[2] == s[3])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

int T,N,K,X[100000+10],A[100000+10];

int main(){
	cin >> T;
	for (int t=0; t<T; ++t){
		cin >> N >> K;
		for (int i = 0; i<N; ++i){
			cin >> X[i];
		}
		for (int i = 0; i+1<N; ++i){
			A[i] = X[i+1] - X[i];
		}
		sort(A,A+N-1);
		int sum = 0;
		for (int i = 0; i < max(0,N-1-(K-1)); i++){
	sum += A[i];
}
cout << sum << endl;
	}
}

Measured memory_bytes: 1956
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<random>
#include<numeric>
#include<string>
#include<stack>
#include<cstring>
typedef long long ll;
typedef long double ld;
using namespace std;
ll dx[] = { 0,0,1,-1 };
ll dy[] = { 1,-1,0,0 };

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}
ll prime(ll x) {
	ll i;
	if (x < 2)return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (i = 3; i*i <= x; i += 2) {
		if (x%i == 0) return 0;
	}
	return 1;
}
int main() {
	string S;
	cin >> S;
	if (S[0] == '9' || S[1] == '9')
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
/****** define constant end ********/
/****** define variable start ******/
ll r;
/******* define variable end *******/
int solve() {
	cin >> r;
	cout << 2 * PI * r << endl;
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3792
# coding: utf-8
def main():
    x,y= map(int, input().split())
    total = 0
    if x == 1:
        total += 300000
    elif x == 2:
        total += 200000
    elif x == 3:
        total += 100000
    if y == 1:
        total += 300000
    elif y == 2:
        total += 200000
    elif y == 3:
        total += 100000
    if total == 600000:
        total += 400000
    print(total)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
	int n,m,p;
	int x;
	int sum;
	int num;

	while(1){
		cin>>n>>m>>p;
		if(n+m+p==0) break;

		sum=0;

		for(int i1=0;i1<n;i1++){
			cin>>x;
			sum+=(x*100);

			if(i1==m-1) num=x;
		}
		sum-=(sum*p/100);

		if(num==0) cout<<0<<endl;
		else cout<<sum/num<<endl;

	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <algorithm>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include<deque>
#include<iomanip>

#define INF 1e9
#define MOD 1000000007
#define ll long long
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef unsigned long long ull;
typedef pair<ll, int> pr;

ll a[100001];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int>l(n);
    int x=0;
    for(int i=0;i<n;i++){
        cin>>l[i];
        x+=l[i];
    }
    int ma=*max_element(l.begin(), l.end());
    if(ma<x-ma){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

int md(pair<int,int> a,pair<int,int> b){
	return abs(a.first-b.first)+abs(a.second-b.second);
}

int main(){
	//マスに入れる数字を0~h*w-1と思う
	int h,w,d;
	cin>>h>>w>>d;
	vector<pair<int,int>> b(h*w);
	int ta;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin>>ta;
			b[ta-1]=make_pair(i,j);
		}
	}
	int q;
	cin>>q;
	vector<pair<int,int>> query(q);
	int tl,tr;
	for (int i = 0; i < q; i++) {
		cin>>tl>>tr;
		query[i]=make_pair(tl-1,tr-1);
	}
	//mp[i][j]:iからj回移動するのに掛かる魔力
	vector<vector<int>> mp(d,vector<int>(h*w/d+1,0));
	for (int i = 0; i < d; i++) {
		for (int j = 1; i+j*d<h*w; j++) {
			mp[i][j]=mp[i][j-1]+md(b[i+d*(j-1)],b[i+d*j]);
		}
	}
	int start;
	int step1,step2;
	for (int i = 0; i < q; i++) {
		start=query[i].first%d;
		step1=query[i].first/d;
		step2=query[i].second/d;
		cout<<mp[start][step2]-mp[start][step1]<<endl;
	}
}

Measured memory_bytes: 6784
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if (a+b<c+d){
        	System.out.print("Right");
        }else if (a+b>c+d){
        	System.out.print("Left");
        }else{
        	System.out.print("Balanced");
        }
		
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007



ll a[100010],b[100010];
int main() {
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	ll sum=0;
	for(int i=0;i<=n;i++){
		b[i]=abs(a[i+1]-a[i]);
		sum+=b[i];
		//cout << b[i];
	}
	for(int i=1;i<=n;i++){
		ll now=abs(a[i+1]-a[i-1])-abs(a[i-1]-a[i])-abs(a[i+1]-a[i]);
		cout << sum+now<<" ";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 2816
k = int(input())

class Myqueue:
  def __init__(self):
    self.queue = []
    
  def enqueue (self, item):
    self.queue.append(item)
  
  def dequeue (self):
    if len(self.queue) ==0:
      return None
    result =self.queue[0]
    del self.queue[0]
    return result

myq = Myqueue()
myq.enqueue(1)
myq.enqueue(2)
myq.enqueue(3)
myq.enqueue(4)
myq.enqueue(5)
myq.enqueue(6)
myq.enqueue(7)
myq.enqueue(8)
myq.enqueue(9)

K = 9
s = 9
if k < 10:
  None
elif k >= 10:
  while s <= k:
    x = myq.dequeue()
    I = x % 10
    if I == 0:
      myq.enqueue(x*10 + I)
      myq.enqueue(x*10 + (I+1))
      s += 2
    elif I ==9:
      myq.enqueue(x*10 + (I-1))
      myq.enqueue(x*10 + I)
      s += 2
    else:
      myq.enqueue(x*10 + (I-1))
      myq.enqueue(x*10 + I)
      myq.enqueue(x*10 + (I+1))
      s += 3

if k < 10:
  print(k)
elif s - 2 == k:
  print(myq.queue[-3])
elif s - 1 == k:
  print(myq.queue[-2])
elif s == k:
  print(myq.queue[-1])
elif s -3 == k:
  print(myq.queue[-4])
  

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

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

    int ans = 0;
    for(int i = 0; i < N; i++){

        if(a[i] % 2) continue;
        
        while(a[i] % 2 == 0){
            ans++;
            a[i] /= 2;
        }

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

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
int x,y,z,i;
int a=0;
cin >> x  >> y >> z;
for (i=x;i<=y;i++){
  if(z%i==0){
    a++;
  } else {
  }

}
cout << a << endl;
  return 0;
}



Measured memory_bytes: 3116
#include<stdio.h>
int main(void)
{
	int i = 0;
	int height[10] ={NULL};
	int temp, flag=0;

	for (i = 0; i < 10; i++) {
		scanf("%d", &height[i]);
	}


	do {
		flag = 0;
		for (i = 0; i < 9; i++) {
			if (height[i] > height[i + 1]) {
				flag = 1;
				temp = height[i + 1];
				height[i + 1] = height[i];
				height[i] = temp;
			}
		}
	} while (flag);
	printf("%d\n%d\n%d\n", height[9], height[8], height[7]);

	return 0;

}

Measured memory_bytes: 600
#include <iostream>
#define llint long long

using namespace std;

llint r, g, b, n;

int main(void)
{
	cin >> r >> g >> b >> n;
	
	llint ans = 0;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++){
			llint rem = n-(r*i+g*j);
			if(rem >= 0 && rem % b == 0) ans++;
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

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

    int t = 5;
    while (t--) {
        int x;
        cin >> x;
        if (!x) {
            cout << (5 - t) << '\n';
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  char c;
  cin >> c;
  string ans = "consonant";

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    ans = "vowel";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
S = input()

def dfs(i, f):
    if i == N-1:
        return sum(map(int, f.split('+')))
    return dfs(i+1, f + S[i+1]) + dfs(i+1, f+'+'+S[i+1])

N = len(S)
print(dfs(0, S[0]))


Measured memory_bytes: 9124
# coding: utf-8

import sys
import math
import collections
import itertools
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
MOD = 10 **9 + 7

N = int(input())
# S = input()
# N, M = map(int, input().split())
# 横
# L = [int(x) for x in input().split()]
# 縦
S = [''.join(sorted(input())) for _ in range(N)]
# 多次元
# L = [[int(x) for x in input().split()] for _ in range(N)]

ans = 0
dic = {}
for s in S :
    if not s in dic :
        dic[s] = 0
    
    ans += dic[s]
    dic[s] += 1

print(ans)


Measured memory_bytes: 63452
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int N;
	cin >> N;
	int A[N];
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	int ret = 0;
	for(int i = 0; i < N; i++){
		while(1){
			if(A[i]%2 == 0){
				A[i] /= 2;
				ret++;
			}else{
				break;
			}
		}
	}
	cout << ret << endl;
	return 0;
}

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

int digit(int x) {
	int y = 0;
	while (x != 0) {
		y += x % 10;
		x /= 10;
	}
	return y;
}
int main() {
	int N, min = 1000;
	cin >> N;
	for (int i = 1; i <= N / 2; i++) {
		int j = N - i;
		int X = digit(i) + digit(j);
		if (X < min) min = X;
	}
	cout << min << endl;
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++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 ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    lint a, b, c;
    cin >> a >> b >> c;
    lint ans = b + c - max(c - a - b - 1LL, 0LL);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        x: usize,
    }

    let mut burger = vec![0; n+1];
    let mut p = vec![0; n+1];

    p[0] = 1;
    burger[0] = 1;
    for i in 1..n+1 {
        p[i] = 2 * p[i - 1] + 1;
        burger[i] = 2 * burger[i - 1] + 3;
    }

    let ans = f(n, x, &burger, &p);

    println!("{}", ans);
}

fn f(n: usize, x: usize, burger: &Vec<usize>, p: &Vec<usize>) -> usize {
    if n == 0 {
        return if x == 0 { 0 } else { 1 };
    } else if x <= 1 {
        return 0;
    } else if x > 1 && x <= burger[n - 1] + 1 {
        return f(n - 1, x - 1, burger, p);
    } else if x == burger[n - 1] + 1 {
        return p[n - 1] + 1;
    } else {
        return f(n - 1, x - burger[n - 1] - 2, burger, p) + p[n - 1] + 1;
    }
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k;
string s;


// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> m;
	cout<<(n+m+1)/2;
	
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 238032
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long mod=1000000007;
		int num=0;
		long ans=1;
		for(int i=0; i<n; i++){
			int x=sc.nextInt();
			int next=2*num+1;
			num++;
			if(next>x){
				ans*=num;
				ans%=mod;
				num--;
			}
		}
		for(int i=num; i>=2; i--){
			ans*=i;
			ans%=mod;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 48688
N = int(input()) #1行目のNを取得
l = [int(input()) for i in range(N)] #N回繰り返し s に値を取得

l.sort()


a=0
ans=0
for i in l:
	if i==a:
		ans -= 1
		a=0
	else:
		ans += 1
		a=i

print(ans)


Measured memory_bytes: 7388
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef pair<double,double> P;
typedef pair<double,int> Q;
struct BIT
{
	// [0,size)
	vector<int> tree;
	int size;
	BIT(int s){
		size=s;
		tree.resize(size+1);
	}
	void init(int s){
		size=s;
		tree.clear();
		tree.resize(size+1);
	}
	void add(int i,int v){
		i++;
		while(i<=size){
			tree[i]+=v;
			i+=(i&-i);
		}
	}

	// [0,i)
	int collect(int i){
		int r=0;
		while(i>0){
			r+=tree[i];
			i-=(i&-i);
		}
		return r;
	}

	// [a,b)
	int collect(int a, int b){
		return collect(b)-collect(a);
	}
};



int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<double> A(N);
    std::vector<double> B(N);
    std::vector<double> C(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lf",&A[i]);
        scanf("%lf",&B[i]);
        scanf("%lf",&C[i]);
    }

	BIT bit(N);
	vector<P> ps;
	vector<Q> qs;
	double ret[2];
	for(int K=0;K<2;K++){
		double low=-1e9;
		double hi=1e9;
		ps.clear();
		for(int i=0;i<N;i++){
			ps.push_back(P(-A[i]/B[i],C[i]/B[i]));
		}
		sort(ps.begin(),ps.end());
		for(int t=0;t<100;t++){
			double m=(low+hi)/2;
			qs.clear();
			for(int i=0;i<N;i++){
				qs.push_back(Q(ps[i].first*m+ps[i].second,i));
			}
			sort(qs.begin(),qs.end());
			bit.init(N);
			int c=0;
			for(int i=0;i<N;i++){
				c+=bit.collect(qs[i].second,N);
				bit.add(qs[i].second,1);
			}
			if(c<=N*(N-1)/4)
			{
				hi=m;
			}
			else{
				low=m;
			}
		}
		ret[K]=(low+hi)/2;
		A.swap(B);
	}
	cout.precision(17);
	cout << ret[0] << " " << ret[1] << endl;


    return 0;
}


Measured memory_bytes: 3572
package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)

	p := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &p[i])
	}
	wrong := 0
	for i, pi := range p {
		if (i+1) != pi {
			wrong++
		}
	}

	if wrong <= 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
from collections import Counter

n = int(input())
c = Counter(input())
for _ in range(n-1):
    nc = Counter(input())
    for k, v in c.items():
        c[k] = min(v, nc[k])
        
s = ''
for k, v in c.items():
    s += k*v
print(''.join(sorted(list(s))))

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
const int N = 2e5 + 5;
vector<vector<int> > adj(N);
bool visited[N];
int n, m;
int ans = 1;
int cnt = 0;
void dfs(int s){
    if(!visited[s]){
        visited[s] = 1;
        cnt++;
        for(int i = 0; i < adj[s].size(); i++){
            dfs(adj[s][i]);
        }
    }
}
int main(){
    FAST
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for(int i = 0; i < n; i++){
        if(!visited[i]){
            dfs(i);
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    cout << ans<< endl;
    return 0;
}


Measured memory_bytes: 20604