akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,k=0,z=0,m;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        if(k>=n)break;
        k+=i,z=i;
    }
    m=k%n;
    for(int i=1;i<=z;i++){
        if(i==m)continue;
        else cout<<i<<"\n";
    }
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        ll N; cin >> N;
        ll ans = INFL;
        repeat(i, 1, sqrt(N) + 2) {
            if(N % i == 0) set_min(ans, i + N / i);
        }
        cout << ans - 2 << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
	int h, w, cnt;
	string s, str = "snuke";
	cin >> h >> w;
	for(cnt = 0; cnt < h * w; cnt++){
		cin >> s;
		if(s == str){
			break;
		}
	}
	cout << (char)('A' + (cnt % w)) << cnt / w + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        String str = sc.next();
        
        int[] tmp = new int[3];
        tmp[0] = Integer.parseInt(String.valueOf(str.charAt(0)));
        tmp[1] = Integer.parseInt(String.valueOf(str.charAt(2)));
        tmp[2] = Integer.parseInt(String.valueOf(str.charAt(3)));
        
        long tmpa = a * tmp[0];
        long tmpb = a * tmp[1];
        long tmpc = a * tmp[2];
        
        long tmpb2 = tmpb / 10;
        long tmpc2 = tmpc / 100;
        
        long tmpb3 = (tmpb % 10) * 10;
        long tmpc3 = tmpc % 100;
        
        long tmpx = (tmpb3 + tmpc3) / 100;
        System.out.println(tmpa + tmpb2 + tmpc2 + tmpx);
    }
}

Measured memory_bytes: 35796
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);


int main(void) {

	int    N,i,sum=0,max=0;
	char   S[11];

	s_cin(S);
	N=strlen(S);
	for (i = 0; i < N; i++) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')
			sum++;
		else sum = 0;
		if (sum > max) max = sum;
	}
	i_cout(max);

	return 0;	
}
	

int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}



Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val aList = readLine()!!.split(' ').map(String::toInt)

    val nums = mutableMapOf(1 to 2, 2 to 5, 3 to 5, 4 to 4, 5 to 5, 6 to 6, 7 to 3, 8 to 7, 9 to 6)
    for (i in 1..9) if (aList.contains(i).not()) nums.remove(i)//利用可能な数字のみをnumsに残す
    val bars = mutableMapOf<Int, Int>()//(必要な本数,数値)のマップ
    nums.forEach { entry -> bars[entry.value] = entry.key }//同じ本数が必要な数値の内、小さいほうを除去


    //配るDPで最大桁数を算出
    val dp = Array(n + 10) { 0 }//dp[i]=マッチ棒がちょうどi本の時に作れる最大桁数
    for (bar in bars.keys) dp[bar] = 1
    for (bar in bars.keys) {
        for (i in 1 until n) {
            if (dp[i] != 0) dp[i + bar] = Math.max(dp[i + bar], dp[i] + 1)
        }
    }

    var ans = ""
    //一番右の1桁以外に何が入りうるかを算出する
    var leftBar = n//残りのマッチ棒本数
    for (i in 1 until dp[n]) {
        for (num in bars.values.sortedDescending()) {
            val bar = bars.filterValues { it == num }.keys.toList().first()
            if (leftBar - bar >= 0 && dp[leftBar - bar] == dp[leftBar] - 1) {
                ans += num.toString()
                leftBar -= bar
                break
            }
        }
    }

    ans += bars[leftBar]!!.toString()
    println(ans)
}


Measured memory_bytes: 69380
n = int(input())
a = [0]*n
b = [0]*n
c = [0]*n

for i in range(n):
  p, q, r = map(int, input().split())
  a[i], b[i], c[i] = p, q, r

dp_a = [0]*n
dp_b = [0]*n
dp_c = [0]*n

for i in range(n):
  if i == 0:
    dp_a[i], dp_b[i], dp_c[i] = a[i], b[i], c[i]
  else:
    dp_a[i] = max([a[i]+dp_b[i-1], a[i]+dp_c[i-1]])
    dp_b[i] = max([b[i]+dp_a[i-1], b[i]+dp_c[i-1]])
    dp_c[i] = max([c[i]+dp_b[i-1], c[i]+dp_a[i-1]])
print(max([dp_a[n-1], dp_b[n-1], dp_c[n-1]]))

