akhauriyash/Code-Regression huggingface dataset:
from collections import deque
N,M = map(int,input().split())
cnct = [[] for i in range(N+1)]
for _ in range(M):
  A,B = map(int,input().split())
  cnct[A].append(B)
  cnct[B].append(A)
Q = deque()
Q.append(1)
ans = [0]*(N+1)
vstd = [0]*(N+1)
while Q:
  temp = Q.popleft()
  for a in cnct[temp]:
    if vstd[a] == 0:
      ans[a] = temp
      vstd[a] = 1
      Q.append(a)
print('Yes')
for a in ans[2:]:
  print(a)

Measured memory_bytes: 99040
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class atD {
private:
    int N, W;
    vector<int> w, v;
    vector<map<int, int>> dp;
    int solve(int id, int remW) {
        if (remW == 0 || id == N) {
            return 0;
        }
        if (dp[id].find(remW) != dp[id].end()) {
            return dp[id][remW];
        }
        if (w[id] > remW) {
            return dp[id][remW] = solve(id + 1, remW);
        } else {
            return dp[id][remW] = max(solve(id + 1, remW), v[id] + solve(id + 1, remW - w[id]));
        }
    }
public:
    void solve(istream& in, ostream& out) {
        in >> N >> W;
        w.resize(N);
        v.resize(N);
        vector<pair<int, int>> wv(N);
        for (int i = 0; i < N; ++i) {
            in >> w[i] >> v[i];
            wv[i] = {w[i], v[i]};
        }
        
        
        /*for (int i = 1; i < N; ++i) {
            w[i] -= w[0] - 1;
        }
        W -= w[0] - 1;
        w[0] = 1;
        
        cout << W << endl;
        
        if (W > 0) {
            dp.assign(N, vector<int>(W+1, -1));
    
            out << solve(0, W) << "\n";
        } else {
            out << 0 << "\n";
        }*/
        
        dp.resize(N);
        out << solve(0, W) << "\n";
        
        
        /*sort(wv.begin(), wv.end(), [](const pair<int, int>& lhs, const pair<int, int>& rhs) {
            return lhs.first < rhs.first || (lhs.first == rhs.first && lhs.first > rhs.first);
        });
        
        vector<int> res;
        int res_w = 0, res_v = 0;
        for (int i = 0; i < N; ++i) {
            if (res_w + wv[i].first <= W) {
                res.push_back(i);
                res_w += wv[i].first;
                res_v += wv[i].second;
            }
        }
        
        out << res_v << "\n";*/
    }
};


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

	atD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

const int K = 31;

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	ll n, k;
	cin >> n >> k;
	vector<pair<ll, ll> > v(n);
	rep(i,0,n) {
		cin >> v[i].F >> v[i].S;
	}
	ll L = 0;
	ll ret = 0;
	rep(i,0,n) {
		if(v[i].F == 0) ret += v[i].S;
	}
	per(i,0,K) {
		if((k & (1LL << i)) == 0) continue;
		ll l = (L | ((1LL << i) - 1));
		ll loc = 0;
		rep(i,0,n) {
			if((v[i].F & l) == v[i].F) {
				loc += v[i].S;
			}
		}
		ret = max(ret, loc);
		l = (L | (1LL << i));
		loc = 0;
		rep(i,0,n) {
			if((v[i].F & l) == v[i].F) {
				loc += v[i].S;
			}
		}
		ret = max(ret, loc);
		L = (L | (1LL << i));
	}
	cout << ret << '\n';
	return 0;
}


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

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

int a,b,ans;
vector<int> p;
map<int,int> m;

signed main() {
    p.pb(2);
    for(int i=3;i<=1000000;i+=2) {
        bool f=true;
        for(auto j : p) {
            if (sqrt(i) < j) break;
            if (i%j == 0) {
                f=false;
                break;
            }
        }
        if (f) p.pb(i);
    }
    cin >> a >> b;
    for(auto i : p) if (a%i == 0) {
        m[i]++;
        while(a%i == 0) a/=i;
    }
    for(auto i : p) if (b%i == 0) {
        m[i]++;
        while(b%i == 0) b/=i;
    }
    m[a]++;
    m[b]++;
    m[1] = 2;
    for(auto i : m) if (i.se >= 2) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,maxw;
	cin >> n >> maxw;
	long long int w[n],v[n],i,j,k;
	for(i=0;i<n;i++)
	cin >> w[i] >> v[i];
	long long int arr[n][maxw+1];
	for(i=0;i<n;i++)
	{
		for(j=0;j<=maxw;j++)
		{
			if(j==0)
			arr[i][j]=0;
			else if(i==0&&j!=0)
			{
				if(w[i]<=j)
				arr[i][j]=v[i];
				else
				arr[i][j]=0;
			}
			else 
			{
				if(w[i]>j)
				arr[i][j]=arr[i-1][j];
				else
				arr[i][j]=max(arr[i-1][j],v[i]+arr[i-1][j-w[i]]);
			}
		}
	}
	cout << arr[n-1][maxw];
	return 0;
}

