akhauriyash/Code-Regression huggingface dataset:
n = int(input())
marchSentence = ["M", "A", "R", "C", "H"]
marchCount = [0, 0, 0, 0, 0]
marchSum = 0
for i in range(n):
    s = input()
    sa = s[0]
    if marchSentence.count(sa) > 0:
        num = marchSentence.index(s[0])
        if num > -1:
            marchCount[num] += 1

for a in range(0, 3):
    for b in range(a + 1, 4):
        for c in range(b + 1, 5):
            marchSum += marchCount[a] * marchCount[b] * marchCount[c]
print(marchSum)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define err(x) debug() << "[" << #x << ": " << x << "]\n"
template<class c> auto try_out(c a) -> decltype(cerr << a, 0);
char try_out(...);
struct debug {
#ifdef LOCAL
template<class c, class d> debug& operator<<(pair<c,d> e){
    return *this << "(" << e.first << ", " << e.second << ")";
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) != 1, debug&>::type operator<<(c a){
    cerr << boolalpha << a;
    return *this;
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) == 1, debug&>::type operator<<(c a){
    *this << "{";
    for (auto it = a.begin(); it != a.end(); it++)
        *this << ","[1 - (it != a.begin())] << *it;
    return *this << "}";
}
#else
template<class c>debug& operator<<(c){
    return *this;
}
#endif
};



bool cmp(pair<int,int> a, pair<int,int> b)
{
    if (a.second != b.second)
        return a.second > b.second;
    return a.first > b.first;
}



int main() 
{
    
    int n, m;
    scanf("%d %d", &n, &m);
    
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a[i]);
        
    sort(a.begin(), a.end());
    
    vector<pair<int,int>> queries(m);
    for (int i = 0; i < m; i++)
    {    
        scanf("%d %d", &queries[i].first, &queries[i].second);
    }
    
    sort(queries.begin(), queries.end(), cmp);
    
    err(queries);
    
    int ind = 0;
    for (int i = 0; i < n;)
    {
        int j = i;
        bool fl = false;
        
        for (int it = 0; i < n && it < queries[ind].first; ++i, ++it)
        {
            if (a[i] > queries[ind].second)
            {
                fl = true;
                break;
            }
            //~ err("hi");
        }
        
        for (; j < i; ++j)
        {
            a[j] = queries[ind].second;
        }
        
        if (fl) break;
        
        ind++;
        //~ break;
    }
    
    err(a);
    
    ll ans = 0;
    for (int el : a)
        ans += el;
    
    printf("%lld\n", ans);
}


Measured memory_bytes: 2304
# -*- coding: utf-8 -*-
def two_pointers(ary, l, r, split, ary_func, comb_func, comp_func):
    '''
    This function is supposed to be repeatedly called so that 'split' keeps
    renewing, under an assumption that 'split' increases monotonously.
    ('l' and 'r' just specify the region to be searched in 'ary')
    '''

    left = ary_func(ary, l, split)
    right = ary_func(ary, split, r)
    val = comb_func(left, right)

    for i in range(split + 1, r):
        tmp_left = ary_func(ary, l, i)
        tmp_right = ary_func(ary, i, r)
        tmp_val = comb_func(tmp_left, tmp_right)

        if comp_func(val, tmp_val):
            return i - 1, val, left, right
        else:
            left = tmp_left
            right = tmp_right
            val = tmp_val

    else:
        return r - 1, val, left, right


if __name__ == '__main__':
    '''
    an example of using this function
    At-Coder ABC 102 - D
    '''

    from operator import add
    from itertools import accumulate

    n = int(input())
    a = [int(_) for _ in input().split()]
    cul_ary = [0] + list(accumulate(a, add))

    l_split = 1
    r_split = 3
    funcs = (lambda ary, l, r: ary[r] - ary[l],
             lambda left, right: abs(left - right),
             lambda val1, val2: True if val1 < val2 else False)
    griefs = []
    for i in range(2, n - 1):
        # left
        l_split, l_diff, p, q = two_pointers(cul_ary, 0, i, l_split, *funcs)

        # right
        r_split, r_diff, r, s = two_pointers(cul_ary, i, n, r_split, *funcs)

        griefs.append(max(p, q, r, s) - min(p, q, r, s))

    print(min(griefs))


Measured memory_bytes: 28064
#include <iostream>
#include <utility>

using namespace std;

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

int lcm(int a,int b){
	int t=a;
	while(t%b!=0)t+=a;
	return t;
}

typedef pair<int,int> R;

void yakubun(R&a){
	int d = gcd(a.first,a.second);
	a.first/=d;
	a.second/=d;
}

bool cmp(R a,R b){
	double va = (double)a.first / (double)a.second;
	double vb = (double)b.first / (double)b.second;
	return va <= vb;
}

R sub(R a,R b){
	int m = lcm(a.second,b.second);
	int t = a.first*(m/a.second) - b.first*(m/b.second);
	R r = make_pair(t,m);
	yakubun(r);
	return r;
}

double val(R a){
	return (double)a.first/(double)a.second;
}

