akhauriyash/Code-Regression huggingface dataset:
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let k = scan.read::<usize>();
    let a = scan.readn::<i64>(n);
    let cum = Cum::new(&a);
    let cum2 = Cum2::new(&a);
    let mut ret = 0;
    for i in 0..n - k + 1 {
        ret = max(ret, cum2.sum(0..i) + cum.sum(i..i + k) + cum2.sum(i+k..n));
        ret = max(ret, cum2.sum(0..i) + cum2.sum(i+k..n));
    }
    println!("{}", ret);
}

#[derive(Debug)]
#[allow(dead_code)]
struct Cum {
    s: Vec<i64>,
}


#[allow(dead_code)]
impl Cum {
    fn new(a: &Vec<i64>) -> Cum {
        let mut s = vec![0; a.len() + 1];
        for i in 0..a.len() {
            s[i + 1] = s[i] + a[i];
        }
        Cum { s: s }
    }
    /// [l,r)
    fn sum(&self, range: Range<usize>) -> i64 {
        self.s[range.end] - self.s[range.start]
    }
}

use std::ops::Range;
use std::cmp::max;

#[derive(Debug)]
#[allow(dead_code)]
struct Cum2 {
    s: Vec<i64>,
}


#[allow(dead_code)]
impl Cum2 {
    fn new(a: &Vec<i64>) -> Cum2 {
        let mut s = vec![0; a.len() + 1];
        for i in 0..a.len() {
                s[i + 1] = s[i] + max(a[i], 0);
        }
        Cum2 { s: s }
    }
    /// [l,r)
    fn sum(&self, range: Range<usize>) -> i64 {
        self.s[range.end] - self.s[range.start]
    }
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

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

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

    int l,r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i=l; i<=r; ++i){
        if( (i % d) == 0 )
            ans++;
    }
    cout << ans << '\n';


    return 0;
}

Measured memory_bytes: 3564
fun main(args: Array<String>) {
    val s = readLine()!!
    var num = 0
    when(true) {
        s[0] == '1' -> {
            num += 1
        }
    }
    when(true) {
        s[1] == '1' -> {
            num += 1
        }
    }
    when(true) {
        s[2] == '1' -> {
            num += 1
        }
    }
    println(num)
}

Measured memory_bytes: 31480
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    unsigned long long int a, b, x; cin >> a >> b >> x;
    unsigned long long int ans = b / x + 1;
    if (a != 0) ans -= (a - 1) / x + 1;
    cout << ans << endl;
}


Measured memory_bytes: 3608
H,W=map(int,input().split())
A=[input() for i in range(H)]
from collections import Counter
count=Counter(''.join(A))
c4,c2=0,0
for c in count.most_common():
    e=c[1]
    if e>=4:
        c4+=e//4
        e=e%4
    if e>=2:
        c2+=e//2
a=1
if (H//2)*(W//2)>c4:
    a=0
else:
    c2+=(c4-(H//2)*(W//2))*2
if (H%2)*(W//2)+(W%2)*(H//2)>c2:
    a=0
print(['No','Yes'][a])

Measured memory_bytes: 3380
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> seq(n), occs(1e5 + 1);
	for (int i = 0; i < n; ++i) {
		cin >> seq[i];
		int a = seq[i] - 1;
		int b = seq[i] + 1;
		if (a >= 0) {
			++occs[a];
		}
		
		++occs[b];
		++occs[seq[i]];
	}

	int max_occs = 0;
	for (int i = 0; i <= 1e5; ++i) {
		max_occs = max(max_occs, occs[i]);
	}

	cout << max_occs << "\n";

	return 0;

}

Measured memory_bytes: 1024
using System;

public class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[1]);
        int b = int.Parse(input[2]);
        int n = int.Parse(input[0]);

        int res = 0;
        for (int i = 1; i <= n; i++)
        {
            int j = i;
            int sum = 0;
            while (j > 0)
            {
                sum += j % 10;
                j /= 10;
            }

            if (a <= sum && sum <= b)
                res += i;
        }

        Console.WriteLine(res);
    }
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int output = 0;
            if (n % 2 == 0) {
                output = n / 2 - 1;
            } else {
                output = n / 2;
            }

            Console.WriteLine(output);
        }
    }

}

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

using namespace std;
using ll = long long;
using ld = long double;