Measured memory_bytes: 78336
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.nextLine();
    char c[]=s.toCharArray();
    for(int i=0;i<s.length();i++){
      if(Character.isUpperCase(c[i])){
        c[i]=Character.toLowerCase(c[i]);
      }else if(Character.isLowerCase(c[i])){
        c[i]=Character.toUpperCase(c[i]);
      }
    }
    StringBuffer sb=new StringBuffer(new String(c));
    System.out.println(sb.toString());
  }
}



Measured memory_bytes: 26156
n, y = map(int, input().split())
ans = [-1, -1, -1]
for i in range(n + 1):
    if y < 10000 * i:
        break
    m = n - i
    x = y - 10000 * i
    k = (x - 1000 * m) // 4000
    if 0 <= k <= m and 1000 * (m - k) + 5000 * k == x:
        ans = [i, k, m - k]
        break

print(' '.join(map(str, ans)))

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

using namespace std;
#define sc(x) scanf("%lld", &x);
#define pr(x) printf("%lld\n", x);
typedef long long ll;
typedef pair<ll, ll> P;

ll n, x[200007], ans, b;

int main()
{
    cin>>n;
    for(int i=0;i<n;i++) cin>>x[i];
    for(int i=0;i<n;i++){
        x[i] -= (i+1);
    }
    sort(x, x+n);
    if(n%2) b = x[n/2];
    else b = (x[n/2]+x[n/2-1])/2;
    for(int i=0;i<n;i++) ans += abs(x[i] - b);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int n; string s; cin >> n >> s; int cnt = 0; ll ans[n];
  rep(i, n){
    if(s[i]=='1') cnt++;
  }
  if(cnt==1){
    if(s[n-1]=='1'){
      rep(i, n-1) ans[i] = 2;
      ans[n-1] = 0;
    }
    else{
      rep(i, n){
        if(i==n-1) ans[i] = 2;
        else if(s[i]=='1') ans[i] = 0;
        else ans[i] = 1;
      }
    }
    rep(i, n){
      cout << ans[i] << endl;
    }
    return 0;
  }
  ll mi=0, pla=0; ll momi[n] = {}, mopla[n] = {}; ll now = 1;
  for(int i=n-1; i>=0; i--){
    momi[i] = now;
    if(s[i]=='1'){
      mi+=now; 
    }
    now*=2; now%=(cnt-1); mi%=(cnt-1);
  }
  now = 1;
  for(int i=n-1; i>=0; i--){
    mopla[i] = now;
    if(s[i]=='1'){
      pla+=now; 
    }
    now*=2; now%=(cnt+1); pla%=(cnt+1);
  }
  for(int i=n-1; i>=0; i--){
    if(s[i]=='1'){
      now = mi;
      now-=momi[i];
      if(now<0) now+=(cnt-1);
      now%=(cnt-1);
      ans[i] = 1;
      while(now>0){
        ll waru = __builtin_popcount(now);
        now%=waru;
        ans[i]++;
      }
    }
    else{
      now = pla;
      now+=mopla[i];
      now%=(cnt+1);
      ans[i] = 1;
      while(now>0){
        ll waru = __builtin_popcount(now);
        now%=waru;
        ans[i]++;
      }
    }
  }
  rep(i, n){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 8424
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] inputs = Console.ReadLine().Split(' ');
        int a = int.Parse(inputs[0]);
        int b = int.Parse(inputs[1]);

        int apb = a + b;
        int amb = a - b;
        int ab = a * b;

        if(apb >= amb)
        {
            if (apb >= ab)
            {
                Console.WriteLine(apb);
            }
            else
            {
                Console.WriteLine(ab);
            }
        }
        else
        {
            if(amb >= ab)
            {
                Console.WriteLine(amb);
            }
            else
            {
                Console.WriteLine(ab);
            }
        }


    }



}