int calc = 0;
int A;
int f(R mx,R cur,int a,int n){
	int ret=0;
	if(cur.first==0)return 1;
	if(n==0)return ret;
	for(int k=1;k <= A/a && cmp(cur,make_pair(n,k)) ;k++){
		calc++;
		R r = make_pair(1,k);
		if(cmp(r,mx)&&cmp(r,cur)){
			ret+=f(r,sub(cur,r),a*k,n-1);
		}
	}
	return ret;
}

int main(){
	while(true){
		int p,q,n;
		cin >> p >> q >> A >> n;
		if(p==0&&q==0&&A==0&&n==0)return 0;
		calc=0;
		cout << f(make_pair(p,q),make_pair(p,q),1,n) << endl;
		//cerr << "calc=" << calc << endl;
	}
}

Measured memory_bytes: 868
h = Hash.new(0)
n = gets.to_i
a = gets.split.map(&:to_i)
a.each do |x|
  h[x - 1] += 1
  h[x] += 1
  h[x + 1] += 1
end
h = h.sort { |a, b| a[1] <=> b[1] }
puts h.last.last

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return abs(x-y)/gcd(x,y); }


int main() {
  lint n,m; cin >> n >> m;
  vector<lint> a(m,0),b(m,0); for(lint i=0;i<m;i++) { cin >> a[i] >> b[i]; }

  vector< vector<lint> > mat(n);
  vector<int> check(n,-1);


  for(lint i=0;i<m;i++) {
    mat[a[i]-1].push_back(b[i]-1);
    mat[b[i]-1].push_back(a[i]-1);
  }

  queue<lint> q;
  q.push(0);

  while(!q.empty()) {
    lint elem = q.front();
    q.pop();
    lint size=(int)mat[elem].size();

    for(lint i=0;i<size;i++) {
      if( check[mat[elem][i]] == -1 ) {
        check[mat[elem][i]] = elem;
        q.push(mat[elem][i]);
      }
    }
  }

  for(lint i=1;i<n;i++) {
    if(check[i] == -1) {
      cout << "No\n";
      return 0;
    }
  }

  cout << "Yes\n";
  for(lint i=1;i<n;i++) { cout << check[i]+1 << endl; }
  return 0;
}

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

int main(){

  int a=0,b=0,x,y,n;

  while(cin >> n){
    if(n==0)break;

    a=b=0;

    for(int i=0;i<n;i++){
      cin >> x >> y;

      if(x!=y){
	if(x==max(x,y)) a=a+x+y;
	if(y==max(x,y)) b=b+x+y;
      }

      else{
	a=x+a;
	b=x+b;
      }

    }
    cout << a << ' ' <<  b << endl;
  }
}

