akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let nab = util::gets::<i64>();
    
    let high = nab[1] + nab[2] * (nab[0] - 1);
    let low = nab[2] + nab[1] * (nab[0] - 1);

    println!("{}", max(0, high - low + 1));
}


Measured memory_bytes: 4352
N=int(input())
S=input()

#(RGB)になる組み合わせをカウント
count= S.count("R")*S.count("G")*S.count("B")
count0=0

#条件を満たさないものを引いていく
for i in range(1,N-2 +1):
    for j in range(i+1,(N+i)//2 +1):
        k=2*j-i
        if S[k-1]!=S[i-1] and S[k-1]!=S[j-1] and S[i-1]!=S[j-1]:
            count0 += 1
print(count-count0)


Measured memory_bytes: 68248
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define mod 1000000007
#define N 500043
#define mp(a,b) make_pair(a,b)
#define loop(a,b) for(int i=a;i<b;i++)
#define test int t; cin >> t; while(t--)
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ptr=n-1,ptr2=0;
    int coun=0;
    while(ptr2<ptr&&ptr>=0&&ptr2<n)
    {
        if(s[ptr2]=='R'){
            ptr2++;
        }
        else if(s[ptr]=='W')
            ptr--;
        else{
            coun++;
            ptr--;
            ptr2++;
        }
    }
    cout << coun << endl;
}


Measured memory_bytes: 3768
n = int(input())
ls = list(map(int, input().split()))


def calc(ls, sign):
    count = 0
    acc = 0
    for x in ls:
        y = acc + x
        if y == 0 or y // abs(y) != sign:
            z = sign - y
            count += abs(z)
            acc = sign
        else:
            acc = y
        sign *= -1
    return count


count = min(calc(ls, 1), calc(ls, -1))
print(count)

Measured memory_bytes: 14332
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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

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

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

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

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

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

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String{
    input!{
        source = src,
        x: isize,
        n: isize,
        pn: [isize; n],
    }

    let mut pnn = pn;
    pnn.sort();

    let ans1 = solve_rec_i(x, &pnn);
    let ans2 = solve_rec_d(x, &pnn);


    if let Some(a1) = ans1 {
        if let Some(b1) = ans2 {
            let a = x - a1;
            let aa = a * a;

            let b = x - b1;
            let bb = b * b;

            if aa > bb {
                return b1.to_string();
            } else if aa < bb {
                return a1.to_string();
            }
            if a1 >= b1 { 
                return b1.to_string();
            }
            return a1.to_string();
        }
    }

    return 0.to_string();
}

fn solve_rec_i(x: isize, pn: &Vec<isize>) -> Option<isize> {
    let res = pn.binary_search(&x); 
    if let Err(_v) = res {
        return Some(x);
    }

    let a = solve_rec_i(x + 1, pn);
    return a;
}
fn solve_rec_d(x: isize, pn: &Vec<isize>) -> Option<isize> {
    let res = pn.binary_search(&x); 
    if let Err(_v) = res {
        return Some(x);
    }

    let a = solve_rec_d(x - 1, pn);
    return a;
}


Measured memory_bytes: 2152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <queue>
#include <cstring>
#include <set>
#include <list>
#include <map>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;

#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define forn(i, a, b) for(int i = a; i < b; i++)

#define pb push_back
#define mp make_pair

int main()
{

    int n;
    ll x;
    cin>>n>>x;
    vll a(n);
    forn(i,0,n) cin>>a[i];
    ll ans = 0;
    forn(i,0,n) ans += a[i];
    forn(s,1,n) {
        vll b(n);
        forn(i,1,n) b[i] = min(a[i], a[i-1]);
        b[0] = min(a[0], a[n-1]);
        a = std::move(b);
        b.clear();
        ll sum = (ll)s*x;
        forn(i,0,n) sum += a[i];
        ans = min(ans, sum);
    }
    cout<<ans;
    
    
}



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

typedef long long ll;

