akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 2e5 + 5;
int n;
LL k;
int a[maxn], f[maxn];
bool check(LL mid)
{
    LL cnt = 0;
    for (int i = 1; i <= n; i++) {
        LL temp = mid / f[i];
        if (a[i] >= temp)
            cnt += LL(a[i]) - temp;
    }
    if (cnt <= k)
        return true;
    return false;
}
int main()
{
    scanf("%d%lld", &n, &k);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
        scanf("%d", &f[i]);
    sort(a + 1, a + 1 + n);
    sort(f + 1, f + 1 + n, [](const int& a, const int& b) {
        return a > b;
    });
    // for (int i = 1; i <= n; i++)
    //     cout << a[i] << ' ';
    // cout << '\n';
    // for (int i = 1; i <= n; i++)
    //     cout << f[i] << ' ';
    // cout << '\n';
    LL Max = 0;
    for (int i = 1; i <= n; i++) {
        Max = max(Max, LL(a[i]) * f[i]);
    }
    LL left = 0, right = Max, mid, ans;
    while (left <= right) {
        mid = (left + right) >> 1;
        if (check(mid))
            ans = mid,
            right = mid - 1;
        else
            left = mid + 1;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i32 = read();
    let s: String = read();
    println!("{}",
        if a < 3200 {
            "red".to_owned()
        } else {
            s
        }
    );
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(){
int N=0;
scanf("%d",&N);
if(N/100==7){
    printf("Yes\n");
}else if((N%100)/10==7){
    printf("Yes\n");
}else if(((N%100)%10)==7){
    printf("Yes\n");
}else{
    printf("No\n");
}

return 0;

}

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

using namespace std;
#define DIM 109
#define INF -1000000000000

long long a[DIM][100009],m1[DIM],c[DIM];
long long i,j,k,l,n,m,maxi;
int main()
{
    cin>>n>>m;
    for(i=1;i<=n;i++){
        cin>>m1[i]>>c[i];
    }

    for(i=0;i<=n;i++){
        for(j=0;j<=100000;j++)a[i][j]=-INF;
    }

    a[0][0]=0;
    for(i=1;i<=n;i++){
        for(j=0;j<=100000;j++){
            a[i][j]=a[i-1][j];
            if(j>=c[i])a[i][j]=min(a[i][j],m1[i]+a[i-1][j-c[i]]);
           // if(j==90 || j==0 || j==60 || j==30 || j==50 || j==110 || j==140 || j==80)cout<<i<<' '<<j<<' '<<a[i][j]<<endl;
        }
    }

    for(i=1;i<=n;i++){
        for(j=0;j<=100000;j++){
            if(a[i][j]<=m)maxi=max(maxi,j);
        }
    }
    cout<<maxi<<endl;
    return 0;
}


Measured memory_bytes: 80128
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new W(); }
class W
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public W()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int K, N;
	int[] x, y;
	void Solve()
	{
		var I = G();
		N = I[0];
		K = I[1];
		x = new int[N];
		y = new int[N];
		for (int i = 0; i < N; i++)
		{
			I = G();
			x[i] = I[0];
			y[i] = I[1];
		}
		var ys = new SortedSet<int>(y).ToList();
		var Y = ys.Count;
		var min = long.MaxValue;
		for (var a = 0; a < Y; a++)
			for (var b = a + 1; b < Y; b++)
			{
				long d = ys[b] - ys[a];
				var t = new List<int>();
				for (var i = 0; i < N; i++) if (ys[a] <= y[i] && y[i] <= ys[b]) t.Add(x[i]);
				t.Sort();
				for (var c = 0; c + K <= t.Count; c++)
				{
					var s = d * (t[c + K - 1] - t[c]);
					if (s < min) min = s;
				}
			}
		WriteLine(min);
	}
}


Measured memory_bytes: 13652
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
/*        
    double a,b; cin >> a >> b;

    int ans = ceil (a / 0.08);

    if(ans/10 != b){
        ans = -1;
        cout << ans << ln;        
        return 0;
    }
    
    int mn_tmp = ans - 1;
    
    for(;;){
        if(floor(mn_tmp * 0.08) != a  || floor(mn_tmp * 0.1) != b) break;
        ans = mn_tmp;
        mn_tmp--;
    }
*/    
    int a,b; cin >> a >> b;

    rep(x, 10000){
        int y = x * 0.08;
        int z = x * 0.1;
        if(a == y and b == z){
            cout << x << ln;
            return 0;
        }
    }

    cout << -1 << ln;
    return 0;
}

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

int main(){
	int a,b,input,max=0,level=1;
	int arr[2010]={0};
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>input;
		max+=input;
		for(int i=1;i<=max-input;i++){
			if(arr[i]!=0&&arr[i]!=level){
				if(arr[i+input]==0)arr[i+input]=level;
			}
		}
		arr[input]=level;
		level++;
	}
	cin>>b;
	for(int i=0;i<b;i++){
		cin>>input;
		if(arr[input]==0)cout<<"no"<<endl;
		else cout<<"yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	string s; cin >> s;

	s[5] = ' ';
	s[13] = ' ';

	cout << s << endl;

	return 0;

}


