akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
int dp[100010][13];
int modhako[100010];
int main(){
  string s;
  cin >> s;
  int a=1;
  rep(i,0,100010){
    modhako[i] =a; 
    a *= 10;
    a = a % 13;
  }
  int n = s.length();
  if(s[n-1] == '?'){
    rep(i,0,10){
      dp[0][i] = 1;
    }
  }else{
    dp[0][s[n-1] - '0'] = 1;
  }
  rep(i,1,n){
    if(s[n-i-1] == '?'){
      rep(j,0,13){
        rep(k,0,10){
          int a = (j + k * modhako[i]) % 13;
          dp[i][a] += dp[i-1][j];
          dp[i][a] = dp[i][a] % MOD;
        }
      }
    }else{
      rep(j,0,13){
        int a = (j + (s[n-i-1] - '0') * modhako[i]) % 13;
        dp[i][a] += dp[i-1][j];
          dp[i][a] = dp[i][a] % MOD;
      }
    }
  }
  cout << dp[n-1][5] << endl;
  return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9 + 7;
const ld PI = 3.141592653589793;

main(){

	ios_base::sync_with_stdio(false);
	

    ll a,b,x;
    cin>>a>>b>>x;
    int cnt=10;
    while (cnt--) {
    	x=a*x-b;
    	cout<<x<<endl;
    }
    return 0; 
    }

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

const ll FAC_MAX = 510000;

ll fac[FAC_MAX]; //階乗
ll finv[FAC_MAX]; //階乗の逆元

//繰り返し二乗法
//x^n mod
ll mod_pow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 1) { //奇数
        return mod_pow(x, n - 1) * x % MOD; //偶数の再帰にできるように変形
    } else { //偶数
        ll t = mod_pow(x, n / 2); //半分のものを求めて、2乗する
        return t * t % MOD;
    }
}

void init() {
    fac[0] = 1;
    for (ll i = 1; i <= FAC_MAX; ++i) {
        fac[i] = (fac[i - 1] * i) % MOD; //階乗を計算
    }

    for (ll i = 0; i <= FAC_MAX; ++i) {
        finv[i] = mod_pow(fac[i], MOD - 2); //フェルマーの小定理を使い、階乗の逆元を計算
    }
}

//nCr
ll comb(ll n, ll r) {
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return (((fac[n] * finv[r]) % MOD) * finv[n - r]) % MOD;
}

int main() {

    ll n, a, b; cin >> n >> a >> b;

    init();

    if (n == 2) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = (mod_pow(2, n) % MOD - 1) % MOD;

    ll c_a = 1;
    for (ll i = 0; i < a; ++i) {
        c_a = (c_a * (n - i)) % MOD;
    }

    c_a = (c_a * finv[a]) % MOD;

    ll c_b = 1;
    for (ll i = 0; i < b; ++i) {
        c_b = (c_b * (n - i)) % MOD;
    }

    c_b = (c_b * finv[b]) % MOD;

    ll t = (c_a + c_b) % MOD;

    if (ans < t) {
        ans += MOD;
    }
    ans = (ans - t) % MOD;

    cout << ans << endl;
}

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

int main(){
    map<string, int> cards;
    
    int n; cin>>n;
    string s;
    rep(i,n){
        cin>>s;
        cards[s]++;
    }
    int m; cin>>m;
    rep(i,m){
        cin>>s;
        cards[s]--;
    }
    int ans = 0;
    
    for(auto c: cards){
        ans = max(c.second, ans);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def merge_jibun(A, left, mid, right):
    L = A[left:mid] + [1000000]
    R = A[mid:right] + [1000000]
    # L.append(1000000)
    # R.append(1000000)

    i = 0
    j = 0
    global count
    
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def merge_hoka(A, left, mid, right):
    global count
    inf = 10 ** 9
    L = A[left:mid] + [inf]
    R = A[mid:right] + [inf]
 
    i = 0
    j = 0
    for k in range(left, right):
        count += 1
        # print(L)
        # print(R)
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        # merge_jibun(A, left, mid, right)
        merge_hoka(A, left, mid, right)

n = int(input())
A = list(map(int, input().split()))
count = 0
mergeSort(A, 0, n)

print(' '.join(list(map(str, A))))
print(count)


Measured memory_bytes: 66728
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int sum = 0;
        for(int i=0; i<n.length(); i++) {
            sum += Integer.parseInt(String.valueOf(n.charAt(i)));
        }
        String ans = "";
        if (sum % 9 == 0) ans = "Yes";
        else ans = "No";

        System.out.println(ans);
    }
}

