akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }



void solve()
{
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    if(n%2 == 0)
    {
        for(ll i = n-1; i >= 0; i-=2) cout << a[i] << " ";
        for(ll i = 0; i < n; i+=2) cout << a[i] << " ";
    }
    else{
        for(ll i = n-1; i >= 0; i-=2) cout << a[i] << " ";
        for(ll i = 1; i < n; i+=2) cout << a[i] << " ";
    }

}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
const int M=2e6+100;//M=300000;//
typedef long long int ll;
using namespace std;
 
ll n,m,i,j,x,y,z,t,k(0),cnt(0),ans(0),sum(0),mn(M),mx(-9e9);

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s,s2;
	cin>>s>>s2;
	for(i=0;i<=s.size()-s2.size();i++)
	{
		j=0;
		k=i;
		cnt=0;
		for(j=0;j<s2.size();j++)
		{
			if(s[k]==s2[j])
			{
				cnt++;		
			}
			k++;
		}
		mx=max(mx,cnt);
		
	}
	//cout<<mx<<endl;
	cout<<s2.size()-mx;

}

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

void solve(long long N, std::vector<long long> A){
    vector<pair<ll, ll> > v;
    for (ll i = 0; i < N; i++) {
        v.push_back(make_pair(i + 1, A[i]));
    }
    sort(v.begin(), v.end(), 
        [](auto x, auto y) {return x.second < y.second;});

    for (ll i = 0; i < N; i++) {
        cout << v[i].first;
        if (i != N -1) cout << " ";
    }
    cout << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 3312
n = int(input())

import itertools

arr = []

for i in range(n):
    arr.append(list(map(int,input().split())))


ptr = list(itertools.permutations(arr, n))


dis = 0

for i in range(len(ptr)):
    for j in range(n-1):
        dis +=((ptr[i][j][1]-ptr[i][j+1][1]) **2 + (ptr[i][j][0]-ptr[i][j+1][0])**2)**0.5
        
print(dis/len(ptr))


    

Measured memory_bytes: 8180
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    long K = Long.parseLong(sc.next());
    long[] count = new long[100001];
    for (int i =0; i<N; i++) {
      int a = Integer.parseInt(sc.next());
      count[a] += Long.parseLong(sc.next());
    }
    long total =0, ans =0;
    for (int i =0; i<100001; i++) {
      total += (long)count[i];
      if (total >= K)  {
        ans =i;
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 50168
import sys

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
B = rl()
l = []
for i in range(N):
    if i + 1 < B[i]:
        print(-1)
        exit()

while B:
    for i in range(len(B)-1, -1, -1):
        if i + 1 == B[i]:
            l.append(B.pop(i))
            break

l = l[::-1]
print(*l, sep='\n')
# 47


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

using namespace std;

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

const ll MOD = 1000000007;

ll n, k, ans = 0;

void solve(ll b) {
	ll s = (n - k) / b;
	ans += s*(b - k);
	ans += min(n, b*s + b - 1) - (b * s + k) + 1;
}


int main() {
	cin >> n >> k;
	for (ll i = k + 1; i <= n; i++) {
		solve(i);
	}
	if (k == 0)ans -= n;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def cmb(n, k, mod, fac, ifac):
    # nCkを計算する
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod

def make_tables(mod, n):
    # 階乗テーブル、逆元の階乗テーブルを作成する
    fac = [1, 1] # 階乗テーブル
    ifac = [1, 1] # 逆元の階乗テーブル
    inverse = [0, 1] # 逆元テーブル 0の階乗は1

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

X, Y = map(int, input().split())
if X > Y:
    X, Y = Y, X
dist = X + Y
if dist % 3 != 0:
    print(0)
    exit()

total = int((X+Y) / 3)
n = X - total
if Y > 2*X:
    print(0)
else:
    MOD = 10**9 + 7
    fac, ifac = make_tables(MOD, total)
    answer = cmb(total, n, MOD, fac, ifac)
    print(answer)

"""
p = (p/a)×a + (p %a)
この両辺の mod p をとると、
(p/a)×a + (p%a) ≡ 0
⇔(p/a) + (p%a)×a−1 ≡ 0　(両辺に a−1 をかける)

⇔(p%a) × a−1 ≡ −(p/a)
⇔a−1 ≡ −(((p%a)^−1) × (p/a))
"""

Measured memory_bytes: 82644
x,y = map(int, input().split())

mat = [list(map(int, input().split())) for i in range(x)]
vct = [int(input()) for i in range(y)]

for m in mat:
    ddd = 0
    for a in range(y):
        ddd += m[a] * vct[a]
    print(ddd)


Measured memory_bytes: 6012
long d[2<<17],*p;main(a,k){scanf("%*d%d",&k);p=d+k;for(*p=1;~scanf("%d",&a);){for(;d-p--;)*p+=p[1];for(;*++p;*p%=k=1e9+7)*p-=p[a+1];}printf("%d",*d);}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <utility>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef list<ll> listl;
typedef string str;

#define min(A, B) min(static_cast<ll>(A), static_cast<ll>(B))
#define max(A, B) max(static_cast<ll>(A), static_cast<ll>(B))
#define all(x) (x).begin(), (x).end()
#define mp make_pair

#define _rep(i, m)		for(ll i = 0, i_max = m; i < i_max; i++)
#define _erep(i, m)		for(ll i = 0, i_max = m; i <= i_max; i++)
#define _brep(i, b, m)	for(ll i = b, i_max = m; i < i_max; i++)
#define _ebrep(i, b, m)	for(ll i = b, i_max = m; i <= i_max; i++)
#define _rrep(i, m)		for(ll i = m; i >= 0; i--)
#define _rerep(i, b, e)	for(ll i = b; i >= e; i--)

#define rep(m)			_rep(i, m)
#define erep(m)			_erep(i, m)
#define brep(b, m)		_brep(i, b, m)
#define ebrep(b, m)		_ebrep(i, b, m)
#define rrep(m)			_rrep(i, m)
#define rerep(b, e)		_rerep(i, b, e)

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void in(ll& I)
{
	cin >> I;
}

void in(vl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(listl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(str& s)
{
	cin >> s;
}

void out(ll O)
{
	cout << O;
}

void out(vl& O)
{
	for (auto& o : O)
	{
		cout << o;
	}
}

void rout(bool b, str True, str False)
{
	if (b) cout << True.c_str();
	else cout << False.c_str();
}

int main()
{
	ll N;
	string S;

	cin >> N >> S;

	ll Num = 0;

	rep(N-2)
	{
		if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C')
		{
			Num++;
		}
	}

	cout << Num;

	return 0;
}

Measured memory_bytes: 256
a,b,h,m = list(map(int,input().split()))
import math
pi = math.pi
l = (h+m/60)*2*pi/12
s = m*2*pi/60
theta = (l+s if l+s<2*pi else l-s)
ans = (a**2+b**2-2*a*b*math.cos(l-s))**(1/2)
print('{:.10f}'.format(ans))

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

int main() {
    vector<vector<int>> a(3,vector<int>(3));
    rep(i,3){
        rep(j,3){
            cin >> a[i][j];
        }
    }
    int n; cin >> n;
    vector<int> b(n);
    rep(i,n){
        cin >> b[i];
    }
    rep(i,3){
        rep(j,3){
            rep(k,n){
                if(a[i][j] == b[k]) a[i][j] = -1;
            }
        }
    }

    vector<int> s(8);
    s[0] = a[0][0]+a[0][1]+a[0][2];
    s[1] = a[1][0]+a[1][1]+a[1][2];
    s[2] = a[2][0]+a[2][1]+a[2][2];
    s[3] = a[0][0]+a[1][0]+a[2][0];
    s[4] = a[0][1]+a[1][1]+a[2][1];
    s[5] = a[0][2]+a[1][2]+a[2][2];
    s[6] = a[0][0]+a[1][1]+a[2][2];
    s[7] = a[0][2]+a[1][1]+a[2][0];
    bool bl = false;
    rep(i,8){
        if(s[i] == -3){
            bl = true;
            break;
        }
    }
    if(bl){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=1e5,MOD=1e9+7;
ll N;
string S;
ll b[MAX_N*2+1];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>S;
	for(auto &c:S){
		if(c=='B'){
			c='1';
		}else{
			c='0';
		}
	}
	b[0]=S[0]-'0';
	REP(i,N*2-1){
		b[i+1]=((ll)(S[i+1]-'0')-(ll)(S[i]-'0')+2)%2;
	}
	string sosa;
	REP(i,N*2){
		if(b[i]==0){
			b[i+1]=1-b[i+1];
			sosa.push_back('S');
		}else{
			sosa.push_back('F');
		}
	}
//	cout<<sosa<<endl;
	ll ans=1,beff=0,cnt=0;
	REP(i,N*2){
		if(sosa[i]=='F'){
			beff++;
		}else{
			ans*=beff;
			ans%=MOD;
			beff--;
			cnt++;
		}
	}
	REP(i,N){
		ans*=(i+1);
		ans%=MOD;
	}
	if(cnt!=N)ans=0;
	cout<<ans<<endl;
}

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

const int MAXN = 110;
const int mod = 998244353;
typedef long long LL;
typedef std::string str;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
std::map<str, int> M;
int calc(str s) {
	if (M.count(s)) return M[s];
	const int L = s.length();
	int f = mul((s[0] & 15) + 1, calc(s.substr(1)));
	for (int i = 1; i <= L; ++i) {
		str nxt(s.begin(), s.begin() + i);
		for (int j = 1; (j + 1) * i <= L; ++j) {
			for (int k = 0; k < i; ++k)
				nxt[k] = std::min(nxt[k], s[j * i + k]);
			reduce(f += mul(calc(nxt), calc(s.substr((j + 1) * i))) - mod);
		}
	}
	return M[s] = f;
}

int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	str t; std::cin >> t; M[""] = 1;
	std::cout << calc(t) << std::endl;
	std::cerr << M.size() << std::endl;
	return 0;
}


Measured memory_bytes: 5632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {
	int[][] ta = new int[16][4096];
	int ptr = 0;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 64 * 1024 * 1024).start();
    }

    public void run() {
    	FastScanner sc = new FastScanner(System.in);
    	//int[] ar = new int[3];
    	//ar[0]=Integer.parseInt(sc.next());
    	//Arrays.parallelSort(ar);
		Long s = Long.parseLong(sc.next());
		//long a = Long.parseLong(sc.next());
		//String s = sc.next();
		//String str = sc.next();
		//char c[] = str.toCharArray();
		//char a[][] = new char[n];
		//ArrayList<Str_4> lists = new ArrayList<Str_4>();
		//lists = new ArrayList;
		PrintWriter out = new PrintWriter(System.out);
		//int[] ra = new int[r];
		//ArrayList<ArrayList<Integer>> lists = new ArrayList<>();
		out.print("0 0 ");
		long ans1 = 1;
		long ans2 = 1;
		long ans3 = 1;
		long ans4 = 1;
		if(s%1000000000l!=0)
		{
			ans1 = s/1000000000l +1;
		}
		else
		{
			ans1 = s/1000000000l;
		}
		ans4 = 1000000000l;
		long s2 = s%1000000000l;

		if(s2 == 0l)
		{
			ans2 = 0l;
			ans3 = 0l;
		}
		else
		{
			s2 = 1000000000l - s2;
			ans2 = 1l;
			ans3 = s2;
		}
				
		out.print(ans1 + " " + ans2 + " ");
		out.print(ans3 + " " + ans4 + " ");
		//out.println(ans1*ans4-ans2*ans3);
		out.println();
		out.flush();
    }
    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }
}

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

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int a[n];
    float sum=0;
    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        a[i]=t;
        sum=sum+t;
    }
   sort(a,a+n);
   int k=0;
   for(int i=n-1;i>=0;i--)
   {
       if(a[i]<(sum/(4*m)))
        break;
        else
        {
            k++;
            if(k==m)
            break;
        }
   }
   if(k==m)
   cout<<"Yes";
   else
   cout<<"No";
   
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <stdint.h>
int main(){
  long long int x,y,num;
  int cnt=0;
  scanf("%llu %llu",&x,&y);
  num=y/x;
  while(num>0){
    cnt++;
    num/=2;
  }
  printf("%d\n",cnt);
}

Measured memory_bytes: 128
import math as m
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
c=m.radians(c)
S=0.5*a*b*m.sin(c)
L=a+b+m.sqrt(a*a+b*b-2*a*b*m.cos(c))
H=b*m.sin(c)
print(S)
print(L)
print(H)


Measured memory_bytes: 5716
n = input()
l = len(n)

dp = [[0]*2 for i in range(l+1)]
dp[l] = [0,0]
for i in range(l):
    dp[l-i-1][0] = max(dp[l-i][0]+int(n[l-i-1]), dp[l-i][1]+int(n[l-i-1])-1)
    dp[l-i-1][1] = max(dp[l-i][0]+9, dp[l-i][1]+9)
dp[0][1] = max(dp[1][0]+int(n[0]), dp[1][1]+int(n[0])-1)
print(max(dp[0]))

Measured memory_bytes: 3064
#include<iostream>
int main()
{
  bool bs[4];
  for (size_t idx{};idx<4;++idx)
    {
      bs[idx]=false;
    }
  int input;
  for (size_t idx{};idx<4;++idx)
    {
      std::cin>>input;
      if (input==1)
	bs[0]=true;
      if (input==9)
	bs[1]=true;
      if (input==7)
	bs[2]=true;
      if (input==4)
	bs[3]=true;
    }
  for (size_t idx{};idx<4;++idx)
    if (!bs[idx])
      {
	std::cout<<"NO";
	return 0;
      }
  std::cout<<"YES";
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = str(input())
t = str(input())

slen = len(s)
tlen = len(t)

if slen != tlen:
    print("No")

for i in range(slen):
    if s == t:
        print("Yes")
        break
    s = s[-1] + s[:-1]

if s != t:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int H,W;
    int i, j, k, l;
    cin >> H>> W;
    vector<string> str1(H);
    vector<vector< string > > str2(H, vector<string>(W));
    for (i = 0; i < H; i++){
        cin >> str1[i];
    }
    int count;
    string s;
    for (i = 0; i < H; i++){
        for (j = 0; j < W; j++){
            count = 0;
            if (str1[i][j] != '#'){
                for (k = -1; k <= 1; k++){
                    for (l = -1; l <= 1; l++){
                        if(i+k<0||j+l<0||i+k>=H||j+l>=W){
                            continue;
                        }
                        if (str1[i + k][j + l]=='#'){
                            count++;
                        }
                    }
                }
                str2[i][j] = to_string(count);
            }else{
                str2[i][j]='#';
            }
        }
    }
    for (i = 0; i < H; i++){
        for(j=0;j<W;j++){
            cout << str2[i][j];
        }
        cout<<endl;
    }
}


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

int main()
{
	long q;
	cin >> q;

	map <string, long> mp;

	for (long i = 0; i < q; i++) {
		int t;
		cin >> t;

		string s;
		cin >> s;

		if (t == 0) {
			long x;
			cin >> x;
			mp[s] = x;
		}
		else if (t == 1) {
			std::map<string, long>::iterator itr = mp.find(s);
			if (itr != mp.end())
				cout << itr->second << endl;
			else
				cout << 0 << endl;
		}
		else if (t == 2)
			mp.erase(s);
		else if (t == 3) {
			string r;
			cin >> r;
			std::map<string, long>::iterator itr;
			for (itr = mp.lower_bound(s); itr != mp.upper_bound(r); itr++)
				cout << itr->first << " " << itr->second << endl;
		}
	}

	return 0;
}


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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<P,ll>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9)+7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-9;

int n;
string s;

int test(){
    vector<string> a(n);
    a[0] = s;
    for(int i=1;i<n;i++){
        int m = a[i-1].size();
        for(int j=0;j<m-1;j++){
            a[i].push_back('0'+abs(a[i-1][j]-a[i-1][j+1]));
        }
    }
    return a[n-1][0] - '0';
}



int rec(int idx, int k, int siz){
    // cout << idx << " " << k << " " << siz << endl;
    assert(k > 0);
    if(idx >= siz) return 0;
    if(siz-idx == 1){
        return s[idx]-'0';
    }
    while(idx+k >= siz) k>>=1;
    // cout << k << endl;
    return rec(idx, k, siz-k)^rec(idx+k, k, siz);

}

int main(){
    cin >> n;
    cin >> s;
    // s.resize(n,'0');
    int f = -1;
    // if(n <= 5000){
    //     cout << test() << endl;
    //     return 0;
    // }
    bool one = false;
    for(auto &c : s){
        c--;
        one |= c == '1';
    }
    for(auto &c : s){
        if(c == '2') c = (one ? '0' : '1');
    }
    int ans = rec(0,1<<25,n);
    if(!one && ans==1) ans = 2;
    cout << ans << endl;
    // assert(f < 0 || f == ans);
    return 0;
}


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

public class Main {

	public static void main(String[] args) {

		int n;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		sc.nextLine();
		String[] sArray = new String[n];
		for(int i = 0 ; i < n ; i++) {
			String tmp = sc.nextLine();
			char[] ch = tmp.toCharArray();
			Arrays.sort(ch);
			sArray[i] = new String(ch);
			ch = null;
			tmp = null;
		}
		Arrays.sort(sArray);
		long cnt = 0;
		long cat = 1;
		String pre = null;
		for(String s : sArray) {
			if(pre == null) {
				pre = s;
				continue;
			}
			if(!pre.equals(s)) {
				cnt += count(cat);
				cat = 1;
			} else {
				cat++;
			}
			pre = s;
		}
		cnt += count(cat);
		System.out.println(cnt);
		sc.close();

	}

	private static long count(long n) {
		long ret = 0;
		for(long i = 1 ; i <= n ; i++) {
			ret += (n - i);
		}
		return ret;
	}
}


Measured memory_bytes: 97528
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int a, b, i, j;
    cin >> a >> b;
    while(a!=0||b!=0){
    for ( int i = 0; i < a; i++ ){
        for ( int j = 0; j < b; j++ ){
            cout << "#";
        }
    cout << endl;
    }
    cin >> a >> b;
    cout << endl;
    }
}


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

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}