Measured memory_bytes: 256
### subroutines

# <genom> = <term> | <term> <genom>
# <term> = <elm>+ | <num> <elm> | <num> '(' <genom> ')'
# <elm> = 'A'..'Z'
# <num> = ('0'..'9')+

def genom(gnm, i)
  glen = 0
  gch = nil

  while ! gnm[$pos].nil? && gnm[$pos] != ')'
    tlen, tch = term(gnm, i)
    gch = tch if gch.nil? && ! tch.nil?
    i -= tlen if gch.nil?
    glen += tlen
  end

  [glen, gch]
end

def term(gnm, i)
  if /[A-Z]/ =~ gnm[$pos]
    len = parse_alph(gnm)
    tch = (i < len) ? gnm[$pos + i] : nil
    $pos += len
    return [len, tch]
  end

  len = parse_num(gnm)
  num = gnm[$pos, len].to_i
  $pos += len

  if gnm[$pos] == '('
    $pos += 1
    pos0 = $pos
    glen, gch = genom(gnm, i)
    $pos += 1
    gnlen = glen * num
    return [gnlen, gch] if ! gch.nil? || i >= gnlen

    $pos = pos0
    i0 = i % glen
    glen, gch = genom(gnm, i0)
    $pos += 1
    return [gnlen, gch]
  else
    tch = (i < num) ? gnm[$pos] : nil
    $pos += 1
    return [num, tch]
  end
end

def parse_alph(gnm)
  len = 0
  while /[A-Z]/ =~ gnm[$pos + len]
    len += 1
  end
  len
end

def parse_num(gnm)
  len = 0
  while /[0-9]/ =~ gnm[$pos + len]
    len += 1
  end
  len
end

### main

loop do
  gnm, ist = gets.strip.split
  break if gnm == '0' && ist == '0'

  i = ist.to_i
  #p [gnm, i]

  $pos = 0
  num, ch = genom(gnm, i)
  #p [num, ch]

  puts (ch.nil? ? 0 : ch)
end

Measured memory_bytes: 6132
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

ll gcd(ll a,ll b){
    ll temp;
    if(a<0) a=-a;
    while(b!=0){
        temp=b;
        b=a%b;
        a=temp;
    }
    return a;
}

ll proinverse(ll x,ll m){
    ll res=1,M=m-2;
    while(M>0){
        if(M&1) res=res*x%m;
        x=x*x%m;
        M>>=1;
    }
    return res;
}

int main(){
    ll n,ans=1; cin>>n;
    vector<pair<ll,ll>> w(n);
    vector<ll> mul(n+1,0);
    map<pair<ll,ll>,ll> m;
    ll l0=0,r0=0,cnt0=0;
    rep(i,n){
        ll a,b; cin>>a>>b;
        if(b<0){
            a=-a; b=-b;
        }
        if(a==0 && b==0) cnt0++;
        else if(a==0) l0++;
        else if(b==0) r0++;
        else{
            ll g=gcd(a,b);
            a/=g; b/=g;
            if(!(m.count(mk(a,b)))) m[mk(a,b)]=0;
            m[mk(a,b)]++;
            if(a<0){
                if(!(m.count(mk(b,-a)))) m[mk(b,-a)]=0;
            }
            else{
                if(!(m.count(mk(-b,a)))) m[mk(-b,a)]=0;
            }
        }
    }
    ll c=1;
    rep(i,n+1){
        mul[i]=c;
        c=(c*2)%MOD;
    }
    ll a,b;
    for(auto p:m){
        tie(a,b)=p.first;
        if(a<0) continue;
        ll u=mul[m[mk(a,b)]]+mul[m[mk(-b,a)]]-1;
        u=(u+MOD)%MOD;
        ans=(ans*u)%MOD;
    }
    ans=(ans*(mul[l0]+mul[r0]-1))%MOD;
    cout<<(ans+MOD+cnt0-1)%MOD<<endl;
}

Measured memory_bytes: 32756
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int N, K;