Measured memory_bytes: 26700
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  string str;
  cin>>str;
  cout<<str.substr(0,3)<<endl;
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<list>
#include<string>

using namespace std;

void Output(list<int> ilist)
{
	list<int>::iterator it = ilist.begin();
	cout << *it;
	it++;
	while(it != ilist.end()){
		cout << " " << *it;
		it++;
	}
	cout << endl;
}

list<int> DealDelete(int &key,list<int> &ilist)
{
	list<int>::iterator it = ilist.begin();
	
	while(it != ilist.end()){
		if(*it == key){
			ilist.erase(it);
			return ilist;
		}
		it++;
	}
	return ilist;
}

void Deal(string &command,list<int> &ilist)//??\???????????£??????????????¨????±???????
{
	if(command == "insert"){
		int key;
		cin >> key;
		ilist.push_front(key);
	}else if(command == "delete"){
		int key;
		cin >> key;
		DealDelete(key,ilist);
	}else if(command == "deleteFirst"){
		ilist.pop_front();
	}else{
		ilist.pop_back();
	}
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	list<int> ilist;
	
	cin >> n;
	
	for(int i=0; i<n; i++){
		string command;
		cin >> command;
		Deal(command,ilist);//??\???????????????
	}
	Output(ilist);//??¨?????????
}

Measured memory_bytes: 35608
#include <iostream>

