akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define endl '\n'
#define inf 9223372036854775807
#define maxn 3000001
#define mod (ll)(1e9+7)
#define int ll
 
using namespace std;
 
void io(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

int n,ar[2005];
int D,T,S;

void __solve(){
		cin>>D>>T>>S;
		if(T*S>=D){
			cout<<"Yes"<<endl;
		}else cout<<"No"<<endl;
		
		
}


int32_t main(){
io();
IOS;    
			int t=1;
			// cin>>t;
			while(t--){
				__solve();
			}
		
		



        

        


        
    
        
        
                


 
        
 
 
 
        
 
 
 
 
        
        
 
        
        
 
    
    
    
    
 
 
       
 
 
 
 
      
   
 
 
 
 
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int a, b, ans;

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);

	cin >> a >> b;

	ans += abs(abs(a) - abs(b));

	if(a < 0 && b < 0) {
		if(a > b) {
			ans += 2;
		}
	}

	if(a < 0 && b > 0)
		ans++;

	if(a > 0 && b < 0)
		ans++;

	if(a > 0 && b > 0)
		if(a > b)
			ans += 2;

	if(a == 0) {
		if(b < 0)
			ans++;
	}
	if(b == 0) {
		if(a > 0)
			ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while flag:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] /= 2
        else:
            flag = False
            print(count)
            exit()
    count += 1

Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
c=0
l=[]
for i in range(1,n):
  l.append(a[i]-a[i-1])
if len(l)==1 and l[n-2]==0:c+=1
if len(l)>1 and l[n-2]==0 and l[n-3]!=0:c+=1
p=l.pop(0)
while len(l)!=0:
  if p!=0:
    p=l.pop(0)
  else:
    c+=1
    while len(l)>1:
      if l[0]==0 and l[1]==0:
        p=l.pop(0)
        p=l.pop(0)
        c+=1
      else:
        break
    while len(l)>0:
      if l[0]==0:
        p=l.pop(0)
      else:
        p=l.pop(0)
        break
print(c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

    if(s == "ABC")cout << "ARC\n";
    else cout << "ABC\n";
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,r;
    cin>>n>>r;
    if(n<10)
    {
     cout<<(100*(10-n))+r;
        return 0;
    }
    else
    {
      cout<<r;
    return 0;
    }
}


Measured memory_bytes: 3584
using System;
using System.Linq;

class D
{
	static void Main()
	{
		var M = 1000000007;
		Console.ReadLine();
		var a = Console.ReadLine().Split().Select(long.Parse).ToArray();

		var p2 = new long[60];
		p2[0] = 1;
		for (int i = 1; i < 60; i++) p2[i] = 2 * p2[i - 1];

		var f = new long[60];
		foreach (var x in a)
			for (int i = 0; i < 60; i++)
				if ((x & p2[i]) > 0) f[i]++;
		Console.WriteLine(f.Select((x, i) => x * (a.Length - x) % M * (p2[i] % M)).Sum() % M);
	}
}


Measured memory_bytes: 60460
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int R, G;

int main()
{
	in >> R >> G;
	out << G * 2 - R << std::endl;
	return 0;
}

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

int main() {
  vector<int> data(3);
  for (int i=0; i<3 ; i++) cin >> data.at(i);
  sort(data.begin(), data.end());
  
  for (int i=0; i<3 ; i++) {
    if (i == 2) cout << data.at(i) << endl;
    else cout << data.at(i) << " ";
  }
    
  return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <cmath>
#include <list>
#include <map>
#include <set>
#include <string>

using namespace std;
typedef long long ll;

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

    ll ans=0;
    for(int i=0;i<(1<<S.size()-1);i++){
        ll tmp=i;
        int ct=1,idx=0;
        for(int j=0;j<S.size()-1;j++){
            if(tmp&1){
                ans+=stoll(S.substr(idx,ct));
                ct=1;
                idx=j+1;
            }
            else ct++;
            tmp>>=1;
        }
        ans+=stoll(S.substr(idx,ct));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define fi first
#define se second
#define all(in) in.begin(),in.end()

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

using ll = long long;
using namespace std;

int main(){
    ll t; cin >> t;
    rep(count,t){
        ll n; cin >> n;
        vector<pair<ll,ll>> right, left;
        ll ans = 0;
        rep(i,n){
            ll k, l, r;
            cin >> k >> l >> r;
            if(l < r) { ans += l; right.pb(make_pair(n-k,r-l)); }// right
            else if(l > r) { ans += r; left.pb(make_pair(k,l-r)); }// left
            else ans += l;
        }
        sort(all(right));
        sort(all(left));
        priority_queue<ll,vector<ll>,greater<ll>> que1, que2;
        rep(i,(int)right.size()){
            if(que1.size() < right[i].fi) { ans += right[i].se; que1.push(right[i].se); }
            else if(que1.size() && que1.top() < right[i].se) { ans -= que1.top(); que1.pop(); ans += right[i].se; que1.push(right[i].se); }
        }
        rep(i,(int)left.size()){
            if(que2.size() < left[i].fi) { ans += left[i].se; que2.push(left[i].se); }
            else if(que2.size() && que2.top() < left[i].se) { ans -= que2.top(); que2.pop(); ans += left[i].se; que2.push(left[i].se); }
        }
        cout << ans << endl;
    }
  return 0;
}

Measured memory_bytes: 8904
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;
using llong = long long;
const int MOD=1000000007;


int main(int argc, char**argv){
    int n;
    string s;
    int k;
    cin >> n;
    cin >> s;
    cin >> k;

    for (int i = 0 ; i < n; i++){
        if (s[i] != s[k-1]) cout << '*';
        else cout << s[i];
    }
    cout << endl;


    return 0;
}












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

int gcd(int x, int y){
    while(y != 0 && x != 0){
        if(x > y){
            x = x % y;
        }else{
            y = y % x;
        }
    }
    if(x != 0){
        return x;
    }else{
        return y;
    }
}
int main(){
    int x,y,d;

    cin >> x >> y;
    if(x > y){
        d = gcd(x, y);
    }else{
        d = gcd(y, x);
    }
    cout << d << endl;

    return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(it,o) for(auto it = (o).begin(); it != (o).end(); ++ it)
typedef long long ll;
struct edge { int to; int from; int cost; };
struct vertex { int x; int y; int idx;};

struct UnionFind {
    vector<int> par; // 親
    vector<int> rank; // 木の深さ

    UnionFind() {
    }

    // n要素で初期化
    void init(int n) {
        par.resize(n);
        rank.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    // 木の根を求める
    int find(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            return par[x] = find(par[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return;
        }

        if (rank[x] < rank[y]) {
            par[x] = y;
        }
        else {
            par[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
    }

    // xとyが同じ集合に属するか否か
    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int cost(const vertex& v1, const vertex& v2) {
    return min(abs(v1.x - v2.x), abs(v1.y - v2.y));
}

bool compX(const vertex& v1, const vertex& v2) {
    return v1.x < v2.x;
}

bool compY(const vertex& v1, const vertex& v2) {
    return v1.y < v2.y;
}

bool compCost(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

vector<vertex> vt;
vector<edge> es;
UnionFind uf;

class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        vt.clear();
        vt.resize(n);
        rep(i, n) {
            in >> vt[i].x >> vt[i].y;
            vt[i].idx = i;
        }
        
        es.clear();
        uf.init(n);
        sort(vt.begin(), vt.end(), compX);
        int c;
        edge e;
        rep(i, n - 1) {
            e.from = vt[i + 0].idx;
            e.to = vt[i + 1].idx;
            e.cost = cost(vt[i + 0], vt[i + 1]);
            es.push_back(e);
        }

        sort(vt.begin(), vt.end(), compY);
        rep(i, n - 1) {
            e.from = vt[i + 0].idx;
            e.to = vt[i + 1].idx;
            e.cost = cost(vt[i + 0], vt[i + 1]);
            es.push_back(e);
        }

        sort(es.begin(), es.end(), compCost);

        ll res = 0;
        each(it, es) {
            if (!uf.same(it->to, it->from))
            {
                uf.unite(it->to, it->from);
                res += it->cost;
            }
        }

        out << res << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}

#include <fstream>
#include <iostream>

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 6772
#include <iostream>

using namespace std;

int main(void){
    int a,b,c,day,dd;
    cin >> a >> b >> c;
    day=0;
    day += 7*(c/(7*a+b));
    c = c%(7*a+b);
    dd = c/a;
    if(dd>=7){
        day+=7;
    }else{
        if(c%a!=0){
            day++;
        }
        day+=dd;
    }
    cout << day << endl;
}



Measured memory_bytes: 3108
/*2019/07/29 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
/*
int asc_t(const void *a,const void *b){return ((user_t*)a)->score - ((user_t*)b)->score;}
int desc_t(const void *a,const void *b){return ((user_t*)b)->score - ((user_t*)a)->score;}
*/

int main(){
    int n;
    scanf("%d",&n);

    for(int i=0;i<=100;i+=4){
        for(int j=0;j<=100;j+=7){
            if(i+j==n){
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
# 文字列の取得
S = [1000]
t = [0] * 100000
S = input().split()
MAX=100000

def isEmpty() :
    return 0

def isFull():
    return top >= MAX - 1

def push(x):
    global top
    x = int(x)
    if isFull():
        print("Error")
        exit
    top += 1
#    print ("top=" , top)
    t[top] = x

def pop():
    global top
    if isEmpty():
        print("Error")
        exit
    top -= 1
    return t[int(top+1)]

## メイン処理
a = 0
b = 0
top = 0

# print('S=',S)

for item in S:
#    print ("item=", item)
    if (item == '+'):
        a = pop()
        b = pop()
#        print('push=', a + b)
        push( a + b )
    elif (item == '-'):
        b = pop()
        a = pop()
#        print('push=', a - b)
        push(a - b)
    elif (item == '*'):
        a = pop()
        b = pop()
#        print('push=', a * b)
        push(a * b)
    else:
 #       print('push=', item)
        push(item)

print(pop())


Measured memory_bytes: 6248
#!/bin/bash

typeset -i res=0
read S
read T

s1=$( echo $S | cut -b  1 )
s2=$( echo $S | cut -b  2 )
s3=$( echo $S | cut -b  3 )
t1=$( echo $T | cut -b  1 )
t2=$( echo $T | cut -b  2 )
t3=$( echo $T | cut -b  3 )

if [[ $s1 == $t1 ]] ; then
        res=$(( $res + 1 ))
fi
if [[ $s2 == $t2 ]] ; then
        res=$(( $res + 1 ))
fi
if [[ $s3 == $t3 ]] ; then
        res=$(( $res + 1 ))
fi

echo $res


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

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        // GO;
        long long ans = 0;
        for (int x = 1; x <= i; x++) {
            int x2 = x * x;
            if (x2 > i) {
                break;
            }
            for (int y = 1; y <= i; y++) {
                int y2 = y * y;
                int xy = x * y;
                if (x2 + y2 + xy > i) {
                    break;
                }
                int L = 1, R = i, z = -1;
                while (L <= R) {
                    int mid = L + R >> 1;
                    int z2 = mid * mid;
                    int zx = mid * x;
                    int zy = mid * y;
                    int go = x2 + y2 + z2 + xy + zx + zy;
                    if (go == i) {
                        z = mid;
                        break;
                    } else if (go > i) {
                        R = mid - 1;
                    } else {
                        L = mid + 1;
                    }
                }
                if (z != -1) ans++;
            }
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
const int Max=1e5;
int N,M,Q,Num=0,num=0,lin[Max+10]={},Col[Max+10]={},v[Max+10]={},d[Max+10]={},c[Max+10]={},q[Max+10]={},vis[Max+10][15]={};
struct kk{
	int Id,Next;
} e[Max*2+10]={};
inline void insert(int x,int y){
	e[++Num].Next=lin[x]; lin[x]=Num; e[Num].Id=y;
}
inline void dfs(int x,int Dep,int col){
	if(!Col[x]) Col[x]=col;
	if(vis[x][Dep]||Dep<=0) return;
	for(int i=0;i<=Dep;i++) ++vis[x][i];
	for(int i=lin[x];i;i=e[i].Next)
	 dfs(e[i].Id,Dep-1,col);
}
int main(){
	scanf("%d%d",&N,&M);
	for(int i=1;i<=M;i++){
		int x,y; scanf("%d%d",&x,&y);
		insert(x,y); insert(y,x);
	}
	scanf("%d",&Q);
	for(int i=1;i<=Q;i++) scanf("%d%d%d",&v[i],&d[i],&c[i]);
	for(int i=Q;i>=1;--i) dfs(v[i],d[i],c[i]);
	for(int i=1;i<=N;i++) printf("%d\n",Col[i]);
	return 0;
}

Measured memory_bytes: 10368
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
                int x,y;
                x = Math.abs(a-b);
                y = Math.abs(a-c);
               if(x > y){
                   System.out.println("B");
               }else{
                   System.out.println("A");
              }
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
#define maxn 200009
using namespace std;
const ll INF = 100000000000;
struct edge
{
	ll a,b,cap,flow;
};
ll num,s,t,d[maxn],ptr[maxn],q[maxn];
vector<ll> g[maxn];
vector<edge> e;
inline void add_edge(ll a,ll b,ll cap)
{
	edge e1={a,b,cap,0};
	edge e2={b,a,0,0};
	g[a].pb(e.size());
	e.pb(e1);
	g[b].pb(e.size());
	e.pb(e2);
}
bool bfs()
{
	queue<ll> q;
	for(int i=0;i<=num;i++)
	{
		d[i]=-1;
	}
	d[s]=0;
	q.push(s);
	while(!q.empty())
	{
		if(d[t]!=-1)
		{
			return true;
		}
		ll x=q.front();
		q.pop();
		for(ll i=0;i<g[x].size();i++)
		{
			ll id=g[x][i];
			ll nxt=e[id].b;
			if(e[id].flow<e[id].cap)
			{
				if(d[nxt]==-1)
				{
					d[nxt]=d[x]+1;
					q.push(nxt);
				}
			}
		}
	}
	return false;
} 
ll dfs(ll vv,ll flow)
{
	if(!flow) return 0;
	if(vv==t) return flow;
	for(;ptr[vv]<(ll)g[vv].size();++ptr[vv])
	{
		ll id=g[vv][ptr[vv]],
			to=e[id].b;
		if(d[to]!=d[vv]+1) continue;
		ll pushed=dfs(to,min(flow,e[id].cap-e[id].flow));
		if(pushed)
		{
			e[id].flow+=pushed;
			e[id^1].flow-=pushed;
			return pushed;
		}
	}
	return 0;
}
ll dinic()
{
	ll flow=0;
	while(1)
	{
		if(!bfs())
		{
			break;
		}
		memset(ptr,0,num*sizeof ptr[0]);
		while(1)
		{
			ll pushed=dfs(s,INF);
			if(!pushed)
			{
				break;
			}
			flow+=pushed;
		}
	}
	return flow;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int h,w;
	cin>>h>>w;
	string str[h+2];
	for(int i=0;i<h;i++)
	{
		cin>>str[i];
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(str[i][j]!='.')
			{
				for(int k=0;k<w;k++)
				{
					if(k!=j&&(str[i][k]!='.'))
					{
						add_edge(h*w+(i*w)+j,i*w+k,INF);
					}
				}
				for(int k=0;k<h;k++)
				{
					if(k!=i&&(str[k][j]!='.'))
					{
						add_edge(h*w+(i*w)+j,k*w+j,INF);
					}
				}
			}
		}
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(str[i][j]=='S')
			{
				s=i*w+j;
				add_edge(i*w+j,(h*w)+(i*w)+j,INF);
			}
			else if(str[i][j]=='T')
			{
				t=((ll)((h*w)+(i*w)+j));
				add_edge(i*w+j,(h*w)+(i*w)+j,INF);
			}
			else if(str[i][j]!='.')
			{
				add_edge(i*w+j,(h*w)+(i*w)+j,1);
			}
		}
	}
	num=2*h*w+100;
	ll ans=dinic();
	if(ans>=INF)
	{
		cout<<"-1\n";
	}
	else
	{
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 176032
#include <iostream>

int main(){
    
    while(true){
    
    int num,a,b,resa=0,resb=0;
    
    std::cin>>num;
    
    if(num==0)
        break;
    
    for(int i=0;i<num;i++){
        std::cin>>a>>b;
        if(a>b)
            resa+=a+b;
        else
        if(a<b)
            resb+=a+b;
        else
            if(a==b)
                resa+=a,resb+=b;
    }
    
    std::cout<<resa<<' '<<resb<<std::endl;
        
    }
    
    return 0;
}

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;
int inf=1<<30;
long long llinf=1ll<<60;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int main(void){
    int n,b[26],i,j,k,a,m;
    char c[300];
    while(1){
        LOOP:
        scanf("%d",&n);
        if(!n)break;
        MEMSET(b);
        getchar();
        fgets(c,n*2,stdin);
        m=0;
        rep(i,n){
            a=(int)(c[2*i]-'A');
            b[a]++;
            if(m<b[a]){
                m=b[a];
                k=a;
            }
            rep(j,26){
                if(k==j)continue;
                if(b[j]+n-i-1>=m)break;
            }
            if(j==26){
                printf("%c %d\n",(char)(k+'A'),i+1);
                goto LOOP;
            }
        }
        puts("TIE");
    }
    return 0;
}


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


int main(){
    int N;
    cin >> N;
    int sum = 0;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin >> d.at(i);
    }
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            sum += d.at(i)*d.at(j);
            // cout << d.at(i) << d.at(j) << endl;
            // cout << sum << endl;
        }
    }
    cout << sum << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			String line = scanner.next();
			loop: if (line.length() % 2 == 1||line.contains("0")) {
				System.out.println("NA");
			} else {
				int[][] num = new int[line.length() / 2][2];
				for (int i = 0; i < line.length() / 2; i++) {
					int a = line.charAt(i * 2) - '0';
					int b = line.charAt(i * 2 + 1) - '0';
					if (a > 6 || b > 5) {
						System.out.println("NA");
						break loop;
					}
					num[i][0] = a - 1;
					num[i][1] = b - 1;
					
				}
				char[] ch = {'z','.','?','!',' '};
				for (int[] t : num) {
					if (t[0] != 5) {
						System.out.print((char) (t[0] * 5 + t[1] + 'a'));
					}
					else{
						System.out.print(ch[t[1]]);
					}
				}
				System.out.println();

			}
		}
	}
}

Measured memory_bytes: 17204
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int i;
	int ans=210000000;
	for(i=1;i<=n/2+1;i++)
	{
		int sum=0;
		int t=i;
		while(t!=0)
		{
			sum+=t%10;
			t/=10;
		}
		t=n-i;
		while(t!=0)
		{
			sum+=t%10;
			t/=10;
		}
		ans=min(ans,sum);
	}
	printf("%d\n",ans);
	return 0;
}

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

int x[100000], y[100000];
int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		int a, b; scanf("%d%d", &a, &b);
		x[i] = a - b; y[i] = a + b;
	}
	int X[2]{ -INF,INF }, Y[2]{ -INF,INF };
	rep(i, n) {
		X[0] = max(X[0], x[i]); X[1] = min(X[1], x[i]);
		Y[0] = max(Y[0], y[i]); Y[1] = min(Y[1], y[i]);
	}
	int l = 0, r = INF;
	while (l != r) {
		int t = (l + r) / 2;
		bool flag = false;
		rep(i, 2)rep(j, 2) {
			bool ok = true;
			rep(k, n) {
				if (abs(x[k] - X[i]) <= t&&abs(y[k] - Y[j]) <= t)continue;
				if (abs(x[k] - X[!i]) > t || abs(y[k] - Y[!j]) > t) { ok = false; break; }
			}
			if (ok) { flag = true; break; }
		}
		if (flag)r = t;
		else l = t + 1;
	}
	printf("%d\n", l);
}

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

main(){
  ll n,i,ans;
  cin >> n;
  
  if(n%2==0){
     ans = n/2 -1;
  }else{
    ans = (n-1)/2;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
typedef pair<ll,ll> Pair;
const ll inf =1000000007;

const ll MAX = 510000;
const ll MOD = 1000000007;

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

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

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

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(){
    COMinit();
    ll n,m,k;
    cin >> n >> m >> k;
    ll ans=0;
    ll kake=COM(n*m-2,k-2);
    for(ll i=0;i<m;i++){
        for(ll j=0;j<n;j++){
            ll score=0;
            score+=n*(m-1-i)*(m-i)/2;
            score%=MOD;
            score+=n*i*(i+1)/2;
            score%=MOD;
            score+=m*(n-1-j)*(n-j)/2;
            score%=MOD;
            score+=m*j*(j+1)/2;
            score%=MOD;
            score*=kake;
            score%=MOD;
            ans+=score;
            ans%=MOD;
        }
    }
    ans*=modinv(2,MOD);
    ans%=MOD;
    kaku(ans);
}



Measured memory_bytes: 12160
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	int n;
	cin>>n;
	int t=n%10;
	if(t==2||t==4||t==5||t==7||t==9)cout<<"hon";
	else if(t==0||t==1||t==6||t==8)cout<<"pon";
	else cout<<"bon"; 
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int x;
    if ((a+b)%2==0) x=(a+b)/2;
    else x=(a+b)/2+1;
    cout<<x<<endl;
    system("pause");
    return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    int a ;
    cin >> a ;

    a %= 1000 ;

    a = 1000 - a ;
    a %= 1000 ;

    cout << a ; line ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


Measured memory_bytes: 3632
/*
	EDPC[C] Vacation
	https://atcoder.jp/contests/dp/tasks/dp_c
*/

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

#define N_MAX 100010

int main() {
	
	int N;
	int a[N_MAX], b[N_MAX], c[N_MAX];
	
	cin >> N;
	for(int i=0; i<N; i++) cin >> a[i] >> b[i] >> c[i];
	
	int dp[N_MAX][3];
	for(int i=0; i<3; i++) dp[0][i] = 0;
	
	int m;
	for(int i=0; i<N; i++){
		dp[i+1][0] = max(dp[i][1], dp[i][2]) + a[i];
		dp[i+1][1] = max(dp[i][0], dp[i][2]) + b[i];
		dp[i+1][2] = max(dp[i][0], dp[i][1]) + c[i];
		//printf("dp[%d]: %d, %d, %d\n", i+1, dp[i+1][0], dp[i+1][1], dp[i+1][2]);
	}
	
	cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
	
	return 0;
}

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

int main(){
  int i,j,v,N;
  int *A;

  scanf("%d",&N);
  A = (int *)malloc(sizeof(int) * N);
  for(i = 0;i < N;i++)
    scanf("%d",&A[i]);
  
  for(i = 1;i <= N-1;i++){
    for(j = 0;j < N;j++){
      printf("%d",A[j]);
      if(j < N-1)
	printf(" ");
    }
    printf("\n");
    v = A[i];
    j = i-1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
  }
  for(j = 0;j < N;j++){
      printf("%d",A[j]);
      if(j < N-1)
	printf(" ");
  }
    printf("\n");
  return 0;
}



Measured memory_bytes: 2060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[]a = new int[N];
		int sum = 0;
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}
		sc.close();
		int x = sum / N;
		int ans1 = 0;
		int ans2 = 0;
		for(int i = 0; i < N; i++) {
			int t1 = x - a[i];
			int t2 = x + 1 - a[i];
			ans1 += t1 * t1;
			ans2 += t2 * t2;
		}
		System.out.println(Math.min(ans1, ans2));
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <vector>
constexpr int N = 20;
int n, k;
int dp[1 << (N + 1)][N + 1], to[1 << (N + 1)][2];
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin >> n >> k;
    for (int len = 0; len <= n; ++len) {
        for (int s = 0; s < (1 << len); ++s) {
            int t = s | 1 << len;
            int i = len - 1;
            while (i >= 0 && (s >> i & 1))
                --i;
            to[t][0] = i;
            i = len - 1;
            while (i >= 0 && (~s >> i & 1))
                --i;
            to[t][1] = i;
        }
    }
    for (int len = 0; len <= n; ++len) {
        for (int s = 0; s < (1 << len); ++s) {
            char c;
            std::cin >> c;
            if (c == '1')
                dp[s | 1 << len][0] = 1;
        }
    }
    for (int len = n; len >= 0; --len) {
        for (int s = 0; s < (1 << len); ++s) {
            for (int p = 0; p < len; ++p) {
                int t = len - p;
                int suf = s & ((1 << t) - 1) | 1 << t, pre = s >> t | 1 << p;
                if (to[suf][0] != -1)
                    dp[pre << (to[suf][0] + 1) | s & ((1 << to[suf][0]) - 1)][p + 1] += dp[s | 1 << len][p];
                if (to[suf][1] != -1)
                    dp[(pre << 1 | 1) << to[suf][1] | s & ((1 << to[suf][1]) - 1)][p + 1] += dp[s | 1 << len][p];
                dp[pre][p] += dp[s | 1 << len][p];
            }
        }
    }
    for (int len = n; len >= 0; --len) {
        for (int s = 0; s < (1 << len); ++s) {
            if (dp[s | 1 << len][len] >= k) {
                for (int i = len - 1; i >= 0; --i)
                    std::cout << (s >> i & 1);
                std::cout << "\n";
                return 0;
            }
        }
    }
}

Measured memory_bytes: 188672
#include <iostream>

using namespace std;

#define MOD 1000000007LL

long long power(int a, int b)
{
	if(b == 0) { return 1LL; }
	
	if(b % 2 == 1) { return power(a, b / 2) * power(a, b / 2) % MOD * a % MOD; }
	
	return power(a, b / 2) * power(a, b / 2) % MOD;
}

int main()
{
	int n, m;
	
	cin >> m >> n;
	
	cout << power(m, n) << endl;
	
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define fst first
#define snd second
using namespace std;
typedef long long ll;

const int N=2e5+5, K=30;
ll A[N], B[N], n, C[N], D[N];

int main(){FIN;
    cin >> n;
    fore(x,0,n)cin>>A[x];
    fore(x,0,n)cin>>B[x];
    
    int ans=0;
    fore(k,0,K){
        fore(x,0,n)C[x]=A[x]&((1LL<<(k+1))-1LL);
        fore(x,0,n)D[x]=B[x]&((1LL<<(k+1))-1LL);
        sort(C,C+n);sort(D,D+n);
        int cnt=0, i=n-1, j=n-1;
        ll T=1<<k;
        fore(x,0,n){
            while(i>=0&&D[i]+C[x]>=T)i--;
            while(j>=0&&D[j]+C[x]>=2LL*T)j--;
            cnt=(cnt+j-i)%2;
        }
        i=n-1; j=n-1;
        fore(x,0,n){
            while(i>=0&&D[i]+C[x]>=3LL*T)i--;
            while(j>=0&&D[j]+C[x]>=4LL*T)j--;
            cnt=(cnt+j-i)%2;
        }
        if(cnt)ans+=1<<k;
    }
    
    cout << ans << "\n";
}

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

using namespace std;

int n,m,p;
string ans;

int main(){
	scanf("%d%d%d",&n,&m,&p);
	ans="No";
	for (int i=0;i<=n;i++)
		for (int j=0;j<=m;j++)
			if (i*(m-j)+(n-i)*j==p) ans="Yes";
	cout<<ans<<endl;
	
	return 0;
}
			

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

int main() {
  int a,b,c,d,e;
  while(cin >> a >> b >> c >> d >> e && a) {
    int na,nb,nc;
    cin >> na >> nb >> nc;
    vector<int> v;
    for(int i=0;i<nc;i++)v.push_back(c);
    for(int i=0;i<nb;i++)v.push_back(b);
    for(int i=0;i<na;i++)v.push_back(a);
    int sum=na*a+nb*b+nc*c;
    int ans=sum,x=0;
    for(int i=0;i<v.size();i++) {
      int y=i+1;
      x+=v[i];
      sum-=v[i];
      if(y>=d) ans=min(ans,y*e+sum);
      else if(x>=d*e) ans=min(ans,d*e+sum);
    }
    cout << ans << endl;
  }
  return 0;
}


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

int main() {
    int x;
    cin >> x;
    int count = 0;
    int np = 0;
    for(int i = x; i < 105000; i++){
        for(int j = 2; j < sqrt(i); j++)
        if(i % j == 0){
            count++;
        }
        if(count == 0){
            np = i;
            break;
        } else {
            count = 0;
        }
    }
    cout << np << endl;
}


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

int main() {
	int N; cin >> N;
	vector<pair<int, int>> R(N);
	for (auto& i : R) { cin >> i.first >> i.second; i.second += i.first; }
	sort(R.begin(), R.end());
	vector<int> dp(N+1,1), f(N);
	for (int i = N-1; i >= 0; i--) {
		int &d = f[i]; d=i+1;
		while (d < N && R[d].first < R[i].second) d = f[d];
		dp[i]=(dp[i+1]+dp[d])%998244353;
	}
	cout << dp[0] << '\n';
	return 0;
}


Measured memory_bytes: 3328
from collections import deque

N, Q = list(map(int, input().split()))

links = [[] for _ in range(N)]

for i in range(N-1):
  a, b = list(map(int, input().split()))
  links[b-1].append(a-1)
  links[a-1].append(b-1)

counter = [0] * (N)
for i in range(Q):
  p, x = list(map(int, input().split()))
  counter[p-1] += x

counted = [0] * (N)

queue = deque()
queue.append(0)
#print("links", links)
#print("counter", counter)
while queue:
  v = queue.pop()
  #print("v", v)
  counted[v] = 1
  for q in links[v]:
    if not(counted[q] == 1):
      counter[q] += counter[v]
      queue.append(q)
      #print("q",  q, counter)

print(" ".join([str(i) for i in counter]))

Measured memory_bytes: 75888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define MOD 1'000'000'007LL

#define N 32768
ll a[N], b[N];
ll c[N], d[N];

int main(){
	int n, k; scanf("%d%d", &n, &k);
	FOR(i, 1, N) a[i] = min(i, n);
	FOR(i, 1, N) b[i] = min(n/i, n);
	REP(j, k-1){
		c[0] = 0;
		// DEBUG("%d ko\n", j+2);
		FOR(i, 1, N){
		 	c[i] = (c[i-1] + b[i]) % MOD;
			// DEBUG("<=%d --- %lld\n", i, c[i]);
		}
		d[N-1] = c[n/(N-1)];
		for(int i=N-2; i>=1; i--){
			d[i] = d[i+1] + a[i] * (n/i - n/(i+1));
			d[i] %= MOD;
		}
		swap(a, c);
		swap(b, d);
	}
	printf("%lld\n", b[1]);
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include<string>
#include<cctype> 
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
  int W,a,b;
  int A,B;
  cin >> W >> a >> b; 
  A=a+W;
  B=b+W;
  if(A<b){
    cout << b-A << endl;
  }else if(B<a){
    cout << a-B << endl;
  }else if((a<=b && b<=A) || (a<=B && B<=A)){
    cout << 0 << endl;
  }

  return 0;
} 



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

int main() {
	int card[4][13]={0};
	
	int n;
	cin >>n;
	
	char symbol;
	int num;
	for(int i=0; i<n; i++){

		cin >> symbol >> num;
		
		if(symbol=='S'){card[0][num-1]=1;}
		else if(symbol=='H'){card[1][num-1]=1;}
		else if(symbol=='C'){card[2][num-1]=1;}
		else if(symbol=='D'){card[3][num-1]=1;}
		
	}
	
	for(int i=0; i<4; i++){
		for(int j=0; j<13; j++){
			if(card[i][j]==0){
				if(i==0){cout << "S " << j+1 << endl;}
				else if(i==1){cout << "H " << j+1 << endl;}
				else if(i==2){cout << "C " << j+1 << endl;}
				else if(i==3){cout << "D " << j+1 << endl;}
				
			}
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int v[200005], n;
long long res;
int32_t main() {
    DAU
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> v[i];
    for (int i = 2; i <= n; ++i)
        if (v[i] < v[i-1]) {
            res += v[i-1] - v[i];
            v[i] = v[i-1];
        }
    cout << res;
    PLEC
}


Measured memory_bytes: 4428
n=int(input())
dictionary=[]
count=1
ans=0
for i in range(n):
    s=list(input())
    s.sort()
    dictionary.append(s)
dictionary.sort()
for i in range(n-1):
    if dictionary[i]==dictionary[i+1]:
        count+=1
    else:
        ans+=count*(count-1)//2
        count=1
    if i==n-2:
        ans+=count*(count-1)//2
print(ans)


Measured memory_bytes: 24652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
inline int GCD(int a, int b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;


int main()
{
    int H, W;
    cin >> H >> W;
    vs A(H);
    // vector<pair<int, int>> black;
    vvi bmap(H, vi(W, 0));
    queue<vector<int>> qb;
    rep(i, H)
    {
        cin >> A.at(i);
        rep(j, W)
        {
            if (A.at(i).at(j) == '#')
            {
                // black.push_back(make_pair(i,j));
                bmap.at(i).at(j) = 1;
                qb.push({0, i, j});
            }
        }
    }
    // int L = black.size();
    int ans = 0;
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    while (!qb.empty())
    {
        vi qf = qb.front();
        ans = qf[0];
        rep (i, 4)
        {
            if (0 <= qf[1] + dx[i] && qf[1] + dx[i] < H && 0 <= qf[2] + dy[i] && qf[2] + dy[i] < W)
            {
                if (!bmap.at(qf[1] + dx[i]).at(qf[2] + dy[i]))
                {
                    bmap.at(qf[1] + dx[i]).at(qf[2] + dy[i]) = 1;
                    qb.push({qf[0]+1, qf[1] + dx[i], qf[2] + dy[i]});
                }
                // cout << qf[1] << " " << qf[2] << endl;
            }
        }
        qb.pop();
    }
    /*
    // TLE
    rep(i, H)
    {
        rep(j, W)
        {
            int mind = H + W;
            rep(k, L)
            {
                int d = abs(i - black.at(k).first) + abs(j - black.at(k).second);
                if (d < mind)
                {
                    mind = d;
                }
            }
            if (ans < mind)
            {
                ans = mind;
            }
        }
    }
    */
    cout << ans << endl;
}

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;
typedef vector<unordered_map<lli,lli>> graph;

lli n;
vll a;
vll l;
lli ans;

int main(){
  cin >> n;
  a = vll(n);
  for(lli i = 0;i < n;i++) cin >> a[i];
  for(lli i = 0;i < n;i+= 2){
    l.push_back(a[i]);
  }
  sort(a.begin(),a.end());
  for(auto x : l){
    if((lower_bound(a.begin(),a.end(),x)-a.begin())%2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1660
n=10**5+2
#n=100
p=[0]*n
ac=[0]*n
def prime_list(x):
    for i in range(2,x+1):
        flg=True
        for j in range(2,int(i**0.5)+1):
            if i%j==0:
                flg=False
        if flg==True:
            p[i]=1

prime_list(n)
#print(p)
pre=0
for i in range(n):
    if p[i]==1 and p[int((i+1)/2)]==1 and i%2==1:
        k=1
    else:
        k=0
    pre+=k
    ac[i]=pre

q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    print(ac[r]-ac[l-1])

Measured memory_bytes: 52440
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  vector<int> ans(8);
  int p=0;
  rep(i,n){
    if(a.at(i)<3200){
      ans.at(a.at(i)/400)=1;
    }else{
      p++;
    }
  }
  int mini,maxi;
  rep(i,8){
    mini+=ans.at(i);
  }
  maxi=mini+p;
  cout << max(1,mini) <<  " " << maxi;
}
      

Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define all(v) (v).begin(),(v).end()
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    ll T;
    cin >> T;
    vector<ll> N(T), M(T), A(T), B(T);
    for (ll i = 0; i < T; i++) {
        cin >> N[i] >> M[i] >> A[i] >> B[i];
    }

    for (ll i = 0; i < T; i++) {
        ll ans = floor_sum(N[i], M[i], A[i], B[i]);
        cout << ans << endl;
    }

    return 0;
}


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

int main(){
  
  int i,a;
  string s;
  cin >> a >> s;
  
  for(i=0; i < s.size(); i++){
    int b = s.at(i);
    b += a;
    if(b > 90)
      b-=26;
    
    char c = b;
    
    cout << c;
      
  }
    
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	string s;
	int content;
	int tmp_a;
	int tmp = 1000;
	cin >> s;
	content = s.length();
	rep(i, content) {
		int a = s[i] - '0';
		int b = s[i+1] - '0';
		int c = s[i+2] - '0';
		tmp_a =abs(753 -  (a * 100 + b * 10 + c));
		if (tmp_a < tmp) tmp = tmp_a;
		if (content - i == 3) break;
	}
	cout << tmp << endl;
	return 0;
}

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


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	ll res = 1000000000001;
	ll a;
	ll b;
	for (ll i = 1; i <= sqrt(n); ++i) {
		if (n % i == 0) {
			res = min(res, i + n / i);
		}
	}
	cout << res - 2ll << endl;
 	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int a = 1, count = 0;
  while(a < k) {
    a *= 2;
    count++;
    if(count == n) break;
  }
  
  cout << a + (n - count) * k << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)
using namespace std;
typedef long long ll;
const int MAXN = 5 + 100;
const int MAXV = 5 + 1000;
const ll INF = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
int N,W;
int w[MAXN], v[MAXN];
ll memo[MAXN][MAXN*MAXV];

ll dp(int i, int val) {
    if(val < 0) return INF;
    if(val == 0) return 0LL;
    if(i == N) {
        if(val == 0) {
            return 0LL;
        } else {
            return INF;
        }
    }
    ll& ans = memo[i][val];
    if(ans == -1LL) {
        ans = min(dp(1 + i, val), w[i] + dp(1 + i, val - v[i]));
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> N >> W;
    foi(i,0,N) {
        cin >> w[i] >> v[i];
    }
    memset(memo, -1, sizeof memo);
    for(int val = MAXV * MAXN; val >= 0; --val) {
        if(dp(0, val) <= W) {
            cout << val << '\n';
            return 0;
        }
    }
    assert(false);
    return 0;
}


Measured memory_bytes: 86784
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int h;
    int res = 0;
    for (int i = 0; i < N; i++) {
        cin >> h;
        if (K <= h) res += 1;
    }

    cout << res << endl;
    return 0;
}

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


vector<ll> enum_div(ll n)//nの約数を列挙
{
	std::vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
 
int main(){
    ll N;
    cin >> N;
    
    /*
    for(ll i=1;i<=sqrt(N);i++){
        if(N%i == 0)
            vec.push_back(i);
    }
    vec.push_back(N);
    */
    vector<ll> vec = enum_div(N);
    vec.push_back(N);
    ll ans = 0, l = vec.size(), m;
    /*
    for(ll i=0;i<l;i++){
        cout << vec[i] << endl;
    }
    */
    for(ll i=0;i<l;i++){
        m = vec[i];
        if(m-1 > 0){
            if(N/(m-1) == N%(m-1))
                ans += m - 1;
        }
    }

    cout << ans << endl;    

}

Measured memory_bytes: 384