akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn dfs(adj: &Vec<Vec<(usize, usize)>>, a: usize, b: usize, prev: usize) -> i64 {
  for &(v, i) in &adj[a] {
    if v == prev {
      continue;
    }
    if v == b {
      return 1 << i as i64;
    }
    let ret = dfs(adj, v, b, a);
    if ret != 0 {
      return ret | (1 << i as i64);
    }
  }
  return 0;
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    es: [(usize1, usize1); n-1],
    m: usize,
    cs: [(usize1, usize1); m],
  }
  let mut adj = vec![vec![]; n];
  for (i, &(a, b)) in es.iter().enumerate() {
    adj[a].push((b, i));
    adj[b].push((a, i));
  }
  let mut path = vec![0i64; m];
  for (i, &(a, b)) in cs.iter().enumerate() {
    path[i] = dfs(&adj, a, b, n);
  }
  let mut ans = 0i64;
  for pat in 0 .. 1 << m {
    let mut white = 0;
    let mut count = 0;
    for (i, &p) in path.iter().enumerate() {
      if (pat >> i) & 1 == 0 {
        continue;
      }
      count += 1;
      white |= p;
    }
    let mut popl = 0;
    for i in 0 .. n {
      if (white >> i) & 1 != 0 {
        popl += 1;
      }
    }
    if count % 2 == 1 {
      ans -= 1 << (n - 1 - popl);
    } else {
      ans += 1 << (n - 1 - popl);
    }
  }
  assert!(ans >= 0);

  puts!("{}\n", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>


int main()
{
    int n=0,k=0;
    int i;
    int a[200020]={0};

    scanf("%d %d",&n,&k);

    for(i=1;i<=n;i++)
    {
        scanf("%d",&(a[i]));
        if(i>=(k+1))
        {
            if(a[i]>a[i-k])printf("Yes\n");
            else printf("No\n");
        }
    }
}


Measured memory_bytes: 2440
import math
N, H = map(int, input().split())
a = [0] * N
b = [0] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())
huru = max(a)  # 振るのは1本だけでいい
ans = 0
b = sorted(b, reverse=True)
for k in range(N):
    if b[k] < huru:
        break
    H -= b[k]
    ans += 1
    if H <= 0:
        break

if H > 0:
    ans += math.ceil(H / huru)
print(ans)


Measured memory_bytes: 12080
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <memory.h>
using namespace std;
int dp[101];
int rec ( int b) {

	if ( b == 1)
		return 1;

	if (dp[b] != -1)
		return dp[b];
	dp[b] = 0;

	if ( b % 2 == 0){
		dp[b] = max ( dp[b] , rec ( b / 2) + 1);

	}

	return dp[b];

}
int main(){

	int n , res = 0 , ans = 0 , tmp = 0;
	scanf ("%d" , &n);

	memset ( dp , -1 , sizeof dp);

	for ( int i = 1 ; i <= n ; ++i){
		res = rec ( i );
		if ( res > tmp ){
			tmp = res;
			ans = i;
		}
	}

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

return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int preT = 0;
        int preX = 0;
        int preY = 0;

        boolean can = true;
        for (int i=0; i<N; i++) {
            int postT = sc.nextInt();
            int postX = sc.nextInt();
            int postY = sc.nextInt();

            int dt = postT - preT;
            int dist = Math.abs(postX - preX) + Math.abs(postY - preY);
            if ((dt < dist) || ((dist - dt) % 2 != 0)) {
                can = false;
                break;
            }

            preT = postT;
            preX = postX;
            preY = postY;
        }

        if (can)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 88548
N=int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

sums = 0
old_i = -11 
for i in range(N):
    now_i = A[i] -1
    sums += B[now_i]
    if old_i+1 == now_i:
        sums += C[now_i-1]
    
    old_i = now_i

print(sums)

Measured memory_bytes: 3064
import math

def round_manual(n):
    if n-int(n) >= 0.5:
        res = math.ceil(n)
    else:
        res = math.floor(n)
    return res

def resolve_c():
    n = input()
    l = list(map(int, input().split()))
    mean = sum(l) / len(l)
    res = round_manual(mean)
    ans = sum([(i-res) ** 2 for i in l])
    print(ans)
resolve_c()

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,I##_N=N;I<I##_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;

template<typename F>
void for_monotonic_seq(std::vector<i8t>& vec, int min_depth, int max_depth, int max_value, F functor) {
  int depth = min_depth;
  for (;;) {
    for (; depth < max_depth; depth++)
      vec[depth] = vec[depth-1];
    functor();
    do depth--; while (depth >= min_depth && vec[depth] == max_value);
    if (depth < min_depth) return;
    vec[depth++]++;
  }
}

int main() {
  R(N)R(M)R(Q);
  std::vector<i8t> a,b,c,d;
  F(I,Q){
    R(a1)R(b1)R(c1)R(d1);
    a.push_back(a1-1);
    b.push_back(b1-1);
    c.push_back(c1);
    d.push_back(d1);
  }

  // int count=0;
  std::vector<i8t> A(N);
  A[0]=1;
  i8t max_score=0;
  for_monotonic_seq(A, 1, N, M, [&](){
    i8t score=0;
    F(I,Q){
      if(A[b[I]]-A[a[I]]==c[I])
        score+=d[I];
    }
    max_score=std::max(score,max_score);
  });
  P(max_score);
  return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int cnt = 0;
            char ac = a.charAt(i);
            char bc = b.charAt(i);
            char cc = c.charAt(i);
            if (ac == bc) {
                if (ac == cc) {

                } else {
                    cnt = 1;
                }
            } else if (ac == cc) {
                cnt = 1;
            } else if (bc == cc) {
                cnt = 1;
            } else {
                cnt = 2;
            }
            ans += cnt;
        }
        System.out.println(ans);

    }

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a,b;
  cin>>a>>b;
  vector<ll>vec(b);
  for(ll i=0;i<b;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  vector<ll>re(b);
  for(ll i=0;i<b-1;i++){
    re.at(i)=vec.at(i+1)-vec.at(i);
  }
  re.at(b-1)=vec.at(0)+a-vec.at(b-1);
  sort(re.begin(),re.end());
  cout<<a-re.at(b-1)<<endl;
  
}