Measured memory_bytes: 13140
#include<iostream>
    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    using namespace std;
    typedef long long ll;
    int main()
    {
        ios::sync_with_stdio(false);
        int t;
        cin >>t;
        for(int i=1;i<=t;i++)
            {
                ll a,b,c,d;
                cin >>a>>b>>c>>d;
                if(a<b){cout <<"No"<<endl;continue;}
                if(a>=b&&d>=b&&c>=b){cout <<"Yes"<<endl;continue;}
                if(d<b){cout <<"No"<<endl;continue;}
                if(c>=b)
                    {
                        if(d<b){cout <<"No"<<endl;continue;}
                        else {cout <<"Yes"<<endl;continue;}
                    }
                else 
                    {
                        ll g=__gcd(b,d);
                        if(b-g+a%g>c)
                            {cout <<"No"<<endl;continue;}
                        else {cout <<"Yes"<<endl;continue;}                        
                    }
            }
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    size_t A;
    string B;    
    cin >> A >> B;

    int shift =1;
    int iB = 0;
    char temp[10];
    const char *cB = B.c_str();

    bool flag = false;
    int j = 0;
    for(size_t i = 0; i < B.size(); ++i)    
    {
        if(cB[i] == '.')
        {
            flag = true;    
        }
        else
        {
            temp[j++] = cB[i];
            if(flag)
            {
                shift *= 10;    
            }
        }
    }
    temp[j] = '\0';
    size_t BB = static_cast<size_t>(atoi(temp));

    cout << (A * BB / shift) << endl;

    return 0;    
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b;
	cin >> a>>b;
	if (a + b >= 10)
		cout << "error" << endl;
	else
		cout << a + b << endl;

} 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int x,y;
    cin >> x >> y;
    vector<int> v;
    if(x <= y)
    {
        v.push_back(y - x);
    }
    if(-x <= y)
    {
        v.push_back(y + x + 1);
    }
    if(x <= -y)
    {
        v.push_back(-y - x + 1);
    }
    if(-x <= -y)
    {
        v.push_back(-y + x + 2);
    }
    sort(v.begin(),v.end());
    cout << v.at(0) << "\n";
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N; cin >> N;
    using P = tuple<string,int,int>;
    vector<P> ans(N);
    rep(i,N){
        string s;
        int p;
        cin >> s >> p;
        p *= -1;
        ans[i] = make_tuple(s,p,i);
    }

    sort(all(ans));
    for(int i=0;i<N;i++){
        string s;
        int p,x;
        tie(s,p,x) = ans[i];
        cout << x+1 << endl;
    }
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String s = sc.next();
        String t = sc.next();
        if (s.equals(t.substring(0, t.length() - 1))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 32532
import math

n=int(input())
arr=list(map(int,input().split(" ")))

cap= 1000
stocks=0
for i in range(n-1):
    if arr[i]<arr[i+1]:
        k= math.floor(cap/arr[i])
        stocks+=k
        cap-=k*arr[i]
    elif arr[i]>arr[i+1]:
        cap += stocks * arr[i]
        stocks =0
cap+=stocks*arr[-1]
print(cap)



Measured memory_bytes: 9196
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/STACK: 20000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec vector
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){IOS;
    ll n;cin>>n;
    ll x,y;cin>>x>>y;x--;y--;
    map<ll,ll> dist_cant;
    for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
        ll s = j-i;
        ll b = abs(i-x)+1+abs(j-y);
        dist_cant[min(s,b)]++;
    }
    for(int d=1;d<=n-1;d++) cout<<dist_cant[d]<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int a,b,c,d;
           cin>>a>>b>>c>>d;
           int ans=0;
           rep(i,0,101){
             if(a<=i&&i<b&&c<=i&&i<d)ans++;
           }
           cout<<ans<<endl;
}

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

using namespace std;

int main() {
    int n, m; cin >> n;
    vector<string> s(n);
    vector<string> t(m);
    map<string, int> st;
    set<string> d1;
    set<string> d2;

    for(int i = 0; i < n; i++) {
        std::cin >> s[i];
        d1.insert(s[i]);
    }

    cin >> m;
    for(int i = 0; i < m; i++) {
        std::cin >> t[i];
        d2.insert(t[i]);
    }

    for (auto itr = d1.begin(); itr != d1.end(); itr++)
    {
        st.insert(make_pair(*itr, 0));
    }

    for (auto itr = d2.begin(); itr != d2.end(); itr++)
    {
        if(d1.find(*itr) != d1.end()) {
          st.insert(make_pair(*itr, 0));
        }
    }

    for (int i = 0; i < n; i++)
    {
        st[s[i]]++;
    }

    for (int i = 0; i < m; i++)
    {
        st[t[i]]--;
    }

    int max = 0;
    for(auto itr = st.begin(); itr != st.end(); itr++) {
        max = std::max(max, itr->second);
    }

    std::cout << max << std::endl;
}






