akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(N: int):
    if N % 2 == 0:
        print(N // 2)
    else:
        print(N // 2 + 1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
int main(void){
    while (true){
        int a, b;
        cin >> a >> b;
            if (a == 0 && b == 0) break;
        if (a > b){
            swap(a, b);
        }
        cout << a << " " << b << endl;
    }
}

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

using namespace std;

const int N = 2005, M = 2005;

int n;
int a[N];

bitset<N * M / 2> s;

int main() {
    scanf("%d", &n);
    int sum = 0;
    s[0] = 1;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        sum += a[i];
        s |= s << a[i];
    }
    int res;
    for (res = sum / 2; !s[res]; --res);
    printf("%d\n", sum - res);
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>

int main() {
  char scores[50];
  int student_nums = 0;
  while (1)
  {
    int m, f, r;
    scanf("%d %d %d", &m, &f, &r);
    if (m == -1 && f == -1 && r == -1) {
      break;
    }
    int total = m + f;
    if (m == -1 || f == -1) {
      scores[student_nums] = 'F';
    } else if (total >= 80) {
      scores[student_nums] = 'A';
    } else if (65 <= total && total < 80) {
      scores[student_nums] = 'B';
    } else if (50 <= total && total < 65) {
      scores[student_nums] = 'C';
    } else if (30 <= total && total < 50) {
      if (r >= 50) {
        scores[student_nums] = 'C';
      } else {
        scores[student_nums] = 'D';
      }
    } else if (total < 30) {
      scores[student_nums] = 'F';
    }
    student_nums++;
  }
  for (int i = 0; i < student_nums; i++)
  {
    printf("%c\n", scores[i]);
  }
}


Measured memory_bytes: 2760
fun main(args: Array<String>) {
    val (n, x) = readLine()!!.split(" ").map { it.toInt() }
    val l = readLine()!!.split(" ").map { it.toInt() }
    var ans = 1
    var bounds = 0
    for (i in 0 until n) {
        bounds += l[i]
        if (bounds > x) {
            return println(ans)
        } else {
            ans++
        }
    }
    println(ans)
}


Measured memory_bytes: 37876
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n,k; cin >> n >> k;
    VI l(n); REP(i,n) cin >> l[i]; SORT(l); REVERSE(l);
    int ans = 0;
    REP(i,k) ans += l[i];
    out(ans);

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

N = input()
hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]

if int(N[-1]) in hon :
    print("hon")
elif int(N[-1]) in pon :
    print("pon")
elif int(N[-1]) in bon :
    print("bon")

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.1415926535

ll dpa[100004],dpb[100004],dpc[100004];

int main() 
{
    FAST;
    ll n;
    cin>>n;
    ll a[n],b[n],c[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    dpa[0]=a[0];
    dpb[0]=b[0];
    dpc[0]=c[0];
    for(ll i=1;i<n;i++)
    {
        dpa[i]=max(dpb[i-1],dpc[i-1])+a[i];
        dpb[i]=max(dpa[i-1],dpc[i-1])+b[i];
        dpc[i]=max(dpb[i-1],dpa[i-1])+c[i];
    }
    cout<<max(dpa[n-1],max(dpb[n-1],dpc[n-1]));
    return 0;
}

Measured memory_bytes: 4992
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int i, w = 0;
	int f = 0;
	for (i = 0; i<n; i++) {
		if (s[i] == 'c')
			cout << "No"<<endl;
		else if (s[i] == 'a') {
			if (w<a + b) {
				cout << "Yes" << endl;
				w++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			f++;
			if (w<a + b && f <= b) {
				cout << "Yes" << endl;
				w++;
			}
			else {
				cout << "No" << endl;
			}
		}
	}
}

Measured memory_bytes: 896
fun main(args: Array<String>) {
    abc081c()
}

fun abc081c() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val aList = readLine()!!.split(" ").map { it.toInt() }

    val grouped = aList.groupBy { it }.map { it.value }

    if (grouped.size <= k) return println(0)

    val answer = grouped.sortedBy { it.size }.dropLast(k).sumBy { it.size }

    println(answer)
}


Measured memory_bytes: 95196
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def solve(S):
    before = set()
    for i in range(1,len(S)):
        a,b = S[:i],S[i:]
        ab = (a,a[::-1])
        cd = (b,b[::-1])
        for j in range(2):
            for k in range(2):
                before.add(ab[j] + cd[k])
                before.add(cd[k] + ab[j])
    print(len(before))

def main():
    M = int(input())
    for _ in range(M):
        S = input()
        solve(S)
if __name__ == '__main__':
    main()


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

using namespace std;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long

#define for(i,a,b) for (i=a; i<b; i++)
#define forb(i,a,b) for (i=a; i>b; i--)
#define all(S) S.begin(),S.end()
#define sort(S) sort(all(S))

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

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    ll n,k,i;
    cin >> n >> k;
    ll ans = 0;
    for (i,k,n+2)
    {
        ll a = (i-1)*i/2;
        ll b = n*(n+1)/2 - (n-i)*(n-i+1)/2;
        ans = (ans+b-a+1)%inf;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}

int main() {
  int a,b;
  cin>>a>>b;
  cout<<(a*(a-1))/2+(b*(b-1))/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; using namespace atcoder;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;
	scc_graph g(N);
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		g.add_edge(a, b);
	}
	auto v = g.scc();

	int K = v.size();
	printf("%d\n", K);
	fore(w, v) {
		int n = w.size();
		printf("%d", n);
		fore(x, w) printf(" %d", x);
		printf("\n");
	}
}