int main(){
  //エラトステネス？
  ll N;cin>>N;
  vll v = divisor(N);
  ll ans = 0;
  rep(i,v.size()){
    if(N < v[i]) break;
    if(v[i]==1) continue;
    vll tmp = divisor(v[i]);
    bool flag = true;
    rep(j,tmp.size()){
      ll t = v[i];
      while(t%tmp[1]==0){
        t /= tmp[1];
      }
      if(t!=1) flag=false;
    }
    if(N%v[i]==0 && flag){
      N /= v[i];
      ans++;
      //cout << "v[i] " << v[i] << endl;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3652
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

w, h, n = MAP()
a = [LIST() for i in range(n)]
x0 = 0
x1 = w
y0 = 0
y1 = h

for i in range(n):
        if a[i][2] == 1:
                x0 = max(x0, a[i][0])
        elif a[i][2] == 2:
                x1 = min(x1, a[i][0])
        elif a[i][2] == 3:
                y0 = max(y0, a[i][1])
        elif a[i][2] == 4:
                y1 = min(y1, a[i][1])

print(max(0, y1-y0)*max(0, x1-x0))

Measured memory_bytes: 10112
<?php
fscanf(STDIN, "%d", $i);
$v = explode(' ',trim(fgets(STDIN)));
$c = explode(' ',trim(fgets(STDIN)));

$ans = 0;
foreach(range(0,$i-1) as $index){
    $diff = $v[$index] - $c[$index];
    if($diff > 0){
        $ans += $diff;
    }
}
echo $ans;
?>

Measured memory_bytes: 4604
import sys
import numpy as np
import math
import collections
import copy
from collections import deque 
from functools import reduce
from itertools import product
from itertools import combinations

# input = sys.stdin.readline
N, D = map(int, input().split())
zn = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for z in zn:
    x, y = z
    kyo = np.sqrt(x**2 + y**2)
    if (kyo <= D):
        ans += 1

print(ans)












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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Graph;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 100000 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int k, x;
    cin >> k >> x;
    if (500 * k >= x)
        out("Yes");
    else
        out("No");
}


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

#define INF 100000000;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const double eps = 1.0e-14;
const double PI = (acos(-1));
int main(){
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n){
        ans += i + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
                                Bismillahi-r-Rahmani-r-Rahim
                                        RhIeyAaD
                                    IIT-7th Batch,JU
*/
#include<bits/stdc++.h>
using namespace std;

#define ll              long long int
#define MAX             2134567891
#define fr(i,n)         for(i=0;i<n;i++)
#define rep(i,n)        for(i=1;i<=n;i++)
#define rev(i,a,n)      for(i=n;i>=a;i--)
#define FOR(i,a,n)      for(i=a;i<=n;i++)
#define ALL(n)          n.begin(),n.end()
#define mem(x,n)        memset(x,n,sizeof(x))
#define TC(t)           printf("Case %lld: ",t)
#define ans(t,c)        printf("Case %lld: %lld\n",t,c)
#define SETP(n)         cout<<setprecision(n)<<fixed
#define READ            freopen("F:\\Project\\Test_Case.txt","r",stdin)
#define WRITE           freopen("F:\\Project\\Output_Test.txt","w",stdout)
#define IO              ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define PAIR            pair<ll,ll>
#define MP              make_pair
#define pb(a)           push_back(a)
#define ff              first
#define ss              second
#define NL              print("\n");
#define debug(a)        cout<<a<<" ";
#define hlw             printf("hlw\n");
#define NN              111
#define MOD             1000000007///10^9
#define N               1000007 ///10^6->6 zero after 1 **

ll x[N],y[N],z[N],n;
string s,S;
vector<ll>v;
//map <ll,ll> mp;

int main()
{
    //IO;
    //while(1)
    //READ;WRITE;
{
    ll a=0,b=0,c=0,d,e,f,g,i,j,k,l,m,p,q,r,u,w,t,tc,in,mod,loc,diff,val,sz,lo,hi,mid,mn=MAX,mx=0,sum=0,ans=0;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
}
    return 0;
}

/*

*/
/// Check for constraint 0 or 1?
/// long long or double? sqrt or division will work fine??


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

//#define int long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main()
{
    int n;
    cin>>n;
    int co=0;
    vector<int> h(n);
    vector<int> a(n);
	for (int i = 0; i < n; ++i){
		cin >> h[i];
    }
    a[0]=0;
    for (int i=1; i<n; i++){
        if (max(h[i-1],h[i])==h[i-1]){
            a[i]+=a[i-1]+1;
        }
        else{
            a[i]=0;
        }
        
    }
    for (int i=0; i<n; i++){
        co=max(co,a[i]);
    }
    cout<<co<<endl;

    
}

Measured memory_bytes: 1024
n = int(input())

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

res = prime_factorization(n)
tmp = [str(n) + ':']
res = tmp + res

print(*res)


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  string A,B;
  ll a,b;
  string C;
  cin>>A>>B>>a>>b>>C;
  if(A==C){
    cout<<a-1<<' '<<b<<endl;
  }
  else{
    cout<<a<<' '<<b-1<<endl;
  }
}

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

int i,o,t,j,l,s,z;

#define int long long

signed main()
{
	cin >>i>>o>>t>>j>>l>>s>>z;
	int result = 0;
	result += o;

	int v1 = 0;

	int v2 = 0;
	
	int cou;
	cou = i / 2;
	v1 += cou * 2;
	cou = l / 2;
	v1 += cou * 2;
	cou = j / 2;
	v1 += cou * 2;
  
  if(i > 0 && j > 0 && l > 0)
  {
    v2 = 3;
    i--;j--;l--;
    cou = i / 2;
	v2 += cou * 2;
	cou = l / 2;
	v2 += cou * 2;
	cou = j / 2;
	v2 += cou * 2;
  }
	
	cout << result + max(v1,v2) << endl;
}


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin >> n;
    vi v(n);
    for(int &x : v)cin >> x;
    vi s = v;
    sort(ALL(s));

    bool flag = (s == v);
    loop(i,n){
        range(j,i+1,n-1){
            swap(v[i],v[j]);
            flag |= (v == s);
            swap(v[i],v[j]);
        }
    }

    if(flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;


    return 0;
}


Measured memory_bytes: 256
import sys

def check_sekisairyo(p_min):
    p_now = 0
    k_now = 0
    for w in w_i:
        p_now += w
        if p_now > p_min:
            p_now = w
            k_now += 1
        elif p_now == p_min:
            p_now = 0
            k_now += 1
        if k_now == k and p_now != 0:
            return False
    return True

n, k = map(int, input().split())
w_i = [int(input()) for i in range(n)]
left, right, p_min = max(w_i), sum(w_i), 0
while left < right:
    p_min = (left + right) // 2
    if check_sekisairyo(p_min):
        right = p_min
    else:
        left = p_min = p_min + 1
print(p_min)

Measured memory_bytes: 11612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); 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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;
const int MAXP = 3005;

ll p, p_1Cr[MAXP];

ll modpow(ll a,ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % p;
    a = a * a % p;
    n >>= 1;
  }
  return res;
}