int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
    ll n, W;
    cin >> n >> W;
    vector<ll> w(n), p(n);
    for (int i = 0; i < n; i++) {
        cin >> w[i] >> p[i];
    }
    vector<pair<ll, ll>> v = {{0, 0}, {w[0], p[0]}};
    for (int i = 1; i < n; i++) {
        vector<pair<ll, ll>> t;
        for (auto e : v) {
            t.push_back(e);
            if (e.first + w[i] <= W) {
                t.push_back({e.first + w[i], e.second + p[i]});
            }
        }
        sort(t.begin(), t.end());
        v.clear();
        ll curMax = -1;
        for (auto e : t) {
            if (e.second <= curMax) {
                continue;
            }
            curMax = e.second;
            v.push_back(e);
        }
    }
    cout << v.back().second << "\n";
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){

	int num1,num2;
	int sum = 0;

	cin >> num1 >> num2;

	for (int i = num1; i <= num2; i++) {
		if( (i/10000) == (i%10) && ((i/1000)%10) == ((i/10)%10))
			sum++;
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>

int main(){
    int alpha[26];
    for (int i = 0; i < 26; i++){
        alpha[i] = 0;
    }

    char c;
    while (scanf("%c", &c) != EOF){
        c = tolower(c);
        if (isalpha(c)){
            alpha[c - 'a']++;
        }
    }

    for (int i = 0; i < 26; i++){
        printf("%c : %d\n",'a'+i , alpha[i]);
    }
    return 0;
}



Measured memory_bytes: 2660
#pragma GCC optimize("O3")
int main(void){
  puts("1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1");
  return 0;
}

Measured memory_bytes: 1524
import collections
import math

n = int(input())
s = []
for i in range(n):
    ss = input()
    s.append(tuple(sorted(collections.Counter(list(ss)).items())))
s = sorted(s)

ans = []
px = None
a = 0
for x in s:
    if x == px:
        a += 1
    else:
        px = x
        if a > 0:
            ans.append(a + 1)
        a = 0
if a > 0:
    ans.append(a + 1)
print(sum([math.factorial(a) // (2 * math.factorial(a - 2)) for a in ans]))


Measured memory_bytes: 70520
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define int long long
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
	int A,B,C,K;
	int D=0;
	bool a=false;
	cin>>A>>B>>C>>K;
	rep(i,A){
		D++;
		K--;
		if(K==0){
			a=true;
			break;
		}
	}
	if(!a){
		rep(i,B){
			K--;
			if(K==0){
				a=true;
				break;
			}
		}
	}
	if(!a){
		rep(i,C){
			D--;
			K--;
			if(K==0){
				a=true;
				break;
			}
		}
	}
	cout<<D<<endl;
}


Measured memory_bytes: 3212
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
//解説参照
int main(){
    int n,k;
    cin >> n >> k;

    vector<int> num(n);
    for ( int i = 0 ; i < n ; i++ ){
        int a;
        cin >> a;
        num.at(a-1)++;
    }
    sort(num.begin() , num.end() ,greater<int>());

    int  cnt = 0;
    for ( int i = 0 ; i < k ; i++ ) {
        cnt += num.at(i);
    }
    cout << n-cnt << endl;
}

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

const int mod = 1e9 + 7;
int n, k, a[105];
using ll = long long;
ll dp[105][100005];

int main()
{
	cin >> n >> k;
	
	for(int i = 1; i <= n; i++) 
	    cin>>a[i];
	
	dp[0][0] = 1;
	
	for(int i = 1; i <= n; i++)
	{
		ll pre = 0;
		for(int j = 0; j <= k; j++)
		{
			//dp[i][j] <- dp[i-1][j-a[i]] + ..... + dp[i-1][j]
			pre += dp[i - 1][j];
			if(j - a[i] - 1 >= 0) 
			    pre -= dp[i-1][j-a[i]-1];
			
			pre = (pre + mod)%mod;
			dp[i][j] = pre;
		}
	}
	
	cout << dp[n][k] << endl;
	
	return 0;
}

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

int main(void){
  string s;
  cin >> s;
  size_t size = s.length();
  int num=0;
  for(int i=0;i<size-1;i++){
  //cout<<s[i]<<" "<<s[i+1]<<endl;
    if(s[i]==s[i+1]){
      num+=1;
      //cout <<"before:"<< s[i+1] << endl;
      if(s[i+1]=='0')s[i+1]='1';
      else s[i+1]='0';
     // cout <<"after:"<< s[i+1] << endl;
    }   
  }
  cout<<num<<endl;

  return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
#define ll long long
ll n,W,a[105][2],dp[100008][105];

ll max(ll a,ll b) {return a>b?a:b;}

ll sack(ll i, ll w)
{
	if(i==n)
		return 0;

	if(dp[w][i]!=-1)
		return dp[w][i];

	dp[w][i] = sack(i+1,w);

	if(w+a[i][0]<=W)
		dp[w][i] = max( dp[w][i] , a[i][1]+sack(i+1,w+a[i][0]));

return dp[w][i];
}

int main()
{

	scanf("%lld %lld",&n,&W);

	for(ll i=0;i<n;i++)
	{
		scanf("%lld %lld",&a[i][0],&a[i][1]);
	}

	for(int i=0; i<105; i++)
		for(int j=0; j<100008; j++)
			dp[j][i]=-1;

	ll value = sack(0,0);

	printf("%lld\n",value);

	return 0;
}


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

p1=[i for i in P if i <= A]
p2=[i for i in P if A+1<= i <=B]
p3=[i for i in P if i >= B+1]

print(min([len(p1),len(p2),len(p3)]))

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

string str;
int joi, ioi;

int main(){
	while(cin >> str){
		joi = 0; ioi = 0;
		for(int i = 2; i < str.size(); i++){
			if(str[i-2] == 'J' && str[i-1] == 'O' && str[i] == 'I') joi++;
			if(str[i-2] == 'I' && str[i-1] == 'O' && str[i] == 'I') ioi++;
		}
		cout << joi << endl << ioi << endl;
	}
}

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

int main() {

	int a;
	string s;

	cin >> a >> s;

	if (a >= 3200) {
		cout << s << endl;
	}
	if (a < 3200) {
		cout << "red" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
# 9:39
s = gets.to_s.chomp
# p s.include?('N') ^ s.include?('S')
# p s.include?('E') ^ s.include?('W')
if !(s.include?('N') ^ s.include?('S')) && !(s.include?('E') ^ s.include?('W'))
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s;
	int ans = 0;
	cin >> s;
	int n = s.length();
	for(int i = 0; i < n; i++){
    	if(s.substr(i, 1) == "1") ans += 1;
    }
 	cout << ans << endl;
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

ll dp[1<<16], score[1<<16];
ll a[16][16];

ll rec(int S){
    if(dp[S] != -1) return dp[S];
    if(S == 0) return dp[S] = 0;

    ll ret = score[S];
    for(int T=S; T>0; T=T-1&S){
        if(S==T) continue;
        chmax(ret, rec(T) + rec(S^T));
    }

    return dp[S] = ret;
}

int main(void){
    int N; cin >> N; REP(i,1<<N) dp[i] = -1;
    REP(i,N)REP(j,N) cin >> a[i][j];

    REP(S,1<<N){
        REP(i,N)FOR(j,i+1,N) if(S>>i & S>>j & 1) score[S] += a[i][j];
    }

    ll ans = rec((1<<N)-1);
    cout << ans << en;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  loop(i, N) cin >> s.at(i);

  int M;
  cin >> M;
  vector<string> t(M);
  loop(i, M) cin >> t.at(i);

  vector<int> score(N, 0);
  int ans = 0;

  loop(i, N) {
    loop(j, N) {
      if (s.at(i) == s.at(j)) score.at(i) += 1;
    }

    loop(j, M) {
      if (s.at(i) == t.at(j)) score.at(i) -= 1;
    }
  }

  loop(i, N) {
    if (ans < score.at(i)) ans = score.at(i);
  }

  cout << ans << endl;
}


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

int main() {
	int n, k;
	cin>>n>>k;
	string s;
	cin>>s;
	string t = s;
	reverse(t.begin(), t.end());
	char c = 'z';
	for (auto &p:s) c = min(c, p);
	s += t;
	int mx = 0;
	for (int i = 0, cur = 0; i < s.length(); i ++) {
		if (s[i] == c) cur ++;
		else cur = 0;
		mx = max(mx, cur);
	}
	if (k >= 14 || (mx<<k-1) >= n) {
		for (int i = 0; i < n; i ++) cout<<c;
		return 0;
	}
	string ans;
	for (int i = 0; i <= n; i ++) {
		if (k > 1) {
			int j = i + n - 1;
			int cnt = 0;
			for (int k = j; k >= i && s[k] == c; k --) cnt ++;
			if (cnt < mx) continue;
			int d = (mx<<k-1) - mx;
			int f = i + d;
			string t = s.substr(f, n-(mx<<k-1));
			for (int l = n - 1; l >= n - (mx<<k-1); l --) t.push_back(c);
			reverse(t.begin(), t.end());
			if (ans.empty() || t < ans) {
				ans = t;
			}
		}
		else {
			string t = s.substr(i, n);
			if (ans.empty() || t < ans) {
				ans = t;
			}
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3672
public class Main {

	private static void solve() {
		int n = ni();
		int[] p = na(n);
		
		int count = 0;
		for (int i = 0; i < n; i ++) {
			if (i < n - 1 && i + 1 == p[i] && i + 2 == p[i + 1]) {
				count ++;
				i ++;
			} else if (i + 1 == p[i]) {
				count ++;
			}
		}
		System.out.println(count);
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			@Override
			public void run() {
				long start = System.currentTimeMillis();
				String debug = System.getProperty("debug");
				if (debug != null) {
					try {
						is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
					} catch (Exception e) {
						throw new RuntimeException(e);
					}
				}
				reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
				solve();
				out.flush();
				tr((System.currentTimeMillis() - start) + "ms");
			}
		}, "", 64000000).start();
	}

	private static java.io.InputStream is = System.in;
	private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
	private static java.util.StringTokenizer tokenizer = null;
	private static java.io.BufferedReader reader;

	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new java.util.StringTokenizer(reader.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	private static double nd() {
		return Double.parseDouble(next());
	}

	private static long nl() {
		return Long.parseLong(next());
	}

	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private static char[] ns() {
		return next().toCharArray();
	}

	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private static int[][] ntable(int n, int m) {
		int[][] table = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[i][j] = ni();
			}
		}
		return table;
	}

	private static int[][] nlist(int n, int m) {
		int[][] table = new int[m][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[j][i] = ni();
			}
		}
		return table;
	}

	private static int ni() {
		return Integer.parseInt(next());
	}

	private static void tr(Object... o) {
		if (is != System.in)
			System.out.println(java.util.Arrays.deepToString(o));
	}
}


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

int main(){
	string S;
	cin>>S;
	int num0=0;
	int num1=0;
	for(int i=0;i<S.length();++i){
		if(S[i]=='0')num0++;
		else num1++;
	}
	cout<<2*min(num0,num1)<<endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = (a+b)/2;
        if((a+b)%2==0){
            System.out.println(x);
        }
        else{
            System.out.println(x+1);
        }
   
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

long int combination(long int n, long int r);

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

long int combination(long int n, long int r)
{
	if(r>n-r) r = n-r;
	if(r == 0) return 1;
	else if(r == 1) return n;
	return (combination(n-1, r) + combination(n-1, r-1));
	//大きくなるとき
	/*
	long int tmp1, tmp2, tmp3;
	tmp1 = combination(n-1, r);
	if(tmp1>=MOD) tmp1 = tmp1%MOD;
	tmp2 = combination(n-1, r-1);
	if(tmp2>=MOD) tmp2 = tmp2%MOD;
	tmp3 = tmp1+tmp2;
	if(tmp3>=MOD) tmp3 = tmp3%MOD;
	return (tmp3);
	*/
}


int main(){
	int n;
	scanf("%d", &n);
	int array[n];
	for(int i=0; i<n; i++){
		scanf("%d", &array[i]);
	}

	int count=1, mode=0;
	for(int i=0; i<n-1; i++){
		if(mode==0){
			if(array[i]==array[i+1]) mode=0;
			else if(array[i]<array[i+1]) mode=1;
			else mode=-1;
		}
		else if(mode==1){
			if(array[i]>array[i+1]){
				count++;
				mode=0;
			}
		}
		else{
			if(array[i]<array[i+1]){
				count++;
				mode=0;
			}
		}
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N; cin >> N;
	if(N >= 30)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

ll kiri(ll a,ll b){return a%b==0?a/b:a/b+1;}

ll a,b,c,d;
map<ll,ll> mp;

ll dfs(ll n){
  if(n==0) return 0;
  if(n==1) return d;
  if(mp.count(n)) return mp[n];
  ll res=1e18;
  if(n<res/d) res=n*d;
  ll ret=min({
    res,
    d*abs(n-n/5*5)+c+dfs(n/5),
    d*abs(n-kiri(n,5)*5)+c+dfs(kiri(n,5)),
    d*abs(n-n/3*3)+b+dfs(n/3),
    d*abs(n-kiri(n,3)*3)+b+dfs(kiri(n,3)),
    d*abs(n-n/2*2)+a+dfs(n/2),
    d*abs(n-kiri(n,2)*2)+a+dfs(kiri(n,2))
  });
  mp[n]=ret;
  return ret;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll T; cin >> T;
  vector<ll> ans(0);
  rep(z,T){
    mp.clear();
    ll n;
    cin >> n >> a >> b >> c >> d;;
    ans.push_back(dfs(n));
  }
  rep(i,T){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 4472
n,k = map(int,input().split())
ans = 0
a = list(map(int, input().split()))

for i in range(n-1):
  for j in range(i+1,n):
    if a[i]>a[j]:
      ans +=1
ans2=0
for i in range(n):
  for j in range(n):
    if a[i]>a[j]:
      ans2+=1
k = k%(10**9+7)
ans = (ans*k)%(10**9+7) + (ans2*(k-1)*k//2)%(10**9+7)
print(ans%(10**9+7))

Measured memory_bytes: 3188
// Hovalhagh
// Ya Aziz & Hakim
// AliReza Kaboli

#include <bits/stdc++.h>

using namespace std;

int main() {
	int n, k, r, s, p, ans = 0;
	string t, sa;
	cin >> n >> k >> r >> s >> p >> t;
	for (int i = 0; i < n; ++i) {
		if (t[i] == 'r') {
			ans += p;
			sa += 'p'; 
		}
		else if (t[i] == 's') {
			ans += r;
			sa += 'r';
		}
		else {
			ans += s;
			sa += 's';
		}
	}
	for (int i = 0; i < n; ++i) {
		if (i + k < n && sa[i] == sa[i + k]) {
			if (sa[i + k] == 'r')
				ans -= r;
			else if (sa[i + k] == 's')
				ans -= s;
			else
				ans -= p;
			if (i + 2 * k < n) {
				if (sa[i] != 'r' && sa[i + 2 * k] != 'r')
					sa[i + k] = 'r';
				if (sa[i] != 's' && sa[i + 2 * k] != 's')
                                	sa[i + k] = 's';
				if (sa[i] != 'p' && sa[i + 2 * k] != 'p')
                        	        sa[i + k] = 'p';
			}
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

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

        int[] a = new int[3];
        int[] b = new int[3];
        for (int i=0; i<3; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }

        boolean ans = solve(a, b);

        System.out.println(ans ? "YES" : "NO");
    }

    private static boolean solve(int[] a, int[] b) {
        int[] count = new int[4];
        for (int i=0; i<3; i++) {
            count[a[i]-1]++;
            count[b[i]-1]++;
        }

        for (int i=0; i<4; i++) {
            if (count[i] > 2) return false;
        }

        return true;
    }
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

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

int main()

{

    ll n, x;
    cin >> n >> x;
    ll mn = inf;
    for(ll i = 0; i < n; i++)
    {

        ll z;
        cin >> z;
        x-=z;
        mn = min(mn, z);
    }
    ll xt = x/mn;
    cout << xt+n;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    priority_queue<P,vector<P>,greater<P>> que;
    REP(i,n){
        P p;
        cin>>p.se>>p.fi;
        que.push(p);
    }
    int now=0;
    while(que.size()){
        P p=que.top();que.pop();
        if(now+p.se>p.fi){
            cout<<"No"<<endl;
            return 0;
        }
        now+=p.se;
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-3;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define CHECK cout<<"arrived"<<endl

ll N,K;
vec d;
vector<P> D;
const ll MAXN=(1<<19)+1;

ll memo[MAXN][2];

void Solve(ll x){
    if(memo[x][1]>=0) return;
    if(!x) {
        memo[x][0]=0;
        return;
    }
    vector<P> p;
    rep(i,N) if(x & (1<<i)){
        ll A=x-(1<<i);
        Solve(A);
        if(memo[A][0]>=0) p.pb(mp(d[memo[A][0]],memo[A][0]));
        if(memo[A][1]>=0) p.pb(mp(d[memo[A][1]],memo[A][1]));
    }
    p.pb(mp(d[x],x));
    sort(ALL(p));
    U_ERASE(p);
    reverse(ALL(p));
    rep(i,2) memo[x][i]=p[i].second;
    return;
}


int main(){
    cin>>N; K=(1<<N);
    rep(i,MAXN) rep(j,2) memo[i][j]=-1;
    rep(i,K) {
        ll x; cin>>x;
        d.pb(x);
    }
    vec ans(K,0);
    Solve(K-1);
    //REP(i,1,K) cout<<memo[i][0]<<' '<<memo[i][1]<<endl;
    REP(i,1,K) ans[i]=max(d[memo[i][0]]+d[memo[i][1]],ans[i-1]);
    REP(i,1,K) cout<<ans[i]<<endl;

}

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

#define FOR(i, m, n) for (int i = int(m); i < int(n); i++)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
#define F first
#define S second
#define INF 1e9 + 7

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

typedef long long ll;

int main() {
    int a;
    string s;
    cin >> a >> s;
    if (a < 3200) {
        s = "red";
    }
    cout << s << endl;

    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    ll N; cin >>N;
    vector<ll> A(N); cin >>A;
    vector<ll> B(N); cin >>B;
    vector<ll> C(N); cin >>C;
    sort(ALL(A));
    //sort(ALL(B));
    sort(ALL(C));

    ll ans = 0;
    for (int j = 0; j < N; j++) { //B
        auto a_end = upper_bound(ALL(A), B[j]-1);  //cout<<FMT(*a_end)<<endl;
        ll a = a_end - A.begin();
        auto c_begin = lower_bound(ALL(C), B[j]+1); //cout<<FMT(*c_begin)<<endl;
        ll c = C.end() - c_begin;
        ans += a*c;
        //cout<<FMT3(B[j],a,c)<<endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

template<typename T>
bool is_even(T const& val){
  return val % 2 == 0;
}
template<typename T>
bool is_odd(T const& val){
  return !is_even(val);
}

int main(void)
{
  int A, B, C;
  cin >> A >> B >> C;
  if(is_odd(A) || is_odd(B) || is_odd(C)){
    cout << 0 << endl;
    return 0;
  }

  int a = (B+C)/2, b = (A+C)/2, c = (A+B)/2;
  int ans = 1;
  while(is_even(a) && is_even(b) && is_even(c)){
    int aa = (b+c)/2, bb = (a+c)/2, cc = (a+b)/2;
    ans++;
    if(aa == A && bb == B && cc == C){
      ans = -1;
      break;
    }
    a = aa, b = bb, c = cc;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  stack<char> stk;
  rep(i,n){
    if(!stk.empty() && (stk.top() == '(' && s.at(i) == ')')){
      stk.pop();
    }else{
      stk.push(s.at(i));
    }
  }
  int lcnt = 0;
  int rcnt = 0;
  while(!stk.empty()){
    if(stk.top() == '('){
      lcnt++;
    }else if(stk.top() == ')'){
      rcnt++;
    }
    stk.pop();
  }
  string result;
  rep(i,rcnt) result += '(';
  result += s;
  rep(i,lcnt) result += ')';
  cout << result << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if b - a <= k and c - a <= k and d - a <= k and e - a <= k and c-b <= k and d-b <= k and e-b <= k and d-c <= k and e-c <= k and e - d <= k:
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
 
struct Segmenttree {
	static const int N = 1 << 18;
	vector<ll>seg;
	vector<ll>idx;
	void st(ll p, ll v) {
		p += N - 1;
		seg[p] = v;
		idx[p] = p - N + 1;
		while (p > 0) {
			p = (p - 1) / 2;
			seg[p] = max(seg[2 * p + 1], seg[2 * p + 2]);
			if (seg[2 * p + 1] < seg[2 * p + 2])idx[p] = idx[2 * p + 2];
			else if (seg[2 * p + 1] > seg[2 * p + 2])idx[p] = idx[2 * p + 1];
			else idx[p] = min(idx[2 * p + 1], idx[2 * p + 2]);
		}
	}
	pair<ll, ll> query(ll l, ll r, ll a, ll b, ll k) {
		if (r <= a || b <= l)return { -inf,inf };
		if (l <= a && b <= r)return { seg[k],idx[k] };
		ll m = (a + b) / 2;
		auto p1 = query(l, r, a, m, 2 * k + 1);
		auto p2 = query(l, r, m, b, 2 * k + 2);
		if (p1.first > p2.first) return p1;
		else if (p1.first < p2.first)return p2;
		else return { p1.first,min(p1.second,p2.second) };
	}
 
	void init() {
		seg.resize(2 * N);
		idx.resize(2 * N);
		for (int i = 0; i < 2 * N; i++)seg[i] = -inf;
	}
	//[l,r]
	ll get(int l, int r) {
		return query(l, r + 1, 0, N, 0).first;
	}
	ll getidx(int l, int r) {
		return query(l, r + 1, 0, N, 0).second;
	}
	pair<ll, ll>getp(int l, int r) {
		return query(l, r + 1, 0, N, 0);
	}
};
 
ll dp[202020];
ll sum[202020];
ll MOD = 998244353;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
 
	int N;
	cin >> N;
	Segmenttree seg = Segmenttree();
	seg.init();
	
	vector<pair<ll, ll>>p(N);
	for (int i = 0; i < N; i++) {
		ll X, D;
		cin >> X >> D;
		p[i].first = X;
		p[i].second = D;
	}
	sort(all(p));
 
	for (int i = 0; i < N; i++) {
		seg.st(i,p[i].first + p[i].second);
	}
 
 
	dp[0] = 1;
	sum[0] = 1;
	for (int i = 1; i < N; i++) {
		int ok = i, ng = -1;
		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			if (seg.get(mid + 1,i-1) <= p[i].first)ok = mid;
			else ng = mid;
		}
		if (ok == 0)dp[i] = sum[i - 1];
		else dp[i] = (sum[i - 1] - sum[ok-1] + 8LL*MOD)%MOD;
		if (seg.get(0, i - 1) <= p[i].first)dp[i]++;
		sum[i] = sum[i - 1] + dp[i];
		sum[i] %= MOD;
	}
	ll ans = 1;
	for (int i = 0; i < N; i++) {
		ans += dp[i];
		ans %= MOD;
	}
	puts(ans);
 
	return 0;
}

Measured memory_bytes: 16512
#include <stdio.h>

int main(){
	int a,b,c,d;
	scanf("%d",&a);
	b=a;
	b=b/3600;
	c=a;
	c=c%3600;
	c=c/60;
	d=a;
	d=d%60;
	printf("%d:%d:%d\n",b,c,d);
}


Measured memory_bytes: 1932
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    
    int a = scanner.nextInt();
    int b = scanner.nextInt();
	int c = scanner.nextInt();
    
    String sa = String.valueOf(a);
    String sb = String.valueOf(b);
    String sc = String.valueOf(c);
    
    int ab = Integer.parseInt(sa + sb);
    int ac = Integer.parseInt(sa + sc);
    int ba = Integer.parseInt(sb + sa);
    int bc = Integer.parseInt(sb + sc);
    int ca = Integer.parseInt(sc + sa);
    int cb = Integer.parseInt(sc + sb);
    
    if (a >= b && b >= c) {
      System.out.println(ab + c);
    } else if (a >= c && c >= b) {
      System.out.println(ac + b);
    } else if (b >= a && a >= c) {
      System.out.println(ba + c);
    } else if (b >= c && c >= a) {
      System.out.println(bc + a);
    } else if (c >= a && a >= b) {
      System.out.println(ca + b);
    } else if (c >= b && b >= a) {
      System.out.println(cb + a);
    }
  }
}

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

int main() {
    int k, t;
    cin >> k >> t;
    vector<int> a(t);
    rep(i,t) cin >> a[i];
    sort(all(a));
    int mx = a[t-1];
    int e = k-mx;
    if(mx-1 <= e) cout << 0 << endl;
    else cout << mx-1-e << endl;
    return 0;
}

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

int main() {
  string s, t; cin >> s >> t;
  bool flag = false;
  if (s == t) flag = true;
  vector<char> svec(s.size());
  vector<char> tvec(t.size());
  for (int i = 0; i < s.size(); i++) {
    svec.at(i) = s.at(i);
  }
  for (int i = 0; i < t.size(); i++) {
    tvec.at(i) = t.at(i);
  }
  sort(svec.begin(), svec.end());
  sort(tvec.begin(), tvec.end());
  reverse(tvec.begin(), tvec.end());
  if (flag) {
    cout << "No" << endl;
  }
  else {
    if (svec > tvec) cout <<"No" << endl;
    else cout << "Yes" << endl;
  }
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N[4];
    int result;

    for(int i=0;i<4;i++)scanf("%d",&N[i]);

    for(int i=0;i<4;i++){
        if(N[i]==1){result++;break;break;}
    }

    for(int i=0;i<4;i++){
        if(N[i]==9){result++;break;break;}
    }

    for(int i=0;i<4;i++){
        if(N[i]==7){result++;break;break;}
    }

    for(int i=0;i<4;i++){
        if(N[i]==4){result++;break;break;}
    }    

    if(result==4)printf("YES\n");
    else printf("NO\n");

    return 0;
}

Measured memory_bytes: 128
use std::cmp;
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 行ごとのiterが取れる
    let mut iter = buf.split_whitespace();
    let amount: u32 = iter.next().unwrap().parse().unwrap();
    // Nの最大値 + 1こ作っとく
    let mut dp: Vec<u32> = vec![amount; 100001 as usize];
    dp[0] = 0;

    for n in 1..(amount + 1) {
        let n = n as usize;
        dp[n] = cmp::min(dp[n], dp[n - 1] + 1);

        // その要素番号(金額)までの最小手を求めて現在のdp[n]より小さければそちらを採用する
        fill_min_step_to_dp(&mut dp, 6, n);
        fill_min_step_to_dp(&mut dp, 9, n);
    }
    println!("{}", dp[amount as usize]);
}

fn fill_min_step_to_dp(dp: &mut Vec<u32>, coin: u32, n: usize) {
    for j in 1..n {
        if n as u32 >= coin.pow(j as u32) {
            dp[n] = cmp::min(dp[n], dp[n - coin.pow(j as u32) as usize] + 1);
        } else {
            break;
        }
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll n,s;cin >> n >>s;
    vvl dp(n+1,vl(s+1,0));
    vl a(n);rep(i,n)cin >> a[i];
    //a[0]=inf;
    dp[0][0]=0;
    rep(i,n){
        rep(j,s+1){
            if(j+a[i]<=s){
                dp[i+1][j+a[i]]+=dp[i][j];
                dp[i+1][j+a[i]]%=MOD9;
            }
            dp[i+1][j]+=dp[i][j];
            dp[i+1][j]%=MOD9;
        }
        dp[i+1][0]++;
        if(a[i]<=s)dp[i+1][a[i]]++;
    }
    ll ans=0;
    rep(i,n+1){
        ans+=dp[i][s];
        ans%=MOD9;
    }
    cout <<ans <<endl;
}   

Measured memory_bytes: 70784
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1

#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <random>
#include <ctime>

const long long INF = 10000000000000000;

using namespace std;



int main(){
	int K,S;
	cin>>K>>S;
	int ans=0;
	for(int x=0;x<=K;x++){
		for(int y=0;y<=K;y++){
			int tmp=x+y;
			if( tmp<=S && S-tmp<=K){
				ans++;
				//cout<<x<<" "<<y<<" "<<S-(x+y)<<endl;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ans = 0
"""
for c in range(1,N):
    ans += len(make_divisors(N-c))
print(ans)
"""

for a in range(1,N):
    ans += (N-1)//a
print(ans)

Measured memory_bytes: 62960
N,K = map(int,input().split())
S = input()

ans = ""
cou = 0

for i in S:
    if cou + 1 == K:
      if S[cou] == "A":
        i = "a"
      elif S[cou] == "B":
        i = "b"
      else:
        i = "c"
    ans += i
    cou += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n,k;
    in(n,k);
    vector<int> vec(n);
    int minv,mini;
    rep(i,n){
        in(vec[i]);
        if(vec[i]==1){
            minv=vec[i];
            mini=i;
        }
    }
    int l,r,ans=10000000,kaisuu;
    for(int i=0;i<k;i++){
        l=mini-i;
        r=mini+k-1-i;
        //debug(l,r);
        kaisuu=1;
        if(l>0){
            kaisuu+=l/(k-1);
            if(l%(k-1)!=0)kaisuu++;
        }
        if(r<n){
            kaisuu+=(n-1-r)/(k-1);
            if((n-1-r)%(k-1)!=0)kaisuu++;
        }
        ans=min(ans,kaisuu);
    }
    out(ans);
}

Measured memory_bytes: 3836
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class test
{	

    public static int ans = 0;
    public static int n;
    //public static int m;
    //public static int cnt;

    public static void Main()
	{
        int[] nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int n = nums[0];
        int m = nums[1];

        int[] islands = new int[n];
        int[] A = new int[m];
        int[] B = new int[m];

        for(int i = 0 ; i < m ; i++)
        {
            nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            A[i] = nums[0];
            B[i] = nums[1];
        }
        Array.Sort(B,A);
        int c = 0;
        for(int i = 0 ; i < m ; i++)
        {
            if(A[i] < c){
            } else {
                islands[B[i]-1] = 1;
                c = B[i];
            }
        }
        ans = islands.Sum();
        Console.WriteLine(ans);
 
        
    }
}

Measured memory_bytes: 18400