Measured memory_bytes: 6420
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

a,b,c,d = map(int, input().split())
ac = (a-1)//c
ad = (a-1)//d
bc = b//c
bd = b//d
cd = int(c*d/(gcd(c,d)))
acd = (a-1)//cd
bcd = b//cd
aaa = bc+bd-bcd-ac-ad+acd
print(b-a+1-aaa)

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

	int N,x[3000]={0},i,answer=0;
	
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&x[i]);
	}
	for(i=0;i<N;i++){
	
		answer+=x[i]-1;
	}
	printf("%d",answer);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {

    int n,x;
    cin>>n>>x;
    vi l(n);
    rep(i,n)cin>>l[i];

    int sum=0;
    int ans=0;
    for(int i=0;i<n;i++){
        sum+=l[i];
        if(sum<=x)ans++;
        else break;

    }
    fin(ans+1);

}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<long long>An(N);
	for (int n = 0;n<N;++n) {
		cin >> An[n];
	}
	for (int n = 0; n < N; ++n) {
		if (0 == An[n]) {
		std::cout << 0 << endl;
		return 0;
		}
	}
	long long nAns = 1;
	for (int n = 0; n < N; ++n){
		long long nllMax = 1000000000000000000;
		long long nMax = nllMax / nAns;
		if (nMax < An[n]) {
			std::cout << -1 << endl;
			return 0;
		}
		nAns *= An[n];
	}
	std::cout << nAns << endl;
	return 0;
}