int main() {
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    
    vector<int> cost(N);
    for (int i = 1; i < N; i++) {
        int c = 1e9;
        for (int j = 1; j <= K && i >= j; j++) {
            c = min(c, cost[i - j] + abs(h[i] - h[i - j]));
        }
        cost[i] = c;
    }
    cout << cost[N - 1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define lli long long int

bool test(lli r, string &s){
    if(r%2==0){
        r = r/2;
        for(int i=0;i<r;++i){
            if(s[i]!=s[i+r])
                return false;
        }
        return true;
    }else{
        return false;
    }
}

int main() {
    lli r;
    cin>>r;
    string s;
    cin>>s;
    if(test(r,s)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
	return 0;
}


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


int main() {
    int a,b;
    cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 110
int read()
{
    int x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
int n,a,b,p[N];
int main()
{
    n=read(),a=read(),b=read();
    for (int i=1;i<=n;i++) p[i]=read();
    int ans=0,x=0,y=0,z=0;
    for (int i=1;i<=n;i++)
    {
        if (p[i]<=a) x++;
        if (p[i]>a&&p[i]<=b) y++;
        if (p[i]>b) z++;
    }
    cout<<min(x,min(y,z));
}

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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define pi acos(-1.0)
#define eps 1e-8
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;


int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    int n, m, x ;
    bool pos=true ;
    cin>> n >> m ;
    char c ;
    vi cnt(26, 0) ;
    for(int i=1 ; i<=n ; i++)
      for(int j=1 ; j<=m ; j++)
        {
          cin>> c ;
          cnt[c-'a']++ ;
        }
    int one=0, four=0, two=0 ;
    for(int i=0 ; i<26 ; i++)
      if(cnt[i])
        {
          x=cnt[i] ;
          if(x>=4)
            {
              four+=x/4 ;
              x=x%4 ;
            }
          if(x==3) one++, two++ ;
          else if(x==2) two++ ;
          else if(x==1) one++ ;
        }
    if(n%2 && m%2)
      {
        if(one>1) pos=false ;
        if(two>(n/2)+(m/2)) pos=false ;
      }
    else if(n%2==0 && m%2==0)
      {
        if(two || one) pos=false ;
      }
    else if(n%2==0 && m%2)
      {
        if(one) pos=false ;
        if(two>n/2) pos=false ;
      }
    else
      {
        if(one) pos=false ;
        if(two>m/2) pos=false ;
      }
    if(4*four+one+2*two!=n*m) pos=false ;
    if(pos) cout<< "Yes" ;
    else cout<< "No" ;
  }


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

Measured memory_bytes: 4416
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
ss = []
tt = []
for _ in range(N):
    s,t = input().split()
    ss.append(s)
    tt.append(int(t))

x = input()
i = ss.index(x)

print(sum(tt[i+1:]))


Measured memory_bytes: 4452
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define SZ(x) ((int)(x).size())
#define MSB(x) (31 - __builtin_clz(x))
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 19, maxS = 513, mod = 998244353;
const long long INF = 1000000000000000000ll;

template <class T1, class T2> inline void addMod(T1& a, T2 b)	{   a = (a + b) % mod;  }
template <class T1, class T2> inline void multMod(T1& a, T2 b)	{   a = a * b % mod;    }

long long pows[maxN], T[3][maxS];
vector <int> graph[3][maxN];
int mex[maxN], vis[maxN];
 
int main()
{
	int n;
	scanf ("%d", &n);
	pows[1] = INF % mod;
	FOR(i, 2, n+1)
		pows[i] = pows[i-1] * pows[1] % mod;
	FOR(s, 0, 3)
	{
		vector <int>* G = graph[s];
		int m;
		scanf ("%d", &m);
		while (m--)
		{
			int a, b;
			scanf ("%d%d", &a, &b);
			if (a > b)
				swap(a, b);
			G[a].pb(b);
		}
		
		FORD(v, n, 0)
		{
			for (int u : G[v])
				vis[mex[u]] = v;
			for (mex[v] = 0; vis[mex[v]] == v; mex[v]++) ;
			addMod(T[s][mex[v]], pows[v]);
		}
		
		fill(vis, vis+n+1, 0);
	}
	
	long long res = 0;
	FOR(a, 0, maxS) FOR(b, 0, maxS) FOR(c, 0, maxS) if ((a^b^c) == 0)
	{
		long long tak = T[0][a];
		multMod(tak, T[1][b]);
		multMod(tak, T[2][c]);
		addMod(res, tak);
	}
	
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 46976
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,S,ma = 0,mi = 0,ans = 1000000;
  cin >> N >> S;
  vector<int> a(N);
  for(int i = 0;i < N;i++)cin >> a[i];
  int sum = a[0];
  while(1){
    if(sum < S){
      ma++;
      if(ma == N)break;
      sum += a[ma];
    }
    else{
      ans = min(ma-mi+1,ans);
      sum -= a[mi];
      mi++;
    }
  }
  if(ans != 1000000)cout << ans << endl;
  else cout << 0 << endl;
}



Measured memory_bytes: 3132
import sys
def main():
    input = sys.stdin.readline
    R, C, k = map(int, input().split())
    s = [[0] * (C + 1) for i in range(R + 1)]
    dp = [[[0] * (C + 1) for i in range(R + 1)] for j in range(4)]
    for i in range(k):
        r, c, v = map(int, input().split())
        s[r][c] = v
    for i in range(R):
        for j in range(C):
            m = max(dp[0][i][j + 1], dp[1][i][j + 1], dp[2][i][j + 1], dp[3][i][j + 1])
            for k in range(4):
                if k == 0:
                    dp[k][i + 1][j + 1] = max(dp[k][i + 1][j], m)
                else:
                    dp[k][i + 1][j + 1] = max(dp[k][i + 1][j], dp[k - 1][i + 1][j] + s[i + 1][j + 1])
            dp[1][i + 1][j + 1] = max(dp[1][i + 1][j + 1], s[i + 1][j + 1] + m)
    print(max(dp[0][R][C], dp[1][R][C], dp[2][R][C], dp[3][R][C]))
if __name__ == "__main__":
    main()


Measured memory_bytes: 428376
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

int main(){
  int h, w, n;
  cin >> h >> w >> n;
  int sum = 0;
  if (h > w) sum = (n % h != 0 ? n / h  + 1: n / h);
  else sum = (n % w != 0 ? n / w  + 1: n / w);
  
  cout << sum;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int A = 26;
int ct[A];

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

    for(int i=0; i<n; i+=2) ++ct[s[i]-'a'];

    int num[10]={};
    rep(i,A) ++num[ct[i]];

    int ans = 2*num[1];
    for(int i=2; i<10; ++i){
        if(num[i] == 0) continue;
        if(num[i] == 1){
            ans += 4;
            continue;
        }
        ans += 5+2*num[i]-1;
    }
    --ans;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3228
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    count = 0
    for i in range(1, N+1):
        if len(str(i))%2 == 1:
            count += 1
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38768
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y)
{
	if(y==0)return x;
	return gcd(y,x%y);
}
int n;
int x;
int xx[100010];
int ans;
int main()
{
	cin>>n>>x;
	cin>>xx[1];
	ans=fabs(xx[1]-x);
	for(int i=2;i<=n;i++)
	{
		cin>>xx[i];
		ans=gcd(ans,fabs(x-xx[i]));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
X=int(input())
lst=[]
N=500000
for i in range(-N,N+1):
    lst.append([i**5,i])
B=set([A for A,a in lst])
dic=defaultdict(int)
for A,a in lst:
    dic[A]=a
for A,a in lst:
    if A-X in B:
        print(a,dic[A-X])
        exit()


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

Measured memory_bytes: 1816
loop{

if (target = gets.to_i) == 0
	break
end

time = Array.new(gets.to_i);

time.size.times do |i|
	time[i] = gets.chomp
	target = target - (time[i].split(nil)[1].to_i - time[i].split(nil)[0].to_i)
end

if target <= 0
	print "OK\n"
elsif
	print target,"\n"
end

}

Measured memory_bytes: 6108
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
using namespace std;
  
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	ll k;
	cin>>k;
	vector<ll> v;
	for(i=1;i<=9;i++)
	v.pb(i);
	for(i=0;i<=1000000;i++)
	{
		if(v.size()>100000)
		break;
		ll last=v[i]%10;
		if(last==0)
		{
			v.pb(v[i]*10);
			v.pb(v[i]*10+1);
		}
		else if(last==9)
		{
			v.pb(v[i]*10+8);
			v.pb(v[i]*10+9);
		}
		else
		{
			v.pb(v[i]*10+last-1);
			v.pb(v[i]*10+last);
			v.pb(v[i]*10+last+1);
		}
	}
	cout<<v[k-1];
 cout<<"\n"; 
 } 
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define rep1(i,n,a) for(int i=0;i<n;i+=a)
#define rep2(i,n,a) for(int i=a;i<n;i++)
#define rep3(n)     for(int i=0;i<n;i++)
#define inarr(arr,n) rep1(i,n,1)cin>>arr[i]
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define trav(a,x) for(auto x:a)
#define endl "\n"
#define eb emplace_back
#define fr first
#define sc second
#define gcd(a,b) __gcd(a,b)
#define pres(a,x) a.find(x)!=a.end()
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define psi pair<string,int>
#define pss pair<string,string>
#define pll pair<ll,ll>
#define vec vector<int>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ret return 0
#define pi 3.1415926536
#define hell 1000000007
#define narak 998244353
const int inf1=1e9;
const ll inf2=1e18;
using namespace std;
int dirs[4][2] ={{1,0},{-1,0},{0,1},{0,-1}};
// syntax for min priority_queue of pairs
// priority_queue<pair<ll,ll>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
int solve(){
  int h,w,n;cin>>h>>w>>n;
  int ma=max(h,w);
  int j=n/ma+(n%ma!=0);
  cout<<j<<endl;
  ret;
}
int main(){
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    ret;
}
 


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

typedef long long ll;
typedef long double ld;

int main(){
  ll n;
  cin >> n;
  ld a=100;
  for(ll i=1;i<3761;++i){
    a=a*101/100;
    a=floor(a);
    if(a>=n){
      cout << i ;
      break;
    }
  }
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<char, int>;

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( a > b ) { a = b; return 1; } return 0; }

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

signed main(){
    int a[5];
    REP( i, 5 ) cin >> a[i];
    int k; cin >> k;
    REP( i, 4 ){
        FOR( j, i + 1, 5 ){
            if( a[j] - a[i] > k ){
                cout << ":(" << endl;
                return 0;
            }
        }
    }

    cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <climits>

using namespace std;

int gcd(int a, int b)
{
    if(a > b)
        swap(a, b);
    while(1)
    {
        if(b%a == 0)
            return a;
        b = b%a;
        swap(a, b);
    }
}

int main(void)
{
    int tests;
    tests = 1;
    // cin >> tests;
    for(int test = 0;test < tests;test++)
    {
        int n, k;
        cin >> n >> k;
        int a[100000];
        int maxi = INT_MIN;
        for(int i = 0;i < n;i++)
        {
            cin >> a[i];
            maxi = max(maxi, a[i]);
        }
        int ans = a[0];
        if(n != 1)
            ans = gcd(a[0], a[1]);
        for(int i = 2;i < n;i++)
        {
            ans = gcd(ans, a[i]);
        }
        // cout << maxi << endl;
        if(k%ans || maxi < k)
            cout << "IM";
        cout << "POSSIBLE" << endl;

    }
    return 0;
}


Measured memory_bytes: 640
/*mokosucio's file*/
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+5; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll m, n, a;
	cin>>m>>n;
	forn(i,n){
		cin>>a;
		m-=a;
	}
	(m>=0)?cout<<m<<"\n":cout<<"-1\n";
	return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; (i) < ((int)(n)); ++(i))
const ll INF = 10e10;
const ll MOD = 10e9 + 7;

int main() {
    int ans = 10000;
    string S, T;
    cin >> S >> T;
    int n_s = S.size();
    int n_t = T.size();

    rep(i, n_s - n_t + 1) {
        int count = 0;
        rep(j, n_t) {
            if(S[i + j] != T[j])
                count++;
        }
        ans = min(ans, count);
    }

    cout << ans << endl;
}

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

// リファクタリング兼とき直し

const int N = 2000;
vector<pair<int, int>> g[N];
vector<pair<int, int>> ng[N];
int n, m;
int ecas[N], qina[N];
vector<pair<int, int>> noel[N];
vector<int> tap[N];

int u[N], v[N];
int did[N], edgeUsed[N];

int dfs(int i, int p, int to, int id) {
  if(i == to) return 1;
  int f = 0;
  for(auto e : g[i]) {
    int j, ei; tie(j, ei) = e;
    if(j == p) continue;
    int t = dfs(j, i, to, id);
    f += t;
    if(t) {
      tap[ei].emplace_back(id);
    }
  }
  return f;
}
int dfs2(int i, int p, int to0, int to1) {
  int f = (i == to0) + (i == to1);
  for(auto e : g[i]) {
    int j, ei; tie(j, ei) = e;
    if(j == p) continue;
    int t = dfs2(j, i, to0, to1);
    f += t;
    if(t == 2) {
      edgeUsed[ei] = 1;
    }
  }
  return f;
}

int used[N];
int ans[N];
void dfs3(int i) {
  used[i] = 1;
  for(auto e : ng[i]) {
    int j, usi; tie(j, usi) = e;
    if(used[j]) continue;
    ans[j] = ans[i] ^ usi;
    dfs3(j);
  }
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> m;
  for(int i = 0; i < n - 1; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].emplace_back(b, i);
    g[b].emplace_back(a, i);
  }
  for(int i = 0; i < m; i++) {
    cin >> u[i] >> v[i];
    u[i]--; v[i]--;
    dfs(u[i], -1, v[i], i);
    ecas[i] = u[i];
    qina[i] = v[i];
    noel[u[i]].emplace_back(i, 0);
    noel[v[i]].emplace_back(i, 1);
  }
  ll val = 0;
  for(int i = 0; i < n - 1; i++) val += min((int) tap[i].size(), 2);

  queue<int> q;
  for(int i = 0; i < n; i++) if(g[i].size() == 1) q.emplace(i);
  while(q.size()) {
    int i = q.front();
    did[i] = 1;
    q.pop();
    for(auto e : g[i]) {
      int j, ei; tie(j, ei) = e;
      if(did[j]) continue;
      int cnt = 0;
      for(auto e2 : g[j]) if(!did[e2.first]) cnt++;
      if(cnt == 1) q.emplace(j);
      vector<pair<int, int>> filt;
      for(auto el : noel[i]) if(ecas[el.first] != qina[el.first]) filt.emplace_back(el);
      noel[i] = filt;
      if(noel[i].size() >= 2 && !edgeUsed[ei]) {
        int to0 = noel[i][0].second ? ecas[noel[i][0].first] : qina[noel[i][0].first];
        int to1 = noel[i][1].second ? ecas[noel[i][1].first] : qina[noel[i][1].first];
        dfs2(i, -1, to0, to1);
        ng[noel[i][0].first].emplace_back(noel[i][1].first, noel[i][0].second == noel[i][1].second);
        ng[noel[i][1].first].emplace_back(noel[i][0].first, noel[i][0].second == noel[i][1].second);
        noel[to1].erase(find(begin(noel[to1]), end(noel[to1]), make_pair(noel[i][1].first, int(!noel[i][1].second))));
        noel[to1].emplace_back(noel[i][0]);
        (!noel[i][0].second ? ecas : qina) [noel[i][0].first] = to1;
        noel[i].erase(begin(noel[i]), begin(noel[i]) + 2);
      }
      for(auto el : noel[i]) {
        (!el.second ? ecas : qina) [el.first] = j;
        noel[j].emplace_back(el);
      }
      noel[i].clear();
    }
  }

  for(int i = 0; i < m; i++) if(!used[i]) dfs3(i);
  cout << val << endl;
  for(int i = 0; i < m; i++) {
    if(ans[i]) swap(u[i], v[i]);
    cout << u[i] + 1 << " " << v[i] + 1 << endl;
  }
}



Measured memory_bytes: 19584
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll n, s[110000], c[110000], t;
int main() {
	bool ok = true;
	cin >> n;
	REP(i, n) {
		cin >> s[i];
		c[s[i]]++;
	}
	sort(s, s + n, greater<ll>());
	t = s[0];
	FORR(i, t, (t + 1) / 2) {
		if (t % 2 == 0 and i == t / 2) {
			if (c[i] == 0)ok = false;
			c[i]--;
		}
		else {
			if (c[i] <= 1)ok = false;
			c[i]-= 2;
		}
	}
	REPR(i, (t + 1) / 2) {
		if (c[i] > 0) ok = false;
	}
	cout << (ok ? "Possible" : "Impossible") << endl;
}


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

int main(){
	int n; scanf("%d",&n);
	long long R[200000];
	for(int i=0;i<n;++i) scanf("%lld",&R[i]);
	long long minv=1LL<<60;
	long long ans=-1LL<<60;
	for(int i=0;i<n;++i){
		ans=max(ans,R[i]-minv);
		minv=min(minv,R[i]);
	}
	printf("%lld\n",ans);
}



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

typedef long long ll;

int main()
{
  int n, k;
  cin >> n >> k;

  ll ans = n/k;
  ans = ans * ans * ans;

  if(k % 2 == 0){
    ll x = (n + k/2) / k;
    x = x * x * x;
    ans += x;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll Inf = 1e18;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

bool check(char c) {
    return (c == 'A' || c == 'T' || c == 'C' || c == 'G');
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s;
    cin >> s;
    s += 'a';
    int res = 0;
    rep (i, s.size()) {
        if (check(s[i])) {
            FOR (j, i + 1, s.size()) {
                if (!check(s[j])) {
                    res = max(res, j - i);
                    break;
                }
            }
        }
    }
    cout << res << endl;
    
    return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

int colors[205];
bool is_bipartite_graph(const Graph & graph, int v, int c) {
    colors[v] = c;
    for (int u: graph[v]) {
        if (colors[u] == c) {
            return false;
        }
        if (colors[u] == 0 && ! is_bipartite_graph(graph, u, -c)) {
            return false;
        }
    }
    return true;
}

void warshall_floyd(Graph &graph) {
    int V = graph.size();
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
}

void Main() {
    int N;
    cin >> N;
    Graph graph(N);
    Graph dist(N, vector<ll>(N, INF));
    rep(i, N) {
        string s;
        cin >> s;
        rep(j, N) {
            if (s[j] == '1') {
                graph[i].push_back(j);
                dist[i][j] = 1;
            }
        }
    }
    if (is_bipartite_graph(graph, 0, 1)) {
        warshall_floyd(dist);
        ll ans = 0;
        rep(i, N) {
            rep(j, i) {
                ans = max(ans, dist[i][j]);
            }
        }
        cout << ans + 1<< '\n';
    }else{
        cout << -1 << '\n';
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


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

using namespace std;

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

int main() {
  int N, X;
  cin >> N >> X;
  int x[N];
  int distance[N];
  for (int i = 0; i < N; i++) {
    cin >> x[i];
    distance[i] = abs(x[i] - X);
  }

  if (N == 1) {
    cout << distance[0] << endl;
    return 0;
  }
  
  int ans = gcd(distance[0], distance[1]);
  for (int i = 2; i < N; i++) {
    ans = gcd(ans, distance[i]);
  }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100000
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;

int main(){
    cin >> n;
    if(n < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
}



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

int main(){
  int N , K ;
  cin >> N >> K;
  string S ;
  cin >> S;
  if (S[K - 1] == 'A') S[K - 1] = 'a';
  if (S[K - 1] == 'B') S[K - 1] = 'b';
  if (S[K - 1] == 'C') S[K - 1] = 'c';

  cout << S << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int kosuu;
  cin>>kosuu;
  vector <string> data(kosuu);
  for (int i = 0; i < kosuu; i++) {
    cin >> data.at(i);
    if(data.at(i)=="Y"){
      cout<<"Four"<<endl;
      return 0;
    }
  }
  cout<<"Three"<<endl;
}
  

Measured memory_bytes: 256
# coding: utf-8

import sys
input = sys.stdin.readline

def f(n, W):
    dp = [0] * (W + 1)
    for i in range(n):
        wi, vi = map(int, input().split())
        for w in range(W, wi - 1, -1):
            v_ = dp[w - wi] + vi
            if dp[w] < v_:
                dp[w] = v_
    return(dp[-1])

n, w = map(int, input().split()) # 1 <= n <= 100, 1 <= w <= 10^5
print(f(n, w))


Measured memory_bytes: 9588
#include<iostream>
#include<string.h>
using namespace std;
 
long long n,i,m,a,r,c,h;
string s[100000];
int main()
{ 
  cin >> n;
  for(i=0;i<n;i++){
     cin >> s[i];
  }
  for(i=0;i<n;i++){
    if(strncmp("M",&s[i][0],1)==0) {m++;
                                 }
    if(strncmp("A",&s[i][0],1)==0) {a++;
                                 }
    if(strncmp("R",&s[i][0],1)==0) {r++;
                                 }
    if(strncmp("C",&s[i][0],1)==0) {c++;
                                 }
    if(strncmp("H",&s[i][0],1)==0) {h++;
                                 }
  }
  printf("%lld",m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h);
}

Measured memory_bytes: 6144
fn main() {
    let mut h = 1;
    let mut w = 1;
    h = read();
    w = read();
    while h != 0 || w != 0 {
        for _ in 0..h {
            let mut st = String::new();
            for __ in 0..w {
                st.push('#');
            }
            println!("{}", st);
        }
        println!("");
        h = read();
        w = read();
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: isize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========



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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

int main(){
  int N, K;
  cin >> N >> K;
  string s;
  cin >> s;
  s[K-1] = tolower(s[K-1]);
  cout << s << endl;
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

int n, m;
vi h;
vvi to;

void Main(){
    cin >> n >> m;
    h.resize(n);
    to.resize(n);

    rep(i,n) cin >> h[i];
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--; 
        to[a].pb(b);
        to[b].pb(a);
    }

    int cnt = 0;
    rep(i,n){
        bool ok = true;
        for(auto u : to[i]){
           if(h[i] <= h[u]) ok = false; 
        }
        if(ok) cnt++;
    }

    cout << cnt << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 8676
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
string s;
map<string,ll>m;
void solve()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s;
		sort(s.begin(), s.end());
		m[s]++;
	}
	ll sol = 0;
	for (auto it = m.begin(); it != m.end(); it++)
	{
		ll x = it->second;
		sol = sol + x * (x - 1) / 2;
	}
	cout << sol;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 11136
n = int(input())
a = []
b = []
for i in range(n):
  s = int(input())
  a.append(s)
  b.append(s)
m = max(a)
b.sort()
b = b[:-1]
m2 = b[-1]
for i in range(n):
  if a[i] == m:
    print(m2)
  else:
    print(m)

Measured memory_bytes: 14212
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        int[] dnum = new int[13];
        dnum[0] = 1;
        for(int i=0; i<n; i++){
            d[i] = sc.nextInt();
            dnum[d[i]]++;
        }

        for (int mnum : dnum) {
            if(mnum > 2){
                System.out.println(0);
                return;
            }
        }
        if(dnum[0] > 1 || dnum[12] > 1){
            System.out.println(0);
            return;
        }

        boolean[][] map = new boolean[13][2];
        if(dnum[0] == 1){
            map[0][0] = true;
            map[0][1] = true;
        }
        if(dnum[12] == 1){
            map[12][0] = true;
            map[12][1] = true;
        }
        boolean side = true;
        for(int i=1; i<12; i++){
            if(dnum[i] == 1){
                if(side){
                    map[i][0] = true;
                }else{
                    map[i][1] = true;
                }
                side = !side;
            }else if(dnum[i] == 2){
                map[i][0] = true;
                map[i][1] = true;
            }
        }

        int minlen = 100;
        int clen1 = 1, clen2 = 1;
            boolean state = true;

        for(int j=1; j<13; j++){
            if(map[j][0]){
                state = false;
                if(clen1 < minlen) minlen = clen1;
                clen1 = 1;
            }else{
                clen1++;
            }
        }
        state = true;
        for(int j=1; j<13; j++){
            if(map[j][1]){
                state = false;
                if(clen2 < minlen) minlen = clen2;
                clen2 = 1;
            }else{
                clen2++;
            }
        }

        if(!map[12][0] && clen1 + clen2 - 2 < minlen){
            minlen = clen1+clen2-2;
        }

        System.out.println(minlen);

    }
}

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

//modの割り算
// a/bをa*modint(b,MOD) %MODに変換
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;
}

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}


int main(){
  string L;
  cin >> L;
  int64_t MOD = 1000000007;
  int64_t dp[L.size()+1][2];
  for(int i=0; i<L.size()+1; i++){
    for(int j=0; j<2; j++){
      dp[i][j] = 0;
    }
  }
  dp[0][1] = 1;
  //dp[1][0] = pow(3,L.size()-1);
  for(int i=0; i<L.size(); i++){
    dp[0][1] *= 3;
    dp[0][1] %= MOD;
  }
  //cout << dp[0][0] << " " << dp[0][1] << endl;
  
  for(int i=0; i<L.size(); i++){
    if(L.at(i) == '1'){
      dp[i+1][0] = dp[i][0] + (dp[i][1]*modinv(3,MOD) % MOD);
      dp[i+1][1] = dp[i][1] - (dp[i][1]*modinv(3,MOD) % MOD);
    }
    else{
      dp[i+1][0] = dp[i][0];
      dp[i+1][1] = dp[i][1]*modinv(3,MOD) % MOD;
    }
    dp[i+1][0] %= MOD;
    dp[i+1][1] = mod(dp[i+1][1],MOD);
    //cout << dp[i+1][0] << " " <<  dp[i+1][1] << endl;
  } 
  cout << (dp[L.size()][0] + dp[L.size()][1]) %MOD << endl;

  
  /*int ans = 0;
  int N = 13;
    
  for(int i=0; i<=N; i++){
    for(int j=0; j<=N; j++){
      if(i+j <=N && (i^j) == i+j){
        ans++;
      }
    }
  }
  cout << ans << endl;*/
    
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define INF (1e18)

int main(){   
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    string s1 = S.substr(0,4);
    string s2 = S.substr(5,2);
    string s3 = S.substr(8,2);
    if(s2 == "04" || s2 == "03" || s2 == "02" || s2 == "01"){
        print("Heisei");
    }else{
        print("TBD");
    }
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut tseq = vec![0 as i32; n + 2];
    let mut vseq = vec![0 as i32; n + 2];
    tseq[0] = 1;
    tseq[n + 1] = 1;
    for i in 0..n {
        tseq[i + 1] = read();
    }
    for i in 0..n {
        vseq[i + 1] = read();
    }
    let mut dp = vec![vec![-1e+9 as f32; 101]; 101 * 202];
    dp[0][0] = 0f32;
    let mut t = 0;
    let n = n + 2;
    for i in 0..n {
        for _iter in 0..tseq[i] {
            for v in 0..vseq[i] + 1 {
                for &dv in [-1, 0, 1].iter() {
                    let nv = v + dv;
                    if nv < 0 || vseq[i] < nv {
                        continue;
                    }
                    let mut sum = dp[t][v as usize] + (v + nv) as f32 / 2.0;
                    if dv == 0 && nv < vseq[i] {
                        sum += 0.25;
                    }
                    dp[t + 1][nv as usize] = dp[t + 1][nv as usize].max(sum);
                }
            }
            t += 1;
        }
    }
    println!("{:.8}", dp[t][0]);
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vector<int> a;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        a.push_back(t);
    }
    sort(a.rbegin(), a.rend());
    vector<int> pfactor(a[0] + 1, -1);
    pfactor[1] = 1;
    for (int i = 2; i <= a[0]; i++) {
        if (pfactor[i] != -1) continue;
        int k = i;
        while (k <= a[0]) {
            if (pfactor[k] == -1) {
                pfactor[k] = i;
            }
            k += i;
        }
    }
    unordered_map<int, int> m;
    bool coprime = true;
    for (int t : a) {
        int temp = 1;
        while (t > 1) {
            if (pfactor[t] != temp) {
                m[pfactor[t]]++;
                if (m[pfactor[t]] > 1) {
                    coprime = false;
                }
                if (m[pfactor[t]] == n) {
                    cout << "not coprime" << endl;
                    return 0;
                }
            }
            temp = pfactor[t];
            t = t / temp;
        }
    }
    if (coprime) {
        cout << "pairwise coprime" << endl;
    } else {
        cout << "setwise coprime" << endl;
    }
    return 0;
}

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

int main(){
	int n, m;
	string s,t;
	cin >> n;
	map<string,int> ma;
	for (int i=0;i<n;i++){
		cin >> s;
		ma[s]++;
	}
	cin >> m;
	int maxi = 0;
	for (int i=0;i<m;i++){
		cin >> t;
		ma[t]--;
	}
	
	for(auto x:ma){
		maxi=max(maxi,x.second);
	}
	cout << maxi;
}


Measured memory_bytes: 256