using namespace std;

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

    int ans = (l + l + n - 1) * n / 2;
    if (l > 0) {
        ans -= l;
    } else if (l + n - 1 < 0) {
        ans -= l + n - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def ten_to_3(X):
    num = ''
    while X != 0:
        num = str(X % 3) + num
        X //= 3

    return num

N = int(input())
counter = 0

for k in range(len(str(N)), 2, -1):
    for i in range(3 ** k):
        case = ten_to_3(i)
        case = '0' * (k - len(case)) + case
        if '0' not in case or '1' not in case or '2' not in case:
            continue
        num = ''
        for j in range(len(case)):
            if case[j] == '0':
                num += '3'

            elif case[j] == '1':
                num += '5'

            else:
                num += '7'

        if int(num) <= N:
            counter += 1

print(counter)
    


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

#define llint long long int

void gcd_upbound(llint total, llint val, std::vector<llint> &alist){
  for(int i=1; i*i<total; i++){
    if(total % i == 0){
      alist.push_back(i);
      alist.push_back(total/i);
    }
  }
  return;
}

int main(void){
  int n, k;
  std::cin >> n >> k;
  std::vector<llint> a(n);

  llint total = 0;
  for(int i=0; i<n; i++){
    std::cin >> a[i];
    total += a[i];
  }

  std::vector<llint> possible_list;
  gcd_upbound(total, a.size(), possible_list);
  int best = 1; // initialize
  for(const auto& i: possible_list){
    llint diff = 0;
    std::vector<llint> b;
    for(const auto& elem: a){
      b.push_back(elem % i);
    }
    std::sort(b.begin(), b.end());
    int st = 0;
    int ed = b.size()-1;
    llint count = 0;
    while(st < ed){
      llint temp = std::min(b[st], i-b[ed]);
      b[st] -= temp;
      b[ed] += temp;
      if(b[st] == 0) st++;
      if(b[ed] == i) ed--;
      count += temp;
    }
    if(count <= k) best = best < i ? i : best;
  }
  std::cout << best << std::endl;

  
  
  return 0;
}


Measured memory_bytes: 256
def exp(n, k)
    x = 1   
    r = n 
    while k > 0 
        x *= r if k & 1 == 1
        r *= r    
        k >>= 1
    end 
    x   
end

require 'matrix'
p (exp(Matrix[[1, 1], [1, 0]], gets.to_i) * Vector[1, 0])[0]

Measured memory_bytes: 6360
input_lines = gets.chop.split.map(&:to_i)
n = input_lines[0]
count = 0
n = n-1
decreaseK = n
a = n/2
b = n%2 + a
sumK = (n + 1) * a
if n%2 == 1
    sumK = sumK + b
end
puts sumK

Measured memory_bytes: 1788
import bisect
def main():
    N = int(input())
    A = []
    c = 1
    l = []
    for _ in range(N):
        a = int(input())
        A.append(a)
    l.append(A[-1])
    for j in reversed(A[:-1]):
        i = bisect.bisect_right(l, j)
        if i == len(l):
            l.append(j)
        else:
            l[i] = j
    print(len(l))
main()



Measured memory_bytes: 8664
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    n = int(input().rstrip())
    a_list = list(map(int, input().split()))
    flag = False
    try:
        if a_list.index(0):
            flag = True
            print(0)
            exit()
    except:
        if flag:
            exit()
        ans = 1
        for i in a_list:
            ans *= i

            if ans > 10 ** 18:
                print(-1)
                exit()

        print(ans)



if __name__ == "__main__":
    resolve()



Measured memory_bytes: 82804
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>

using namespace std;
int main(void){
    string s;
    cin>>s;
    int a=s.size();
    for(int i=0;i<a;i++){
        cout<<"x";
    }
    cout<<endl;
}


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

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a-1;i>=0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7

int main() {
    ll n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    bool f = s[0] - '0';
    VE tmp, sum;
    if (!f)tmp.push_back(0);
    ll cnt = 1;
    rep(i, 1, s.size()) {
        if (f and s[i] == '1') {
            cnt++;
        }
        else if (f and s[i] == '0') {
            tmp.push_back(cnt);
            cnt = 1;
            f = false;
        }
        else if (!f and s[i] == '1') {
            tmp.push_back(cnt);
            cnt = 1;
            f = true;
        }
        else if (!f and s[i] == '0') {
            cnt++;
        }
    }
    tmp.push_back(cnt);
    if(!f)tmp.push_back(0);
    sum.push_back(0);
    REP(i, tmp.size()) {
        sum.push_back(tmp[i] + sum[i]);
    }
    jkl;
    ll ans = 0;
    if(sum.size() - 1< 2 * k + 1){
        print(n);
        return 0;
    }
    for(ll i = 2 * k + 1; i < sum.size(); i += 2) {
        ans = max(ans, sum[i] - sum[i - 2 * k - 1]);
    }
    print(ans);
}

Measured memory_bytes: 2676
while True:
	n, x = map(int, input().split())
	if n == 0 and x == 0:
		break
	results = [] 
	n_list = [i for i in range(1, n+1)] 
	for i in n_list:
		for j in n_list:
			r = x - (i+j)
			if r in n_list:
				value = sorted([i, j, r])
				if len(list(set(value))) == 3 and not value in results:
					results.append(value)
	print(len(results))


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int a[100005];
string s;
map<string, int> dp;
map<string, int>::iterator its;

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> s;
        sort(s.begin(), s.end());
        dp[s]++;
    }
    LL ans = 0;
    for(its = dp.begin();its != dp.end();its++){
        ans += its->second*1ll*(its->second-1)/2;
    }
    printf("%lld\n", ans);
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n;cin >>n;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    ll ans=0;
    for (int i = 0; i < n;) {
        if(i==n-1){
            ans+=a[i]/2;
            i++;
        }
        else if(a[i]%2==1&&a[i+1]%2==1){
            ans+=(a[i]+a[i+1])/2;
            a[i]=a[i+1]=0;
            i+=2;
        }
        else if(a[i]%2==0&&a[i+1]%2==0){
            ans+=(a[i]+a[i+1])/2;
            a[i]=a[i+1]=0;
            i+=2;
        }
        else if(a[i]%2==0&&a[i+1]%2==1){
            ans+=a[i]/2;
            a[i]=0;
            i++;
        }
        else if(a[i]%2==1&&a[i+1]%2==0){
            if(a[i+1]==0){
                ans+=a[i]/2;
                i+=2;
            }
            else {
                a[i]--;a[i+1]--;
                ans++;
                ans+=a[i]/2;
                i++;
            }
        }
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 1024
import math
N=int(input())
C=[0,0,0]
for i in range(N):
  B=C
  C=list(map(int,input().split()))
  x=abs(B[1]-C[1])
  y=abs(B[2]-C[2])
  t=abs(B[0]-C[0])
  if x+y>t or (t-x-y) % 2 != 0:
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int cnt[n];
  for(int i = 0; i < n; i++) 
    cnt[i] = 0;
  for(int i = 0; i < n - 1; i++) {
    int a;
    cin >> a;
    cnt[a - 1]++;
  }
  for(int i = 0; i < n; i++)
     cout << cnt[i] << endl;
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod) { a %= _mod; b %= _mod; ll res = 1; switch(op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break; } if (res < 0) res += _mod; return res; }