ll H1, M1, H2, M2, K;
int main() {
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  cout << ((H2 * 60 + M2) - (H1 * 60 + M1)) - K << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int n;
    scanf("%d", &n);

    int p[n][3];
    for (int i = 0; i < n; i++) {
        int x, y, h;
        scanf("%d %d %d", &x, &y, &h);
        p[i][0] = x;
        p[i][1] = y;
        p[i][2] = h;
    }

    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            int ans_h = -1, cnt = 0;
            int ok = 1;
            int q[n][3];
            for (int l = 0; l < n; l++) {
                int x = p[l][0], y = p[l][1], h = p[l][2];
                if (h == 0) {
                    q[cnt][0] = x;
                    q[cnt][1] = y;
                    q[cnt][2] = h;
                    cnt++;
                    continue;
                }

                int tmp = abs(x - i) + abs(y - j) + h;

                if (tmp < 1) {
                    ok = 0;
                    break;
                }

                if (ans_h == -1) {
                    ans_h = tmp;
                    continue;
                }

                if (ans_h != tmp) {
                    ok = 0;
                    break;
                }
            }

            for (int k = 0; k < cnt; k++) {
                int x = q[k][0], y = q[k][1];
                if ((ans_h - abs(x - i) - abs(y - j)) > 0) {
                    ok = 0;
                    break;
                }
            }
            if (ok) {
                printf("%d %d %d\n", i, j, ans_h);
                return 0;
            }
        }
    }

    return 0;
}


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

int main() {
  string S; cin >> S;
  vector<string> v = { "", "A" };
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        for (int l = 0; l < 2; l++) {
          string T = v.at(i) + "KIH" + v.at(j) + "B" + v.at(k) + "R" + v.at(l);
          if (S == T) {
            cout << "YES" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  int k, x;
  cin >> k >> x;
  for (int i = -k + 1; i < k; ++i) {
    cout << " " << (i + x);
  }
  cout << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    double x1, y1, x2, y2, x3, y3, x4, y4;
    while (n--) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        if (y1 == y2 && y3 == y4) {
            cout << "YES" << endl;
            continue;
        } else if (y1 == y2 || y3 == y4) {
            cout << "NO" << endl;
            continue;
        }
        double a = (x2 - x1) / (y2 - y1);
        double b = (x4 - x3) / (y4 - y3);
        if (abs(a - b) < 1e-8) {
            cout << "YES" << endl;
            continue;
        }
        cout << "NO" << endl;
    }
    return 0;
}

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

int main(int argc, char const *argv[]) {
  int a,b,c,d;
  std::cin >> a >> b >>c >> d;

  if(a*b>c*d) std::cout << a*b << endl;
  else std::cout << c*d << endl;
  return 0;
}

Measured memory_bytes: 628
import Control.Monad
import Data.List
main = do
 [n,k] <- map read . words <$> getLine
 asbs<-replicateM n (map read . words <$> getLine)
 let sasbs = sort asbs
 let bs = map last sasbs
 print $ head (sasbs !! (f bs k))
f (x:xs) k
    |x>=k = 0
    |otherwise =1 + (f xs (k-x))


Measured memory_bytes: 131452
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }


    static Scanner cin;

    int X;

    void calc()
    {
        X = cin.nextInt();
        int now = 0;
        for(var i = 1;i <= X; i++)
        {
            now += i;
            if(now >= X)
            {
                Console.Write(i);
                break;
            }
        }
        Console.ReadLine();
    }


    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}


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

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

const long long MOD = 1000000007;

int main(){
  string s,t;
  cin >> s >> t;
  int a=s.size(),b=t.size();
  vector<vector<int>> dp(a+1,vector<int>(b+1,0));

  rep(i,a+1) dp.at(i).at(0) = i;
  rep(i,b+1) dp.at(0).at(i) = i;

  rep(i,a){
      rep(j,b){
          dp.at(i+1).at(j+1)=min(min(dp.at(i).at(j),dp.at(i+1).at(j)),dp.at(i).at(j+1));
          dp.at(i+1).at(j+1) += 1;

          if(s.at(i)==t.at(j)) dp.at(i+1).at(j+1)=min(dp.at(i+1).at(j+1),dp.at(i).at(j));
      }
  }
  cout << dp[a][b] << endl;
}