Measured memory_bytes: 49904
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)

	g := make([][]int, n)
	for i := 0; i < n-1; i++ {
		u, v := scanInt()-1, scanInt()-1
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}

	ans := make([]int, n)
	dp := make([]int, n)
	for i := 0; i < n; i++ {
		dp[i] = 1e10
	}
	var dfs func(v, p int)
	dfs = func(v, p int) {
		ans[v] = sort.Search(n, func(idx int) bool { return 1e10 <= dp[idx] })
		for _, u := range g[v] {
			if u == p {
				continue
			}
			idx := sort.Search(n, func(idx int) bool { return a[u] <= dp[idx] })
			t := dp[idx]
			dp[idx] = a[u]
			dfs(u, v)
			dp[idx] = t
		}
	}
	dp[0] = a[0]
	dfs(0, 0)

	for i := 0; i < n; i++ {
		fmt.Fprintln(wr, ans[i])
	}
}


Measured memory_bytes: 123016
#include<bits/stdc++.h>
using namespace std;
const long double EPS = 1e-14;
int main()
{
   long double a,b,k,c=0,x,y;
    cin>>a>>b>>c;
    if(sqrt(a)+sqrt(b)+EPS<sqrt(c))
        cout<<"Yes\n";
    else
        cout<<"No\n";

}