int main()
{
        ll H, W, N;
        cin >> H >> W >> N;
        ll bigger = max(H, W);
        cout << rup(N, bigger) << endl;
}


Measured memory_bytes: 3588
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<string> S(N);
	for (int i = 0; i < N; i++) cin >> S[i];
	for (int i = 0; i < N; i++) sort(S[i].begin(), S[i].end());
	sort(S.begin(), S.end());

	lint ans = 0, tmp = 0;
	S.emplace_back(""); //番兵
	for (int i = 0; i < N; i++) {
		if (S[i] == S[i + 1]) tmp++; 
		else {
			ans += tmp * (tmp + 1) / 2;
			tmp = 0;
		}
	}

	cout << ans << "\n";

	return 0;
}

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

int main()
{
    long long n,i,j,k;
    long long ans=0,res=0;
    long long a[102];
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n-2;i++){
        for(j=i+1;j<n-1;j++){
            for(k=j+1;k<n;k++){
                if((a[i]+a[j]>a[k])&&a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i])ans++;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
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<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const ll MOD=998244353;
const ll LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




struct UnionFind{
    vector<int> data;

    UnionFind(int sz){
        data.assign(sz, -1);
    }

    int find(int k){
        if(data[k] < 0) return k;
        return data[k] = find(data[k]);
    }

    bool unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y) return false;
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int size(int k){
        return -data[find(k)];
    }

};

int main(){
    int n;cin >> n;
    vector<pair<P,int>> v(n);
    for (int i = 0; i < n; i++) {
        int x,y;cin >> x >> y;
        x--,y--;
        v[i] = mp(mp(x, y),i);
    }
    sort(ALL(v));
    priority_queue<P ,vector<P>, greater<P>> pq;
    UnionFind uf(n);
    for (int i = 0; i < n; i++) {
        int id = v[i].sc;
        ll mini = v[i].fs.sc;
        while(not pq.empty() and pq.top().fs < v[i].fs.sc){
            auto pp = pq.top(); pq.pop();
            chmin(mini, pp.fs);
            uf.unite(pp.sc, id);
        }
        pq.push(mp(mini, id));
    }
    for (int i = 0; i < n; i++) {
        cout << uf.size(i) << endl;
    }
    return 0;
}



Measured memory_bytes: 9016
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    D = int(input())
    C = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(D)]

    for d in range(D):
        ma = res = 0
        for i in range(26):
            s = S[d][i]
            if ma < s:
                ma = s
                res = i + 1
        print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9200
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define PI acos(-1.0)
#define mod 1e9+7
using namespace std;
vector<int>v[100010];
int DP[100010];
int dp(int cur)
{
    if(DP[cur]!=-1) return DP[cur];
    int ans=0;
    for(int i:v[cur])
    {
        ans=max(ans, dp(i));
    }
    ans++;
    return DP[cur]=ans;
}
int main()
{
    memset(DP, -1, sizeof(DP));
    int n, m;
    cin>>n>>m;
    int x, y;
    for(int i=0; i<m; i++)
    {
        scanf("%d%d", &x, &y);
        v[x].pb(y);
    }
    int ans=0;
    for(int i=1; i<=n; i++)
    {
        ans=max(ans, dp(i));
    }
    printf("%d\n", ans-1);
    return 0;
}


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

int main(){

    int n;
    string s;

    int i=0;

    cin >> n;
    cin >> s;

    int count = 0;
    i = s.find("ABC",i);

    while(i!=-1){
        count++;
        i= s.find("ABC",i+3);            
    } 

    cout << count <<endl;
    
    return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
        
n, m = map(int, input().split())
edge = []
for i in range(m):
    a, b = map(int, input().split())
    edge.append((a - 1, b - 1))

ans = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if j == i:
            continue
        uf.union(edge[j][0], edge[j][1])
    if uf.group_count() != 1:
        ans += 1

print(ans)
    

    

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

#define pb     push_back
#define mp     make_pair
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
const ll INF =  0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int MAX = 1e5+5;

string s;
int ans;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);

	// #ifndef ONLINE_JUDGE
	// freopen("in","r",stdin);
	// freopen("out","w",stdout);
	// #endif

	cin >> s;
	int l = 0;
	int r = s.size() - 1;

	while(l < s.size()){
		if(s[l] == 'x')
			l++;
		else
			break;
	}

	while(r >= 0){
		if(s[r] == 'x')
			r--;
		else
			break;
	}
	ans += abs(l - ((int)s.size() - r - 1));
	while(l < r){
		if(s[l] == s[r])
			l++, r--;
		else{
			if(s[l] == 'x')
				ans++, l++;
			else if(s[r] == 'x')
				ans++, r--;
			else{
				cout << "-1";
				return 0;
			}
		}
	}
	cout << ans;
	return 0;
}  

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int sum;
    int cnt1=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='o') cnt1++;

    }
    if(cnt1>=0){
        sum=700+(100*cnt1);

    }
    cout<<sum<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