ll nCr(ll n, ll r) {
  r = min(n-r, r);
  if (r == 0) return 1;
  ll ans = 1;
  FOR(i, n-r+1, n+1) ans = ans * i % p;
  ll a = 1;
  FOR(i, 1, r+1) a = a * i % p;
  ans = ans * modpow(a, p-2) % p;
  return ans;
}

int main() {
  cin >> p;
  vector<int> a(p);
  rep(i, p) cin >> a[i];

  rep(i, p) p_1Cr[i] = nCr(p - 1, i);
  vector<ll> ans(p, 0);

  rep(i, p) {
    if (a[i] == 1) {
      ans[0] = (ans[0] + 1);
      ll modpowi = 1;
      repr(j, p - 1) {
        ll res = 1;
        res *= p_1Cr[j];
        res *= modpowi;
        res %= p;
        modpowi *= i;
        modpowi %= p;
        if ((p - j) & 1) res = (p - res) % p;
        ans[j] = (ans[j] + res) % p;
      }
    }
  }

  rep(i, p) {
    if (i) cout << " ";
    cout << ans[i];
  }

  

  
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void) {
	
	int A, B;
	scanf("%d%d", &A, &B);
	if (A >= 2 * B) {
		printf("%d", A - 2 * B);
	}
	else {
		printf("%d", 0);
	}
	return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
long long i[300000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a=0,b=0,c=0,d=0,e=1,f=0;
  string s;
  cin >>s;
  if(s=="Sunny") cout <<"Cloudy\n";
  else{
    if(s=="Cloudy") cout <<"Rainy\n";
    else cout <<"Sunny\n";
  }
  return (0);
}


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

#define pb push_back
#define mp make_pair
#define F(i, a, n) for(int i=a;i<n;i++)
#define REP(i, n) F(i, 0, n)
#define REP1(i, n) for(int i=1;i<=n;i++)
#define REV(i, n) for(int i=n;i>=0;i--)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define MOD 1000000007

typedef unsigned long long ll;

const ll MAX = 1e6 + 5;

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

	cin>>s;
	if(s == "Sunny")
		cout<<"Cloudy";
	else if(s == "Cloudy")
		cout<<"Rainy";
	else
		cout<<"Sunny";
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stdlib.h>
#include <queue>
#include <set> 
#include <string>
#include <string.h>
#include <cstring>
#include <stdio.h>
#include <fstream>
#include <stack>
#include <iomanip>
//#include <conio.h>
//#include <windows.h>
//#include <time.h>
#define rep(N) for(int i=0;i<N;i++)
#define ll long long 
#define pii pair<int,int>
#define For(I,N) for(int I=0;I<N;I++)
#define rep(N) for(int i=0;i<N;i++)
using namespace std;
vector <int> vec[2005];
vector <pair<int,int> >num[2005];
bool visit[2005];
int leaf[2005];
int dist[2005][2005];
int n,k;
vector <int> leave;

int dfs(int x,int p,int s,int ma)
{
	int ans=1;
	if(ma!=s)
	{
		for(int i=0;i<vec[x].size();i++)
		{
			if(vec[x][i]!=p)
			{
				ans+=dfs(vec[x][i],x,s+1,ma);
			}
		}
	}
	return ans;
}

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>k;
	int x,y;
	rep(n-1)
	{
		cin>>x>>y;
		vec[--x].push_back(--y);
		vec[y].push_back(x);
		leaf[x]++;
		leaf[y]++;
	}
	int ans=0;
	if(k%2==0)
	{
		rep(n)
		{
			ans=max(dfs(i,-1,0,k/2),ans);
		}
	}
	else
	{
		rep(n)
		{
			for(int j=0;j<vec[i].size();j++)
			{
				ans=max(ans,dfs(i,vec[i][j],0,k/2)+dfs(vec[i][j],i,0,k/2));
			}
		}
	}
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {

	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> a(Q);
	vector<int> score(N, K - Q);
	rep(i, Q) cin >> a.at(i);

	rep(i, Q) {
		score.at(a.at(i) - 1)++;
	}
	rep(i, N) {
		if (score.at(i) <= 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
	
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    string ans;
    rep(i,n){
        
        if(i==0){
            ans=s[i];
            ans+=t[i];
        }
        else{
        ans+=s[i];
        ans+=t[i];
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
D=list(map(str,input().split()))

while True:
    flg=True
    for i in range(len(str(N))):
        #print(str(N)[i])
        if str(N)[i] in D:
            #print("S",str(N)[i])
            N+=1
            flg=False
            break
    if flg:
        break

print(N)


Measured memory_bytes: 40924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
//void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////



int main(){fastio
    ll a,b;cin>>a>>b;
    if(a>=13){
        cout<<b;
    }else if(a>=6){
        cout<<b/2;
    }else{
        cout<<0;
    }
    
    
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    string s; cin >> s;
    if(s == "SUN") cout << 7 << endl;
    else if(s == "MON") cout << 6 << endl;
    else if(s == "TUE") cout << 5 << endl;
    else if(s == "WED") cout << 4 << endl;
    else if(s == "THU") cout << 3 << endl;
    else if(s == "FRI") cout << 2 << endl;
    else cout << 1 << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

struct tree {
	int value;
	unique_ptr<tree>ltree, rtree;
	tree(const int value_):value(value_) {

	}

};
void ins(unique_ptr<tree>&t, int num) {
	if (t == nullptr) {
		t = make_unique<tree>(num);
	}
	else {
		if (num < t->value) {
			ins(t->ltree, num);
		}
		else {
			ins(t->rtree, num);
		}
	}
}
bool fi(unique_ptr<tree>&t, int num) {
	if (t == nullptr)return false;
	else {
		if (num == t->value)return true;
		else if (num < t->value) {
			return fi(t->ltree, num);
		}
		else {
			return fi(t->rtree, num);
		}
	}
}
void dfs(unique_ptr< tree>&t,bool mid,vector<int>&v) {
	if (mid) {
		v.emplace_back(t->value);
	}
	if (t->ltree) {
		dfs(t->ltree, mid, v);
	}
	if (!mid) {
		v.emplace_back(t->value);
	}
	if (t->rtree) {
		dfs(t->rtree, mid, v);
	}
	
	return;
}

int main() {
	int N; cin >> N;
	unique_ptr<tree> t(nullptr);
	while (N--) {
		string st;  cin >> st ;
		if (st == "print") {
			vector<int> v;
			for (int i = 0; i < 2; ++i) {
				dfs(t, bool(i), v);
				cout << " ";
				for (int i = 0; i < v.size(); ++i) {
					cout << v[i];
					if (i == v.size() - 1)cout << endl;
					else cout << " ";
				}
				v.clear();
			}
			
		}
		else if(st=="insert") {
			int a; cin >> a;
			ins(t, a);
		}
		else {
			int a; cin >> a;
			bool ok = fi(t, a);
			if (ok)cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}

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

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

	int a, z;
	for (int i = 0;i < s.size();i++) {
		if (s[i] == 'A') {
			a = i;
			break;
		}
	}
	for (int i = s.size() - 1;i > -1;i--) {
		if (s[i] == 'Z') {
			z = i;
			break;
		}
	}
	cout << z - a + 1 << endl;
	return 0;
}

Measured memory_bytes: 768
s = input()
s_length = len(s)
reversed_s = "".join(list(reversed(list(s))))

while(True):
  s_length = len(reversed_s)
  if s_length == 0:
    break
  else:
    if reversed_s[:7] == "remaerd":
      reversed_s = reversed_s[7:]
    elif reversed_s[:6] == "resare":
      reversed_s = reversed_s[6:]
    elif reversed_s[:5] == "esare":
      reversed_s = reversed_s[5:]
    elif reversed_s[:5] == "maerd":
      reversed_s = reversed_s[5:]
    else:
      break

if s_length == 0:
  print("YES")
else:
  print("NO")


Measured memory_bytes: 4724
N, K = map(int, input().split())

ANS_TABLE = [0] * (N + 1)
TMP_MIN = sum([i for i in range(0, K)])
TMP_MAX = sum([i for i in range(N, N - K, -1)])
TMP_UP = K
TMP_LOW = N - K

for i in range(K, N + 1):
    ANS_TABLE[i] = TMP_MAX - TMP_MIN + 1
    TMP_MAX += TMP_LOW
    TMP_MIN += TMP_UP
    TMP_UP += 1
    TMP_LOW -= 1

print((sum(ANS_TABLE) + 1) % (10 ** 9 + 7))


Measured memory_bytes: 19852
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n],dp[n];
    dp[0]=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++){
        int c=INT_MAX;
        for(int j=i-1;j>max(-1,i-k-1);j--){
            c=min(c,dp[j]+abs(arr[i]-arr[j]));
        }
        dp[i]=c;
    }
    cout<<dp[n-1]<<'\n';
    return 0;
}


Measured memory_bytes: 1024
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): 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 LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)
N = I()
i = N%10
if i in [2,4,5,7,9]:
    print('hon')
elif i in [0,1,6,8]:
    print('pon')
else:
    print('bon')


Measured memory_bytes: 72524
#include<bits/stdc++.h>
using namespace std;
main(){
long long i,j,k,l,m,n;
cin>>m>>n;
    l=0;
    for(i=0;i<n;i++) {cin>>k; l+=k;  }
    if(l>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
 return 0;
}


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
typedef long long ll;

int main(void) {
    while (1) {
        string s;
        cin >> s;
        if (s == "0") break;
        map<string, int> mi;
        queue<string> q;
        q.push(s);
        mi[s] = 0;
        bool flag = true;
        while (!q.empty()) {
            string now = q.front(); q.pop();
            // 全て同じ文字かどうかのチェック
            int i;
            for (i = 0; i < now.size()-1; i++) {
                if (now[i] != now[i+1]) {
                    break;
                }
            }
            if (i == now.size()-1) {
                cout << mi[now] << endl;
                flag = false;
                break;
            }
            // いろいろ移行するところを考える
            for (int i = 0; i < now.size()-1; i++) {
                string s = now;
                if (s[i] != s[i+1]) {
                    if (s[i] != 'r' && s[i+1] != 'r') {
                        s[i] = 'r'; s[i+1] = 'r';
                    } else if (s[i] != 'g' && s[i+1] != 'g') {
                        s[i] = 'g'; s[i+1] = 'g';
                    } else {
                        s[i] = 'b'; s[i+1] = 'b';
                    }
                }
                if (mi.find(s) == mi.end()) {
                    q.push(s);
                    mi.insert(map<string, int>::value_type(s, mi[now]+1));
                }
            }
        }
        if (flag) cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 2884
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int n; cin>>n;
    vector <int> a(n); 
    rep(i,n) cin>>a[i];
    int sum = 0;
    int l = 0, r = 0, ans = 0;
    while(l!=n){
        while(1){
            if(r!=n&&sum+a[r] == (sum^a[r])){
                sum+=a[r];
                //cout<<sum+a[r+1]<<' '<<sum^a[r+1]<<endl;
                r++;
                continue;
            }else break;
        }
        //cout<<l<<' '<<r<<endl;
        ans += r-l;
        sum^=a[l++];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<vector>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define rep(i,N) for(int i=0;i<N;i++)

using namespace std;

int main(void){
    int A,B;
    cin>>A>>B;
    if((A+B)%2==0){
        cout<<int((A+B)/2)<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args:Array[String]) = {
    val n = readInt
    val d = (1 to n).map(_ => -1).toArray

    val g = {
      for(i<-0 until n) yield {
        val v = readLine.split(" ").map(_.toInt)
        (for(j<-2 until 2+v(1)) yield v(j) ).toArray
      }
    }.toArray

    def scan(list:Array[Int], cnt:Int):Unit = {
      val a = new ArrayBuffer[Int]
      if(list.length>0 && cnt <= n) {
        for(e<-list if d(e-1) == -1) {
          d(e-1) = cnt
          g(e-1).foreach( a += _ )
        }
        scan(a.toArray,cnt+1)
      }
    }
    scan(Array(1),0)

    for(i<-0 until n) println((i+1) + " " + d(i))
  }
}

Measured memory_bytes: 44236
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long ans = 0;
		for(int i = 1; i+2 <= (N+i-1)/i; i++) {
			if((N-i) % i == 0) 
				ans += (N-i)/i;
		}
		System.out.println(ans);

	}

}

Measured memory_bytes: 22868
#約数の個数の和（１~N）約数そのものを求めないので「速い」
def divisor_num(N):
    ans =0
    for i in range(1,N):
        ans +=(N-1)//i #項数
    return ans


# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない

N = int(input())
ans =divisor_num(N)

print(ans)

Measured memory_bytes: 65828
package main

import "fmt"

func main() {
	var s string
	var oddCorrect, evenCorrect int
	fmt.Scan(&s)
	ans := "No"
	if len(s) % 2 != 0{
		oddCorrect = len(s)/2+1
		evenCorrect = len(s) - oddCorrect
	}else{
		oddCorrect, evenCorrect = len(s)/2, len(s)/2
	}


	odd := 0
	even := 0
	for i:=0; i<len(s); i+=2{
		if s[i] == 'R' || s[i] == 'U' || s[i] == 'D'{
			odd++
		}
	}

	for i:=1; i<len(s); i+=2{
		if s[i] == 'L' || s[i] == 'U' || s[i] == 'D'{
			even++
		}
	}


	if odd == oddCorrect && even == evenCorrect{
		ans = "Yes"
	}

	fmt.Println(ans)
}

Measured memory_bytes: 1772
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define rep(countName, left, right, up) for (ll countName = left; countName < right; countName += up)
#define rev(countName, right, left, down) for (ll countName = right - 1; countName >= left; countName -= down)

auto solve1()
{
    int a, b;
    int ans;
    cin >> a >> b;

    ans = std::max(a, b) + std::max(--a, --b);

    if (a == b)
    {
        ans++;
    }

    return ans;
}

int main(void)
{
    cout << solve1() << endl;
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop


def main():

    N, M = [int(v) for v in input().split()]

    H = [int(v) for v in input().split()]
    link = [0] * N

    for _ in range(M):
        a, b = [int(v) - 1 for v in input().split()]
        link[a] = max(link[a], H[b])
        link[b] = max(link[b], H[a])

    count = 0
    for h, nh in zip(H, link):
        if h > nh:
            count += 1
    print(count)


main()


Measured memory_bytes: 19960