Measured memory_bytes: 4052
#include<iostream>
using namespace std;
int main(){
	int ball;
	int n;
	while(cin >> n){
		bool flag = true;
		for(int i=0; i<n; i++){
			int B=0, C=0;
			for(int j=0; j<10; j++){
				cin >> ball;
				if(flag){
					if(B < ball) B=ball;
					else if(C < ball) C=ball;
					else flag=false;
				}
			}
			
			if(flag) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans;
    switch(s){
       case "MON": ans=6; break;
       case "TUE": ans=5; break;
       case "WED": ans=4; break;
       case "THU": ans=3; break;
       case "FRI": ans=2; break;
       case "SAT": ans=1; break;
      default: ans=7;
    }
    System.out.println(ans);
  }
}


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

using namespace std;

#define reps(i, j, n) for(int i = j; i < (int)n; i++)
#define rep(i, n) reps(i, 0, n)

int main()
{
  int N, K;
  cin >> N >> K;
  int gcd = 0;
  bool high = false;
  rep(i, N) {
    int A;
    cin >> A;
    gcd = __gcd(gcd, A);
    if(A >= K)high = true;
  }
  if(K % gcd == 0 && high) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
mod = 10**9+7

dp = [[0 for _ in range(M+1)] for _ in range(N+1)]
for i in range(N+1):
    dp[i][0] = 1
for j in range(M+1):
    dp[0][j] = 1
for i in range(N):
    for j in range(M):
        flg = 0 if S[i] == T[j] else 1
        dp[i+1][j+1] = (dp[i+1][j] + dp[i][j+1] - dp[i][j] * flg)%mod

print(dp[-1][-1])


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

int main() {
  string s;
  cin >> s;
  if(s[2] == s[3] && s[5] == s[4]){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/* ****revpro**** */
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		string s;
		cin>>s;
		ll cnt=0;
		rep(i,0,sz(s)){
			if(s[i]!=s[sz(s)-1-i]) s[i]=s[sz(s)-1-i],cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int na;
int a[2000];

int check (int getI,int diff) {
  if (diff == 0) {
    return 1;
  }else if (getI >= na) {
    return 0;
  }
  int res=check(getI+1,diff-a[getI]) || check(getI+1,diff);
  return res;
}

int main () {
  int n;
  int pre;
  scanf("%d",&na);
  for (pre=0;pre<na;pre++) {
    scanf("%d",&a[pre]);
  }
  scanf("%d",&n);
  int target[n];
  for (pre=0;pre<n;pre++) {
    scanf("%d",&target[pre]);
  }
  for (pre=0;pre<n;pre++) {
    int result = check(0,target[pre]);
    if (result) {
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

//-------------------------------------------------------------------
#define P 1000000007
#define N_MAX 10000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
  if(n<0||k<0||n<k) return 0;
  return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
  fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
  for(int i = 2; i <= N_MAX; i++){
    fac[i] = (fac[i-1]*i)%P;
    inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
    finv[i] = (finv[i-1]*inv[i])%P;
  }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
ll mpow(ll a, ll b, ll p = -1){
  ll ret = 1, num = a;
  if(p==-1){
    while(b>0){
      if(b%2) ret *= num;
      num = num * num;
      b /= 2;
    }
  }else{
    while(b>0){
      if(b%2) ret = (ret*num)%p;
      num = (num*num)%p;
      b /= 2;
    }
  }
  return ret;
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll n, a, b;std::cin >> n >> a >> b;
  init();
  ll s = mpow(2, n, P);
  ll ans = (s-1+P)%P;
  ll A = 1, B = 1;
  for(ll i=1;i<=a;i++) A = (A * pp(n+1-i, inv[i]))%P;
  for(ll i=1;i<=b;i++) B = (B * pp(n+1-i, inv[i]))%P;
  ans = (ans - A - B + P + P)%P;

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 234752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,a;
    cin>>n>>a;
    int x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    ll dp[n+1][2525]={};
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=n-1;j>=0;j--){
            for(int k=2500;k>=0;k--){
                dp[j+1][k+x[i]]+=dp[j][k];
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=dp[i][a*i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1280
#!/usr/bin/env python3
def main():
    import numpy as np

    N = int(input())

    can = [1]
    limit = 100
    for i in range(1, limit):
        six = 6 ** i
        if six <= N:
            can.append(six)
        nine = 9 ** i
        if nine <= N:
            can.append(nine)
        if six > N and nine > N:
            break

    INF = 10 ** 9
    dp = np.full(N + 1, INF, dtype=np.int32)
    dp[0] = 0
    for c in can:
        for _ in range(9):
            dp[c:] = np.minimum(dp[c:], dp[:-c] + 1)
    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 27668
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 100000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

string s;
int k;
int ans;
int cnt1, cnt2, cnt3, cnt4;

signed main() {
	cin >> s >> k;
	cnt1 = 1;
	for (int i = 1; i < (int)s.size(); i++) {
		if (s[i - 1] == s[i])cnt1++;
		else break;
	}
	ans += cnt1 / 2;
	cnt2 = 1;
	for (int i = cnt1 + 1; i <= (int)s.size() + cnt1; i++) {
		int j = i % (int)s.size();
		if (s[(j + (int)s.size() - 1) % (int)s.size()] == s[j])cnt2++;
		else {
			cnt4 += cnt2 / 2;
			cnt2 = 1;
		}
	}
	cnt4 += cnt2 / 2;
	cnt3 = 1;
	for (int i = cnt1 + 1; i < (int)s.size(); i++) {
		if (s[i - 1] == s[i])cnt3++;
		else {
			ans += cnt3 / 2;
			cnt3 = 1;
		}
	}
	ans += cnt3 / 2;
	if (cnt1 == (int)s.size())cout << cnt1 * k / 2 << endl;
    else cout << ans + cnt4 * (k - 1) << endl;
}

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

using namespace std;
typedef long long ll;
ll n, k, x;
ll ans;
ll cns;

int main() {
    scanf("%lld", &n);
    k = n - 1;
    ans = 0;
    cns = 0;
    ll i, j, p;
    for (i = 1; i <= sqrt(k); i++) {
        if (k % i == 0) {
            ans += 2;
        }
    }
    ans--;
    i--;
    if (i * i == k) {
        ans--;
    }
    for (j = 2; j <= sqrt(n); j++) {
        if (n % j == 0) {
            x = n;
            while (x % j == 0)x /= j;
            if (x % j == 1)cns++;
            p = n / j;
            if (p != j) {
                x = n;
                while (x % p == 0) {
                    x /= p;
                }
                if (x % p == 1)cns++;
            }
        }
    }
    cns++;
    printf("%lld\n", ans + cns);
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int h,w,i,j;
	char c;
	while(scanf("%d %d", &h, &w)!=EOF && (h!=0 || w!=0)){
		for(i=h;i;i--){
			printf("#");
			c = (i==h || i==1)?'#':'.';
			for(j=w-2;j;j--){
				putchar(c);
			}
			printf("#\n");
		}
		printf("\n");
	}
    return 0;
}

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

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

int main() {
  string s;
  cin >> s;
  if(s=="SSS"){
    cout << 0 << endl;
  }
  else if(s=="RRS"||s=="SRR"){
    cout << 2 << endl;
  }
  else if(s=="RRR"){
    cout << 3 << endl;
  }
  else {
    cout << 1 << endl;
  }
  

  return 0;

}

Measured memory_bytes: 3624
#include<stdio.h>
int str_length(const char s[])
{
    int len = 0;
    while(s[len])
    len++;
    return len;
}

int main(void)
{
  char str[11];
  int i;
  int count=0;
  int max=0;
  
  scanf("%s",str);
  for(i=0;i<str_length(str);i++)
  {
    if(str[i]=='A'||str[i]=='C'||
       str[i]=='G'||str[i]=='T')
    {
        count++;
    }else{
        count=0;
        
    }
  
    if(max<count)
    {
        max=count;
        
    }
  }
    printf("%d",max);
    
    return 0;
}

Measured memory_bytes: 128
import sys
def sieve(m):
    N=range(1,m+2,2)
    r=int(m**.5)
    h=len(N)
    N[0]=0
    i=0
    while i<h:
        x=N[i]
        if x>r: break
        if x and i+x<h: N[i+x:h:x]=[0]*((h-1-i-x)/x+1)
        i+=1
    return N
def f0056(n):
    x=0
    if n<4:x=0
    elif n==4:x=1
    elif n%2:
        if S[(n-2)/2]: x=1
    else:
        a=n/2
        for e in PRIMES:
            if e>a: break
            if S[(n-e)/2]: x+=1
    return x

S=sieve(50000)
PRIMES=filter(None,S)
for n in sys.stdin:
    n=int(n)
    if n==0: break
    print f0056(n)

Measured memory_bytes: 5304
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    int cnt=0;
    REP(i,n) cin>>a[i];
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(a[j-1]>a[j]) swap(a[j-1],a[j]),cnt++;
        }
    }
    REP(i,n) cout<<a[i]<<(i<n-1?" ":"");
    cout<<endl;
    cout<<cnt<<endl;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] point = br.readLine().split(" ");
		
		double x1 = Double.parseDouble(point[0]);
		double y1 = Double.parseDouble(point[1]);
		double x2 = Double.parseDouble(point[2]);
		double y2 = Double.parseDouble(point[3]);
		
		double a = Math.abs(x2 - x1);
		double b = Math.abs(y2 - y1);
		
		double a2 = a * a;
		double b2 = b * b;
		
		double c = Math.sqrt(a2 + b2);
		
		System.out.printf("%.8f\n", c);
	}
}

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

public class Main {

    public static void main(String[] args) {

        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);

        String str1 = null;
        String str2 = null;
        String str3 = null;
        String str4 = null;

        try {
            str1 = br.readLine();
            int cnt500 = Integer.parseInt(str1);

            str2 = br.readLine();
            int cnt100 = Integer.parseInt(str2);

            str3 = br.readLine();
            int cnt50 = Integer.parseInt(str3);

            str4 = br.readLine();
            int cntAll = Integer.parseInt(str4);

            int ptn = 0;

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

                for (int j = 0 ; j <= cnt100 ; j++) {

                    for (int k = 0 ; k <= cnt50 ; k++) {

                    	int money = i*500 + j*100 + k*50;

                    	if (money == cntAll) {
                    		ptn ++;
                    	}

                    }

                }

            }

            br.close();


            System.out.println(ptn);




        } catch (IOException e) {
            e.printStackTrace();
        }


    }

}

Measured memory_bytes: 22996
// 2020/08/03 Tazoe

#include <iostream>
using namespace std;

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

	if(65<=N && N<=90){
		cout << 1 << endl;
	}
	else if(97<=N && N<=122){
		cout << 2 << endl;
	}
	else{
		cout << 0 << endl;
	}

	return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <bits/stdc++.h>
#define scan(n)      scanf("%I64d",&n);
#define scan2(a,b)   scanf("%I64d%I64d",&a,&b);
#define scan3(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c);
#define sc(n)        scanf("%c",&n);
#define sf(n)        scanf("%lf",&n);
#define ss(n)        scanf("%s",n);
#define forall(i,a,b)for(long long int i=a;i<b;i++)
#define all(a)       a.begin(), a.end()
#define pb           push_back
#define mp           make_pair
#define FAST_IO      ios_base::sync_with_stdio(false); cin.tie(NULL);
#define minimum(a)   *min_element(a.begin(),a.end())
#define maximum(a)   *max_element(a.begin(), a.end())
#define display(a)   for(auto i : a) cout<<i<<" ";
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
using namespace std;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
vector<ll> scanVector(ll n, vector<ll> &v)
{
  ll temp;
  for(ll i = 0; i < n ; i++)
  {
     cin>>temp;
     v.pb(temp);
  }
  return v;
}

int main() {
    FAST_IO
    ll t;
    //cin>>t;
    t = 1;
    while(t--)
    {
        ll n,w;
        cin>>n>>w;
        vector<ll> w1;
        vector<ll> v1;
        ll w2,v2;
        w1.pb(0);
        v1.pb(0);
        for(ll i = 0; i < n ; i++)
        {
            cin>>w2>>v2;
            w1.pb(w2);
            v1.pb(v2);
        }
        ll dp[n+1][w+1];
        for(ll i = 0; i < w+1; i++)
        {
            dp[0][i] = 0;
        }
        // for(ll i = 1; i < n+1; i++) cout<<v1[i]<<" ";
        // cout<<endl;
        for(ll i =1; i < n+1; i++)
        {
            for(ll j = 0; j < w+1; j++)
            {
                if(j < w1[i])
                {
                    dp[i][j] = dp[i-1][j];
                }
                else
                {
                    dp[i][j] = max((v1[i]+dp[i-1][j-w1[i]]),dp[i-1][j]);
                }
            }
        }
        // for(ll i = 0; i < n+1; i++)
        // {
        //     for(ll j = 0; j < w+1; j++)
        //     {
        //         cout<<dp[i][j]<<" ";
        //     }
        //     cout<<endl;
        // }
        cout<<dp[n][w]<<endl;
    }
    return 0;
}

Measured memory_bytes: 79232
<?php 

$n = fgets(STDIN);
$array = [];

$a=1;
$b=1;
$ans=0;

while($a*$b<$n){
    while($a*$b<$n){
        $ans++;
        $b++;
    }
    $a++;
    $b=1;
}

echo $ans."\n";
// print_r($array);

Measured memory_bytes: 16284
#include <cstdio>
#include <string>
#include <iostream>

using namespace std;

int main()
{
	string s;

	cin >> s;

	int n = s.length();

	for (int i = 0; i < n - 8; i++) {
		cout << s[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

const ld eps = 1.0e-14;

int main() {
  ld a,b,c;
  cin >> a >> b >> c;
  if(sqrt(a)+sqrt(b)+eps<sqrt(c)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
arr = gets.chomp.split("")
alf = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
ans = []

arr.each do |s|
    if alf.index(s)+N > 25
        ans.push(alf[alf.index(s)+N - 26])
    else
        ans.push(alf[alf.index(s)+N])
    end
end

ans.each do |n|
    print n
end


Measured memory_bytes: 3964
n = int(raw_input())
a = [0] + map(int, raw_input().split()) + [0]
s = 0
for i in range(n+1):
    s += abs(a[i+1] - a[i])
for i in range(1,n+1):
    print s + abs(a[i+1] - a[i-1]) - (abs(a[i+1] - a[i]) + abs(a[i] - a[i-1]))


Measured memory_bytes: 11108
#include <bits/stdc++.h>
using namespace std;
int main(){
  long a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a>=0&&c>=0)cout<<b*d<<endl;
  else if(b<=0&&c>=0)cout<<b*c<<endl;
  else if(a>=0&&d<=0)cout<<a*d<<endl;
  else if(b<=0&&d<=0)cout<<a*c<<endl;
  else{
    if(a>=0)cout<<b*d<<endl;
    else if(c>=0)cout<<b*d<<endl;
    else if(b<=0)cout<<a*c<<endl;
    else if(d<=0)cout<<a*c<<endl;
    else {
      cout<<max(a*c,b*d)<<endl;
    }
  }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const int n = 1e7;
int cnt, prime[n + 1], vis[n + 1], r[n + 1];

int main() {
    for (int i = 2; i <= n; i++) {
        if (!vis[i]) prime[++cnt] = i;
        for (int j = 1; j <= cnt && (long long)i * prime[j] <= n; j++) {
            vis[i * prime[j]] = 1;
            if (i % prime[j] == 0) break;
        }
    }
    for (int i = 2; i <= n; i++) {
        if (!vis[i])
            r[i] = r[i - 1] + 1;
        else
            r[i] = r[i - 1];
    }
    int a;
    while (cin >> a) cout << r[a] << "\n";
}


Measured memory_bytes: 83780
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

ll seg[524288];

ll rsq(int s, int t, int k = 1, int l = 0, int r = 262143) {
	if (t < l || r < s)return 0;
	if (s <= l && r <= t)return seg[k];
	ll lv = rsq(s, t, k * 2, l, (l + r) / 2);
	ll rv = rsq(s, t, k * 2 + 1, (l + r) / 2 + 1, r);
	return lv + rv;
}

void upd(ll x) {
	x += 262144;
	seg[x]++;
	while (x) {
		x /= 2;
		seg[x] = seg[x * 2] + seg[x * 2 + 1];
	}
}

int main() {
	for (int i = 0;i < 524288;i++)seg[i] = 0;
	ll N, L;
	cin >> N;
	L = N * (N + 1) / 2;
	vector<ll> A(N), AR(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		AR[i] = A[i];
	}
	sort(all(AR));

	ll ng = -1, ok = N - 1, T, x, y, s;
	vector<ll> B(N + 1, 0);
	while (ng + 1 != ok) {
		T = (ok + ng) / 2;
		x = AR[T];

		for (int i = 0;i < 524288;i++)seg[i] = 0;
		for (int i = 0;i < N;i++) {
			if (A[i] > x)B[i + 1] = -1;
			else B[i + 1] = 1;

			B[i + 1] += B[i];
		}

		s = 0;
		for (int i = 0;i <= N;i++) {
			upd(B[i] + 100005);
			s += rsq(0, B[i] + 100004);
		}
		if (s < L / 2 + 1)ng = T;
		else ok = T;
	}
	cout << AR[ok] << endl;
}

Measured memory_bytes: 6656
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
using namespace std; 
int main(){
  int n;
  cin>>n;
  int  a=0;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    if(s=="A"){
      a+=1;
    }else{
      a-=1;
      if(a<0){
	cout<<"NO"<<endl;
	return 0;
      }
    }
  }
  if(a==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  } 

  return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <algorithm>

using   namespace std;

const long long int MOD = 1000000007;
const long long int INF = 100000000;
long long int N,M;
long long int C[30];
long long int dp[21][100000];

int DP(int n,int v)
{
	if(n<0||v<0) return INF;

	if(dp[n][v]!=-1) return dp[n][v];
	return dp[n][v] = min(DP(n-1,v),DP(n,v-C[n])+1);
}

int main()
{
    cin >> N >> M;

		for(int i = 0; i < M; i++){
			cin>>C[i];
		}

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

		for(int i = 0; i < 21; i++){
			dp[i][0]=0;
		}
    cout << DP(M - 1,N) << endl;

		return 0;
}



Measured memory_bytes: 19620
import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
      String n = sc.next();
      StringBuffer N = new StringBuffer(n);
      String ren = N.reverse().toString();
      int total = 0;
      if(n.length()%2==0){
        for(int i=0;i<n.length();i++){
          if(n.charAt(i)!=ren.charAt(i)){
            total++;      
          }
        }
      }else{
        for(int i=0;i<n.length();i++){
          if(n.charAt(i)!=ren.charAt(i)){
            total++;      
          }
        }
      }
      System.out.println(total/2);

  }
}


Measured memory_bytes: 23124
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
char c[100];
int main()
{
	scanf("%s",c+1);
	printf("%c%c%c",c[1],c[2],c[3]); 
}


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

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> one;
    set<int> enu;
    rep(i, M){
        int a, b;
        cin >> a >> b;
        if(a == 1) one.push_back(b);
        if(b == N) enu.insert(a);
    }
    bool is = false;
    int len = (int)one.size();
    rep(i, len){
        if(enu.count(one[i]) == 1) is = true;
    }
    if(is) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);                      \
	cin.exceptions(cin.failbit);
#define int long long int //Comment when Unnecessary
#define ll long long
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define pii pair<int, int>
#define vi vector<int>
#define F first
#define S second
#define endl "\n" // Remove on Interactive

const int N = 300009;
const int mod = 1000000007;

void pre()
{
}

int32_t main()
{
	IOS;
	pre();
	int n, m;
	int s, c;
	cin >> n >> m;
	string st = "";
	rep(i, 0, n)
	    st += '#';

	if (n == 1)
	{
		if (m == 0)
		{
			cout << 0 << endl;
			return 0;
		}
		else
		{
			rep(i, 0, m)
			{
				cin >> s >> c;
				if (st[s - 1] != '#' && (st[s - 1] != (c + '0')))
				{
					cout << -1 << endl;
					return 0;
				}
				st[s - 1] = (c + '0');
			}
			cout << st << endl;
			return 0;
		}
	}

	// string st = "";
	// rep(i, 0, n)
	//     st += '#';

	rep(i, 0, m)
	{
		cin >> s >> c;
		if (st[s - 1] != '#' && (st[s - 1] != (c + '0')))
		{
			cout << -1 << endl;
			return 0;
		}
		st[s - 1] = (c + '0');
	}
	if (st[0] == '0')
	{
		cout << -1 << endl;
		return 0;
	}
	if (st[0] == '#')
	{
		st[0] = '1';
	}
	rep(i, 1, n) if (st[i] == '#')
	    st[i] = '0';
	cout << st << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<vector>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
    string n;
    int a,ans;
    cin >> n;
    (int)(n.length());
    a = n.length();
    if(n[(a-1)]=='0' || n[(a-1)]=='1' ||n[(a-1)]=='6' || n[(a-1)]=='8'){
        ans = 1;
    }else if(n[(a-1)]=='3'){
        ans = 2;
    }else if(n[(a-1)]=='2' || n[(a-1)]=='4' ||n[(a-1)]=='5' || n[(a-1)]=='7' || n[(a-1)]=='9'){
        ans = 3;
    }
    if(ans == 1){
        cout << "pon" << endl;
    }else if(ans == 2){
        cout << "bon" << endl;
    }else if(ans == 3){
        cout << "hon" << endl;
    }
    return 0;
}

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

int main(void) {
    int x,i;
    cin >> x;
    for (i = 2; i < x; i++) {
        if (x % i == 0) {
            x++;
            i = 2;
        }
    }
    cout << x;
    return 0;
}

Measured memory_bytes: 256
n = int(input())

lis = [input() for _ in range(n)]

dic = {}

for s in lis:
    dic[s] = dic.get(s, 0) + 1
max_num = max(dic.values())

res = []
for k, v in dic.items():
    if v == max_num:
        res.append(k)
res = sorted(res, reverse=False)
for r in res:
    print(r)

Measured memory_bytes: 35220
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        List<String> numbers = Arrays.asList(sc.nextLine().split(""));
        
        int count = 0;
        for (String number : numbers) {
            if (number.equals("1")) {
                count++;
            }
        }
        System.out.println(count);
	}
}

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

int main(){

  int m, n_min, n_max, gap = 1000000, z;
  int ary[1000001];

  
  while(1){
    cin >> m >> n_min >> n_max;
    if(m == 0 && n_min == 0 && n_max == 0) break;

    for(int i = 1 ; i <= m ; i++){
      cin >> ary[i];
    }

    for(int i = n_min ; i <= n_max ; i++){
      if(gap >= ary[i+1] - ary[i]){
	gap = ary[i+1] - ary[i];
	z = i;
      }
    }
    cout << z << endl;
    gap = 1000000;
    z = 0;
  }

  return 0;
}

Measured memory_bytes: 3080
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        BigInteger ans = BigInteger.ONE;
        for(int i=0;i<n;i++){
            ans = lcm(ans, new BigInteger(sc.next()));
        }
        System.out.println(ans);
    }
    static BigInteger gcd(BigInteger a, BigInteger b){
        return a.gcd(b);
    }
    static BigInteger lcm(BigInteger a, BigInteger b){
        return a.multiply(b).divide(gcd(a,b));
    }}


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

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

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

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	//int → string変換
	string a_str = std::to_string(a);
	string b_str = std::to_string(b);

	string ab;
	for (int i = 0; i < b; i++) {
		ab = ab + a_str;
	}
	//cout << ab << endl;

	string ba;
	for (int i = 0; i < a; i++) {
		ba = ba + b_str;
	}
	//cout << ba << endl;

	if (ab < ba) {
		cout << ab << endl;
	}
	else {
		cout << ba << endl;
	}

	
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (ll i=0; i<n; i++)
#define	Rep1(i, n)	for (ll i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	ll n, m;
	cin >>n >>m;
	vector<ll> x(n+1);
	Rep1(i, n)
		cin >>x.at(i);
	vector<ll> y(m+1);
	Rep1(i, m)
		cin >>y.at(i);
	ll X=0;
	Rep1(i, n-1) {
		x.at(i)=x.at(i+1)-x.at(i);
		x.at(i) *=i;
		x.at(i) %=MOD;
		x.at(i) *=n-i;
		x.at(i) %=MOD;
		X +=x.at(i);
		X %=MOD;
	}
	ll Y=0;
	Rep1(i, m-1) {
		y.at(i)=y.at(i+1)-y.at(i);
		y.at(i) *=i;
		y.at(i) %=MOD;
		y.at(i) *=m-i;
		y.at(i) %=MOD;
		Y +=y.at(i);
		Y %=MOD;
	}
	cout <<X*Y%MOD <<endl;
	return 0;
}



Measured memory_bytes: 1792
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg(){write2(-1);exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=998244353;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=1e2+10;

	ll C[N][N];
	ll f[N][N][2],g[N][N][2];//f=上次删的是行，g=列
	char mp[N][N];
	void main()
	{
		C[0][0]=1;fo(i,1,N-1){ C[i][0]=1;fo(j,1,i) C[i][j]=mm(C[i-1][j-1]+C[i-1][j]); }
		int n=qread(),m=qread();fo(i,0,n-1) scanf("%s",mp[i]);
		fo(mm,0,m) g[n][mm][1]=C[m][mm]*bin(m-mm)%MOD;
		fd(nn,n,0) fd(mm,m,0)
		{
			fo(ad,1,n-nn)
				add(f[nn][mm][0],C[ad+nn][nn]*(g[nn+ad][mm][0]+g[nn+ad][mm][1]*2)%MOD ),
				add(f[nn][mm][1],C[ad+nn][nn]*g[nn+ad][mm][1]%MOD*(bin(ad)-2)%MOD );
			fo(ad,1,m-mm)
				add(g[nn][mm][0],C[ad+mm][mm]*(f[nn][mm+ad][0]+f[nn][mm+ad][1]*2)%MOD ),
				add(g[nn][mm][1],C[ad+mm][mm]*f[nn][mm+ad][1]%MOD*(bin(ad)-2)%MOD );
		}
		ll ans=0;fo(mm,1,m) add(ans,f[0][mm][1]);fo(nn,1,n) add(ans,g[nn][0][1]);
		fo(S1,1,bin(n)-1) fo(S2,1,bin(m)-1)
		{
			bool ok=1;
			fo(i,0,n-1) if(S1&bin(i)){
				bool same=1;int lst=-1;
				fo(j,0,m-1) if(S2&bin(j)) same&=(lst<0 or mp[i][j]==mp[i][lst]),lst=j;
				ok&=(same==0);
			}fo(j,0,m-1) if(S2&bin(j)){
				bool same=1;int lst=-1;
				fo(i,0,n-1) if(S1&bin(i)) same&=(lst<0 or mp[i][j]==mp[lst][j]),lst=i;
				ok&=(same==0);
			}
			if(!ok) continue;
			fo(pp,0,1) add(ans, mm(f[PC(S1)][PC(S2)][pp]+g[PC(S1)][PC(S2)][pp])*invm(C[n][PC(S1)]*C[m][PC(S2)]%MOD)%MOD );
		}write(ans);
	}
};//(ans+MOD)%MOD
signed main()
{
	srand(time(0));
	mine::main();
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  string S;
  cin >> S;
  string ans = "ABC";
  if(S == "ABC")
    ans = "ARC";
  cout << ans << endl;
  return 0;
}

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


#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); ++i)


int insertionSort(int A[], int N, int g){
    int cnt = 0;
    for(int i = g; i < N; ++i){
        int v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j + g] = A[j];
            j -= g;
            ++cnt;
        }
        A[j + g] = v;
    }
    return cnt;
}