Measured memory_bytes: 40116
flag = 0
N = int(input())
Us = [input() for _ in range(N)]
M = int(input())
for _ in range(M):
    T = input()
    if T in Us: flag ^= 1
    else:
        print("Unknown {}".format(T))
        continue
    print("{} by {}".format(["Closed", "Opened"][flag], T))


Measured memory_bytes: 5608
"use strict";

let squares = [];
let width = [];
let size;
let h = 0;

function Main(input)
{
    // let arr = input.split(' ').map(Number);
    // OR
    let arr = input.split(' ').map(function(a) {
        return parseInt(a, 10);
    });
    let results = [];
    for(let i = 0; i < arr.length; i++)
    {
        for(let j = 0; j < arr.length; j++)
        {
            if(i == j) continue;
            results.push(arr[i]+arr[j]);
        }
    }
    let result = Math.min(...results);
    console.log(result);
    return result;
}

// Main(require("fs").readFileSync("input.txt", "utf8"));
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 7372
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

void dfs(const vector<vector<u64>>& uv, const vector<u64>& a, const u64 u, const u64 p_v,
stack<pair<u64, u64>>& rt, vector<u64>& dp, vector<u64>& ans) {
    
    auto itr = lower_bound(dp.begin(), dp.end(), a[u]); 
    rt.push(make_pair(distance(dp.begin(), itr), *itr));
    *itr = a[u];

    auto ai = lower_bound(itr, dp.end(), UINT64_MAX); 
    ans[u] = distance(dp.begin(), ai);

    for(const auto n_u : uv[u]) {
        if(n_u == p_v) continue;
        dfs(uv, a, n_u, u, rt, dp, ans);
    }

    dp[rt.top().first] = rt.top().second;
    rt.pop();
    
}