void output_result(int a[], int n)
{
    for(int i=1; i<=n; i++) {
        if(i > 1)
            cout << " ";
        cout << a[i];
    }
    cout << endl;
}
int main()
{
	int n, a[105], i, j, flag = 0;
	cin >> n;
	for(i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	for(i = 1; i <= n - 1; i++){
		for(j = 1; j <= n - i; j++){
			if(a[j] > a[j+1]){
				swap(a[j], a[j+1]);
				flag++;
			}
		}
	}
	
	output_result(a, n);
	cout << flag << endl;
	return 0;
}



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

int main(){
    int N, X;
    int m;
    int min = 1e9;

    cin >> N >> X;
    
    for(int i = 0; i < N; ++i){
        cin >> m;

        if(m < min) min = m;

        X -= m;

    }

    int res = N + X / min;
    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int N;
char S[10000];
char subst[5001];

int judge(int slen)
{
    int l1;
    char *result;
    if (slen == 0)
        return 0;
    for (l1=0; l1 < N+1-2*slen; l1++) {
        memcpy(subst, S+l1, slen);
        subst[slen] = '\0';
        result = strstr(S+l1+slen, subst);
        //printf("slen %d l1 %d subst %s result %s\n", slen, l1, subst, result?"Yes":"No");
        if (result != NULL) {
            return 0; // false
        }
    }
    return 1; // true
}

int find_min_true(int n)
{
    int i = 0;
    int j = n;
    while (i < j) {
        int h = (i+j) >> 1;
        if (!judge(h))
            i = h + 1;
        else
            j = h;
    }
    return i;
}

int main()
{
    int ans;
    int _ = scanf("%d %s", &N, S);
    ans = find_min_true(N/2+1);
    if (ans == 0) {
        printf("0\n");
    } else {
        printf("%d\n", ans-1);
    }
}

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

typedef long long int ll;
typedef long double ld;
int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    if(k >= a) 
    {
        k -= a;
        a = 0;
        if(k >= b)
        {
            b = 0;
            cout << a << " " << b << endl;
        }
        else
        {
            b -=k;
            cout << a << " " << b << endl;
        }
    } 
    else 
    {
        a -= k;
        cout << a << " " << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
	int a = 0, b = 0, c = 0;
	int temp = 0;

	CI a >> b >> c;
	
	if (a > b) {
		temp = b;
		b = a;
		a = temp;
	}
	if(b > c){
		temp = c;
		c = b;
		b = temp;
	}
	if (a > b) {
		temp = b;
		b = a;
		a = temp;
	}
	if (b > c) {
		temp = c;
		c = b;
		b = temp;
	}

	CO a << " " << b << " " << c E
	
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
int main(){
    // Your code here!
  int a,b,d,r;
  double A,B,f;
  cin>>a>>b;
  d=a/b;
  r=a%b;
  A=a;B=b;
  f=A/B;
  cout<<fixed << setprecision(10);
  cout<<d<<" "<<r<<" "<<f<<endl;
}  




Measured memory_bytes: 3264
using System;

class main
{
    public static void Main()
    {
        bool isRoop = true;
        while (isRoop)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            char o = char.Parse(s[1]);
            int b = int.Parse(s[2]);

            switch (o)
            {
                case '+':
                    Console.WriteLine(a + b);
                    break;
                case '-':
                    Console.WriteLine(a - b);
                    break;
                case '*':
                    Console.WriteLine(a * b);
                    break;
                case '/':
                    Console.WriteLine(a / b);
                    break;
                case '?':
                    isRoop = false;
                    break;
            }
        }
    }
}

Measured memory_bytes: 9252
#include <bits/stdc++.h>
#define ll long long
#define INF 9999999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;
typedef pair<double,int>pdi;

struct edge{
	int to;   //行き先
	double cost; //コスト
};


const int MAX_N = 1005;

P cor[MAX_N];
double d[MAX_N];
vector<edge> G[MAX_N];
double r[MAX_N];

void dijkstra(int s) //n:点数 m:枝数 s:スタート点
{
	priority_queue<pdi,vector<pdi>,greater<pdi> > que;
	d[s] = 0.0;
	que.push(pdi(0.0,s));
	while(!que.empty()){
		pdi p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		vector<edge>::iterator it = G[v].begin();
		while(it != G[v].end()){
			if(d[it->to] > d[v] + it->cost){
				d[it->to] = d[v] + it->cost;
				que.push(pdi(d[it->to],it->to));
			}
			it++;
		}
	}
}

int main()
{
	int n;
	cin >> cor[0].first >> cor[0].second >> cor[1].first >> cor[1].second;
	r[0] = r[1] = 0;
	cin >> n;
	rep(i,n){
		cin >> cor[i+2].first >> cor[i+2].second >> r[i+2];
	}
	rep(i,n+2){
		rep(j,n+2){
			if(i!=j){
				edge e;
				e.to = j;
				double D = sqrt(pow((cor[i].first-cor[j].first),2)+pow((cor[i].second-cor[j].second),2));
				e.cost = max(D-r[i]-r[j],0.0);
				G[i].push_back(e);
			}
		}
	}
	fill(d,d+n+2,INF);
	dijkstra(0);
	printf("%.10f\n",d[1]);
	return 0;
}

Measured memory_bytes: 22128
#include <bits/stdc++.h>
#define int long long
using namespace std;
bool cmp(pair<string, int> &a, pair<string, int> &b){
    if (a.first != b.first) return (a.first > b.first);
    return (a.second < b.second);
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<pair<int, int> > g;
    vector<bool> good;
    int I = 0;
    while (I < s.size()){
        int b = 2*(s[I] == 'a') - 1;
        int B = b;
        int S = g.size();
        for (int j=I+1; j < s.size(); j++){
            B += (2*(s[j] == 'a') - 1);
            if (B==0){
                g.push_back({I, j});
                good.push_back(b < 0);
                I = j+1;
                break;
            }
        }
        if (g.size() == S){
            g.push_back({I, s.size()-1});
            good.push_back(b < 0);
            break;
        }
    }
    vector<string> choose;
    for (int i=0; i < g.size(); i++){
        if (!good[i]){
            int L = g[i].first, R = g[i].second;
            vector<int> as, bs;
            for (int j=L; j <= R; j++){
                if (s[j] == 'a') as.push_back(j);
                else bs.push_back(j);
            }
            map<int, int> ft;
            for (int j=0; j < as.size(); j++) ft[as[j]] = bs[j];
            int dp[R-L+2];
            dp[R-L+1] = 0;
            for (int j=R; j >= L; j--){
                dp[j-L] = dp[j-L+1];
                if (s[j] == 'b') continue;
                else dp[j-L] = max(dp[j-L], dp[ft[j]+1-L] + 1);
            }
            string ss = "";
            for (int j=0; j < dp[0]; j++) ss += "ab";
            choose.push_back(ss);
        }
        else{
            vector<string> vv;
            int L = g[i].first, R = g[i].second;
            int B = 0;
            for (int j=L; j <= R; j++){
                string pp = "";
                int b = 0;
                int ed = 0;
                for (int p=j; p <= R; p++){
                    if (s[p] == 'a' && ed < B){
                        ed++;
                        continue;
                    }
                    b += (2*(s[p] == 'a') - 1);
                    if (s[p] == 'a') ed++;
                    pp += s[p];
                }
                vv.push_back(pp);
                B += (2*(s[j] == 'b') - 1);
            }
            sort(vv.begin(), vv.end());
            choose.push_back(vv.back());
        }
    }
    vector<pair<string, int> > ppp;
    for (int i=0; i < choose.size(); i++){
        if (choose[i] == "") continue;
        ppp.push_back({choose[i], i});
    }
    sort(ppp.begin(), ppp.end(), cmp);
    int nw = -1;
    string ans = "";
    for (int i=0; i < ppp.size(); i++){
        if (ppp[i].second < nw){
            continue;
        }
        if (ppp[i].first[0] == 'a'){
            for (int j=i; j < ppp.size(); j++){
                if (ppp[j].second > nw) ans += ppp[j].first;
            }
            break;
        }
        ans += ppp[i].first;
        nw = ppp[i].second;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 32128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int moding[s.size()+1 ];
  moding[0]=0;
  map<int,int> mp;
  mp[moding[0]]++;
  reverse(s.begin(),s.end() );
  int num=1;
  repi(i,1,s.size()+1 ){
    if(i!=1){
      num*=10;
      num%=2019;
    }
    moding[i]=moding[i-1]+(s[i-1]-'0')*num;
    moding[i]%=2019;
    // cout<<moding[i]<<endl;
    mp[moding[i]]++;
  }
  
  int ans=0;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    ans+=(itr->S*(itr->S-1))/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5256
N, M = map(int, input().split())

A = (100 * (N - M) + 1900 * M) / pow(2, M)

B = 0
r = 1 / pow(2, M)
for i in range(1, 10 ** 5):
    B += i * pow(1 - r, i - 1)

print(int(round(A * B, 0)))


Measured memory_bytes: 39152
#include <vector>
#include <cstdio>
#include <cassert>

using namespace std;

int N = 3;
vector<int> A(N);
int sum;

int inputInt() {
    int i;
    scanf("%d", &i);
    return i;
}

int main() {
    for(int i=0; i<N; ++i) A[i] = inputInt();
    for(int i=0; i<A.size(); ++i) assert(1<=A[i] && A[i]<=13);
    sum = 0;
    for(int i=0; i<A.size(); ++i) sum += A[i];
    printf("%s\n", 22<=sum ? "bust" : "win");
    return 0;
}

Measured memory_bytes: 3116
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int ans = -1;
    for(int i=0; i<10000; i++){
      if((int)(i*0.08)==A) {
        if((int)(i*0.1)==B){
        ans = i;
        break;
        }
      }
    }
    System.out.println(ans);
  }
}
    

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m,q,k;
string s,t;
vll a,b,c;
// <------------- Implement Functions Here ----------> //

ll dp[200000][5][5][5];

ll solve(ll x, ll c1,ll c2, ll c3) {
	if(c1 == 2 || c2 == 2 || c3 == 2) return -INF;
	if(x == n) return 0;

	if(dp[x][c1][c2][c3]!=-1) return dp[x][c1][c2][c3];

	return dp[x][c1][c2][c3] = max({solve(x+1,c1+1,0,0)+a[x],solve(x+1,0,0,c3+1)+c[x],solve(x+1,0,c2+1,0)+b[x]});
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n ;
	a = vll(n);
	b = vll(n);
	c = vll(n);
	for(ll i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];	
	
	for(ll i=0;i<=n;i++) {
		for(int j=0;j<3;j++) {
			for(int k=0;k<3;k++) {
				for(int l=0;l<3;l++) {
					dp[i][j][k][l] = -1;
				}		
			}		
		}
	}

	cout<<solve(0,0,0,0);
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 345312
#include<iostream>
#include<algorithm>
#include<string>
#include<cctype>
#include<map>

using namespace std;

int now;
string str;
map<string,int>mp;

int Number(void){
	string res;
	while('0'<=str[now] && str[now]<='9')res+=str[now++];
	return atoi(res.c_str());
}

int Atom(void){

	string s;
	s+=str[now++];
	if(islower(str[now]))s+=str[now++];
	if(mp.count(s))return mp[s];
	return -1;
}

int Molecule(void){
	
	int res=0;
	if(isupper(str[now])){
		res+=Atom();
		if(res<0)return -1;
		if('0'<=str[now] && str[now]<='9')res*=Number();
	}
	else if(str[now]=='('){
		now++;
		int tmp=Molecule();
		if(tmp<0)return -1;
		res+=tmp;
		now++;
		res*=Number();
	}
	
	
	if(now<str.size() && str[now]!=')'){
		int tmp=Molecule();
		if(tmp<0)return -1;
		res+=tmp;
	}
	return res;
}

int main(void){
	
	int n;
	string s;
	
	while(true){
		cin >> s;
		if(s=="END_OF_FIRST_PART")break;
		cin >> n;
		mp[s]=n;
	}
	
	while(true){
		cin >> str;
		if(str=="0")break;
		now=0;
		int res=Molecule();
		if(res<0)cout << "UNKNOWN" << endl;
		else cout << res << endl;
	}
	
return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 100005
 
#define PI   3.14159265358979323846264338327950

#define PB push_back 
#define F first
#define S second
 
#define ll 	 long long int

#define mod  1000000007


map<char, int> m;


int main()
{
	FAST;
	ll n;
	cin >> n;
	ll a[n+5];
	for(ll i = 0; i < n; i++){
		cin >> a[i];
	} ll ans = 0;
	for(ll i = 1; i  + 1 < n ; i ++){
		ll x = min(a[i-1], min(a[i], a[i+1]));
		ll y = max(a[i-1], max(a[i], a[i+1]));
		ll z = a[i] + a[i-1] + a[i+1] - x - y;
		if(a[i] == z){
			ans ++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

int main()
{
    string S;
    cin >> S;
    int ans = 0;

    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == '+')
        {
            ans++;
        }
        else
        {
            ans--;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
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 pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////


signed main(){
  int x;cin>>x;
    int ans = 0;
    ans += (x / 11)*2;
    x %= 11;
    ans += x/6;
    x %= 6;
    if(x > 0)ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

  lli N,A;
  string s;
  cin >> N >> A >> s;
  
  s[A - 1] += abs('A' - 'a');

  COUT(s);
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a[200009], cnt[200009];
long long ans[200009];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	for (int i = 1; i < n; i++) {
		int tmp = cnt[a[i]] - 1;
		if (a[0] == a[i]) tmp--;
		ans[0] += tmp;
	}
	ans[0] /= 2;
	for (int i = 1; i < n; i++) {
		ans[i] = ans[0];
		if (a[i] == a[0]) continue;
		int tmp = cnt[a[i]] - 1;
		ans[i] -= tmp;
		tmp = cnt[a[0]] - 1;
		ans[i] += tmp;
	}
	for (int i = 0; i < n; i++) cout << ans[i] << E;
	//system("pause");
	return 0;
}

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

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

	int n, y;
	cin >> n >> y;

	for(int i=0; i<=n; i++) {
		for(int j=0; j<=n-i; j++) {
			if(n < i + j)
				continue;

			int k = n - (i + j);
			int cur = 10000 * i + 5000 * j + 1000 * k;
			if(y == cur) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}

	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int main() {
	ll n,m;
	cin >> n >> m;
	ll a[n],s[n];
	map<ll,ll> nums;
	ll ans = 0;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	ll sum = 0;
	nums[sum]++;
	for (int i = 0;i < n;i++) {
		sum = (sum + a[i])%m;
		nums[sum]++;
	}
	for (auto itr = nums.begin();itr != nums.end();itr++) {
		ans += itr->second * (itr->second-1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.

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

int mod = 1000000007;
ll dp[100005];;

ll gcd(long long a,long long b){

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


bool sortByVal(const pair<string, int> &a,
               const pair<string, int> &b)
{
    return (a.second < b.second);
}

int main(){

 string s;
 cin>>s;

  long long n = s.length();
  long long fronts=0,ans=0;

 for(int i=0;i<n;i++){

    if(s[i] == 'A'){
        fronts++;
        continue;
    }
    else if(i<n-1 && s[i] == 'B' && s[i+1] == 'C'){
        ans += fronts;
         i++;
         continue;
    }
     fronts = 0;
 }

  cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 3752
loop do

      max, sum = gets.split.map(&:to_i)
      max.zero? && sum.zero? && break

      count = 0

      1.upto(max) do | n1 |

          (n1 + 1).upto(max) do | n2 |
            break if n1 + n2 > sum

            (n2 + 1).upto(max) do | n3 |
              break if n1 + n2 + n3 == sum && count += 1

          end
        end
      end

      puts count

    end



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

using namespace std;

int main()
{long long int N,E=10000000000;
cin>>N;
long long int W[N];
long long int S = 0,S1=0,S2=0;
for(int x = 0;x<N;x++){
    cin>>W[x];
    S+=W[x];
}
for(int x = 0;x<N;x++){
    S1+=W[x];
    S2 = S-S1;
    if(E>abs(S1-S2)){
        E = abs(S1-S2);
            }
}
cout<<E<<"\n";
}

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

int main()
{
	char S[4];
	cin >> S;
	int ans = 0;
	for(int i = 0; i < 4; i++){
		if(S[i] == '+'){
			ans++;
		}else{
			ans--;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

        int t = sc.nextInt();
        int x = sc.nextInt();
        double ans = (double)t/x;
        
        System.out.println(ans);


    }
}





Measured memory_bytes: 23252