Measured memory_bytes: 3792
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto kab = readln.split.to!(long[]);
    auto K =kab[0];
    auto A = kab[1];
    auto B = kab[2];

    if (A+2 > B) {
        writeln(K+1);
        return;
    } else if (K == 1) {
        writeln(2);
        return;
    } else {
        auto K2 = K - A + 1;
        if (K2 < 2) {
            writeln(K + 1);
            return;
        }
        auto b = B;
        K2 -= 2;
        b += (K2 / 2) * (B - A);
        b += (K2 % 2);
        writeln(b);
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,a,i,sum=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		a=(int)(log10(i))+1;
		if(a%2==1)
			sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>

using namespace std;

template<typename T, typename S>
istream& operator >> (istream& is, pair<T, S>& p) {
    is >> p.first >> p.second;
    return is;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& v) {
    for (auto& x : v) {
        is >> x;
    }
    return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    for (auto& x : v) {
        os << x << " ";
    }
    os << "\n";
    return os;
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    sort(a.rbegin(), a.rend());
    int d = a[0];
    map<int, int> acnt;
    for (auto x : a) acnt[x]++;
    bool good = true;
    for (int i = d; 2 * i >= d; --i) {
        // cout << i << " " << acnt[i] << " " << cur_s << endl;
        if (2 * i == d) {
            good &= (acnt[i] == 1);
        } else if (2 * i - 1 == d) {
            good &= (acnt[i] == 2);
            // if (cur_s > 2) good = false;
        } else {
            good &= (acnt[i] >= 2);
            // if (i != d && acnt[i] > acnt[i - 1]) {
            //    cur_s += 1;
            // }
        }
    }
    for (int i = d / 2; i >= 0; --i) {
        if (i * 2 < d) {
            good &= (acnt[i] == 0);
        }
    }
    cout << (good ? "Possible" : "Impossible");
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 10005;
const int mod = 1e9 + 7;

unordered_map<ll,int>mp;
vector<ll>p2;
int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(0);
    ll n;
    for (ll i = 1 ; i <= 100000 ; i++) {
        mp[i * i] = i;
    }
    p2.pb(1);
    p2.pb(1);
    for (ll i = 2 ; i <= 2500 ; i++) {
        p2.pb(i * i);
    }
    while (cin >> n) {
        int ans = n;
        map<pair<ll,ll>,int>cnt;
        while(n--) {
            ll x;
            cin >> x;
            ll one = 1, two = 1;
            for (int i = 2 ; p2[i] * i <= x ; i++) {
                //cout << p2[i] <<' '<<i<<endl;
                if (x % i) {
                    continue;
                }
                int cur = 0;
                while (x % i == 0) {
                    x /= i;
                    cur++;
                }
                cur %= 3;
                if (cur == 1) {
                    one *= i;
                }
                else if (cur == 2){
                    two *= i;
                }
            }
            if (mp.count(x)) {
                two *= mp[x];
            }
            else {
                one *= x;
            }
            //cout << one <<' '<<two<<'\n';
            cnt[{one,two}]++;
            //cout << one <<' '<<two << '\n';
        }
        
        //cnt[{1,1}] = min(cnt[{1,1}],1);
        for (auto i:cnt) {
            if (i.F.F == 1 && i.F.S == 1) {
                ans-=i.S-1;
            }
            else if (i.F.F < i.F.S&& cnt.count({i.F.S,i.F.F})) {
                ans-= min(cnt[{i.F.S,i.F.F}],cnt[{i.F.F,i.F.S}]);
            }
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 10788
N, M = map(int, input().split())
Es = [[] for _ in range(N)]
for n in range(M):
    a, b = map(int, input().split())
    Es[a - 1].append(b - 1)
    Es[b - 1].append(a - 1)

for e in Es:
    print(len(e))


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


#define ll long long
#define FOR(x,y,z) for(ll x = y; x < (ll)z; x++)

using namespace std;

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

    string s;
    cin >> s;
    string newS;
    cin >> newS;
    newS.pop_back();
    if(s == newS){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

Measured memory_bytes: 3596
#include <stdio.h>
int main(){

  int a, b;
  scanf("%d%d", &a, &b);
  if ( a < b ) {
    printf("a < b\n");
  } else if( a > b ){
    printf("a > b\n");
  } else if( a == b ){
    printf("a == b\n");
  }
  return 0;

}



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);
  for(int i = 0;i < N;++i) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int T = 0;
  for(int i = 0;i < M;++i) {
    T = T + vec.at(i);
  }
  cout << T << endl;
}

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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

int main(){
    ll n ,k;
    cin >> n;
    vpi vec;
    int cur;
    for (int i = 0; i <n ; ++i) {
        cin>>cur;
        vec.pb({cur,i+1});
    }
    sort(BEND(vec));
    for (int j = 0; j <n ; ++j) {
        cout<<vec[j].se<<" ";
    }
    return 0;
}


Measured memory_bytes: 1780
import numpy as np

n,m = map(int,input().split())
out = []
for i in range(n):
    s = list(input())
    if any(c=="#" for c in s):
        out.append(s)

out = np.array(out).T
# print(out)
out2=[]
for i in range(m):
    if any(c=="#" for c in out[i]):
        out2.append(out[i])

out2=np.array(out2).T
# print(out2)

for line in out2:
    for i in range(len(line)-1):
        print(line[i],end="")
    print(line[-1])





Measured memory_bytes: 14824
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = if n <= m then  List.range n `To m else []
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 1_000_000_007
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'
let itoa n = Char.chr (n + Char.code '0')

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (n,m) = scan "%d %d" Tuple2.make

let () =
  Printf.printf "%d\n" @@ (n*(pred n)/2) + (m*(pred m)/2)


Measured memory_bytes: 5488
#include <iostream>
#include <vector>
#include <cmath>
#include <map>

typedef long long int ll;

using namespace std;
string N;
int K;

ll e(string strN, int k)
{
  int i,j;
  int top;
  int second=0, si=0;
  int third=0, ti=0;
  int keta;
  ll ret = 0;

  top = strN[0] - '0';
  keta = strN.length();
  if (keta<k) return 0;
  for (i=1; i<keta; i++) {
    if (strN[i]-'0'>0) {
      second = strN[i] - '0';
      si = keta-i;
      i++;
      break;
    }
  }
  for (; i<keta; i++) {
    if (strN[i]-'0'>0) {
      third = strN[i] - '0';
      ti = keta-i;
      break;
    }
  }

//printf("top=%d, keta=%d, second=%d, si=%d, third=%d, ti=%d\n", top, keta, second, si, third, ti);

  switch(k) {
  case 1:
    ret = 9LL*(keta-1)+top;
    break;
  case 2:
    ret = (ll)9*9*(keta-1)*(keta-2)/2;  //keta-1���܂ł̕��� (keta-1C2)*9*9
    ret += (ll)(top-1)*9*(keta-1);      //�ŏ�ʌ��̍ő�l-1��keta-1�܂ł̑g�ݍ��킹
    if (second) {
      ret += (ll)9*(si-1)+second;       //�ŏ�ʌ��̍ő�l��si�܂ł̑g�ݍ��킹
    }
    break;
  case 3:
    ret = (ll)9*9*9*(keta-1)*(keta-2)*(keta-3)/6;  //keta-1���܂ł̕��� (keta-1C3)*9*9*9
    ret += (ll)(top-1)*9*9*(keta-1)*(keta-2)/2;    //�ŏ�ʌ��̍ő�l-1��keta-1�܂ł̑g�ݍ��킹
    if (second) {
      ret += (ll)9*9*(si-1)*(si-2)/2;
      ret += (ll)(second-1)*9*(si-1);              //2�Ԗڂ̌��̍ő�l-1��si�܂ł̑g�ݍ��킹
    }
    if (third)
      ret += (ll)9*(ti-1)+third;                   //2�Ԗڂ̌��̍ő�l��ti�܂ł̑g�ݍ��킹
    break;
  }

  return ret;
}

bool ncount(int j, int n) {
  int nc=0;
  while(j>0) {
    if (j%10) nc++;
    if (nc>n) return false;
    j/=10;
  }
  return nc==K;
}
int ho() {
  int n=stoi(N);
  int ret=0;

  for (int i=1; i<=n; i++) {
    if (ncount(i, n)) {
//      printf("%d\n", i);
      ret++;
    }
  }
  return ret;
}

main() {

  cin >> N;
  cin >> K;

  printf("%lld\n", e(N, K));
  return 0;
}


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

using namespace std;

int main() {
	int a, b;
	double a_d, b_d;
	cin >> a >> b;
	a_d = static_cast<double>(a);
	b_d = static_cast<double>(b);
	printf("%d %d %.5f\n", (a / b), (a % b), (a_d / b_d));
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int ans[2005];
int n, x, y;

int main() {
  int n,x,y;
  cin >> n >> x >> y;
  x--; y--;
  Graph g(n);
  vector<int> ans(n+1,0);
  REP(i,n-1) {
    g[i].push_back(i+1);
    g[i+1].push_back(i);
  }
  g[x].push_back(y);
  g[y].push_back(x);

  REP(i,n) {
    vector<int> d(n, INF);
    queue<int> q;
    d[i] = 0;
    q.push(i);
    while(!q.empty()) {
      int v = q.front(); q.pop();
      for(auto nv : g[v]) {
        if (d[nv] != INF) continue;
        d[nv] = d[v]+1;
        q.push(nv);
      }
    }
    REP(j,n) if (d[j] != INF) ans[d[j]]++;
  }
  for (int i = 1; i < n; i++)  cout << ans[i]/2 << endl;
  return 0;
}

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

int main() {
    int n,temp;
    int ans=0;
    std::vector<int> v;
    std::cin>>n;
    for(int i=0;i<n;i++) {
        std::cin >> temp;
        v.push_back(temp);
    }
    for(int i=0;i<n;i++){
        int f=0;
        for(int j=0;j<i;j++){
            if(v[i]>=v[j]){
                continue;
            }
            else{
                f++;
            }
        }
        if(f==0){
            ans = ans+1;
        }
    }
    std::cout<<ans<<std::endl;
    return 0;
}

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

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

Measured memory_bytes: 256
# Problem: https://atcoder.jp/contests/agc012/tasks/agc012_a
# Python 3rd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def solver(groups, eachScore):
    result = 0
    sortEachScore= sorted(eachScore)
    for userNo in range(groups, groups*3, +2):
        result = result + sortEachScore[userNo]
    return result
if __name__ == "__main__":
    N = II()
    AI = LI()
    print("{}".format(solver(N, AI)))


Measured memory_bytes: 37084
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  ll N, K;
  cin >> N >> K;
  ll q = N / K;
  cout << min(N-K*q, K*(q+1)-N) << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.buffer.readline
    X, Y, A, B, C = (int(i) for i in input().split())
    P = [int(i) for i in input().split()]
    Q = [int(i) for i in input().split()]
    R = [int(i) for i in input().split()]
    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.extend(P[:X])
    R.extend(Q[:Y])
    R.sort(reverse=True)
    print(sum(R[:X+Y]))


if __name__ == '__main__':
    main()


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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

void solve() {
  string s;
  cin >> s;
  int q;
  cin >> q;
  int rev = 0;
  deque<char> deq;
  for (int i = 0; i < s.size(); i++) deq.push_back(s[i]);
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      rev ^= 1;
    } else {
      int f;
      char c;
      cin >> f >> c;
      f--;
      if ((rev ^ f) == 0)
        deq.push_front(c);
      else
        deq.push_back(c);
    }
  }
  if (rev) reverse(all(deq));
  for (int i = 0; i < deq.size(); i++) cout << deq[i];
  cout << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    
    if ((a + b) % 2 == 0) {
        cout << (a + b) / 2 << endl;
    } else {
        cout << (a + b) / 2 + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int dfs(int now, int high, int count,  int sum, vector<pair<int, int>> in, int g) {
    if (now == in.size()) {
        if (sum >= g) return count;
        else {
            for (int i=0; i<in.at(high).first-1; i++) {
                sum += (high+1)*100;
                count++;
                if (sum >= g) return count;
            }
            return INT_MAX;
        }
    }
    return min(dfs(now+1, now, count, sum, in, g), dfs(now+1, high, count+in.at(now).first, sum+in.at(now).first*(now+1)*100+in.at(now).second, in, g));
}

int main() {
    int d = 0, g = 0;
    cin >> d >> g;
    vector<pair<int, int>> in(d);
    int p = 0, c = 0;
    for (int i=0; i<d; i++) {
        cin >> p >> c;
        in.at(i) = make_pair(p, c);
    }
    cout << dfs(0, -1, 0, 0, in, g) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x, i, j) cerr << #x << "------------" << "\n";cerr << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cerr << x[k] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
const ll mod = 1e9 + 7;
const ll inf = 1e11 + 5;
const int MaxN = 2e5 + 5;

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

	int a, b, c;
	cin >> a >> b >> c;
	if(b + c <= a){
		cout << 0;
	}
	else cout << (b + c - a) << endl;
}		


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<cstring>
#include<iomanip>
#include<numeric>
#include<list>
#include<stack>
#include<sstream>
#define lli long long int
#define h 1000000007
#define s 2010
#define pf push_front
#define pb push_back
#define ub upper_bound
#define lb lowepr_bound
#define mp make_pair
#define pi 3.14159
using namespace std;
vector<lli>a(s,-1);
lli solve(lli sum)   
{
	lli i, cnt;
	if(sum==0)return 1;
	else if(sum>=3 && sum<=5) return 1;
	else if(a[sum]!=-1)return a[sum];
	else
	{
		cnt=0;
		for(i=3;i<=sum;i++) 
		{ if((sum-i)>=0)
	  	cnt=((cnt%h)+(solve(sum-i)%h))%h;
	  	else break;
	  } 
		a[sum]=cnt;
		return a[sum];
	} 
} 
int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL) ;
  lli i, n;
  cin>>n;
  cout<<solve(n)<<endl;
  return 0;
} 


Measured memory_bytes: 3720
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
if sum(a)<sum(b):
    print(-1)
    exit()
dif = []
for i in range(n):
    dif.append(a[i]-b[i])
dif.sort()
dif += [0]
ans = 0
i = n
for x in dif:
    if x<0:
        ans += 1
        while x<0:
            if dif[i]<-x:
                x += dif[i]
                i -= 1
                ans += 1
            else:
                dif[i] += x
                x = 0
    else:break
print(ans)


Measured memory_bytes: 18292
# coding: utf-8
N = gets.to_i
S = gets.chomp
code = []

dic =  (('A'..'Z').to_a) * 3

S.chars.each do |char|
  # 辞書から場所を探す
  idx = dic.index(char)
  code << dic[idx + N]
end

puts code.join("")




Measured memory_bytes: 4220
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // AGC 013A - Sorted Arrays
  int N; cin >> N;
  vector<ll> A(N);
  for(auto &i : A) cin >> i;
  int ans = 0;
  REP(i, N){
    while(i+1 < N && A[i] == A[i+1]) i++;
    if(i+1 < N && A[i] < A[i+1]){
      while(i+1 < N && A[i] <= A[i+1]) i++;
    }else if(i+1 < N && A[i] > A[i+1]){
      while(i+1 < N && A[i] >= A[i+1]) i++;
    }
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1000000000000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define s second
#define pb push_back
#define mp make_pair


int d, n, l, r, q, h, w, x;
map< int, pi> m;

int main(){

cin >> h >> w >> d;
vector<int> adj[90005];
for(int i =1;i<=h; i++){
    for(int j =1; j<=w; j++){
        cin >>x;
        m[x].f=i;
        m[x].s=j;
    }
}

for(int i =1; i<=d; i++){
x=0;
    adj[i].pb(x);
    for(int j=i+d; j<=h*w; j+=d){
        int x1 = abs(m[j].f-m[j-d].f);
        int x2 = abs(m[j].s- m[j-d].s);
        x = x + abs(m[j].f-m[j-d].f) + abs(m[j].s- m[j-d].s);
        adj[i].pb(x);

    }

}

cin >> q;
for(int i =1; i<=q; i++){
    cin >> l >> r;
    x = l%d;
    int t = l/d;
    int v = r/d;


    if(x==0){
        cout << abs(adj[d][t-1]-adj[d][v-1])<< endl;
    }
    else cout <<abs( adj[x][t]-adj[x][v])<< endl;
}


return 0;}


Measured memory_bytes: 11008
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)++)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

template <class... T>
void output__(T ...a) {
  for(auto v: {a...}) {
    cout << v << " ";
  }
  cout << endl;
}

int main(){
  string in(a) out(count(a.begin(), a.end(), '1'));
}


Measured memory_bytes: 256
n=int(input())
w=list(map(int,input().split()))
ans=10000

for i in range(n):
	wl=sum([w[j] for j in range(i)])
	wr=sum([w[j] for j in range(i,n)])
	wlr=wl-wr
	if wlr<0:
		wlr=wlr*(-1)
	ans=min(ans,wlr)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265
int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double angle=abs((30*h)-(5.5)*(m));
    double ans=(a*a)+(b*b)-(2*a*b)*cos(angle*acos(-1)/180);
    cout<<fixed<<setprecision(15)<<sqrt(ans)<<endl;
    
    
    
}

Measured memory_bytes: 4228
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int n,k;
    cin >> n>>k;
    int ans=1;
    for(int i=1; i<=n; i++){
        if(ans*2<ans+k){
            ans*=2;
        }else{
            ans+=k;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
pattern = ["S","H","C","D"]
data = [[False for i in range(13)] for j in range(4)]

for i in range(n):
    type,x = list(map(str,input().split()))
    x = int(x)
    data[pattern.index(type)][x - 1] = True

for i,row in enumerate(data):
    for j,elem in enumerate(row):
        if elem == False :
            print(pattern[i], j + 1)


Measured memory_bytes: 5600
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
 
using namespace std;
 
bool used[2000];
 
vector<int> G[2000];
 
void search_(int n){
	if(used[n]){
		return;
	}
	used[n] = true;
	for(int i = 0; i < G[n].size(); i++){
		search_(G[n][i]);
	}
	return;
}

int main(){
	
	long long int N, M;
	cin >> N >> M;
	
	int a[100], b[100];
	
	for(int i = 0; i < M; i++){
		cin >> a[i] >> b[i];
	}
	
	long long int ans = 0;
	
	for(int i = 0; i < M; i++){
		for(int j = 0; j <= N; j++){
			G[j].erase(G[j].begin(), G[j].end());
		}
		for(int j = 0; j < M; j++){
			if(j == i){
				continue;
			}
			G[a[j]].push_back(b[j]);
			G[b[j]].push_back(a[j]);
		}
		
		for(int j = 0; j <= N; j++){
			used[j] = false;
		}
		search_(1);
		bool flag = true;
		for(int j = 1; j <= N; j++){
			if(!used[j]){
				flag = false;
			}
		}
		ans += !flag;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import sys

n, *lst = map(int, sys.stdin.read().split())
lst.sort()
mod = 10 ** 9 + 7
if n % 2:
  for i in range(1, n):
    if lst[i] != (i + 1) // 2 * 2:
      print(0)
      quit()
else:
  for i in range(n):
    if lst[i] != i // 2 * 2 + 1:
      print(0)
      quit()
print((1 << (n >> 1)) % mod)


Measured memory_bytes: 13940
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main() {
	ll mod = 1e9 + 7;
	int h, w;
	cin >> h >> w;
	vector<string> map(h);
	rep(i, h) cin >> map[i];
	vector<vector<ll>> dp(h, vector<ll>(w, 0));
	dp[0][0] = 1;
	rep(i,h){
		rep(j,w){
			if (map[i][j] == '#')
				continue;
			if (i)
			{
				dp[i][j] += dp[i - 1][j];
				dp[i][j] %= mod;
			}
			if (j){
				dp[i][j] += dp[i][j - 1];
				dp[i][j] %= mod;
			}
		}
	}
	cout << dp[h - 1][w - 1] << endl;
	return 0;
}

Measured memory_bytes: 9216
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
long long x;
long long int pw=1;
cin>>x;
for (int i=1;i<=x;i++){
     pw*=i;
     if (pw>1000000007) pw=pw%1000000007;
     }
cout<<pw<<endl;
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a, b;
  scanf("%d%d", &a, &b);
  char n, m;
  if(a<b){
    for(int i=0;i<b;i++){
      printf("%d", a);
    }
  }else{
    for(int i=0;i<a;i++){
      printf("%d", b);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    int d, g;
    cin >> d >> g;
    int p[20], c[20];
    rep(i, 0, d) cin >> p[i] >> c[i];
    rep(i, 0, d) c[i] /= 100; g /= 100;

    int res = 1e9;

    repp(x, 0, 2047){
        int cnt = 0, sum = 0;
        vector<bool> mark(10, 1);
        rep(i, 0, d){
            if((x >> i) & 1){
                cnt += p[i];
                mark[i] = 0;
                sum += (i + 1) * p[i] + c[i];
            }
        }
        priority_queue<int> q;
        rep(i, 0, d) if(mark[i]) rep(j, 0, p[i]) q.push(i + 1);
        while(sum < g && !q.empty()){
            sum += q.top();
            q.pop();
            cnt++;
        }
        res = min(res, cnt);
    }

    cout << res;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 3648
#include <stdio.h>
 
void find3(int n);
  
int main(void) {
    int n;
      
    scanf("%d",&n);
    find3(n);
     
    printf("\n");
    return 0;
}
 
void find3(int n)
{
    int i, j;
     
    for(i=1;i<=n;i++){
        if(i % 3 == 0){
            printf(" %d",i);
        } else {
        	for(j = i; j > 0;j /= 10){
        		if (j % 10 == 3){
					printf(" %d",i);
					break;
				} else {
				}
			}
		}
    }
}

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

int main(){
  int N, L;
  cin >> N >> L;
  vector<string> vec(N);
  for (int i = 0; i < N; i++) {
      cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  string res = "";
  for(int i = 0; i < N; i++){
    res += vec.at(i);
  }
  cout << res << endl;
}

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

ll MAX = pow(10, 5) * 2 + 1;
ll N, K;

vector<ll> calc(vector<ll>& ans) {
  vector<vector<ll>> place(MAX);
  for (ll i = 0; i < ans.size(); ++i) {
    place.at(ans.at(i)).push_back(i);
  }
  vector<ll> res;
  ll index = 0;
  while (index < ans.size()) {
    if (lower_bound(place.at(ans.at(index)).begin(), place.at(ans.at(index)).end(), index + 1) == place.at(ans.at(index)).end()) {
      res.push_back(ans.at(index));
    }
    else {
      index = *lower_bound(place.at(ans.at(index)).begin(), place.at(ans.at(index)).end(), index + 1);
    }
    index += 1;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N >> K;
  vector<ll> A(N);
  vector<vector<ll>> place(MAX);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
    place.at(A.at(i)).push_back(i);
  }
  // A = calc(A);
  // for (ll i = 0; i < A.size(); ++i) {
  //   cout << A.at(i) << " ";
  // }
  // cout << "\n";
  ll power = 45;
  vector<vector<ll>> d(power, vector<ll>(N));
  for (ll i = 0; i < N; ++i) {
    ll index = lower_bound(place.at(A.at(i)).begin(), place.at(A.at(i)).end(), i + 1) - place.at(A.at(i)).begin();
    if (index == place.at(A.at(i)).size()) {
      index = 0;
    }
    d.at(0).at(i) = (place.at(A.at(i)).at(index) + 1) % N;
  }
  for (ll i = 0; i < power - 1; ++i) {
    for (ll j = 0; j < N; ++j) {
      d.at(i + 1).at(j) = d.at(i).at(d.at(i).at(j));
    }
  }
  vector<vector<ll>> len(power, vector<ll>(N));
  for (ll i = 0; i < N; ++i) {
    len.at(0).at(i) = (d.at(0).at(i) - 1) - i;
    if (len.at(0).at(i) <= 0) {
      len.at(0).at(i) += N;
    }
    if (len.at(0).at(i) <= 0) {
      len.at(0).at(i) += N;
    }
    len.at(0).at(i) += 1;
  }
  for (ll i = 0; i < power - 1; ++i) {
    for (ll j = 0; j < N; ++j) {
      len.at(i + 1).at(j) = len.at(i).at(d.at(i).at(j)) + len.at(i).at(j);
    }
  }
  // for (ll i = 0; i < power; ++i) {
  //   for (ll j = 0; j < N; ++j) {
  //     cout << len.at(i).at(j) << " ";
  //   }
  //   cout << "\n";
  // }
  ll now = 0;
  ll num = 0;
  K *= N;
  while (true) {
    bool update = false;
    for (ll i = power - 1; i >= 0; --i) {
      if (len.at(i).at(now) <= K) {
        update = true;
        K -= len.at(i).at(now);
        now = d.at(i).at(now);
        break;
      }
    }
    if (!update) {
      break;
    }
  }
  // cout << now << "\n";
  // cout << K << "\n";
  vector<ll> ans;
  for (ll i = 0; i < K; ++i) {
    ans.push_back(A.at(now + i));
  }
  ans = calc(ans);
  for (ll i = 0; i < ans.size(); ++i) {
    cout << ans.at(i) << " ";
  }
  cout << "\n";
}


Measured memory_bytes: 172472
#include<bits/stdc++.h>
using namespace std ;
#define endl "\n"
#define int long long int 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N = 3e5 + 5  ;


int32_t main()
{ 
  IOS;
  //#ifndef ONLINE_JUDGE 
    //freopen("input.txt","r",stdin) ;
    //freopen("output.txt","w",stdout) ;
  //#endif  
  vector<int>a(5) ;
  int tt = 0 ;
  int mini = 10 , miniind = 0 ;
  for(int i = 0 ; i < 5 ; i++ ) 
  {
      cin >> a[i] ;
      if(a[i] % 10 && a[i] % 10  < mini )
      {
         mini = a[i] %10 ;
         miniind = i ;
      }

  }

  for(int i = 0 ; i < 5 ; i++ )
  {
      if(i != miniind)
      {
          tt += (a[i]) ;
          tt = (tt + 9 ) / 10 ;
          tt = tt * 10 ;
      }
  }
  tt += a[miniind] ;
  cout<<tt<<endl;
  return 0 ;
   
} 


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int N;
int K;
char D[9+2] = {0};
int  d[9+2] = {0};
vector<int> vd; //嫌いな数字ではない数字

int getNDigit(int x){
	if(x == 0) return 1;
	int u = x;
	int ret = 0;
	while(u > 0){
		ret++;
		u /= 10;
	}
	return ret;
}

//右からn桁目の数字を返す
int getRDigit(int x, int n){
	int u = x;
	int ret = 0;
	for(int i=0; i<n; i++){
		ret = u % 10;
		u = u / 10;
	}
	return ret;
}

//xの各桁がvで構成されている場合に、各桁がvで構成されている次の数を返す
int getNextNumber(vector<int>v, int x){
	int ndx = getNDigit(x);
	int ret = 0, MAX= 0;
	int max = v[v.size()-1];
	for(int i=0; i<ndx; i++){
		MAX += max * ((int)pow(10, i)) ;
	}
	if(x == MAX){
		int c = v[0];
		if(v[0] == 0){
			c = v[1];
		}
		ret = c * ((int)pow(10, ndx));
		for(int i=0; i<ndx; i++){
			ret += v[0] * ((int)pow(10, i));
		}
	}
	for(int i=1; i<=ndx; i++){
		int c = getRDigit(x, i);
		int C = 0;
		if(c == v[v.size()-1]){
			//桁上がり処理
			if(v.size() > 1){
				x = x - (c - v[0]) * ((int)pow(10, i-1));
			}
			continue;
		}
		else{
			for(int j=0; j<v.size()-1; j++){
				if(c == v[j]){
					C = v[j+1];
					break;
				}
			}
			ret = x + (C - c) * ((int)pow(10, i-1));
			break;
		}
	}
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> K;
	for(int i=1; i<=K; i++){
		char c;
		char s[2] = {0};
		cin >> c;
		s[0] = c;
		D[i] = c;
		d[i] = atoi(s);
	}
	for(int i=0; i<=9; i++){
		int exist = 0;
		for(int j=1; j<=K; j++){
			if(i == d[j]){ exist = 1; }
		}
		if(exist == 0){ vd.push_back(i); }
	}
	sort(vd.begin(), vd.end());
	int nd = getNDigit(N);
	int min = 0;
	for(int i=0; i<nd; i++){
		int c = vd[0];
		if(i == nd - 1 && c == 0){
				c = vd[1];
		}
		min += c * ((int)pow(10, i));
	}
	int ans = min;
	while(ans < N){
		ans = getNextNumber(vd, ans);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MOD =   1000003;

long exp_mod(long long a, long long b, long m) {
	long long res = 1;
	while (b > 0) {
		if (b&1)
			res = (res * a)%m;
		a = (a * a)%m;
		b >>= 1;
	}
	return (long)res;
}

long fact_mod(long n, long m) {
	long long res = 1;
	for (long i=n; i>0; --i)
		res = (res * i)%m;
	return (long)res;
}

long comb_mod(long n, long r) {
	long long res = 1;
	for (long i=0; i<r; ++i)
		res = (res * (n - i) )%MOD;
	return ( res * exp_mod(fact_mod(r, MOD), MOD-2, MOD) ) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

struct Pony
{
    long s, t, x;

    Pony(long s_, long t_, long x_)
    {
        s = s_;
        t = t_;
        x = x_;
    }

    bool operator<(const Pony &another) const
    {
        return x < another.x;
    };
};

long modinv(long a, long m) {
    long b = m, u = 1, v = 0;
    while (b) {
        long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

  string s;
  cin >> s;

  int state = 0;
  long cnt = 0;
  int acnt = 0;
  for (int i=0; i< s.size(); i++) {
    if(s[i] == 'A') {
      if (state == 1) {
        acnt++;
      } else {
        acnt = 1; 
      }
      state = 1;
    } else if (state == 1 && s[i] == 'B') {
      state = 2;
    } else if (state == 2 && s[i] == 'C') {
      state = 1;
      cnt+=acnt;
    } else {
      acnt = 0;
      state = 0;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 832