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

using namespace std;

const int INF = 1e9 + 3;
const int N = 2e5 + 3;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

const double PI = acos(-1);



void solve() {
    int n;
    cin >> n;
    int a[n];
    for (int &x : a)
        cin >> x;
    auto sum = accumulate(a, a + n, 0ll), ans = 0ll;
    long long suf[n];
    for (int i = n - 1; i >= 0; i--)
        suf[i] = (i == n - 1 ? a[i] : suf[i + 1] + a[i]);
    for (int i = 0; i < n - 1; i++) {
        auto val = suf[i + 1] % MOD;
        ans += (val * a[i]) % MOD;
        ans %= MOD;
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t;
    t = 1;
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 5996
def main():
    n, l = (int(s) for s in input().strip().split(' '))
    an = [int (s) for s in input().strip().split(' ')]
    for i in range(1, n):
        if an[i-1] + an[i] >= l:
            print('Possible')
            index = i
            break
    else:
        print('Impossible')
        return
    for i in range(1, index):
        print(i)
    for i in range(n-1, index, -1):
        print(i)
    print(index)

main()


Measured memory_bytes: 14204
#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, r;
  cin >> n >> r;
  int ans = r;
  if (n < 10) ans += 100*(10-n);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
/** Author: Dwai
 *  Omae wa mou shindeiru!
**/

#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define fr(i,a,b) for (i = a; i <= b; i++)
#define frr(i,a,b) for (i = a; i >= b; i--)
#define rep(i,n) for (i = 0 ; i < n; i++)
#define repr(i,n) for (i = n - 1; i >= 0; i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define flushinput   cin.ignore(numeric_limits<streamsize>::max(),'\n');

void debug_out() { cerr << endl; }

void clock_out(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}

void fileio(){
  freopen("/home/dwai/Desktop/cp/input.txt","r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}

void ofileio(){
  freopen("input.txt","r", stdin);
  freopen("output.txt", "w", stdout); 
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define fio() fileio()
#define ofio() fileio()
#define clock() clock_out()
#else
#define debug(...) 42
#define fio() 42
#define ofio() ofileio()
#define clock() 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef map<ll,ll> mll;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;


ll dp[101][100001];

void solve(){
	ll N,W;
	cin>>N>>W;
	ll i,j;
	ll w[N],v[N];
	ll V=0;
	rep(i,N)
	{
		cin>>w[i]>>v[i];
		V+=v[i];
	}

	fr(i,0,N) fr(j,0,V) dp[i][j]=INF;

	fr(i,0,N) dp[i][0]=0;
	fr(i,1,N)
	{
		fr(j,1,V)
		{
			dp[i][j]=min(dp[i][j],dp[i-1][j]);

			if(j-v[i-1]>=0)
			{
				dp[i][j]=min(dp[i][j],dp[i-1][j-v[i-1]]+w[i-1]);
			}
		}
	}

	ll mx=0;
	fr(j,1,V)
	{
		if(dp[N][j]<=W)
			mx=j;
	}
	cout<<mx;
}

int main(){
	//fio();
	fast

	solve();
	return 0;
}


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

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

    long long i=0;
    long long cnt=0,scnt=0;
    for(long long i=0;i<str.size();i++){
         if(str[i]=='S'){
           scnt++;
         }
         if(str[i]=='T' && scnt > 0){
           scnt--;
           cnt++;
         }
    }
    cout <<str.size()-cnt*2<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#define nmax_def 220000
#define Cmax_def 2200
#define mod 1000000007
using namespace std;
typedef long long ll;

int main() {
	ll i, j;
	ll N, A[nmax_def];
	ll max1 = 0, max2 = 0, max1_num;
	cin >> N;
	for (i = 0; i < N; i++)
	{
		cin >> A[i];
		if (A[i] > max1)
		{
			max2 = max1;
			max1 = A[i];
			max1_num = 1;
		}
		else if (A[i] == max1)
			max1_num++;
		else if (A[i] > max2)
		{
			max2 = A[i];
		}
	}
	for (i = 0; i < N; i++)
	{
		if (A[i] == max1)
		{
			if (max1_num == 1)
				cout << max2 << endl;
			else
				cout << max1 << endl;
		}
		else
			cout << max1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        
        while (H != 0 || W != 0) {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1)) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
            
            H = sc.nextInt();
            W = sc.nextInt();
        }
    }
}


Measured memory_bytes: 60920
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

struct st {
	int f[20][20], cnt, x, y, id;
};
int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };
int main() {
	st in;
	int w, h;
	while (scanf("%d%d", &w, &h), w) {
		rep(i, h)rep(j, w) {
			scanf("%d", &in.f[i][j]);
			if (in.f[i][j] == 2)in.x = i, in.y = j;
		}
		in.cnt = 0;
		in.id = -1;
		queue<st>que;
		que.push(in);
		int Min = INT_MAX;
		while (!que.empty()) {
			st s = que.front(); que.pop();
			if (s.f[s.x][s.y] == 3) {
				Min = min(Min, s.cnt);
				continue;
			}
			if (s.id == -1) {
				rep(i, 4) {
					int nx = s.x + dx[i], ny = s.y + dy[i];
					if (0 <= nx&&nx < h && 0 <= ny&&ny < w&&s.f[nx][ny] != 1) {
						st p = s; p.cnt++; p.x = nx; p.y = ny; p.id = i;
						if (p.cnt <= 10 && p.cnt < Min)que.push(p);
					}
				}
			}
			else {
				int nx = s.x + dx[s.id], ny = s.y + dy[s.id];
				if (0 <= nx&&nx < h && 0 <= ny&&ny < w) {
					if (s.f[nx][ny] == 1) {
						st p = s; p.f[nx][ny] = 0; p.id = -1;
						que.push(p);
					}
					else {
						st p = s; p.x = nx; p.y = ny;
						que.push(p);
					}
				}
			}
		}
		if (Min == INT_MAX)puts("-1");
		else printf("%d\n", Min);
	}
}

Measured memory_bytes: 54308
import java.util.Scanner;
public class Main {
	
	static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		double x1 = stdIn.nextDouble();
		double y1 = stdIn.nextDouble();
		double x2 = stdIn.nextDouble();
		double y2 = stdIn.nextDouble();
		
		double ans = Math.sqrt((x1 - x2)*(x1 - x2) + (y1 - y2) * (y1 - y2));
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 18396
/* ***********************************************************************************************************
									Created By - TANISHQ GUPTA (tanishq_code_c)
**************************************************************************************************************/

#include <bits/stdc++.h>
using namespace std;
#define int             long long
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl             '\n'
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
void stringsplitter(string s, string delim,string arr[]){
	char *ptr = strtok((char *)s.c_str(), (char *)delim.c_str());
	int i=0;
	while(ptr!=NULL){
		arr[i]=((string)ptr);
		ptr = strtok(NULL,(char *)delim.c_str());
		i++;
	}
}
int string_to_int(string s){
	int ans = 0;
	int p=1;
	for(int i=(int)s.size()-1;i>=0;i--){
		ans += (s[i]-'0')*p;
		 p *= 10;
	}
	return ans;
}
void t_c_c()
{
	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*/

	int a,b; cin >> a >> b;
	cout << a*b << endl;

}
int32_t main()
{
	t_c_c();
	return 0;
}

Measured memory_bytes: 3656
import sys
import numpy as np
import itertools as itlt
from collections import deque
 

 
s = [[0,0,0]
    ,[0,0,0]
    ,[0,0,0]]    
s[0] = [int(x) for x in sys.stdin.readline().split()]
s[1] = [int(x) for x in sys.stdin.readline().split()]
s[2] = [int(x) for x in sys.stdin.readline().split()]
g = [[0,0,0]
    ,[0,0,0]
    ,[0,0,0]]
N = int(sys.stdin.readline())
p = list([0]*N)
s = np.array(s)
for _ in range(N):
    a = int(sys.stdin.readline())
    b = np.where(s == a)
    for i in range(np.size(b[0])):
        g[b[0][i]][b[1][i]] = 1
 

 
 
flg_win = 0
 
for i in range(3):
    if (g[i][0] + g[i][1] + g[i][2]) == 3:
        flg_win = 1
    if (g[0][i] + g[1][i] + g[2][i]) == 3:
        flg_win = 1
 
if (g[0][0]+g[1][1]+g[2][2]) == 3:
    flg_win = 1
 
if (g[0][2]+g[1][1]+g[2][0]) == 3:
    flg_win = 1
 
if flg_win == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 27084
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using vi = vector<int>; using vvi = vector<vi>;
const ll MOD = 1e9+7; ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0}; vi d4y = {0, 1, 0, -1};
//---------------------------------------

int main(){
    ll n; cin>>n;
    vector<ll> a(n+1);
    vector<ll> b(n);
    rep(i,n+1) cin>>a[i];
    rep(i,n) cin>>b[i];
    ll ans=0;
    rep(i,n){
        ll front=min(a[i],b[i]);
        ans+=front;
        b[i]-=front;
        ll rht=min(a[i+1],b[i]);
        ans+=rht;
        a[i+1]-=rht;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
import sys
s = input()
li = ['']*len(s)
for i in range(len(s)):
    li[i]=s[i]
li.sort()
for i in range(len(li)):
    if (i == len(li) - 1):
        break
    if (li[i] == li[i + 1]):
        print('no')
        sys.exit()
print('yes')

Measured memory_bytes: 3060
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto LS = readln.split.to!(int[]);
    sort(LS);
    int r;
    foreach (i; 0..N) r += LS[i*2];
    writeln(r);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int factorial(int n){
    if(n>0){
        return n * factorial(n-1);
    }else if(n==0){
        return 1;
    }else{
        return -100;
    }
}
int main(){
	int n;
	cin >> n;
	vector<int> p(n+1), q(n+1);
	for(int i=1; i<=n; ++i) cin >> p[i];
	for(int i=1; i<=n; ++i) cin >> q[i];

	vector<int> v(n+1);
	iota(v.begin(),v.end(),0);
	int a=-1, b=-1;
	int m=factorial(n);
	for(int i=1; i<=m; ++i){
		if(v==p) a=i;
		if(v==q) b=i;
		if(a!=-1 && b!=-1) break;
		next_permutation(v.begin(),v.end());
	}
	 
	cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations
from math import pi, ceil, floor
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")



def main():
    n = int(input())
    A = list(map(int, input().split()))
    cnt = [0] * n
    B = deque([])
    for i in range(n-1, -1, -1):
        if sum(cnt[i::i+1]) % 2 == A[i]:
            continue
        else:
            cnt[i] += 1
    ans = []
    for i, v in enumerate(cnt):
        if v > 1:
            print(-1)
            exit()
        elif v == 1:
            ans.append(i+1)
        else:
            continue
    print(len(ans))
    print(*ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 23136
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
//max_element


int N;
int H[1000];


signed main()
{
	cin >> N;
	REP(i, N) cin >> H[i];

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		bool can = true;
		for (int j = i; j >= 0; j--)
		{
			if (H[i] < H[j])
			{
				can = false;
			}
		}
		if (can) ans++;
	}
	cout << ans << endl;
}



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

#define SZ(x) (((int)x.size()))

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 200*1000+10;
bool mark[maxn];
int n, a[maxn], f[maxn], t, cur;
ll k;
vector<int> loc[maxn], ans;

int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		loc[a[i]].push_back(i);
	}
	for (int i = 0; i < maxn; i++)
	{
		for (int j = 0; j < SZ(loc[i]); j++)
			f[loc[i][j]] = (loc[i][(j + 1) % SZ(loc[i])] + 1) % n;
	}
	do
	{
		if (f[cur] <= cur + 1)
			t++;
		if (f[cur] == 0 && cur == n - 1)
			t++;
		cur = f[cur];
	} while (cur != 0);
	k %= t;
	while (k > 1)
	{
		if (f[cur] <= cur + 1)
			k--;
		cur = f[cur];
	}
	if (k > 0)
	{
		for (int i = cur; i < n; i++)
		{
			if (!mark[a[i]])
			{
				mark[a[i]] = 1;
				ans.push_back(a[i]);
			}
			else
			{
				mark[a[i]] = 0;
				while (ans.back() != a[i])
				{
					mark[ans.back()] = 0;
					ans.pop_back();
				}
				ans.pop_back();
			}
		}
	}
	for (auto w : ans)
		cout << w << " ";
	return 0;
}


Measured memory_bytes: 15096
#include <bits/stdc++.h>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
int main(void){
    int n,k,s; cin >> n >> k >> s;
    rep(i,k){
        cout << s << endl;
    }
    rep(i,n-k){
        if(s==1000000000) cout << 1 << endl;
        else cout << 1000000000 << endl;
    }
}



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

using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if ((A + B) >= C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,m=map(int, input().split())
a=list(map(int, input().split()))

sa = sorted(a, reverse=True)
sum = sum(a)
flg = 0
for index in range(m):
    if sa[index] < sum / (4 * m):
        print("No")
        flg = 1
        break
if flg == 0:
    print("Yes")


Measured memory_bytes: 3060
abck = list(map(int,input().split()))
a=abck[0]
b=abck[1]
c=abck[2]
k=abck[3]
if k%2 ==0:
    ans = a-b
else:
    ans = b-a
if ans > 10**18:
    print('Unfair')
else:
    print(ans)
    

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	string s;
	cin >> s;
	if(s[2] == s[3] and s[4] == s[5]) cout << "Yes";
	else cout << "No";

	return 0;
}



Measured memory_bytes: 256
import math
A, B, C, D = map(int, input().split())
total = B-A+1
A -= 1
waruC = (B//C)-(A//C)
waruD = (B//D)-(A//D)
CD = C * D // math.gcd(C, D)
waruCD = (B//CD)-(A//CD)
print(total-waruC-waruD+waruCD)


Measured memory_bytes: 9176
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int h;
    cin >> h;
    int w;
    cin >> w;
    vector<string> a(h);
    for(int i = 0; i < h; i++) {
        cin >> a[i];
    }

    vector<bool> row(h, false);
    vector<bool> col(w, false);
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; j++) {
            if(a[i][j] == '#') {
                row[i] = true;
                col[j] = true;
            }
        }
    }

    for(int i = 0; i < h; ++i) {
        if (row[i]) {
            for(int j = 0; j < w; j++) {
                if(col[j]) {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int m=1,n,cnt=0,aa[220000],al=0;
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n+1){
        cin>>aa[i];
        al+=aa[i];
    }
    rep(i,n+1){
        cnt+=m;
        al-=aa[i];
        m=min((m-aa[i])*2,al);
        if(m<=0&&i!=n){
            cout<<-1;
            return 0;
        }
        if(m<0){
            cout<<-1;
            return 0;
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 11296
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cstring>
#define N 100000
using namespace std;

int main() {
  int A,B;
  cin >> A >> B;
  if(A>8||B>8)
    cout << ":(";
  else
    cout << "Yay!";
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long h, w;
std::string s;

int main(){
    scanf("%ld%ld", &h, &w);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            std::cin >> s;
            if(s == "snuke"){
                printf("%c%d\n", (char)('A'+j), i+1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b && b==c && c==a)
        printf("No\n");
    else if(a==b||b==c ||c==a)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
  
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>

void tol(std::string& text)
{
	for (auto& c : text)
	{
		if (65 <= c && c <= 90)
		{
			c += 32;
		}
	}
}
 
int main()
{
	std::string key;
	std::getline(std::cin, key, '\n');

	std::string text;
	int counter = 0;
	while (std::cin >> text)
	{
		if (text == "END_OF_TEXT")
			break;

		tol(text);

		if (text == key)
			counter++;
	}

	std::cout << counter << std::endl;

	return 0;
}


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



int main(){
  string s,t;
  cin >> s >> t;
  int n=s.size();
  int nt=t.size();
  int ans=1000000;
  for(int i=0;i<=n-nt;++i){
    int cnt=0;
    for(int j=0;j<nt;++j){
      if(s[i+j]!=t[j]) cnt++;
    }
    ans=min(ans,cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m ;
  cin >> n >> m ;
  vvint G(n,vint(n,0)) ;
  stack<int> S ;
  int ans = 0 ;
  
  vector<pii> vec(m) ;
  
  REP(i,m){
    int a, b ;
    cin >> a >> b ;
    vec[i] = MP(a-1,b-1) ;
    G[a-1][b-1] = 1 ;
    G[b-1][a-1] = 1 ;
  }
  
  REP(i,m){
    vint seen(n,0) ;
    int A = vec[i].FI ;
    int B = vec[i].SE ;
    vector<queue<int>> gra(n) ;
    G[A][B] = 0 ;
    G[B][A] = 0 ;
    
    S.push(0) ;
    seen[0] = 1 ;
    int cnt = 0 ;
    
    REP(I,n){
      REP(J,n){
        if(G[I][J]==1){
          gra[I].push(J) ;
          gra[J].push(I) ;
        }
      }
    }
          
    
    
  while(!S.empty()){
    int k = S.top() ;
    
    while(1){
      if(gra[k].empty()){
        S.pop() ;
        break ;
      }
      int l = gra[k].front() ;
      if(seen[l]==1){
        gra[k].pop() ;
        continue ;
      }
      else{
        S.push(l) ;
        gra[k].pop() ;
        seen[l] = 1 ;
        break ;
      }
    }

    if(S.empty()){
      FOR(i,k,n){
        if(seen[i]==0){
          S.push(i) ;
          seen[i] = 1 ;
          cnt++ ;
          break ;
        }
      }
    }
    
  }
    
    
    if(cnt!=0){
      ans++ ;
    }
    
    
    






    G[A][B] = 1 ;
    G[B][A] = 1 ;
  }
  
  
  cout << ans <<endl ;
    
  
    
    
  
  
  
  return 0 ;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;

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

/*============ Header Template ============*/

const int N = 100000 + 5;

int n, m, q;
char s[N], t[N];
int s1[N], s2[N];

int main() {
	scanf("%s", s + 1); n = strlen(s + 1);
	scanf("%s", t + 1); m = strlen(t + 1);
	for (int i = 1; i <= n; i++) s1[i] = s1[i - 1] + (s[i] == 'B');
	for (int i = 1; i <= m; i++) s2[i] = s2[i - 1] + (t[i] == 'B');
	read(q);
	int l, r, x, y;
	for (int i = 1; i <= q; i++) {
		read(l), read(r);
		read(x), read(y);
		int tmp1 = s1[r] - s1[l - 1];
		int ans1 = tmp1 + (r - l + 1 - tmp1) * 2;
		int tmp2 = s2[y] - s2[x - 1];
		int ans2 = tmp2 + (y - x + 1 - tmp2) * 2;
		if ((ans1 - ans2) % 3 == 0) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int dp[n+1];
    dp[0] = 1;
    dp[1] = 1;
    for(int i = 2; i <= n; i++) dp[i] = dp[i-1] + dp[i-2];

    cout << dp[n] << endl;
}


Measured memory_bytes: 3116
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal


def main():
    n = int(input())
    l = [0]*(n+1)
    for x in range(1,101):
        for y in range(1,101):
            for z in range(1,101):
                temp = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if temp <= n:
                    l[temp] += 1

    for i in range(1, n+1):
        print(l[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 74280
import copy
N=int(input())
c1=list(input().split())
c2=copy.deepcopy(c1)
c3=copy.deepcopy(c1)
def bubble(card):
    for i in range(N):
        for j in [N-x for x in range(1,N-i)]:
            if int(card[j][1]) < int(card[j-1][1]):
                s= card[j]
                card[j]=card[j-1]
                card[j-1]=s
    return card
def selection(card):
    for i in range(N):
        minj = i
        for j in range(i,N):
            if int(card[j][1]) < int(card[minj][1]):
                minj = j
        s = card[i]
        card[i]=card[minj]
        card[minj]=s
    return card
def stable(card):
    j=0
    for i in range(N-1):
        if int(card[i][1]) == int(card[i+1][1]):
            if c3.index(card[i]) > c3.index(card[i+1]):
                j=1
                break
    if j == 0:
        return 'Stable'
    else:
        return 'Not stable' 
print(*bubble(c1))
print(stable(bubble(c1)))
print(*selection(c2))
print(stable(selection(c2)))


Measured memory_bytes: 6348
import fractions

numA, numB, numC, numD = map(int, input().split())

AsplitC = int((numA - 1) // numC)
BsplitC = int(numB // numC)
AsplitD = int((numA - 1) // numD)
BsplitD = int(numB // numD)
AsplitCandD = int((numA - 1) // int(numC * numD // fractions.gcd(numC, numD)))
BsplitCandD = int(numB // int(numC * numD // fractions.gcd(numC, numD)))

count = (numB - numA + 1) - ((BsplitC - AsplitC) + (BsplitD - AsplitD) - (BsplitCandD - AsplitCandD))

print(count)

Measured memory_bytes: 5076
#include <iostream>

using namespace std;

typedef long long ll;

int main () {
  ll n, a, b;
  cin >> n >> a >> b;

  ll m = a + b;

  ll ans = (n / m) * a;
  n %= m;
  if (n <= a) {
    ans += n;
  } else {
    ans += a;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    int ans = n/2;
    if (n % 2 == 0) ans -= 1;

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

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)

ll moddiv(ll a,ll b){
    a %= MOD;
    b %= MOD;
    for(ll m=MOD-2;m>0;m/=2){
        if(m&1){
            a=a*b%MOD;
        }
        b=b*b%MOD;
    }
    return a;
}

ll N, A, B, C;
ll pa,pb;
ll Fa[500000];
ll i, j, k,ans;
int main(){
    scanf("%lld%lld%lld%lld", &N,&A,&B,&C);
    Fa[0] = 1;
    pa=j = moddiv(A, A + B);
    pb=k = moddiv(B, A + B);
    fornum(i,0,222222){
        Fa[i + 1] = Fa[i] * (i + 1) % MOD;
    }
    fornum(i,1,N){
        pa = pa * j % MOD;
        pb = pb * k % MOD;
    }

    fornum(i,0,N){
        ll a = moddiv(Fa[N-1 + i], Fa[N-1]*Fa[i]) * (pa + pb) % MOD;
        ans = (ans + moddiv(100, 100 - C) * a % MOD * (N + i)%MOD) % MOD;
        //printf("%lld\n",(pa+pb)%MOD);
        pa = pa * k % MOD;
        pb = pb * j % MOD;
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <iterator>

using namespace std;

typedef long long ll;
#define mems(p) memset(p,0,sizeof(p))
#define mp make_pair

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int main(){
	fast();
	int n,a,b,c,d;
	string s;
	cin>>n>>a>>b>>c>>d>>s;
	int bb=b;
	while (d-b>2) {
		if (s[b+1]=='.') b+=2;
		else if (s[b]=='.') ++b;
		else {
			cout<<"No"<<endl;
			return 0;
		}
	}
	while (c-a>2) {
		if (s[a+1]=='.') a+=2;
		else if (s[a]=='.') ++a;
		else {
			cout<<"No"<<endl;
			return 0;
		}
	}
	if (c>d) {
		for (int i = bb-2; i < d-1; ++i)
		{
			if (s[i]=='.' && s[i+1]=='.' && s[i+2]=='.') {
				cout<<"Yes"<<endl;
				return 0;
			}
		}
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 592
#include <cstdio>

int main(){
	int x,y;
	scanf("%d %d",&x,&y);
	int groupx;
	int groupy;

	if(x==1||x==3||x==5||x==7||x==8||x==10||x==12) groupx = 1;
	if(y==1||y==3||y==5||y==7||y==8||y==10||y==12) groupy = 1;
	if(x==4||x==6||x==9||x==11) groupx = 2;
	if(y==4||y==6||y==9||y==11) groupy = 2;
	if(x==2) groupx = 3;
	if(y==2) groupy = 3;

	if(groupx==groupy){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 128
/**************************************************
  Solution to: ABC 174 D - Alter Altar
  Writer: InvisibleCyclist
  By/Based on:
**************************************************/
#include<bits/stdc++.h>
using namespace std;
int n;
int res=0;
int a[200005];
int main(){
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i<n;i++){
		if(s[i]=='R'){
			cnt++;
		}
	}
	for(int i=0;i<cnt;i++){
		if(s[i]=='W'){
			res++;
		}
	}
	cout<<res;
/*	for(int i=0;i<n;i++){
		if(s[i]=='W'){
			for(int j=n-1;j>=i;j--){
				if(s[j]=='R'){
					res++;
					s[j]='W';
					s[i]='R';
					break;
				}
			}
		}
	}
	for(int i=0;i<n;i++){
		if(s[i]=='W'){
			for(int j=i;j<n;j++){
				if(s[j]=='R'){
					res++;
					s[i]==1;
					break;
				}
			}
		}
	}
	cout<<res;
	for(int i=0;i<n;i++){
		char c;
		cin>>c;
		if(c=='R'){
			a[i]=1;
		}
		if(c=='W'){
			a[i]=2;
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]==2){
			for(int j=n-1;j>=i;j--){
				if(a[j]==1){
					res++;
					a[j]=2;
					a[i]=1;
					break;
				}
			}
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]==2){
			for(int j=i;j<n;j++){
				if(a[j]==1){
					res++;
					a[i]==1;
					break;
				}
			}
		}
	}
	cout<<res;*/
	return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	int n;
	cin >> n;
	int t[100010] = {}, x[100010] = {}, y[100010] = {};
	for (int i = 1; i <= n; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}
	for (int i = 1; i <= n; i++) {
		int xdest = max(x[i], x[i - 1]) - min(x[i], x[i - 1]);
		int ydest = max(y[i], y[i - 1]) - min(y[i], y[i - 1]);
		//cout << "i:" << i << " xdest:" << xdest << " ydest:" << ydest << " t[i]:" << t[i] << " t[i-1]:" << t[i - 1] << endl;
		if (xdest + ydest > t[i] - t[i - 1]) {
			cout << "No" << endl;
			return 0;
		} else if (((xdest + ydest) - (t[i] - t[i - 1])) % 2 == 1 || ((xdest + ydest) - (t[i] - t[i - 1])) % 2 == -1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1408
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i)

hash = {}
a_arr.each do |a|
  hash[a] ||= 0
  hash[a] += 1
end

result = 0
hash.each do |(x, count)|
  if x > count then
    result += count
  elsif x < count
    result += count - x
  end
end

puts result


Measured memory_bytes: 18180
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final char[] chars = scanner.nextLine().toCharArray();

        int resultA = 0;
        int resultB = 0;

        for (int i = 0; i < chars.length; i++) {
            if (i % 2 == 0) {
                if (chars[i] == '0') {
                    resultA++;
                } else {
                    resultB++;
                }
            } else {
                if (chars[i] == '1') {
                    resultA++;
                } else {
                    resultB++;
                }
            }
        }

        System.out.println(Math.min(resultA, resultB));
    }
}


Measured memory_bytes: 26444
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	int A, B,C,D;
	scanf("%d%d%d%d", &A,&B,&C,&D);
	
	printf("%d", max(A*B, C*D));


}

Measured memory_bytes: 128
H,W = map(int, input().split())

m = []
for _ in range(H):
    line = list(input())
    m.append(line)

for y in range(H):
    for x in range(W):
        if m[y][x]==".":
            continue
        if y+1<H and m[y+1][x]=="#":
            continue

        if y-1>-1 and m[y-1][x]=="#":
            continue

        if x+1<W and m[y][x+1]=="#":
            continue

        if x-1>-1 and m[y][x-1]=="#":
            continue
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){
    //ll P , Q , R;
    //cin >> P >> Q  >> R;
    ll N = 0;
    cin >> N;
    vector <ll > p(N);
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    /*
    p.erase(unique(p.begin(), p.end()), p.end());
    if(p.size() < N){
        cout << "0" << endl;
        return 0;
    }
    */

    if(p[p.size() / 2 - 1] == p[p.size() / 2]){
        cout << "0" << endl;
        return 0;
    }else{
        cout << p[p.size() / 2] - p[p.size() / 2 - 1] << endl;
    }

    /*
    for(int i = 0; i < N; i++){
        cout << p[i] << endl;
    } 
    */

} 

Measured memory_bytes: 1024
import java.util.Scanner;

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

        String s = stdIn.next();
        char[] cs = s.toCharArray();
        int n = cs.length;

        for(int i=0; i<n/2; i++){
            if(cs[i] != cs[n-i-1]){
                System.out.println("No");
                return;
            }
        }

        for(int i=0; i<(n-1)/4; i++){
            if(cs[i] != cs[(n-1)/2-i-1]){
                System.out.println("No");
                return;
            }
        }

        for(int i=0; i<(n-1)/4; i++){
            if(cs[n-i-1] != cs[n-(n-1)/2+i]){
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}

Measured memory_bytes: 22740
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
template <class T> using grid = vector<vector<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
static const lint MOD = (lint)1e9+7;

static const int Nmax = 1000;

std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

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

    sieve(Nmax);

    vector<lint> primes;
    for (lint i = 2; i <= N; ++i)
    {
        if (IsPrime[i])
        {
            primes.pb(i);
        }
    }
    vector<lint> counters(SZ(primes), 1);
    lint sqrtN = sqrt(N) + 1;
    for (lint i = 1; i <= N; ++i)
    {
        lint t = i;
        for (lint p = 0; p < SZ(primes); ++p)
        {
            while (t % primes[p] == 0)
            {
                t /= primes[p];
                counters[p]++;
            }
        }
    }

    lint ans = 1;
    for (lint i = 0; i < counters.size(); ++i)
    {
        ans = (ans * counters[i]) % MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
using namespace std;

typedef vector<int> Ivec;

int main() {
	int n, r;

	while (scanf("%d %d", &n, &r)) {
		if (n == 0) 
			return 0;

		Ivec fuda;
		for (int i = n; 0 < i; i--)
			fuda.push_back(i);

		int p, c;
		for (int i = 0; r > i; i++) {
			scanf("%d %d", &p, &c);
			Ivec buf(fuda);
			for (int j = 0; c > j; j++) {
				fuda.erase(fuda.begin()+p-1+j);
				fuda.insert(fuda.begin()+j, buf[p-1+j]);
			}
		}
		printf("%d\n", fuda[0]);
	}
	return 0;
}

Measured memory_bytes: 3200
def solve():
    N = int(input())
    str_unions = sorted([tuple(sorted(input())) for _ in range(N)])
    count_dict = {}
    ret = 0
    
    for s in str_unions:
        if s not in count_dict:
            count_dict[s] = 1
        else: count_dict[s] += 1

    sum_n = lambda n: n*(n+1)//2
    # print(count_dict)
    print(sum(map(lambda x:sum_n(x-1), count_dict.values())))
    
solve()

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

map<int, int> mp;

int main()
{
    int a, n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        scanf("%d", &a);
        if(mp[a]){
            puts("NO");
            return 0;
        }
        else mp[a] = 1;
    }
    puts("YES");

    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int n;
vector<vector<int>> G;

int dist[300];

int bfs(int begin){
  fill(dist,dist+300,-1);
  queue< P > que;
  que.push(make_pair(begin,0));
  while(!que.empty()){
    int now,d;
    tie(now,d) = que.front();
    que.pop();
    if(dist[now] == -1) {
      dist[now] = d;
      for(int i : G[now]){
        if(dist[i] == -1){
          que.push(make_pair(i,d+1));
        }
      }
    }
  }
  int res = 0;
  for(int i = 0;i < n;++i){
    res = max(res, dist[i]);
  }
  return res;
}

bool is_bin(){
  for(int i = 0;i < n;++i){
    for(int j : G[i]){
      if(dist[i] % 2 == dist[j] % 2){
        return false;
      }
    }
  }
  return true;
}

int main(void){
  cin >> n;
  G = vector<vector<int>>(n);
  for(int i = 0;i < n;++i){
    string s;
    cin >> s;
    for(int j = 0;j < n;++j){
      if(s[j] == '1'){
        G[i].push_back(j);
      }
    }
  }
  bfs(0);
  if(!is_bin()){
    cout << -1 << endl;
    return 0;
  }
  int res = 0;
  for(int i = 0;i < n;++i){
    res = max(res, bfs(i));
  }
  cout << res + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int m = sc.nextInt();
			int n = sc.nextInt();
			if(m==0 && n==0) break;
			
			int[] a = new int[n];
			int sum = 0;
			int max = 0;
			for(int i=0;i<n;i++){
				a[i] = sc.nextInt();
				sum += a[i];
				max = Math.max(max, a[i]);
			}
			max = Math.max(max, sum/m);
			
			int cnt = 0;
			for(int i=max;;i++){
				sum = 0;
				cnt = 0;
				for(int j=0;j<n;j++){
					sum+=a[j];
					if(sum>i){
						j--;
						cnt++;
						sum = 0;
					}
					if(cnt==m) break;
				}
				if(cnt<m){
					System.out.println(i);
					break;
				}
			}
		}	
	}	
}

Measured memory_bytes: 20968
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        //入力
        Scanner scn=new Scanner(System.in);
        int w_h=scn.nextInt();
        int w_w=scn.nextInt();
        int b_h=scn.nextInt();
        int b_w=scn.nextInt();
        //処理と出力
        System.out.println((w_h-b_h)*(w_w-b_w));
    }
}

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

int n;
char s[110];

int main()
{
    scanf("%d%s", &n, s);
    int cnt = 0;
    for (int i = 0; i < n; i++)
        if (s[i] == 'R')
            cnt++;
    if (cnt * 2 > n) puts("Yes");
    else puts("No");
}

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

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

    if ((a+b) % 2 == 0) cout << (a+b) / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func main() {
	var x, n int
	fmt.Scanf("%d %d", &x, &n)
	ps := scanIntSlice(n)

	s := map[int]struct{}{}
	for _, p := range ps {
		s[p] = struct{}{}
	}

	for i := 0; i <= 100; i++ {
		if _, ok := s[x-i]; !ok {
			fmt.Printf("%d\n", x-i)
			os.Exit(0)
		} else if _, ok := s[x+i]; !ok {
			fmt.Printf("%d\n", x+i)
			os.Exit(0)
		}
	}
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


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

#define repeat(i,n) for (int i = 0; i < (n); ++i)
#define repeat_from(i,m,n) for (int i = m; i < (n); ++i)

#define MAX_S 1000
int dp[2][MAX_S+1];

int main() {
    string s1, s2;
    getline(cin, s1);
    getline(cin, s2);
    int *cur = dp[0]; repeat (i,s2.size()+1) cur[i] = i;
    int *prv = dp[1];
    repeat_from (i,1,s1.size()+1) {
        swap(cur,prv);
        cur[0] = prv[0] + 1;
        repeat_from (j,1,s2.size()+1) {
            cur[j] = min(cur[j-1]+1,
                    min(prv[j]+1,
                        prv[j-1]+(s1[i-1]==s2[j-1]?0:1)));
        }
    }
    cout << cur[s2.size()] << endl;
    return 0;
}

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

const int m=1000000007;
ll power (ll x, ll y){
    ll ans =1;
    while(y>0){
        if(y%2==1)
            ans = (ans * x) % m;
        y/=2;
        x=(x*x)%m;
    }
    return ans;
}

void testcase(){
    ll n;
    cin >> n;
    ll res;
    res = power(10,n)-2*power(9,n)+power(8,n)+2*m;
    res%=m;
    cout << res;
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int q=1;
  //  cin >> q;
    while(q--){
    testcase();
    }
    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005
#define MAX_M 100005
typedef pair<int,int> P;

int n,m;
int x[MAX_M],y[MAX_M],w[MAX_M];

vector<int> G[MAX_N];
vector<int> g[MAX_N];

vector<int> group[MAX_N];
int id[MAX_N];
bool visited[MAX_N];
vector<int> vd;

int dp[MAX_N];

bool dfs(int pos,int prev,int root){
  id[pos]=root;
  visited[pos]=true;
  group[root].push_back(pos);
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    if(i&&to==G[pos][i-1])return true;
    if(visited[to])return true;
    if(dfs(to,pos,root))return true;
  }
  return false;
}

bool check(){
  memset(visited,false,sizeof(visited));
  for(int i=0;i<n;i++){
    if(visited[i])continue;
    if( dfs(i,-1,i) )return true;
  }

  vector< int > deg(n);
  vector< vector<int> > graph(n);
  
  for(int i=0;i<m;i++){
    if(w[i]==1){
      int X=id[ x[i] ];
      int Y=id[ y[i] ];
      if(X==Y)return true;
      graph[X].push_back(Y);
      deg[Y]++;
    }
  }

  queue<int> Q;
  for(int i=0;i<n;i++)
    if(deg[i]==0&&id[i]==i)
      Q.push(i);

  while(!Q.empty()){
    int pos=Q.front();Q.pop();
    vd.push_back(pos);
    for(int to:graph[pos]){
      deg[to]--;
      if(deg[to]==0)Q.push(to);
    }
  }
  
  for(int i=0;i<n;i++)
    if(deg[i]>0)return true;
  
  return false;
}

int d[MAX_N];

void init(int root){
  root=id[root];
  for(int pos:group[root])
    d[pos]=-1;
}

void bfs(int root){
  init(root);
  queue<int> Q;
  Q.push(root);
  d[root]=0;
  while(!Q.empty()){
    int pos=Q.front();Q.pop();
    for(int to:G[pos]){
      if(d[to]!=-1)continue;
      d[to]=d[pos]+1;
      Q.push(to);
    }
  }
}

void update(int root,int dif){
  for(int pos:group[root])
    for(int to:g[pos])
      dp[to]=max(dp[to],d[pos]+dif+1);
}

int solve(int root){
  int res=0;
  bfs(root);
  int maxm=-1,maxmid;
  for(int pos:group[root])
    if(d[pos]+dp[pos]>maxm)maxm=d[pos]+dp[pos],maxmid=pos;
  
  bfs(maxmid);
  update(root,dp[maxmid]);
  for(int pos:group[root])res=max(res,d[pos]+dp[maxmid]);
  
  maxm=-1;
  for(int pos:group[root])
    if(d[pos]+dp[pos]>maxm)maxm=d[pos]+dp[pos],maxmid=pos;

  bfs(maxmid);
  update(root,dp[maxmid]);
  for(int pos:group[root])res=max(res,d[pos]+dp[maxmid]);
  
  return res;
}

int main(){
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d %d %d",&x[i],&y[i],&w[i]);
    x[i]--,y[i]--;
    if(w[i]==1){
      g[x[i]].push_back(y[i]);
    }
    if(w[i]==2){
      G[x[i]].push_back(y[i]);
      G[y[i]].push_back(x[i]);
    }
  }
  
  if( check() ){
    printf("Infinite\n");
    return 0;
  }

  int ans=0;
  for(int root : vd ){
    if(root!=id[root])continue;
    ans=max(ans,solve(root));
  }
  printf("%d\n",ans);  
  return 0;
}

Measured memory_bytes: 23616
#include<stdio.h>
int main(){
    int S[1000000];
    int c=1,a=0;
    int N,MIN;
    scanf("%d",&N);
    for(a=0;a<N;a++){
      scanf("%d",&S[a]);
    }
  MIN=S[0];
  

    for(int b=1;b<N;b++){
        if(MIN>=S[b]){
            c++;
          MIN=S[b];
        }else{
        }
    }
    printf("%d",c);
    return 0;

}


Measured memory_bytes: 2944