int shellSort(int A[], int N, vector<int> &G){
    int h = 1;
    while(h <= N){
        G.pb(h);
        h = 3 * h + 1;
    }
    
    int cnt = 0;
    for(int i = G.size() - 1; i >= 0; --i)
        cnt += insertionSort(A, N, G[i]);
    
    return cnt;
}

int main(void){
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; ++i) cin >> A[i];
     
    vector<int> G;
    int cnt = shellSort(A, N, G);
    
    cout << G.size() << endl;
    for(int i = G.size() - 1; i > 0; --i){
        cout << G[i] << " ";
    }
    cout << G[0] << endl;
    cout << cnt << endl;
    for(auto v : A) cout << v << endl;
    
    return 0;
}


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

int main() {
    int N; string S;
    cin >> N >> S;
    long long r = 0, g = 0, b = 0;
   
   for(int i=0;i<N;i++){
       if(S.at(i)=='R')r++;
       if(S.at(i)=='G')g++;
       if(S.at(i)=='B')b++;
   }
    
    long long all = r * g * b;
    long long sub = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (S[i] == S[j]) continue;
            int k = j*2-i;
            if (k >= N || S[k] == S[i] || S[k] == S[j]) continue;
            ++sub;
        }
    }
    cout << all - sub << endl;
}


Measured memory_bytes: 3636