Measured memory_bytes: 4276
day = input()
if day == "SUN":
    i = 7
elif day == "MON":
    i = 6
elif day == "TUE":
    i = 5
elif day == "WED":
    i = 4
elif day == "THU":
    i = 3
elif day == "FRI":
    i = 2
else:
    i = 1
print(i)

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define inf (1000000007)
#define nil -1
int main() {
	int a, b;
	cin >> a >> b;
	cout<<max(a-b,max(a+b,a*b))<<endl;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    AB = [list(map(int, input().split())) for _ in range(N)]
    AB = sorted(AB, key=lambda ab: (ab[1]))
    t = 0
    for ab in AB:
        t += ab[0]
        if ab[1] < t:
            print('No')
            return
    print('Yes')

main()


Measured memory_bytes: 55176
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll n;
	cin >> n;
	int len = 0;
	ll cur = 1LL;
	ll tot = 0LL;
	while(n >= tot){
		cur *= 26;
		tot += cur;
		len++;
	}
	tot -= cur;
	ll cur1 = cur / 26;
	cur = tot;
	rep(i, len){
		char nw = 'a';
		while(n > cur){
			cur += cur1;	
			nw++;
		}
		cur -= cur1, nw--;
		cur1 /= 26;
		if(nw >= 'a' && nw <= 'z') cout << nw;
	}
	cout << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

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

const ll INF=1e18;
const int MOD=1e9+7;

ll mod_pow(ll x, ll n){ //べき乗
    ll ans=1;
    x%=MOD;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1;
    }
    return ans%MOD;
}

int main(){
    int N,K; cin >> N >> K;
    ll a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a,a+N);
    int l=0; int r=N-1;
    ll ans=1;
    if(K%2==1){
        if(a[N-1]<0){
            for(int i=N-1;i>N-1-K;i--){
                ans*=a[i];
                ans%=MOD;
            }
            cout << (ans+MOD)%MOD << endl;
            return 0;
        }else{
            r--; K--;
        }
    }
    ll cl=0; ll cr=0;
    while(K){
        cl=a[l]*a[l+1];
        cr=a[r]*a[r-1];
        if(cl>cr){
            l+=2;
        }else{
            r-=2;
        }
        K-=2;
    }
    for(int i=0;i<l;i++){
        ans*=a[i];
        ans%=MOD;
    }
    for(int i=N-1;i>r;i--){
        ans*=a[i];
        ans%=MOD;
    }
    cout << (ans+MOD)%MOD << endl;
}

Measured memory_bytes: 5140
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""