Measured memory_bytes: 1160
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
ll D;
ll ok(vl x, vl y){
    ll sq = 0;
    rep(i, D){
        sq += (x[i]-y[i])*(x[i]-y[i]);
    }
    rep(i, 1000){
        if(sq == i*i) return 1;
    }
    return 0;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N >> D;
    vvl X(N, vl(D));
    rep(i, N) rep(j, D) cin >> X[i][j];
    ll ans = 0;
    rep(i, N) FOR(j, i+1, N){
        ans += ok(X[i], X[j]);
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define repit(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define sortt(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define mkp make_pair
#define mkt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
// inline void fastio() { ios::sync_with_stdio(false), cin.tie(0); }
/******* Variable ************************************/
const int maxn = 1e6 * 50;
const int inf = 1e9 + 7;
const double pi = 3.141592653589;
/******* Function ************************************/
/******* Main ****************************************/
void Main() {
  double a, b, c;
  cin >> a >> b >> c;
  double rad = c * pi / 180.0;
  double S = 0.5 * a * b * sin(rad);
  double L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(rad));
  double h = b * sin(rad);
  cout << S << " " << L << " " << h << endl;
}

/******************************************************
  Smaile!
▕▔╲┊┊┊┊┊┊┊┊┊╱▔▏
┊╲┈╲╱▔▔▔▔▔╲╱┈╱┊
┊┊╲┈╭╮┈┈┈╭╮┈╱┊┊
┊┊╱┈╰╯┈▂┈╰╯┈╲┊┊
┊┊▏╭╮▕━┻━▏╭╮▕┊┊
┊┊╲╰╯┈╲▂╱┈╰╯╱
                    How`s it going?
                            |＼
                    　／￣＼　ヽ
                    ／　　　ヽ |_
                    ￣＼　　　　 ＼
                    ／￣　/|/| /ﾚ､ ヽ＿
                    ￣＼ Yヘ |/ヘ幺　∠
                    　＜_|(･> <･) 6) ／
                      　　 (ﾞ　_　ﾞ／＜
                      　　　＞､ーイ￣￣
                    　　／厂ヽ／￣/＼
                    　 ( ｜　(亀)(>　)▏

                            Take a rest before getting tired!
                                        　　 ●
                                        　　/⌒ヽ
                                        　 ｜ 　|/⌒ヽ(ヽ
                                        　 (｀　∥ー⌒) |
                                        　|￣||￣￣￣￣￣|
                                        　|―||―――――|
                                        　|　Ｕ　　　　　|
                                        　|￣￣￣￣￣￣￣|
                                        　|＿＿＿＿＿＿＿|
                                        　　|―――――|
                                        　　|―――――|
                                        ｗｗＷｗｗＷｗＷＷｗ

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


Measured memory_bytes: 3388
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-06-27 13:14:18 +0900
# LastModified: 2020-06-27 13:50:05 +0900
#


def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ma = [0]*n
    for _ in range(m):
        a, b = map(int, input().split())
        ma[a-1] = max(ma[a-1], h[b-1])
        ma[b-1] = max(ma[b-1], h[a-1])
#        print(ma)
    cnt = 0
    for i in range(n):
        if ma[i] < h[i]:
            cnt += 1
    print(cnt)




if __name__ == "__main__":
    main()


Measured memory_bytes: 19872
# coding: utf-8
d=sorted([int(input()) for i in range(5)],key=lambda x:(x-1)%10)
m=0
for i in range(1,5):
    d[i]=d[i] if d[i]%10==0 else int((d[i]+10)//10*10)
print(sum(d))

    


Measured memory_bytes: 2940
// use proconio::marker::Chars;
use proconio::{fastout, input};
// use std::cmp::{max, min};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        x: [i64; m]
    };

    let mut x: Vec<i64> = x;
    x.sort();

    let mut d: Vec<(i64, usize)> = vec![];

    for i in 1..m {
        d.push(((x[i - 1] - x[i]).abs(), i))
    }
    d.sort_by(|a, b| b.0.cmp(&a.0));

    let mut p = vec![0, m];

    let z = if n > m { m } else { n };
    for i in 0..z - 1 {
        p.push(d[i].1);
    }
    p.sort();

    let mut result = 0;

    // 次のやつの一個前のx - p[i]のx
    for i in 0..p.len() - 1 {
        result += x[p[i + 1] - 1] - x[p[i]];
    }

    println!("{}", result);
}


Measured memory_bytes: 6188
#include <iostream>

using namespace std;

int main(void){

  int n;
  while( cin >> n , n >= 0  ){

    int I = 0;
    int N[1000000];
    while( n >= 4 ){
      N[I++] = n % 4;
      n /= 4;
    }
    N[I++] = n;
    for( int i = I - 1 ; i >= 0 ; i-- ) cout << N[i];
    cout << endl;

  }
  return 0;
}

Measured memory_bytes: 1168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        Console.ReadLine();
        string[] arrStr = Console.ReadLine().Split(' ');
        List<int> lstInt = new List<int>();

        for(int i = 0; i < arrStr.Length; i++)
        {
            lstInt.Add(int.Parse(arrStr[i]));
        }

        int intSplit = 1;
        int intUpDownFlg = 0; // 1 ならUp, -1 ならDown

        for(int i = 1; i < lstInt.Count; i++)
        {
            switch (intUpDownFlg)
            {
                case 1:
                    if(lstInt[i - 1] > lstInt[i])
                    {
                        intSplit++;
                        intUpDownFlg = 0;
                    }
                    break;
                case -1:
                    if (lstInt[i - 1] < lstInt[i])
                    {
                        intSplit++;
                        intUpDownFlg = 0;
                    }
                    break;
                case 0:
                    if (lstInt[i - 1] > lstInt[i])
                    {
                        intUpDownFlg = -1;
                    }
                    if (lstInt[i - 1] < lstInt[i])
                    {
                        intUpDownFlg = 1;
                    }
                    break;
                default:
                    break;
            }
        }

        Console.WriteLine(intSplit.ToString());
    }
}



Measured memory_bytes: 21088
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;

int main()
{
	ll n;
	cin >> n;
	int r = -1;
	for (int i = 1;i <= sqrt(n);i++)
	{
		if (n % i == 0) r = i;
	}
	r = n / r;
	int g = 0;
	while (r > 0)
	{
		g++;
		r /= 10;
	}
	cout << g;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {

  int A,B,C,K;
  cin >> A >> B >> C >> K;
  
  if(A>=K){
    cout << K << endl;
  }
  
  else if(K>A && A+B>=K){
    cout << A << endl;
  }
  
  else{
    cout << 2 * A + B - K << endl;
  }
}
  

Measured memory_bytes: 3604
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
public class Main {
	public static void main(String[] args) throws ParseException {
	Scanner sc=new Scanner(System.in);

	String S=sc.next();
	SimpleDateFormat s=new SimpleDateFormat("yyyy/MM/dd");
	Date date1=s.parse(S);
	Date date=s.parse("2019/4/30");
	
	if((date1.compareTo(date)== -1)||(date1.compareTo(date)==0)) {
	System.out.print("Heisei");
	}
	
	else if(date1.compareTo(date)==1)  {
		System.out.print("TBD");
}
	
}
}


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

typedef struct {
	char suit, value; 
}Card;

void bubble(Card A[], int N) {
	for( int i = 0; i < N; i++ ) {
		for( int j = N - 1; j >= i + 1; j-- ) {
			if( A[j].value < A[j - 1].value ) swap(A[j], A[j - 1]);
		}
	}
}

void selection(Card A[], int N) {
	for( int i = 0; i < N; i++ ) {
		int minj = i;
		for( int j = i + 1; j < N; j++ ) {
			if(A[j].value < A[minj].value) minj = j;
		}
		swap(A[i], A[minj]);
	}
}

void print(Card A[], int N) {
	for( int i = 0; i < N; i++ ) {
		if(i) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

bool isStable(Card C1[], Card C2[], int N) {
	for( int i = 0; i < N; i++ ) {
		if( C1[i].suit != C2[i].suit) return false;
	}
	return true;
}

int main()
{
	Card C1[36], C2[36];
	int N;
	cin >> N;
	for( int i = 0; i < N; i++ ) {
		cin >> C1[i].suit >> C1[i].value;
		C2[i] = C1[i];
	}

	bubble(C1, N);
	selection(C2, N);

	print(C1, N);
	cout << "Stable" << endl;
	print(C2, N);
	if( isStable(C1, C2, N) ) cout << "Stable" << endl;
	else cout << "Not stable" << endl;

	return 0;
}


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

int main() {
  int A,B,x11,x12,x21,x22;
cin>>A>>B;
  x11=12.5*A+(A%2);
  x12=x11+12-(A%2);
  x21=10*B;
  x22=x21+9;
  int s=-1;
  for(int i=min(x11,x21);i<max(x12,x22);i++){
   if(x11<=i&&i<=x12&&x21<=i&&x22>=i){
     s=i;
     break;
   }
  }
  cout<<s<<endl;
}


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

using namespace std;

#define MAX 100

struct info{
  int g, t;
  info(int g, int t) : g(g), t(t) {}
};

int arr[MAX];
vector<info> seat;

int minite(int i){
  return 17*(i%2) + 3*(i%3) + 19;
}

void make(){
  int g = 0;
  for(int i = 0 ; i < 17 ; i++){
    seat.push_back(info(-1,-1));
  }
  vector<info> _wait;
  for(int i = 0 ; i < 570 ; i++){
    int size = _wait.size();

    if(size){
      for(int j = 0 ; j < size ; j++){
        _wait[j].t++;
      }
    }
   
    for(int j = 0 ; j < 17 ; j++){
      if(seat[j].g != -1){
        seat[j].t--;
        if(seat[j].t == 0){
          seat[j].g = seat[j].t = -1;
        }
      }
    }
 
    if(size){
      for(int j = 0 ; j < size ; j++){
        int n = _wait[j].g;
        int cnt, c;
        bool flg = false;
        if(n % 5 == 1) cnt = c = 5;
        else cnt = c = 2;
        for(int k = 0 ; k < 17 ; k++){
          if(seat[k].g == -1) cnt--;
          else cnt = c;
          if(cnt == 0){
            for(int l = k-c+1 ; l <= k ; l++){
              seat[l].g = n;
              seat[l].t = minite(n);
            }
            arr[n] = _wait[j].t;
            flg = true;
            j--;
            _wait.erase(_wait.begin());
            break;
          }
        }
        if(!flg || !_wait.size()) break;
      }
      size = _wait.size();
    }
    if(g == 100) continue;
    if(i % 5 == 0){
      int cnt = 0;
      bool flg = false;
      if(size){
        _wait.push_back(info(g,0));
        g++;
        continue;
      }
      if(g % 5 != 1){
        for(int j = 0 ; j < 17 ; j++){
          if(seat[j].g == -1) cnt++;
          else cnt = 0;
          if(cnt == 2){
            flg = true;
            for(int k = j-1 ; k <= j ; k++){
              seat[k].g = seat[k].g = g;
              seat[k].t = seat[k].t = minite(g);
            }
            arr[g] = 0;
            break;
          }
        }
      }else{
        for(int j = 0 ; j < 17 ; j++){
          if(seat[j].g == -1) cnt++;
          else cnt = 0;
          if(cnt == 5){
            flg = true;
            for(int k = j-4 ;  k <= j ; k++){
              seat[k].g = seat[k].g = g;
              seat[k].t = seat[k].t = minite(g);
            }
            arr[g] = 0;
            break;
          }
        }
      }
 
      if(!flg){
        _wait.push_back(info(g,0));
      }
      g++;
    }
  }
}

int main(){
  int N;

  make();
  while(cin >> N){
    cout << arr[N] << endl;
  }

  return 0;
}

Measured memory_bytes: 1200
//Bismillahir rahmanir rahim
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int h,w;
char str[1005][1005];
ll dp[1005][1005];
ll solve(int i,int j)
{
    if(i==h-1 && j==w-1) return 1;
    ll &ret=dp[i][j];
    if(ret!=-1) return ret;
    ret=0;
    if(j+1<w && str[i][j+1]!='#'){
        ret+=solve(i,j+1);
        ret%=mod;
    }
    if(i+1<h && str[i+1][j]!='#'){
        ret+=solve(i+1,j);
        ret%=mod;
    }
    return ret;
}
int main()
{
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++){
        scanf("%s",str[i]);
    }
    memset(dp,-1,sizeof(dp));
    ll ans=solve(0,0);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 9216
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define GYOU_MAX 256

int main(void) {
	int X;
	scanf("%d", &X);
	int flag;
	for (int i = 2; ; i++) {
		flag = 0;
		for (int j = 2; j <i; j++) {
			if (i%j == 0) {
				flag = 1;
				break;
			}
		}
		if (flag == 0 && i >= X) {
			printf("%d", i);
			break;
		}
	}

	return 0;


}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define reg register
#define mod 1000000007
using namespace std;
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
int ksm(int u, int v){
	int s = 1;
	for(int i = v; i; i >>= 1){
		if(i & 1) s = 1ll * s * u % mod;
		u = 1ll * u * u % mod;
	}
	return s;
}
int n, m, f[5001][5001], inv2, ans, a[5001], g[5001][5001];
int main()
{
	n = read(); m = read(); inv2 = 500000004;
	for(int i = 1; i <= n; i++) a[i] = read();
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++) f[i][j] = (a[i] > a[j]);
	
	for(int i = 1; i <= m; i++){
		int x = read(), y = read();
		for(int j = 1; j <= n; j++) {
			if(j == x || j == y) continue;
			g[x][j] = 1ll * (f[x][j] + f[y][j]) % mod * inv2 % mod;		
			g[j][x] = 1ll * (f[j][x] + f[j][y]) % mod * inv2 % mod;
			g[y][j] = 1ll * (f[x][j] + f[y][j]) % mod * inv2 % mod;
			g[j][y] = 1ll * (f[j][y] + f[j][x]) % mod * inv2 % mod;
		}
		for(int j = 1; j <= n; j++) {
			if(j == x || j == y) continue;
			f[x][j] = g[x][j]; f[j][x] = g[j][x];
			f[y][j] = g[y][j]; f[j][y] = g[j][y];
		}
		f[x][y] = 1ll * (f[x][y] + f[y][x]) % mod * inv2 % mod; f[y][x] = f[x][y];
	
	}
	for(int i = 1; i <= n; i++)
		for(int j = i + 1; j <= n; j++)
			ans = (ans + f[i][j]) % mod;
	ans = 1ll * ans * ksm(2, m) % mod; cout << ans << endl;
	return 0;
}

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

using namespace std;
#define ll long long int

int main() {
    ll r,d,x;
    cin >> r >> d >> x;
    ll sum =0;
    for(int i=1;i<=10;i++){
        sum = x*r - d;
        x=sum;
        cout << sum<<"\n";
        
    }
    
    //cout<<"Sum of x+y = " << z;
}

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

const int MAX_N = 20002;
int N;

int P[MAX_N];

ll A[MAX_N];
ll B[MAX_N];

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

    cin >> N;

    for (int i = 0; i < N; ++i) {
        cin >> P[i];
        P[i]--;
    }

    for (int i = 0; i < N; ++i) {
        A[i] = 20000 * i + 1;
        B[i] = 20000 * (N - 1 - i) + 1;
    }

    for (int i = 0; i < N; ++i) {
        B[P[i]] += i;
    }


    for (int i = 0; i < N; ++i) {
        cout << A[i];
        if (i != N-1) {
            cout << " ";
        }
    }
    cout << endl;

    for (int i = 0; i < N; ++i) {
        cout << B[i];
        if (i != N-1) {
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    vector<char> v;
    string a; cin >> a;
    int n = a.size();

    for(int i=0; i<n; i++)
        if(a[i]=='B' && v.size()) v.pop_back();
        else if(a[i] != 'B') v.push_back(a[i]);

    for(auto it:v) cout << it;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<vector>
#include<deque>

using namespace std;
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
inline void reader(int& x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; x = x * 10 + k - '0'; }if (m) x = -x; }
inline void writer(int x, char c) { int s = 0, m = 0; char f[7]; if (x<0)m = 1, x = -x; while (x)f[s++] = x % 10, x /= 10; if (!s)f[s++] = 0; if (m)mypc('-'); while (s--)mypc(f[s] + '0'); mypc(c); }
template<class T> void writerLn(T x) { writer(x, '\n'); }
#define rep(i,n)for(int i=0;i<n;i++)
vector<int>E[100000];
int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;
char b[200000], ok[100000];
deque<int>que;

void bfs(int u, int t) {
	que.emplace_back(u);
	while (!que.empty()) {
		int p = que.front(); que.pop_front();
		for (int v : E[p]) {
			if (t) {
				if (d[v] > d[p] && !ok[v]) {
					ok[v] = 1; cnt++; que.emplace_back(v);
				}
			}
			else if (!d[v]) {
				d[v] = d[p] + 1; que.emplace_back(v);
			}
		}
	}
}
int main() {
	ok[0] = d[0] = 1;
	int n, m, q; reader(n); reader(m); reader(q);
	rep(i, m) {
		reader(u[i]); reader(v[i]);
		u[i]--; v[i]--;
		E[u[i]].emplace_back(v[i]); E[v[i]].emplace_back(u[i]);
	}
	bfs(0, 0);
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		reader(r[i]); r[i]--;
		b[r[i]] = 1;
	}
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] > d[u[i]]) {
				E[u[i]].emplace_back(v[i]);
			}
		}
	}
	bfs(0, 1);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] > d[u[r[i]]] && !ok[v[r[i]]]) {
			E[u[r[i]]].emplace_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = 1;
				bfs(v[r[i]], 1);
			}
		}
	}
	rep(i, q)writerLn(ans[i]);
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    map<string, int> m;
    rep(i, n) {
        m[s[i]]++;
    }
    int key_max = 0;
    for (auto p : m) {
        key_max = max(key_max, p.second);
    }
    for (auto p : m) {
        if (p.second == key_max)
            out(p.first);
    }
    return 0;
}


Measured memory_bytes: 26752
#include <stdio.h>
int h, n;
int a[1000], b[1000];
int d[10001];
int main() {
	scanf("%d%d", &h, &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", a + i, b + i);
	}
	for (int i = 1; i <= h; i++) {
		d[i] = h * 10000;
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 0; j < n; j++) {
			if (i - a[j] < 0) {
				if (d[i] > b[j])d[i] = b[j];
			}
			else {
				if (d[i] > d[i - a[j]] + b[j]) {
					d[i] = d[i - a[j]] + b[j];
				}
			}
		}
	}
	printf("%d\n", d[h]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i = 0LL; i < (long long)n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

bool check[220000];

int main() {
  ll n, k;
  cin >> n >> k;
  vll a(n);
  rep(i,n) {
    ll b;
    cin >> b;
    b--;
    a[i] = b;
  }
  vll v;
  ll c = 0LL;
  v.push_back(0LL);
  rep(i,n) {
    v.push_back(a[c]);
    c = a[c];
  }
  rep(i,220000) check[i] = false;
  int key;
  rep(i,v.size()) {
    if(check[v[i]]) {
      key = v[i];
      break;
    }
    check[v[i]] = true;
  }
  vi nv;
  ll ok = 0LL;
  ll cnt = 0LL;
  rep(i,v.size()) {
    if(v[i]==key) ok++;
    if(ok==0LL) cnt++;
    if(ok==1LL) nv.push_back(v[i]);
  }
  ll m = nv.size();
  if(cnt>=k+1) {
    cout << v[k]+1 << endl;
    return 0;
  }
  k -= cnt;
  cout << nv[k%m]+1 << endl;
  return 0;
}

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

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

void Main()
{
  ll K;
  cin >> K;
  ll sum = 0;
    for(ll a = 1; a <= K; a++) {
        for (ll b = 1; b <= K; b++) {
          for (ll c = 1; c <= K; c++) {
            ll res = GCD(a,b);
            res = GCD(res,c);
            sum += res;
          }
        }
    }
  cout << sum << endl;
}

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

Measured memory_bytes: 3660
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define mo 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

ll comb(ll N_, ll C_) {
	const int NUM_ = 400001;
	static ll fact[400002], factr[400002], inv[400002];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%mo, factr[i] = factr[i - 1] * inv[i] % mo;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % mo*factr[N_ - C_] % mo;
}
ll modpow(ll a, ll n = mo - 2) {
	ll r = 1;
	while (n) r = r * ((n % 2) ? a : 1) % mo, a = a * a%mo, n >>= 1;
	return r;
}

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

	int N, M; cin >> N >> M;
	int l = 2;
	VI so, shi;
	while (l*l <= M) {
		int cnt = 0;
		while (M%l == 0) {
			cnt++;
			M /= l;
		}
		if (cnt > 0) {
			shi.push_back(cnt);
			so.push_back(l);
		}
		l++;
	}
	if (M != 1) {
		shi.push_back(1);
		so.push_back(l);
	}
	int ans = 1;

	REP(i, so.size()) {
		ans *= comb(N + shi[i] - 1, shi[i]);
		ans %= mod;
	}






	cout << ans << endl;

	return 0;
}



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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll n, m, a, b, result = 0, ch[55];
bool hen[55][55];
void dfs(int p) {
  if(ch[p] != 1) return;
  int i;
  for(i = 1; !hen[p][i]; i++);
  result++;
  hen[p][i] = hen[i][p] = false;
  ch[p]--; ch[i]--;
  dfs(i);
}
signed main() {
  cin >> n >> m;
  rep(i, m) {
    cin >> a >> b;
    hen[a][b] = hen[b][a] = true;
    ch[a]++; ch[b]++;
  }
  FOR(i, 1, n + 1) dfs(i);
  cout << result << endl;
}

Measured memory_bytes: 256
import heapq
N = int(input())
a_ls = []
q_ls = []
_max = 0
_second = 0
_max_dupli = False
for i in range(N):
    a = int(input())
    a_ls.append(a)
    heapq.heappush(q_ls, -a)
_max = heapq.heappop(q_ls)
_second = heapq.heappop(q_ls)
_max = -_max
_second = -_second
for i in range(N):
    if a_ls[i] == _max:
        print(_second)
    else:
        print(_max)

Measured memory_bytes: 20620
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int x, t;
    cin >> x >> t;
    cout << ( x < t ? 0 : x - t ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
using ll = long long;



int main() {
	string s;
	cin >> s;
	int sum = 0;
	for (int i = 0; i < 4; i++) {
		if (s[i] == '+') sum++;
		else sum--;
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
k = [int(i) for i in input().split()]
M = 0
for i in range(n-1):
    for l in range(n-i-1):

        if k[n-2-l] > k[n-1-l]:
            v = k[n-1-l]
            k[n - 1 - l]=k[n-2-l]
            k[n - 2 - l]=v
            M+=1
        else:
            pass

print(' '.join(map(str, k)))
print(M)

Measured memory_bytes: 7720
<?php
  
fscanf(STDIN,"%d %d %d",$N,$A,$B);

$count = 0;

for($i=1;$i<=$N;$i++){
  $sum = sum_each_place($i);
  if($A<=$sum && $sum <= $B){
    $count += $i;
  }
}

echo $count;

function sum_each_place($number){
  $string = (string) $number;
  $sum = 0;
  for($i=0;$i<strlen($string);$i++){
    $sum += (int) $string[$i];
  }
  return $sum;
}


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

using namespace std;

string s[100];

int n, l;

int main(){
	cin >> n >> l;
	for(int i = 0; i < n; ++i){
		cin >> s[i];
		}
	sort(s, s + n);
	for(int i = 0; i < n; ++i){
		cout << s[i];
		}
	return 0;
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const int MAX = 1000000;
int table[MAX + 1], counter[MAX + 1];
int main() {
    for (int i = 2; i <= 1000; i++) {
        if (table[i] != 0) continue;
        for (int k = i; k <= MAX; k += i) {
            if (table[k] == 0) table[k] = i;
        }
    }
    for (int i = 2; i <= MAX; i++) if (table[i] == 0) {
        table[i] = i;
    }
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    for (int a : A) {
        int b = a;
        while (b != 1) {
            int p = table[b];
            counter[p]++;
            while (table[b] == p) b /= p;
        }
    }
    int maxval = 0;
    for (int i = 2; i <= MAX; i++) {
        maxval = max(maxval, counter[i]);
    }
    if (maxval <= 1) {
        cout << "pairwise coprime\n";
    } else if (maxval != N) {
        cout << "setwise coprime\n";
    } else {
        cout << "not coprime\n";
    }
    return 0;
}


Measured memory_bytes: 14760
#include <stdio.h>

int main() {
  unsigned long long a, b, result;
  scanf("%llu%llu", &a, &b);
  if (a % 2 == 0) {
    unsigned long long t = b - a + 1;
    if (t % 2 == 0) {
      printf("%llu", (t / 2) % 2);
    } else {
      t--;
      t = (t / 2) % 2;
      printf("%llu", t ^ b);
    }
  } else {
    unsigned long long a_ = a;
    a++;
    unsigned long long t = b - a + 1;
    if (t % 2 == 0) {
      printf("%llu", ((t / 2) % 2) ^ a_);
    } else {
      t--;
      t = (t / 2) % 2;
      printf("%llu", t ^ b ^ a_);
    }
  }
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys

def query(i, memo={}):
    if i in memo:
        return memo[i]
    print(i)
    sys.stdout.flush()
    s = input()
    if s == 'Male':
        memo[i] = 0
    elif s == 'Female':
        memo[i] = 1
    else:
        sys.exit()
    return memo[i]

n = int(input())
l, r = -1, n
while True:
    m = (l + r) // 2
    if query(0) ^ query(m) == m & 1:
        l = m
    else:
        r = m


Measured memory_bytes: 3660
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = (a + b) % 24;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21716
def dfs(cnt,a,b,c):
    if cnt == N:
        _sum = abs(A-a) + abs(B-b) + abs(C-c) - 30
        return _sum if min(a,b,c) > 0 else 10**9
    ret0 = dfs(cnt+1, a, b, c)
    ret1 = dfs(cnt+1, a+l[cnt] , b, c) + 10
    ret2 = dfs(cnt+1, a, b+l[cnt], c) + 10
    ret3 = dfs(cnt+1, a, b, c+l[cnt]) + 10
    return min(ret0,ret1,ret2,ret3) 
    
N,A,B,C,*l = map(int,open(0).read().split())
print(dfs(0,0,0,0))

Measured memory_bytes: 3188
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200010

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll N;

int main(){
	string str;
	cin>>str;
	int ans=0,hoge;
	for(int i=0;i<str.size();i++){
		ans+=str[i]-'0';
	}
	hoge=9*(str.size()-1)+str[0]-'0'-1;
	cout<<max(ans,hoge)<<endl;
}

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

import sys

n,m = [ int(x) for x in sys.stdin.readline().split() ]

li, ri = [0] * m, [0] * m
for i in range(m):
    li[i], ri[i] = [ int(x) for x in sys.stdin.readline().split() ]
#    
imin=1
imax=n
for i in range(m):
    if li[i]>imin: imin=li[i]
    if ri[i]<imax: imax=ri[i]
#
if imax>=imin:
    print( imax-imin+1 )
else:
    print( 0 )


Measured memory_bytes: 10868
const line = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

const csort = (arr) => {
    const k = arr.reduce((acc, x) => acc < x ? x : acc);
    const c = [...Array(k+1)].map(_ => 0);
    const result = [...Array(arr.length)];
    for (let i = 0; i < arr.length; i++) {
        c[arr[i]]++;
    }

    for (let i = 1; i <= k; i++) {
        c[i] += c[i-1];
    }
    
    for (let i = arr.length-1; i >= 0; i--) {
        result[c[arr[i]]-1] = arr[i];
        c[arr[i]]--;
    }

    return result;
};

const data = line[1].split(' ').map(Number);
console.log(csort(data).join(' '));



Measured memory_bytes: 301584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	public static void main(String args[]) {

		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";

		try {
			while(true) {
				str=bfr.readLine();
				if(str=="") {
					System.exit(0);
				}
				int input=Integer.parseInt(str);
				int kurai=0;
				int ichi_kazu=0;
				int tmp=0;
				for(int i=0; i<31; i++) {
					tmp=input>>i;
					if(tmp%2==1) {
						kurai=i+1;
						ichi_kazu++;
					}
				}

				System.out.println(Math.max(kurai-1,ichi_kazu));

			}
		} catch (IOException e) {
			System.exit(0);
		}
		catch(NumberFormatException e) {
			System.exit(0);
		}

		catch(NullPointerException e) {
			System.exit(0);
		}
	}
}



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

int main(){
    int n,cnt,tmp,z;
    vector<int> v;
    cin>>n;
    v.resize(n);
    for(int i=0; i<n; i++){
        cin>>v[i];
    }
    cnt=0;
    tmp=0;
    z=1;
    for(int i=0; i<n; i++){
        if(v[i]==z){
            //cout<<"z:"<<z<<" tmp:"<<tmp<<endl;
            z++;
            cnt+=tmp;
            tmp=0;
        }else{
            tmp++;
        }
    }
    cnt+=tmp;
    //cout<<tmp<<endl;
    if(z==1){
        cout<<-1<<endl;
    }else{
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
p,q= input().split()
a,b =(int(p), int(q))
ans_list = []
for i in range(a):
    a_list = input().split()
    ans_list.append(a_list)
ans = 0
for i in range(b+1):
    count = 0
    for j in range(a):
        if str(i)in ans_list[j][1:]:
            count +=1
    if count == a:
        ans +=1
        
print(ans)
        

Measured memory_bytes: 3060
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
can=False
for Z in range(X+1,Y+1):
    if max(x)<Z<=min(y):
        can=True
if can:
    print("No War")
else:
    print("War")

Measured memory_bytes: 38384
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
    ll H;
    cin >> H;
    ll ans = 0;
    ll cnt = 1;
    while(H!=1){
        H /= 2;        
        ans += cnt;
        cnt *= 2;
    }
    ans += cnt;
    cout << ans << endl;
}


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

int main() {
#ifdef LOCAL_DEFINE
	//freopen("data.in", "rt", stdin);
	//freopen("data.out", "w", stdout);
	long long _begin_time = clock();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << (x2 - y2 + y1) << ' ' << (y2 + x2 - x1) << ' ';
	cout << (x1 - y2 + y1) << ' ' << (y1 + x2 - x1) << '\n';

#ifdef LOCAL_DEFINE
	long long _end_time = clock();
	cerr << "time = " << _end_time - _begin_time << " ms\n";
#endif
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

int main() {
    long long A;
    string B;
    cin >> A >> B;
    long long seisuubu = B[0]-'0';
    long long shosuubu = (B[2]-'0') * 10 + (B[3]-'0');
    cout << A * seisuubu + A * shosuubu / 100 << endl;
}

















Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,n,i = 0;
  cin >> a >> b >> c >> n;
  
  while(a >= b){
    if(i == n){
  cout << "No";
  return 0;
    }
    b = b * 2;
    i++;
  }
  while(b >= c){
    if(i == n){
  cout << "No";
  return 0;
    }
    c = c * 2;
    i++;
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	// Code for D - .. (Double Dots)
	n := nextInt()
	m := nextInt()

	path := map[int][]int{}
	for i := 1; i <= n; i++ {
		path[i] = make([]int, 0)
	}

	for i := 0; i < m; i++ {
		x := nextInt()
		y := nextInt()
		// path[a[i]] = append(path[a[i]], b[i])
		// path[b[i]] = append(path[b[i]], a[i])
		path[x] = append(path[x], y)
		path[y] = append(path[y], x)
	}

	mem := make([]int, n+1)
	q := []int{1}

	for len(q) > 0 {
		base := q[0]
		q = q[1:]
		rooms := path[base]

		for _, r := range rooms {
			if mem[r] == 0 {
				q = append(q, r)
				mem[r] = base
			}
		}
	}

	fmt.Println("Yes")
	for _, v := range mem[2:] {
		fmt.Println(v)
	}
}

Measured memory_bytes: 22548
#include<cstdio>
#include<vector>
#include<functional>
#include<algorithm>
using namespace std;
using ull = unsigned long long;

int main(){
	unsigned N;
	long unsigned M;
	scanf("%u %lu", &N, &M);
	ull ans = 0;
	vector<unsigned> discount;
	for (int i = 0; i < N; ++i){
		unsigned A;
		scanf("%u", &A);
		ans += A;
		while(A > 0){
			discount.push_back(A - (A >> 1));
			A >>= 1;
		}
	}
	unsigned use = min(M, discount.size());
	nth_element(discount.begin(), discount.begin() + use - 1, discount.end(), greater<unsigned>());
	for (int i = 0; i < use; ++i){
		ans -= discount[i];
	}
	printf("%llu\n", ans);
	return 0;
}

Measured memory_bytes: 18664