Measured memory_bytes: 6840
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
        a: [i64;n],
    }
    let mut b = vec![0;n+1];
    b[0] = a[0];
    for i in 0..n {
        if i+1 >n-1 {
            continue;
        }
        b[i+1] +=b[i] + a[i+1];
    }
    b.sort();
    // println!("{:?}", b);
    let mut ch = b[0];
    let mut ans:i64 = 0;
    let mut count:i64 = 1;
    for i in 1..n+1 {
        if ch == b[i]{
            count+=1;
        }else{
            ch = b[i];
            ans+=count*(count-1)/2;
            count = 1;
        }
        if i==n && count != 1 {
            ans+=count*(count-1)/2;
        }
    }
    println!("{}", ans);
}

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

int main(){
  ll k, x;
  cin >> k >> x;
  if(500*k >= x){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
    
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    bool flg = true;
    for (int i = 0; i < s.size(); ++i) {
        if ((i%2==0 && s[i]=='L') || (i%2!=0 && s[i]=='R')) flg = false;
    }
    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,ans=0;
	double d,x,y;
	cin>>n>>d;
	d=d*d;
	for (int i=1;i<=n;i++)
	{
		cin>>x>>y;
		double temp=x*x+y*y;
		if (d>=temp)   ans++;
	} 
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 3752
#include<stdio.h>
#include<stdlib.h>

#define N 100
#define INFTY 2000
#define NIL -1
#define WHITE 0
#define BLACK 1

int n;
int G[N+1][N+1]; 

int tree(){

  int i,j,v,u,mim,sum;
  int d[n],Pi[n],C[n];

  sum=0;

  for(u=1;u<=n;u++){
    d[u]=INFTY;
    Pi[u]=NIL;
    C[u]=WHITE;
  }
  d[1]=0;

  while(1){
    mim=INFTY;

    for(i=1;i<=n;i++){
      if(C[i]!=BLACK&&d[i]<mim){
	mim=d[i];
	u=i;
      }
    }
    if(mim==INFTY){
      break;
    }
    C[u]=BLACK;

    for(v=1;v<=n;v++){
      if(C[v]!=BLACK&&G[u][v]<d[v]&&G[u][v]!=NIL){
	Pi[v]=u;
	d[v]=G[u][v];
      }
    }
  }

  for(i=1;i<=n;i++){
    if(d[i]!=INFTY){
      sum+=d[i];
    }
  }

  return sum;
}

main(){

  int i,j;
  int pritree;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&G[i][j]);
    }
  }
  pritree=tree();

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

  return 0;
}

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

    bool isok = true;
    for(int i=0; i<n; i++){
        if(a[i]%2 == 0){
            if(!(a[i]%3 == 0  ||  a[i]%5 == 0)){
                isok = false;
            }
        }
    }
    if(isok){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const ll MOD = 1000000007;
const int H_MAX = 100;
const int W_MAX = 8;

int H, W, K;
vector<vector<ll>> dp(H_MAX+1, vector<ll>(W_MAX, -1));

int amd[9] = {1, 1, 2, 3, 5, 8, 13, 21, 34};

ll dfs(int h, int w) {
  if (dp[h][w]!=-1) return dp[h][w];
  if (h==0) return dp[h][w] = (w==0) ? 1 : 0;
  ll result = 0;

  if (w!=0) result += dfs(h-1, w-1) * amd[w-1] * amd[W-1-w];
  result += dfs(h-1, w) * amd[w] * amd[W-1-w];
  if (w!=W-1) result += dfs(h-1, w+1) * amd[w] * amd[W-2-w];
  result %= MOD;
  return dp[h][w] = result;
}

int main() {
  cin >> H >> W >> K;
  ll result = dfs(H, K-1);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    static int n;
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long K = sc.nextLong();
        long[] a = new long[n];
        for(int i=0;i<n;i++) a[i]=sc.nextLong();
        long[] bitCount = new long[41];
        // for simplicity we write in 1-base.
        for(int i=1;i<=40;i++){
            long mask = 1L<<(i-1);
            for(long w:a) bitCount[i] += (mask&w)>0?1:0;
        }
        // dp[i]: if bit[1],bit[2],...,bit[i] can be chosen randomly. The biggest value
        long[] dp = new long[41];
        for(int i=1;i<=40;i++){
            long mask = 1L<<(i-1);
            dp[i] = dp[i-1]+Math.max(bitCount[i],n-bitCount[i])*mask;
        }
        long ans = 0;
        for(long w:a) ans += w^K; // basic result, with no change
        for(int i=40;i>=1;i--){
            long mask = 1L<<(i-1);
            if((mask&K)==0) continue;
            long submask = ~(mask-1), X = K^mask;
            long cur = 0;
            for(int j=0;j<n;j++) {
                long now = (a[j]^X)&submask;
                cur += now;
            }
            cur += dp[i-1];
            ans = Math.max(ans,cur);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 63232
from itertools import accumulate
n=int(input())
a=list(map(int, input().split()))
acc=list(accumulate(a))
sumA=acc[-1]
cut=[0, 1, 2, len(a)-1]
score=[acc[cut[0]], acc[cut[1]]-acc[cut[0]], acc[cut[2]]-acc[cut[1]], acc[cut[3]]-acc[cut[2]]]
ans=max(score)-min(score)
for i in range(1,len(a)-1):
    cut[1]=i    
    while abs(acc[cut[1]]-acc[cut[0]]-acc[cut[0]]) > abs(acc[cut[1]]-acc[cut[0]+1]-acc[cut[0]+1]):
        cut[0]+=1 
    while abs(acc[cut[3]]-acc[cut[2]]-(acc[cut[2]]-acc[cut[1]])) > abs(acc[cut[3]]-acc[cut[2]+1]-(acc[cut[2]+1]-acc[cut[1]])):
        cut[2]+=1
    score=[acc[cut[0]], acc[cut[1]]-acc[cut[0]], acc[cut[2]]-acc[cut[1]], acc[cut[3]]-acc[cut[2]]]
    ans=min(ans, max(score)-min(score))

print(ans)


Measured memory_bytes: 25536
def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    
    kabu = 0
    tmp = inlis[0]
    shoji = 1000

    for i in range(0, n-1):
        if inlis[i] > tmp:
            shoji += inlis[i] * kabu
            tmp = inlis[i]
            kabu = 0
            #print(i, inlis[i], kabu, shoji)
            if inlis[i+1] > inlis[i]:
                kabu += shoji // inlis[i]
                shoji -= inlis[i] * kabu
                #print(i, inlis[i], kabu, shoji)
        elif inlis[i] <= tmp:
            if inlis[i+1] > inlis[i]:
                kabu += shoji // inlis[i]
                shoji -= inlis[i] * kabu
                tmp = inlis[i]
                #print(i, inlis[i], kabu, shoji)
    if inlis[n-1] > inlis[n-2]:
        shoji += inlis[n-1] * kabu
        kabu = 0
    print(shoji)





if __name__ == "__main__":
    main()

Measured memory_bytes: 9228
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	long long n,k,ans=0;
	cin>>n>>k;
	while (true){
		n=n/k;
		ans++;
		if (n==0){
			cout<<ans;
			re 0;
		}
	}
	re 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

#define ll long long

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int r;
int d;
ll x;

void input() {
  cin >> r >> d >> x;
}

void solve1() {
  ll cur;

  for (int i = 0; i < 10; ++i) {
    cur = 1ll * r * x - d;

    cout << cur << '\n';

    x = cur;
  }
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve1();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	const int mod=1000000007;
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		long[] h=new long[s[1]+2];
		long[,] ans=new long[s[0]+1,s[1]+2];
		h[1]=1;
		for(int i=2;i<s[1]+2;i++){h[i]=h[i-1]+h[i-2];}
		for(int i=1;i<s[1]/2+1;i++){h[i]*=h[s[1]-i];h[s[1]-i]=h[i];}
		h[s[1]]=0;
		ans[0,1]++;
		if(s[1]>1){
			for(int i=1;i<=s[0];i++){
				for(int j=1;j<=s[1];j++){				
					ans[i,j-1]=(ans[i,j-1]+ans[i-1,j]*(h[j-1]))%mod;
					ans[i,j]=(ans[i,j]+ans[i-1,j]*(h[s[1]+1]-h[j-1]-h[j]))%mod;
					ans[i,j+1]=(ans[i,j+1]+ans[i-1,j]*(h[j]))%mod;
				}
			}
			Console.WriteLine(ans[s[0],s[2]]);
		}
		else{Console.WriteLine(1);}
	}
}

Measured memory_bytes: 11220
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
     int H, W;

     cin >> H >> W;

     int pixels[W][H];

     
     for (int w = 0; w < (W + 2); w++) {
	  cout << "#";
     }
     cout << endl;

     char c;
     for (int h = 0; h < H; h++) {
	  cout << "#";
	  for (int w = 0; w < W; w++) {
	       cin >> c;
	       cout << c;
	  }
	  cout << "#" << endl;
     }
     
     for (int w = 0; w < (W + 2); w++) {
	  cout << "#";
     }
     cout << endl;

     return 0;
}


Measured memory_bytes: 256
N,M=gets.split.map(&:to_i)
hs=gets.split.map(&:to_i)
hs.unshift(0)

arr = [1] * (N+1)

M.times do
    a,b=gets.split.map(&:to_i)
    if hs[a] == hs[b]
        arr[a] = 0
        arr[b] = 0
    elsif hs[a]<hs[b]
        arr[a] = 0
    else
        arr[b] = 0
    end
end

arr.shift
# p arr
puts arr.sum


Measured memory_bytes: 22832
import scala.io.StdIn._
object Main extends App {
  val Array(n, y) = readLine.split(" ").map{_.toInt}
  val results = for {
    man <- 0 to n
    gosen <- 0 to (n - man) if man * 10000 + gosen * 5000 + (n - man - gosen) * 1000 == y
  } yield s"${man} ${gosen} ${n - man - gosen}"
  println(results.headOption.getOrElse("-1 -1 -1"))
}

Measured memory_bytes: 37044
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl                endl

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int x, int y) {                                                             //return x^y in order(log(y))
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
struct trio {
  T first{};
  T second{};
  T third{};
};
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class AMultiplication1 {
public:
  static void solve(istream &cin, ostream &cout) {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
  }
};


signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  AMultiplication1 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3696
#include <cstdio>
int main(){
    int S;
    int h, m, s;
    scanf ("%d" ,&S);
    
    h =  S / 3600;
    m =  (S /60) % 60;
    s =  S  % 60;
    
    printf("%d:%d:%d\n" , h , m , s);
}


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

using namespace std;

int main(void){
    string S;
    cin>>S;
    int ans=0;
    for(int i=0;i<S.size();i++){
        int count=0;
        for(int j=i;j<S.size();j++){
            if(S[j]=='A'||S[j]=='C'||S[j]=='G'||S[j]=='T') count++;
            else break;
        }
        ans=max(ans,count);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static <T> void printArray(T[] arr) {
        for (T x : arr)
            print(x, " ");
        printn("");
    }

    static <T> void print(T s, String sep) {
        System.out.print(s + sep);
    }

    static <T> void printn(T s) {
        System.out.println(s);
    }

    static Long[] inputArrL(int n, FastReader fr) {
        Long[] arr = new Long[n];
        for (int i = 0; i < n; i++)
            arr[i] = fr.nextLong();
        return arr;
    }

    static Integer[] inputArr(int n, FastReader fr) {
        Integer[] arr = new Integer[n];
        for (int i = 0; i < n; i++)
            arr[i] = fr.nextInt();
        return arr;
    }

    static int maxValue(Integer[] arr, int idx, int f, int[][] dp) {
        int res = 0;
        if (idx == arr.length)
            return 0;
        if (dp[idx][f] != -1)
            return dp[idx][f];
        if (f == 2) {
            if (arr[idx] == 0)
                res = Math.max(1 + maxValue(arr, idx + 1, 1, dp), maxValue(arr, idx + 1, f, dp));
            else
                res = Math.max(1 + maxValue(arr, idx + 1, f, dp), maxValue(arr, idx + 1, 1, dp));
        } else if (f == 1)
            res = Math.max(1 - arr[idx] + maxValue(arr, idx + 1, f, dp), arr[idx] + maxValue(arr, idx + 1, 0, dp));
        else
            res = arr[idx] + maxValue(arr, idx + 1, f, dp);
        return res;
    }

    static int max(int... args) {
        int max = Integer.MIN_VALUE;
        for (int x : args) {
            max = Math.max(x, max);
        }
        return max;
    }

    static int min(int... args) {
        int min = Integer.MAX_VALUE;
        for (int x : args) {
            min = Math.min(x, min);
        }
        return min;
    }

	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int k, x;
		k = fr.nextInt();
		x = fr.nextInt();
		if(500 * k >= x)
			printn("Yes");
		else
			printn("No");
	}
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int32_t main(){
    fast;
    int n;
    cin>>n;
    vector<pair<int,int> > d(n);
    for(int i=0;i<n;i++)
        cin>>d[i].first>>d[i].second;
    for(int i=2;i<n;i++){
        int count=0;
        if(d[i-2].ff==d[i-2].se)
            count++;
        if(d[i-1].ff==d[i-1].se)
            count++;
        if(d[i].ff==d[i].se)
            count++;
        if(count>2){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main() {
	int n;
	cin >> n;
	if(n%1000) cout << 1000 - (n%1000) << endl;
	else cout << 0 << endl;

	return 0;
}



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

int main()
{
	int n,k,ans=0;
	cin>>n>>k;
	for (int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		ans+=2*min(x,abs(x-k));
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
using System;

namespace AtCoder.BC087
{
    public class A
    {
        public static void Main()
        {
            int x, a, b;
            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            x -= a;

            Console.WriteLine(x % b);
        }
    }
}

Measured memory_bytes: 27272
N = int(input())
C = []
S = []
F = []
for _ in range(N-1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(N):
    t = 0
    for j in range(i, N-1):
        if t < S[j]:
            t = S[j]
        elif t % F[j] != 0:
            t += F[j]-t%F[j]
        t += C[j]
    print(t)

Measured memory_bytes: 9228
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

signed main(){
/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/
  int a;
  cin >> a;

  cout << a * (1 + a * (1 + a)) << endl;

  return 0;
}

Measured memory_bytes: 3196
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = MOD - 1;
const ll LLINF = 4e18;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<vector<int>> dp(n, vector<int>(n, 0));
    int ans = 0;
    REP(i, n - 1) {
        FOR(j, i + 1, n) {
            if (s[i] == s[j]) {
                dp[i][j] = 1;
                if (i > 0 && j > 0) {
                    if (j - i > dp[i - 1][j - 1]) {
                        dp[i][j] = dp[i - 1][j - 1] + 1;
                        ans = max(ans, dp[i][j]);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 98176
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let mut s = get!(String).chars().collect::<Vec<_>>();
    s[3] = '8';
    println!("{}", s.into_iter().collect::<String>());
}

Measured memory_bytes: 2060
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int M=1e9+7;

ll dp[100005][13];
char s[100005];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		if(s[i]!='?'){
			s[i]-='0';
			for(int j=0;j<13;j++)
				dp[i][(j*10+s[i])%13]=(dp[i][(j*10+s[i])%13]+dp[i-1][j])%M;
		}
		else{
			for(int k=0;k<10;k++)
				for(int j=0;j<13;j++)
					dp[i][(j*10+k)%13]=(dp[i][(j*10+k)%13]+dp[i-1][j])%M;
		}
	}
	cout<<dp[n][5];
	return 0;
}

Measured memory_bytes: 10496
import java.lang.reflect.Array;
import java.util.*;


public class Main {
    static class Schedule{
        int num;
        ArrayList<Integer> timeToNextStation, timeOfFirstTrain, freq;
        Schedule(int num){
            this.num = num;
            this.timeToNextStation = new ArrayList<Integer>(num);
            this.timeOfFirstTrain = new ArrayList<Integer>(num);
            this.freq = new ArrayList<Integer>(num);
        }

        void add(int c, int s, int f){
            this.timeToNextStation.add(c);
            this.timeOfFirstTrain.add(s);
            this.freq.add(f);
        }

        public int getTimeToNextStation(int i) {
            return timeToNextStation.get(i);
        }

        public int getTimeOfFirstTrain(int i) {
            return timeOfFirstTrain.get(i);
        }

        public int getFreq(int i) {
            return freq.get(i);
        }

        public int getNum() {
            return num;
        }

        int getTimeToFinalStation(int n){
            int count = 0;
            for(int i = n; i < this.num; i++){
                if(count < this.getTimeOfFirstTrain(i)) {
                    count = this.getTimeOfFirstTrain(i);
                }else if(count % this.getFreq(i) != 0){
                    count += this.getFreq(i) - count % this.getFreq(i);
                }
                count += this.getTimeToNextStation(i);
            }
            return count;
        }
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Schedule schedule = new Schedule(n-1);

        for(int i = 0; i < n-1; i++){
            int c = sc.nextInt();
            int s = sc.nextInt();
            int f = sc.nextInt();
            schedule.add(c, s, f);
        }

        for(int i = 0; i < schedule.getNum(); i++){
            System.out.println(schedule.getTimeToFinalStation(i));
        }

        System.out.println(0);
    }
}

Measured memory_bytes: 26416
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)

int main(){
    int N;
    map<string, bool> S;
    cin >> N;
    bool flag=false;
    string prev = "*";
    rep(i, 0, N)
    {
        string s;
        cin >> s;
        if (S[s] == false)
        {
            S[s] = true;
        }
        else
        {
            flag = true;
        }
        if(prev != "*"){
            if(prev[prev.size()-1] != s[0]){
                flag = true;
            }
        }


        prev = s;
    }
    if(flag) cout << "No" << endl;
    else cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define MAXN 1000
using namespace std;
int main(){
	int h,w;
	cin>>h>>w;
	char a[MAXN][MAXN]={'\0'};
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=h;i++){
		int flag=0;
			for(int j=1;j<=w;j++){
				if(a[i][j]=='.'){
					flag++;
				}else{
					break;
				}
			}
			if(flag==w){
				for(int j=1;j<=w;j++){
					a[i][j]='x';
				}
			}
	}
	// cout<<endl;
	// for(int i=1;i<=h;i++){
	// 	int flag=0;
	// 	for(int j=1;j<=w;j++){
	// 			cout<<a[i][j];
	//
	// 	}
	// 	cout<<endl;
	// }
	// cout<<endl;
	for(int i=1;i<=w;i++){
		int flag=0;
		for(int j=1;j<=h;j++){
			if(a[j][i]=='.'||a[j][i]=='x'){
				flag++;
			}else{
				break;
			}
		}
		if(flag==h){
			// cout<<"yes"<<i<<endl;
			for(int j=1;j<=h;j++){
				a[j][i]='x';
			}
		}
	}
	// cout<<endl;
	// for(int i=1;i<=h;i++){
	// 	int flag=0;
	// 	for(int j=1;j<=w;j++){
	// 			cout<<a[i][j];
	//
	// 	}
	// 	cout<<endl;
	// }
	// cout<<endl;
	for(int i=1;i<=h;i++){
		int flag=0;
		for(int j=1;j<=w;j++){
			if(a[i][j]!='x'){
				cout<<a[i][j];
				flag=1;
			}
		}
		if(flag)
		cout<<endl;
	}
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int save = n;
    int digitSum = 0;
    while(save)
    {
        digitSum += save%10;
        save /= 10;
    }
    
    if(n%digitSum==0 && digitSum!=0)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define in insert
#define er erase
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int) x.size()
using namespace std;
typedef vector <int> vi;
typedef vector <vector<int>> vii;
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
typedef long double ld;

const long double PI=3.141592653589793238462643383279502884;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main(){
    fast;
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    ll hr, mn;
    hr=h*60+m;
    mn=12*m;
    ld delt=abs(mn-hr);
    delt=delt/360;
    ld a1=a, b1=b;
    cout<<setprecision(12)<<sqrt(a1*a1+b1*b1-cos(delt*PI)*a1*b1*2);
    return 0;
}





Measured memory_bytes: 4192
#include<algorithm>
#include<typeinfo>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
#include<functional>
#include<bitset>
#include<stack>
#define e exp(1)
#define eps 0.01
#define pi acos(-1)
using namespace std;
typedef long long ll;
int main() {
    set<int>s;
    int a1, a2, a3;
    while (cin >> a1 >> a2 >> a3) {
        s.clear();
        s.insert(a1);
        s.insert(a2);
        s.insert(a3);
        if (s.size() == 1)
            cout << "0" << endl;
        else {
            set<int>::iterator it = s.begin();
            set<int>::iterator pre = it;
            it++;
            int ans = 0;
            for (; it != s.end(); it++) {
                ans += (*it - *pre);
                pre = it;
            }
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int Heap[251];
int NIL = -1;


int get_parent_index(int i) {
    if (i == 1) {
        return NIL;
    } else {
        return (i - (i % 2)) / 2;
    }
}

int get_left_child_index(int i, int max){
    int a = 2 * i;
    if (a >= max) {
        return NIL;
    } else {
        return  a;
    }
}

int get_right_child_index(int i, int max) {
    int a = 2 * i + 1;
    if (a >= max) {
        return NIL;
    } else {
        return a;
    }
}

int main() {
    int h;
    cin >> h;
    h++;
    for (int n=1; n < h; n++) {
        cin >> Heap[n];
    }

    for (int n=1; n < h; n++) {
        int id = n;
        int key = Heap[n];
        int parent_index = get_parent_index(id);
        int left_child_index = get_left_child_index(id, h);
        int right_child_index = get_right_child_index(id, h);

        cout << "node " << id << ": key = " << key << ", ";
        if (parent_index != NIL) {
            cout << "parent key = " << Heap[parent_index] << ", ";
        }
        if (left_child_index != NIL) {
            cout << "left key = " << Heap[left_child_index] << ", ";
        }
        if (right_child_index != NIL) {
            cout << "right key = " << Heap[right_child_index] << ", ";
        }
        cout << endl;
    }

    return 0;
}



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

int main(){
    int N,K;
    string str;
    cin >> N >> str >> K;

    for(int i = 0;i < str.size();i++){
      if(str.substr(K - 1,1) != str.substr(i,1))str.replace(i, 1, "*");
    }
    cout << str << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int func(int* a){
    for(int i=0; i<26; i++){
        if(*(a+i) % 2 == 1){
            return 0;
        }
    }
    return 1;
}

int main(){
    char w[101];
    scanf("%s", w);
    int a[26];
    for(int i=0; i<26; i++){
        a[i] = 0;
    }
    int buf = 0;
    while(w[buf] != '\0'){
        a[w[buf] - 'a'] += 1;
        buf++;
    }
    if(func(a) == 1){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int h,w;
    cin >> h >> w;
    char C[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> C[i][j];
        }
    }
    for(int i=0;i<2*h;i++){
        for(int j=0;j<w;j++){
            cout << C[i/2][j];
        }
        cout << endl;
    }
}

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


using namespace std;

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

const long long INF = 1LL << 60;

#define rep(i, e) for(int i = 0; i < e; i++)
#define repp(i, s, e) for(int i = s; i < e; i++)
#define MAX_N 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define NIL -1

void print(const std::vector<ll>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

int par[MAX_N];

void init(int n){
    rep(i,n) par[i]=i;
}

int find(int x){
    if(par[x]==x){
        return x;
    }else
    {
        return par[x] = find(par[x]);
    }
}

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

void tree_union(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    par[x] = y;
}

int main() {
    ull N,t[55],target=0,sum=0;
    string s[55],X;
    bool flag;
    cin >> N;
    rep(i,N){
        cin>>s[i]>>t[i];
    }
    cin>>X;
 
    flag = false;
    for (int i = 0; i < N; i++)
    {
        if(X == s[i]){
            flag = true;
            target = t[i];
        }
        if(flag) sum+=t[i];
    }
    cout << sum - target << endl;
}

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

int
str2int(char a, char b, char c)
{
    return (a-'0')*100 + (b-'0')*10 + (c-'0');
}

void
solver(int n, char *s)
{
    int c[1000], c1[100];
    int i, j, k;
    int p = strlen(s);
    int t=0;
    int m;

    bzero(c, sizeof(c));
    bzero(c1, sizeof(c1));
    
    for (i=0; i<p-2; i++) {
        for (j=i+1; j<p-1; j++) {
            m = str2int('0', s[i], s[j]);
            c1[m]++;
            if (c1[m]==1) {
                for (k=j+1; k<p; k++) {
                    m = str2int(s[i], s[j], s[k]);
                    if (c[m]==0){
                        t++;
                    }
                    c[m]++;
                }
            }
        }   
    }
    printf("%d\n", t);
}

int
main(int argc, char *argv[])
{
    int n;
    char s[30001];

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

    solver(n, s);
    return 0;
}

Measured memory_bytes: 256