"""
#solution:
#潜 影 蛇 手 ! !
N=int(input())
T,A=pin()
H=[i for i in pin()]
c=(T-A)/0.006
HH=[abs(h-c) for h in H]
#print(c,HH)
print(HH.index(min(HH))+1)

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var a = new int[N + 1];
		for (var i = 0; i <= N; i++) a[N - i] = F;
		var g = a[N];
		if (g < 0) g = -g;
		for (var i = 0; i <= N; i++) g = GCD(g, a[i]);
		for (var i = 0; i <= N; i++) a[i] /= g;
		var ps = GetPrimes(10010);
		var ok = new SortedSet<long>(Factorize(g, ps).Keys);
		{
			var b = new long[2];
			b[0] = a[0] % 2;
			for (var i = 1; i <= N; i++) b[1] = (b[1] + a[i]) % 2;
			if (b.All(x => x == 0)) ok.Add(2);
		}
		foreach (var p in ps)
		{
			if (ok.Contains(p)) continue;
			if (p > N + 10) continue;
			if (a[0] % p != 0) continue;
			if (p == 2) continue;
			// x^(p-1)==1 => p-2 次
			var b = new long[p - 1];
			for (var i = 0; i <= N; i++)
			{
				var k = i % (p - 1);
				b[k] = (b[k] + a[i]) % p;
			}
			if (b.All(x => x == 0)) ok.Add(p);
		}
		foreach (var p in ok) WriteLine(p);
	}
	public static int GCD(int n, int m)
	{
		if (n < 0) n = -n;
		if (m < 0) m = -m;
		while (m > 0)
		{
			var c = n % m;
			n = m;
			m = c;
		}
		return n;
	}
	public static Dictionary<long, int> Factorize(long n, List<int> primes)
	{
		var d = new Dictionary<long, int>();
		for (var j = 0; j < primes.Count; j++)
		{
			var i = primes[j];
			if (i * i > n) break;
			if (n % i == 0)
			{
				d.Add(i, 0);
				while (n % i == 0) { n /= i; d[i]++; }
			}
		}
		if (n > 1) d.Add(n, 1);
		return d;
	}
	public static List<int> GetPrimes(int n)
	{
		if (n < 3) n = 3;
		var m = (n - 1) >> 1;
		var primes = new List<int>((int)(n / Math.Log(n)));
		primes.Add(2);
		var composites = new bool[m];
		composites[0] = false;
		for (var p = 0; p < m; p++)
		{
			if (!composites[p])
			{
				var pnum = 2 * p + 3;
				primes.Add(pnum);
				for (var k = 3 * p + 3; k < m; k += pnum) composites[k] = true;
			}
		}
		return primes;
	}
}


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

# ぜんぶ
a = 10 ** n
# 0が存在しない
b = 9 ** n
# 9が存在しない
c = 9 ** n
# 0も9も存在しない
d = 8 ** n

ans = a - b - c + d

print(ans % 1000000007)


Measured memory_bytes: 11720
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#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 FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BOrdinaryNumber {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int n;
        cin >> n;
        vector<int> p(n);
        REP(i, n) {
            cin >> p[i];
        }

        int res = 0;
        FOR(i, 1, n - 2) {
            int mi = min({p[i-1], p[i], p[i+1]});
            int ma = max({p[i-1], p[i], p[i+1]});
            if (p[i] != mi && p[i] != ma) {
                res++;
            }
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BOrdinaryNumber solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
	char x,y;
	cin>>x>>y;
	if(x<y) cout<<"<";
	else if(x==y) cout<<"=";
	else cout<<">";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
while True:
    N, A, B, C, X = map(int, raw_input().split())

    if N == 0:
        break

    Y = map(int, raw_input().split())
    cnt = -1
    i = 0

    while i < len(Y):
        if Y[i] == X:
            i += 1
        if cnt == 10000:
            cnt = -1
            break
        X = (A * X + B) % C
        cnt += 1

    print cnt

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll MOD = 1000000007;

ll dp[2010][2010];

ll f1(ll in, ll i, ll n, vector<pair<ll, ll>> &a) {
    if (in == a.size())
        return 0;

    if (dp[in][i] != -1)
        return dp[in][i];
    int end = n - 1 - (in - i);

    ll ans1 = (a[in].first * (a[in].second - i)) + f1(in + 1, i + 1, n, a);
    ll ans2 = (a[in].first * (end - a[in].second)) + f1(in + 1, i, n, a);

    return dp[in][i] = max(ans1, ans2);
}

void solve() {
    ll n;
    cin >> n;
    vector<pair<ll, ll>> a;

    for (ll i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        a.push_back(make_pair(x, i));
    }

    memset(dp, 0, sizeof(dp));
    sort(a.rbegin(), a.rend());

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= i; ++j) {
            ll val = a[i].first;
            ll pos = a[i].second;
            int end = n - 1 - (i - j);  //j= left end=right
            ll d1 = val * abs(pos - j);
            ll d2 = val * abs(pos - end);
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + d1);
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + d2);
        }
    }

    //ll ans = f1(0, 0, n, a);
    ll ans = 0;
    for (int i = 0; i <= n; ++i) {
        ans = max(ans, dp[n][i]);
    }
    cout << ans << "\n";
}

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

    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin >> t;

    // while (t--)
    solve();

    return 0;
}


Measured memory_bytes: 35252
// use std::cmp;
use std::io::Read;

fn main() {
    let mut buff = String::new();
    std::io::stdin().read_to_string(&mut buff).unwrap();
    let mut iter = buff.split_whitespace();

    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let k: i32 = iter.next().unwrap().parse().unwrap();

    let mut v: Vec<i32> = Vec::new();

    for i in a..(a + k) {
        if i <= b - k || i <= b {
            v.push(i)
        }
    }
    for i in (b - k + 1)..(b + 1) {
        if v.last().unwrap() < &i {
            v.push(i)
        }
    }

    for i in v {
        println!("{}", i)
    }
}

Measured memory_bytes: 4352
#include<stdio.h>
#define N 100
const int INF = 1<<29;
int min(int x,int y){
  if(x>=y){
    return y;
  }
  else {
    return x;
  }
}
  int main()
{
	int n;
  int i,j,l,k;
	int left[N], right[N];
	int m[N][N];
scanf("%d",&n);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			m[i][j] = INF;
    }
  }

	for(int i = 0; i < n; i++){
		scanf("%d%d",left+i,right+i);
		m[i][i] = 0;
	}

	for(int l = 1; l < n; l++){
		for(int i = 0; i < n - l; i++){
			int j = i + l;
			for(int k = i; k < j; k++){
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + left[i] * right[k] * right[j]);
			}
		}
	}

	printf("%d\n", m[0][n - 1]);
  return 0;
}



Measured memory_bytes: 2112
#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() {
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  ll ans = LLONG_MAX;
  for(ll i = 0; x>=0 || y>=0; i++) {
    if(x<0 && y<0) ans = min(ans, 2*i*c);
    else if(x<0) ans = min(ans,b*y+2*i*c);
    else if(y<0) ans = min(ans,a*x+2*i*c);
    else ans = min(ans,a*x+b*y+2*i*c);
    x--;
    y--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#pragma warning(disable : 4996)

#define MAX_N 100000

struct Node {
	int id;
	int parentId;
	int depth;
	std::vector<int> childIds;
	Node() : id(-1), parentId(-1), depth(-1) {}
};

Node nodes[MAX_N];

void AddChild(Node *parent, Node *child) {
	child->parentId = parent->id;
	parent->childIds.push_back(child->id);
}
Node *GetNode(int index) {
	return &nodes[index];
}
void CalcDepthR(Node *n, int depth) {
	n->depth = depth;
	for (int i = 0; i < n->childIds.size(); ++i) {
		Node *c = GetNode(n->childIds[i]);
		CalcDepthR(c, depth + 1);
	}
}
void CalcDepth(int n) {
	Node *root = NULL;
	for (int i = 0; i < n; ++i) {
		if (nodes[i].parentId == -1) {
			root = &nodes[i];
		}
	}
	CalcDepthR(root, 0);
}
std::vector<std::string> Split(std::string org) {
	std::vector<std::string> ret;
	int index = 0;
	char tmp[1024];
	int ti = 0;
	while (true) {
		if (org[index] == ' ' || org[index] == '\n') {
			tmp[ti] = '\0';
			if(ti > 0) ret.push_back(tmp);
			ti = 0;
		} else 
		if (org[index] == '\0') {
			tmp[ti] = '\0';
			if (ti > 0) ret.push_back(tmp);
			ti = 0;
			break;
		}
		else {
			tmp[ti++] = org[index];
		}
		++index;

	}
	return ret;
}

int GetNum() {
	char tmp[1024];
	int ti = 0;
	while (true) {
		int c = fgetc(stdin);
		if (c == ' ') {
			break;
		}
		if (c == '\n') {
			break;
		}
		if (c == '\0') {
			return -1;
		}
		tmp[ti++] = (char)c;
	}
	tmp[ti++] = '\0';
	return atoi(tmp);
}

int main(void) {
	int n;
	scanf("%d\n", &n);
	for (int i = 0; i < n; ++i) {
		Node *node = GetNode(i);
		node->id = i;
	}
	char line[1024];
	for (int i = 0; i < n; ++i) {
		int id = GetNum();
		int d = GetNum();

		Node *p = GetNode(id);
		for(int j = 0; j < d; ++j) {
			int cid = GetNum();
			Node *c = GetNode(cid);
			AddChild(p, c);
		}
	}
	CalcDepth(n);
	for (int i = 0; i < n; ++i) {
		Node *n = GetNode(i);
		const char *type = "internal node";
		if (n->parentId == -1) {
			type = "root";
		}
		else if (n->childIds.size() == 0) {
			type = "leaf";
		}
		int depth = n->depth;
		printf("node %d: parent = %d, depth = %d, %s, [", n->id, n->parentId, depth, type);
		for (int j = 0; j < n->childIds.size(); ++j) {
			if (j != 0) {
				printf(", ");
			}
			printf("%d", n->childIds[j]);
		}
		printf("]\n");
	}
	return 0;
}


Measured memory_bytes: 7496
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B;
  cin>>N>>A>>B;
  int ans=0;
  for(int j=1;j<=N;j++){
    int k=j;
  int sum=0;
  for(int i=1;i<=5;i++){
    sum += k%10;
    k /= 10;
  }
  if(A<=sum&&sum<=B){
    ans+=j;
  }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for _ in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)
case_out = lambda i, o: out("Case #{}: {}".format(i, o))


if __name__ == "__main__":
    n = int_in()
    ac = 0
    wa = 0
    tle = 0
    re = 0
    for _ in range(n):
        s = str_in()
        if "AC" == s:
            ac += 1
        elif "WA" == s:
            wa += 1
        elif "TLE" == s:
            tle += 1
        elif "RE" == s:
            re += 1
    out("AC x {}".format(ac))
    out("WA x {}".format(wa))
    out("TLE x {}".format(tle))
    out("RE x {}".format(re))

Measured memory_bytes: 67952
#include <stdio.h>

int main(){
  int i,n,r=0;
  char c[200005];
  scanf("%d",&n);
  scanf("%s",&c);
  for(i=0;i<n;i++){
    if(c[i]=='R') r++;
  }
  i=0;
  for(r--;r>=0;r--){
    if(c[r]=='W') i++;
  }
  printf("%d",i);
  return 0;
}

Measured memory_bytes: 1904
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
typedef pair<int,pair<int, int>> P1;

using Graph = vector<vector<int>>;

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

  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  cout << X * min(N, K) + Y * max((int)0, N-K) << endl;

}

Measured memory_bytes: 256
import sys
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if 10000*(i)+5000*(j)+1000*(n-i-j)==y:
            print(i,j,n-i-j)
            sys.exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
// インクルード
#include <iostream>
#include <string>

// 名前空間省略
using namespace std;

// メイン関数
int main()
{
    // 標準入出力　高速化
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

	string s,t;

	cin >> s;
	cin >> t;

	bool flag = false;

	if(s.length()+1 != t.length()){
		cout << "No\n";
		return 0;
	}

	for(int i=0;i<s.length();i++){
		if(s[i] != t[i]){
			cout << "No\n";
			return 0;
		}
	}

	cout << "Yes\n";
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main() {
	int h, w;
	cin >> h >> w;
	vs board(h);
	vvi data(h, vi(w, 0));
	rep(i, h) {
		cin >> board.at(i);
	}
	vi dx = { -1,0,1,-1,1,-1,0,1 };
	vi dy = { -1,-1,-1,0,0,1,1,1 };
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (board.at(i).at(j) == '#') {
				data.at(i).at(j) = -99;
				for (int k = 0; k < 8; k++) {
					if (!(i + dy.at(k) < 0 || i + dy.at(k) > h - 1 || j + dx.at(k) < 0 || j + dx.at(k) > w - 1)) {
						data.at(i + dy.at(k)).at(j + dx.at(k))++;
					}
				}
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			if (data.at(i).at(j) < 0) {
				cout << "#";
			}
			else {
				cout << data.at(i).at(j);
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void) {

	// 1_4-A  A/B Problem

	int a,b;
	int d,r;
	double f;
	scanf("%d %d",&a,&b);
	
	d = a/b;
	r = a%b;
	f = (double)(a)/(double)(b);
	
	printf("%d %d %.5lf",d,r,f);
        return 0;
}

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

int main(){
  int num;
  cin>>num;
  int pr=num;
  int dig=0;
  while(num>0){
  dig+=(num%10);
  num/=10;
  }
  if(pr%dig==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int n = scanner.nextInt();
        int max = 0;
        int sum = 0;

        for(int i=0;i<n;i++) {
        	int tmp = scanner.nextInt();
        	if(max < tmp) {
        		max = tmp;
        	}
        	sum += tmp;
        }
        sum -= max;

        if(max < sum) {
        	System.out.println("Yes");
        }else {
        	System.out.println("No");
        }


    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}




Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size();
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod =1e9+7;
const int N = (int)2e5 + 5;


void solve(){
	int n;
	cin>>n;
	map<string,int>m;
	while(n--){
		string s;
		cin>>s;
		sort(all(s));
		m[s]++;
	}
	vi v;
	for(auto i : m){
		if(i.S>1){
			v.pb(i.S);
		}
	}
	ll ans=0;
	for(int i=0;i<(int)v.size();i++){
		ll sum=0;
		v[i]--;
		while(v[i]!=0){
			sum+=v[i];
			--v[i];
		}
		ans+=sum;
	}
	cout<<ans;



}
int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

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

using namespace std;

const int max_n = 200022, inf = 1000111222;

int n, d[max_n];
long long sum, tot, c[max_n];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> d[i] >> c[i];
        sum += d[i] * c[i];
        tot += c[i];
    }
    long long ans = tot - 1 + (sum - 1) / 9;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define MOD 1000000007
#define ar array
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);

int32_t main() {
	fast_io;

	// int t; cin >> t;
	// while (t--) {

	// }
	int n, W; cin >> n >> W;
	int values_sum = 0;
	vector<int> weights(n), values(n);
	for (int i = 0; i < n; i++) {
		cin >> weights[i] >> values[i];
		values_sum += values[i];
	}
	vector<int> dp(values_sum + 1, INT_MAX); // dp[i] = min weight of items upto 'item' having value i.
	dp[0] = 0;
	for (int item = 0; item < n; item++) {
		for (int value = values_sum - values[item]; value >= 0; value--) {
			dp[value + values[item]] = min(dp[value + values[item]], dp[value] + weights[item]); 
		}
	}
	int max_val = 0;
	for (int val = 0; val <= values_sum; val++) {
		if (dp[val] <= W) max_val = val;
	}
	cout << max_val << endl;

	return 0;
}

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

using namespace std;
#define ll long long
#define ld long double

ll binPow(ll a, ll b) {
    ll ans = 1;
    while(b > 0) {
        if(b & 1) ans *= a;
        a *= a;
        b >>= 1;
    }
    return ans;
}

ll binPowMod(ll a, ll b, ll m) {
    ll ans = 1;
    a %= m;
    while(b > 0) {
        if(b & 1) ans *= a % m;
        a *= a % m;
        b >>= 1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    double h, a;
    cin >> h >> a;
    cout << (int)ceil(h / a);
    return 0;
}


Measured memory_bytes: 256
h,w,k=map(int,input().split())
c=[list(input()) for _ in range(h)]
ans=0
 
for a in range(2**h):
    sa="0"+str(h)+"b"
    la=list(format(a,sa))
    for b in range(2**w):
        sb = "0" + str(w) + "b"
        lb = list(format(b, sb))
        cnt=0
        for i in range(h):
            for j in range(w):
                if la[i]!="1" and lb[j]!="1" and c[i][j]=="#":
                    cnt+=1
        if cnt==k:
            ans+=1
print(ans)

Measured memory_bytes: 9204
#include <iostream>
#include <vector>
#include <set>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    ll n, m, t;
    cin >> n >> m >> t;
    vector< pair<int, int> > P(t);
    set< pair<int, int> > S;
    for (int i = 0; i < t; ++i)
    {
        int x, y;
        cin >> x >> y;
        P[i] = make_pair(x, y);
        S.insert(make_pair(x, y));
    }
    set< pair<int, int> > C;
    for (int i = 0; i < t; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            for (int k = 0; k < 3; ++k)
            {
                pair<int, int> r = make_pair(P[i].first - j, P[i].second - k);
                if (r.first >= 1 && r.first <= n &&
                    r.second >= 1 && r.second <= m &&
                    r.first + 2 >= 1 && r.first + 2 <= n &&
                    r.second + 2 >= 1 && r.second + 2 <= m)
                        C.insert(r);
            }
        }
    }
    vector<ll> odp(10, 0);
    for (set< pair<int, int> >::iterator it = C.begin(); it != C.end(); ++it)
    {
        pair<int, int> pkt = *it;
        int il = 0;
        for (int i = 0; i < 3; ++i)
            for (int j = 0; j < 3; ++j)
                if (S.find(make_pair(pkt.first + i, pkt.second + j)) != S.end())
                    ++il;
        ++odp[il];
    }
    int il = 0;
    for (int i = 1; i < 10; ++i)
        il += odp[i];
    odp[0] = (n - 2) * (m - 2) - il;
    for (int i = 0; i < 10; ++i)
        cout << odp[i] << endl;
    return 0;
}


Measured memory_bytes: 47872
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
int main ()
{
	int N;
	while (cin>>N)
	{
		int sum=0;
		for(int i=1;i<=N;i++)
		{
			sum=sum+i;
		}
		cout<<sum<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256