int main(void) {
    u64 N;
    cin >> N;

    vector<u64> a(N);
    for(u64 n=0; n<N; n++) cin >> a[n];
    
    vector<vector<u64>> uv(N, vector<u64>());
    for(u64 i=0; i<N-1; i++) {
        u64 u, v;
        cin >> u >> v;
        uv[u-1].push_back(v-1);
        uv[v-1].push_back(u-1);
    }

    stack<pair<u64, u64>> rt;
    vector<u64> dp(N, UINT64_MAX);
    vector<u64> ans(N);
    dfs(uv, a, 0, N, rt, dp, ans);

    for(u64 i=0; i<N; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main(){
  int N,M,K;cin >> N >> M >> K;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=M;j++){
      int S = i*(M-j)+j*(N-i);
      if(S==K){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] line1 = br.readLine().split(" ");
    int n = Integer.parseInt(line1[0]);
    long k = Long.parseLong(line1[1]);
    
    
    long[] array = new long[100000];
    String[] data;
    int a;
    long b;
    for (int i=0; i<n; i++){
      data = br.readLine().split(" ");
      a = Integer.parseInt(data[0]);
      b = Integer.parseInt(data[1]);
      array[a-1] += b;
    }
    long temp = 0;
    for (int i=0; i<100000; i++){
      temp += array[i];
      if (temp>=k) {
        System.out.println(i+1);
        return;
      }
    }
  }
}


Measured memory_bytes: 47304
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<random>
#include<map>
#include<queue>
using namespace std;


int main(){

  int n;
  cin >> n;
  vector<int> num(1000, 0);

  for(int i=2; i<=n; i++){
    int tmp = i;
    int di = 2;
    while(true){
      if( tmp == 1 ) break;

      while( tmp % di == 0 ){
        tmp /= di;
        num[ di ]++;
      }
      di++;
    }
  }

  long long int ans = 1;
  for(int i=0; i<1000; i++){
    if( num[i] != 0 ) ans *= num[i]+1;
    if( ans >= 1000000000 + 7 ) ans %= 1000000000 + 7;
  }
  cout << ans << endl;

  return 0;
}








// EOF


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_128
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            var ons = new HashSet<int>[m];
            for (int i = 0; i < m; i++)
            {
                ons[i] = new HashSet<int>();
                int[] vals = ReadInts();
                for(int j = 1; j <= vals[0]; j++)
                {
                    ons[i].Add(vals[j] - 1);
                }
            }
            int[] ps = ReadInts();

            int allPat = 1 << n;
            int res = 0;
            for(int i = 0; i < allPat; i++)
            {
                int[] cnts = new int[m];
                for(int j = 0; j < n; j++)
                {
                    if ((i & (1 << j)) == 0) continue;

                    for(int k = 0; k < m; k++)
                    {
                        if (ons[k].Contains(j)) cnts[k]++;
                    }
                }

                int onCnt = 0;
                for(int j = 0; j < m; j++)
                {
                    if (cnts[j] % 2 == ps[j]) onCnt++;
                }

                if (onCnt == m) res++;
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13396
let n = stdin.ReadLine() |> int
let a = stdin.ReadLine().Split() |> Array.map int64 |> Array.toList

let rec step list max sum =
    match list with
    | head :: tail ->
        if head > max then step tail head sum
        else step tail max (sum+max-head)
    | [] -> sum

let head,tail = List.head a, List.tail a

(step tail head 0L) |> stdout.WriteLine

Measured memory_bytes: 54100
N, K = map(int, input().split())
P = list(map(int, input().split()))
INF = float('inf')
num = 2**(N-1).bit_length()
segmin = [INF] * num*2
segmax = [-INF] * num*2
for i in range(N):
    segmin[num + i - 1] = P[i]
    segmax[num + i - 1] = P[i]
for i in range(num-2, -1, -1):
    segmin[i] = min(segmin[2*i+1], segmin[2*i+2])
    segmax[i] = max(segmax[2*i+1], segmax[2*i+2])

def query(seg, f, boundary, p, q):
    p += num-1
    q += num-2
    res=boundary
    while q-p>1:
        if p&1 == 0:
            res = f(res,seg[p])
        if q&1 == 1:
            res = f(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = f(res,seg[p])
    else:
        res = f(f(res,seg[p]),seg[q])
    return res

ans = 1
for i in range(N-K):
    if not (P[i] < query(segmin, min, INF, i+1, i+K) and P[i+K] > query(segmax, max, -INF, i+1, i+K)):
        ans += 1

# 昇順にならんでいるケース
combo = 0
nord = 0
for i in range(1,N):
    if P[i] > P[i-1]:
        combo += 1
    else:
        combo = 0
    if combo == K-1:
        nord += 1

print(ans - max(0, nord-1))


Measured memory_bytes: 129520
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int k;
  cin >> k;
  if(k % 2 == 0){
    k /= 2;
    cout << k * k << endl;
  }else{
    k /= 2;
    cout << k * (k + 1) << endl;
  }
}

Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N;
    cin >> N;
    map<string, ll> mp;
    for(ll i = 0; i < N; i++) {
        string s;
        cin >> s;
        sort(ALL(s));
        mp[s]++;
    }

    ll ans = 0;
    for(auto &&ele : mp) {
        ll num = ele.second;
        ans += num * (num - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11264
#include<stdio.h>

int fibonacci(int);

int main(){

  int num,n;
  
  scanf("%d",&num);
  
  n = fibonacci(num);  

  printf("%d\n",n);

    return 0;
}


int fibonacci(int num){

  int fib[10000],i;
  fib[0] = 1;
  fib[1] = 1;
  for(i = 2; i < num; i++){
    fib[i] = fib[i-2] + fib[i-1];
  }
  fib[num] = fib[num-1]+fib[num-2];

  return fib[num];
}

Measured memory_bytes: 600
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;

int main(){
  int n, k;
  cin >> n >> k;
  vector<pair<int,int>> a(k);
  rep(i,k){
    cin >> a[i].first >> a[i].second;
    a[i].second--;
  }
  sort(a.begin(),a.end());
  vector<vector<vector<vector<int>>>> dp(n+1,vector<vector<vector<int>>>(3,vector<vector<int>>(3,vector<int>(3))));
  dp[0][0][0][0]=1;
  int f=0;
  for(int i=1; i<=2; i++){
    while(f<k-1 && a[f].first<i)
      f++;
    rep(j,3){
      rep(l,3){
        rep(m,3){
          rep(o,3){
            if(a[f].first==i && a[f].second!=o)
              continue;
            dp[i][l][m][o] += dp[i-1][j][l][m];
            dp[i][l][m][o] %= 10000;
          }
        }
      }
    }
  }
  for(int i=3; i<=n; i++){
    while(f<k-1 && a[f].first<i)
      f++;
    rep(j,3){
      rep(l,3){
        rep(m,3){
          rep(o,3){
            if(l==m&&m==o)
              continue;
            if(a[f].first==i && a[f].second!=o)
              continue;
            dp[i][l][m][o] += dp[i-1][j][l][m];
            dp[i][l][m][o] %= 10000;
          }
        }
      }
    }
  }
  int res=0;
  rep(i,3){
    rep(j,3){
      rep(l,3){
        res += dp[n][i][j][l];
        res %= 10000;
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3180
#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>;

void Main()
{
  int N, M;
  int cnt = 0;
  int gateMin = 0;
  cin >> N >> M;
  int gateMax = N;
  vector<int> L(M), R(M);
  for (int i = 1; i <= M; i++) {
    cin >> L[i-1] >> R[i-1];
  }
  for (int i = 1; i <= M; i++) {
    gateMin = max(gateMin, L[i-1]);
    //cout << gateMax << ", " << R[i-1] << endl;
    gateMax = min(gateMax, R[i-1]);
  }
  //for (int j = 1; j <= N; j++) {
  //  if (gateMin <= j && j <= gateMax) cnt++;
  //}
  //cout << gateMax << endl;
  //cout << gateMin << endl;
  cout << max(gateMax - gateMin +1,0) << endl;
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if(a <= 5) cout << 0 << endl;
  else if(a <= 12) cout << b/2 << endl;
  else cout << b << endl;
  return 0;
}

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

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

	int x,n;
	cin>>x>>n;
	set<int> ch;
	for(int i=0; i<n; ++i){
		int y; cin>>y; ch.insert(y);
	}

	int lo = x;
	int hi = x;

	while( true ){
		if( ch.find(lo) == ch.end() ){ cout<<lo<<'\n'; return 0; }
		if( ch.find(hi) == ch.end() ){ cout<<hi<<'\n'; return 0; }
		lo--;
		hi++;
	}


	return 0;
}


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

int main(){
  int n;
  cin>>n;
  n=1<<n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  while(a.size()>=2){
    vector<int>b;
    for(int i=0; i<a.size()-1; i+=2){
      if(a[i]!=a[i+1])b.push_back(abs(a[i]-a[i+1]));
      else b.push_back(a[i]);
    }
    a=b;
  }
  cout<<a[0]<<endl;
}

Measured memory_bytes: 4868
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    int n,x=0,max=0;
    string s;
    cin>>n>>s;
    rep(i,n){
        if(s[i]=='I') x += 1;
        else x -= 1;
        if(max <= x) max = x;
    }
    cout<<max<<endl;
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

const int INF=1001001001001001001;

int N,M,P;
vpint G[3333];
vint rG[3333];
int dist[3333];
bool vis[3333];
signed main(){
	cin>>N>>M>>P;
	rep(i,M){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		c-=P;
		c=-c;
		G[a].eb(b,c);
		rG[b].pb(a);
	}
	fill_n(dist,N,INF);

	vis[N-1]=true;
	queue<int>que;
	que.push(N-1);
	while(que.size()){
		int v=que.front();
		que.pop();
		for(auto u:rG[v]){
			if(vis[u])continue;
			vis[u]=true;
			que.push(u);
		}
	}
	dist[0]=0;	

	rep(i,N){
		rep(v,N){
			if(dist[v]==INF)continue;
			for(auto &e:G[v])chmin(dist[e.fi],dist[v]+e.se);
		}
	}

	rep(v,N){
		if(dist[v]==INF)continue;
		for(auto &e:G[v]){
			if(!vis[e.fi])continue;
			if(dist[e.fi]>dist[v]+e.se){
				cout<<-1<<endl;
				return 0;
			}
		}
	}

	cout<<max(0ll,-dist[N-1])<<endl;
	return 0;
}

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

int main()
{
    map<string, int> dict;
    string s, max_s, max_e_s;
    int max_length = 0, max_emerge = 0;
    while (cin >> s)
    {
        dict[s]++;
        if (s.size() > max_length)
        {
            max_length = s.size();
            max_s = s;
        }
    }
    for (auto t = dict.begin(); t != dict.end(); t++)
    {
        if (t->second > max_emerge)
        {
            max_emerge = t->second;
            max_e_s = t->first;
        }
    }
    cout << max_e_s << " " << max_s << endl;
    return 0;
}



Measured memory_bytes: 3012
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long long int gcd(long long int a, long long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long long int lcm(long long int a, long long int b){
  return a * b / gcd(a, b);
}

// 10min
int main(void){
  int N, T;
  int c;
  int t;
  int cmin = 10001;
  
  scanf("%d%d", &N, &T);

  for(int i = 0; i < N; i++){
    scanf("%d%d", &c, &t);

    if(t <= T && c < cmin){
      cmin = c;
    }
  }
  if(cmin == 10001){
    printf("TLE\n");
  }else{
    printf("%d\n", cmin);
  }
  return 0;
}


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

int main() {
	int n;
	cin>>n;
	long long int a[n+1];
	for(int i=0;i<n+1;i++)
		a[i]=1;
		
	a[0] = 0;
	
	for(int i=2;i<n+1;i++) {
		for(int j=i;j<n+1;j+=i) {
			a[j]+=1;
		}
	}
	
	long long int res=0;
	
	for(int i=1;i<n+1;i++) {
		res+= i*a[i];
	}
	
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 81728
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int Y;
  cin >> N >> Y;
  Y /= 1000;
  bool ok = true;
  if (N * 10 < Y || N > Y) {
    cout << "-1 -1 -1" << endl;
  }
  else {
    for (int i = N; i >= 0; i--) {
      int memo;
      for (int j = (N - i); j >= 0; j--) {
        memo = 10 * i + 5 * j + (N - i - j);
        if (memo == Y) {
          cout << i << " " << j << " " << (N - i - j) << endl;
          ok = false;
          break;
        }
      }
      if (ok == false) {
        break;
      }
      if (i == 0) {
        cout << "-1 -1 -1" << endl;
      }
    }
  }
}


Measured memory_bytes: 3576
h, w = map(int, input().split())
n = int(input())
alst = list(map(int, input().split()))

c = [[0 for _ in range(w)] for _ in range(h)]

num = 0
apos = 0
for pos in range(h * w):
    x = pos // w
    y = pos % w
    if x % 2 == 1:
        y = w - y - 1
    c[x][y] = apos + 1
    num += 1
    if alst[apos] == num:
        apos += 1
        num = 0
for lst in c:
    print(*lst)

Measured memory_bytes: 9640
#include <cstdio>
#include <iostream>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;

using namespace std;
int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == s[i+1]){return printf("Bad\n") * 0;}
        
    }
    return printf("Good\n")*0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"_,*l=open(0).readlines();print('YNeos'[any(a[-2]!=b[0]*l.count(a)for a,b in zip(l,l[1:]))::2])\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
#include <stdio.h>
int map[40][2],num,i;
int calc(int x,int y,int a,int b){
    for(i=0;i<num;i++)
        if(x==map[i][0]&&y==map[i][1])
            return 0;
    if(x>a||x<1||y>b||y<1)
        return 0;
    if(x==a&&y==b)
        return 1;
    return calc(x+1,y,a,b)+calc(x,y+1,a,b);
}
int main(void){
    int a,b,sum;
    for(;sum=0,scanf("%d %d",&a,&b),b;){
        scanf("%d",&num);
        for(i=0;i<num;i++)
            scanf("%d %d",&map[i][0],&map[i][1]);
        sum=calc(1,1,a,b);
        printf("%d\n",sum);
    }
    return 0;
}

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

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

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

const int MOD = 1000'000'007;
const double EPS = 0.000'000'001;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

const int N = 100010;
int dp[N][3], h[N][3];
int n;

int solve(int i, int j)
{
	if(i == n) return 0;

	int& r = dp[i][j];

	if(r == -1)
	{
		for(int k = 0; k < 3; k++)
			if(k != j)
				r = max(r, solve(i + 1, k) + h[i][j]);
	}

	return r;
}

int main()
{
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);
	cout.precision(10);
	
	cin >> n;

	memset(dp, -1, sizeof(dp));

	for(int i = 0; i < n; i++)
		for(int j = 0; j < 3; j++)
			cin >> h[i][j];

	int ans = -1;
	for(int j = 0; j < 3; j++)
		ans = max(ans, solve(0, j));

	cout << ans << endl;
	//cerr << "Tempo de execucao: " << (double)clock() / CLOCKS_PER_SEC << endl;
	return 0;
}

Measured memory_bytes: 8832
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] a = new int[N][2];
		int[][] ans = new int[M + 1][];
		for (int i = 1; i <= M; ++i) {
			ans[i] = new int[M / i + 1];
		}
		ArrayList<Integer>[] lis = new ArrayList[M + 1];
		for (int i = 0; i < lis.length; ++i) {
			lis[i] = new ArrayList<>();
		}
		for (int i = 0; i < N; ++i) {
			a[i][0] = sc.nextInt();
			a[i][1] = sc.nextInt();
			lis[a[i][0]].add(a[i][1]);
		}
		FenwickTree ft = new FenwickTree(M + 1);
		ArrayList<Integer>[] div = new ArrayList[M + 1];
		for (int i = 0; i < div.length; ++i) {
			div[i] = new ArrayList<>();
		}
		for (int i = 1; i <= M; ++i) {
			for (int j = i; j <= M; j += i) {
				div[j].add(i);
			}
		}
		for (int i = 1; i <= M; ++i) {
			for (int v : lis[i]) {
				ft.add(v, 1);
			}
			for (int v : div[i]) {
				int k = v;
				int m = i / k;
				ans[m][k] += ft.sum(Math.min(M, (k + 1) * m - 1)) - ft.sum(k * m - 1);
			}
		}
		PrintWriter pw = new PrintWriter(System.out);
		for (int m = 1; m <= M; ++m) {
			int s = 0;
			for (int v : ans[m]) {
				s += v;
			}
			pw.println(s);
		}
		pw.close();
	}

	class FenwickTree {
		int n;
		int[] v;

		public FenwickTree(int n) {
			this.n = n;
			v = new int[n + 1];
		}

		void add(int k, int val) {
			while (k <= n) {
				v[k] += val;
				k += k & -k;
			}
		}

		int sum(int k) {
			int s = 0;
			while (k > 0) {
				s += v[k];
				k -= k & -k;
			}
			return s;
		}

	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


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

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    for(int i = 1; i <= n; i++){
        if(i == k){
            s[i-1] = tolower(s[i-1]);
        }
    }
    cout << s << endl;
}

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

int main(){
  string t;
  cin >> t;
  REP(i,t.size()){
    if(t[i] == '?') t[i] = 'D';
  }
  cout << t << endl;
  return 0;



}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> boroken(n+1);
  for(int i = 0; i < m; i++) {
    int a;
    cin >> a;
    boroken[a] = true;
  }
  vector<int> dp(n+1);
  const int mod = 1000000007;
  dp[n] = 1;
  if(boroken[n-1]) dp[n-1] = 0;
  else dp[n-1] = 1;
  for(int i = n-2; i >= 0; i--) {
    if(boroken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i+1] + dp[i+2]) % mod;
  }
  cout << dp[0]<< endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
  string S; cin>>S;
  rep(i,S.size()) cout<<'x';
  cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif

//	https://tenka1-2018-beginner.contest.atcoder.jp/assignments

static void B_Exchange();

int main()
{
	B_Exchange();

	fflush(stdout);
	return 0;
}

static void B_Exchange()
{
	int K = 0;
	U_L_LONG A = 0, B = 0;

	scanf(" %llu %llu %d", &A, &B, &K);

	int state = 0;
	for (int i = 0; i < K; i++) {
		
		if (state == 0) {
			if (A % 2LLU) {
				A--;
			}
			A /= 2;
			B += A;
			state++;
		}
		else {
			if (B % 2LLU) {
				B--;
			}
			B /= 2;
			A += B;
			state = 0;
		}
	}
	printf("%llu %llu\n", A, B);
}


Measured memory_bytes: 256
# Aizu Problem 00124: League Match Score Sheet
#
import sys, math, os, copy

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


first = True
while True:
    N = int(input())
    if N == 0:
        break
    if first:
        first = False
    else:
        print()
    scoresheet = []
    for n in range(N):
        s = input().split()
        team = s[0]
        won = int(s[1])
        draw = int(s[3])
        scoresheet.append([team, n, 3 * won + draw])
    scoresheet = sorted(scoresheet, key=lambda x: (-x[2], x[1]))
    for team, n, points in scoresheet:
        print("%s,%d" % (team, points))
    

Measured memory_bytes: 8216
#include <cstdio>
#include <set>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    vector<int> prime;
    int p[120000];
    int i,j;
    for(i=0;i<120000;i++){
        p[i]=i+2;
    }
    for(i=0;i<sqrt(120000);i++){
        if(!p[i]){continue;}
        for(j=i+1;j<120000;j++){
            if(!(p[j]%p[i])){p[j]=0;}
        }
    }
    for(i=0;i<120000;i++){
        if(p[i]){prime.push_back(p[i]);}
    }
    
    int start_val,cnt;
    while(1){
        scanf("%d",&start_val);
        scanf("%d",&cnt);
        if(start_val==-1&&cnt==-1){break;}
        vector<int>::iterator tg=upper_bound(prime.begin(),prime.end(),start_val);
        vector<int> st;

        for(i=0;i<cnt;i++){
            for(j=i;j<cnt&&j>=i;j++){
                st.push_back((*(tg+i))+(*(tg+j)));
            }
        }
        sort(st.begin(),st.end());
        printf("%d\n",st[cnt-1]);
    }
    return 0;
}



Measured memory_bytes: 3252
s = input()

if 1<=int(s[:2])<=12 and 1<=int(s[2:])<=12:
  print('AMBIGUOUS')
elif 1<=int(s[:2])<=12 and (int(s[2:])>12 or int(s[2:])==0):
  print('MMYY')
elif (int(s[:2])>12 or int(s[:2])==0) and 1<=int(s[2:])<=12:
  print('YYMM')
else:
  print('NA')

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

int main()
{
    int N, M;
    cin >> N >> M;
    int i;
    vector<int> a(102);
    vector<int> b(102);
    for (i = 0; i < M; i++)
    {
        cin >> a.at(i) >> b.at(i);
    }

    vector<int> Acup(102);
    vector<int> Bcup(102);

    for (i = 0; i < M; i++)
    {
        Acup.at(a.at(i) - 1)++;
        Bcup.at(b.at(i) - 1)++;
    }

    for (i = 0; i < N; i++)
    {
        cout << Acup.at(i) + Bcup.at(i) << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
    
class Main
{
    
    public static void main(String[] args)
    {   Scanner stdIn=new Scanner(System.in);
        int a=stdIn.nextInt();
        int b=stdIn.nextInt();
        int c=stdIn.nextInt();
           
       if(a<=b && b<=c){System.out.println(a+" "+b+" "+c);
    }
       else if(a>=b && b<=c && a<=c){System.out.println(b+" "+a+" "+c);
    }
       else if(a>=b && b>=c && a>=c){System.out.println(c+" "+b+" "+a);
    }
       else if(a>=b && b<=c && a>=c){System.out.println(b+" "+c+" "+a);
    }
       else if(a<=b && b>=c && a>=c){System.out.println(c+" "+a+" "+b);
    }
       else if(a<=b && b>=c && a<=c){System.out.println(a+" "+c+" "+b);
    }
           
    }
}

Measured memory_bytes: 26144
import sys
sys.setrecursionlimit(10000000)
N,X = map(int,input().split())
def n_barg_hight(n):
	if(n == 0):
		return 1

	L1barg_height = n_barg_hight(n-1)
	Lbarg_height = 1 + L1barg_height + 1 + L1barg_height + 1
	return Lbarg_height

def n_barg_pat(n):
	if(n == 0):
		return 1
	L1barg_pat = n_barg_pat(n-1)
	Lbarg_pat = 1 + L1barg_pat*2
	return Lbarg_pat


def answer(N,X):

	if(X == 1):
		if(N == 0):
			return 1
		else:
			return 0
	
	elif(X == n_barg_hight(N)):
		return n_barg_pat(N)

	elif(X == n_barg_hight(N)//2 + 1):
		return n_barg_pat(N-1)+1

	elif(X <= n_barg_hight(N)//2):
		return answer(N-1,X-1)

	elif(X > n_barg_hight(N)//2 + 1):
		Lbarg = n_barg_pat(N-1) + answer(N-1,X-n_barg_hight(N-1)-2) +1
		return Lbarg


print(answer(N,X))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int a, b, c, d; cin >> a >> b >> c >> d;
	if(abs(c-a) <= d) cout << "Yes" << endl;
	else if (abs(b-a) <= d && abs(c-b) <= d) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
#define REP(i,a,b) for( long long i=a;i<b;i++)
#define REPR(i,a,b) for(long long i=a;i>=b;i--)
#define adb(a) for(auto i:a) cout << i << " "; cout << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000009
#define MAX 500005;
#define PI 3.14159265358979323846

ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }

ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); }

ll modInverse(ll a, ll m) { ll g = __gcd(a, m); return power(a, m - 2, m); }


int main()
{


    fastIO;
    int test = 1;
    //cin >> test;
    while (test--)
    {
        int n, k;
        cin >> n;
        ll dp[n + 1][4];
        mem(dp, 0);
        REP(i, 1, n + 1)
        {
            int a, b, c;
            cin >> a >> b >> c;
            dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a;
            dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b;
            dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c;
        }
        cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
    }
    return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int  long long int
#define mod 1000000000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define gcd __gcd
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(i) i.begin(),i.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define set_bit __builtin_popcount //gives number of set_bits
#define ff first
#define ss second
#define cases(t) int t;cin>>t; rep(casn,1,t+1)
#define el cout<<"\n";
#define deci(n) int n; scanf("%lld",&n);
#define decs(n) string n; cin>>n;
#define sz(v) v.size()
#define repit(m) for(auto it=m.begin();it!=m.end();it++)
// #define find(m,i) (m.find(i)!=m.end())
// #define find(m,i) (m.find(i)==m.end())
#define cYES cout<<"YES\n";
#define cNO cout<<"NO\n";
#define ins insert
#define imax 1000000000000000000
#define imin -1000000000000000000
// #define NP 50000
//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
 
//  IIITA
//SUNEET KUMAR -->  ਸੁਨੀਤ
 
// scanning numbers extremely fast/////////
void fs(int &number)
{
    bool negative = false;
    register int c;
    number = 0;
    c = getchar();
    if (c=='-')
    {
        negative = true;
        c = getchar();
    }
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
    if (negative)
        number *= -1;
}
// ========================================
int power(int a,int x)
{
        a%=mod;
    int res=1;
    while(x>0)
    {
        if(x&1)
        res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}
int max(int a,int b)
{
    if(a>b)
    {
        return a;
    }
    else
    {
        return b;
    }
}
int min(int a,int b)
{
    if(a>b)
    {
        return b;
    }
    else
    {
        return a;
    }
}
int madd(int a,int b)
{
    int ans;
    ans=(a%mod+b%mod)%mod;
    return ans;
}
int mmult(int a,int b)
{
    int ans=1;
    ans=((a%mod)*(b%mod))%mod;
    return ans%mod;
}
int modinverse(int a)
{
    return power(a,mod-2);
}
 
void nhi_degi()
{
    string s;cin>>s;
    int n=s.length();
    int dp[2029],mark[n+4],remx[n+3];
    // int remz[2019]={0};
    for(int i=0;i<=2019;i++)
    {
        dp[i]=0;
        // mark[i]=0;
    }

    int rem=0,num,prod=1;
    for(int i=n;i>=1;i--)
    {
        int x=(s[i-1]-'0')*prod;
        rem=(x+rem)%2019;
        prod=prod*10;
        prod%=2019;
        remx[i]=rem; 
        // cout<<"->"<<rem;el
    }
    int ans=0;
    dp[0]=1;
    for(int i=1;i<=n;i++)
    {
        // cout<<dp[remx[i]];el
        ans+=(dp[remx[i]]);
        dp[remx[i]]++;
    }
    // for(int i=0;i<2019;i++)
    // {
    //     ans+=(dp[i]*(dp[i]-1))/2;
    // }
    cout<<ans;el
}
signed main()
{
    // cases(t)
    // {
        nhi_degi();
    // }
}

Measured memory_bytes: 5264
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint a; cin >> a;
    lint b; cin >> b;
    lint c; cin >> c;
    lint d; cin >> d;

    if(a == 1 || b == 1 || c == 1 || d == 1)
      if(a == 9 || b==9 || c==9 || d==9)
        if(a==7||b==7||c==7||d==7)
          if(a==4||b==4||c==4||d==4) {
            PRINT("YES");
            return 0;
          }

    PRINT("NO");

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long x; cin >> x;
  long long distance = 0;
  for(long long i = 1; distance < x; i++){
    distance += i;
    if(distance >= x){
      cout << i << endl;
      return 0;
    }
  }
     
}

Measured memory_bytes: 3612
N = int(input())
n = str(N)
ln = len(n)
K = int(input())
dp0= [[0] * (K+2) for i in range(ln+1)]
#上からi桁目まで決めて、0でない桁がj個あり、Nより小さいことが確定している
dp1 = [[0] * (K+2) for i in range(ln+1)]
#上からi桁目まで決めて、0でない桁がj個あり、Nより小さいことが確定していない

dp1[0][0] = 1

for i in range(ln):
  x = int(n[i])
  dp0[i+1][0] = 1
  for j in range(K):
    if(x == 0):
      dp0[i+1][j+1] = 9*dp0[i][j]+dp0[i][j+1]
      dp1[i+1][j+1] = dp1[i][j+1]
    else:
      dp0[i+1][j+1] = 9*dp0[i][j]+dp0[i][j+1]+(x-1)*dp1[i][j]+dp1[i][j+1]
      dp1[i+1][j+1] = dp1[i][j]
  #print(dp0)
  #print(dp1)
print(dp0[ln][K]+dp1[ln][K])

Measured memory_bytes: 3064