akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int N;
  cin>>N;
  vector<string> a(N);
  rep(i,0,N) cin>>a[i];
  int check=0;
  
  rep(i,0,N){
    if(i==0){
      if(a[0][a[0].length()-1]!=a[1][0]){
        check++;
      }
    }else if(i==N-1){
      if(a[i][0]!=a[i-1][a[i-1].length()-1]){
        check++;
      }
    }else{
      if(a[i][0]!=a[i-1][a[i-1].length()-1]){
        check++;
      }
      if(a[i][a[i].length()-1]!=a[i+1][0]){
        check++;
      }
    }
    if(check) break;
    rep(j,0,N){
      if(i!=j){
        if(a[i]==a[j]){
          check++;
        }
      }
    }
    if(check) break;
  }

  cout<<(!check?"Yes":"No");
    
    
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

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

void solve() {
  int n;
  cin >> n;
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if (n == i * j) {
        cout << "Yes\n";
        return;
      }
    }
  }
  cout << "No\n";
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> h(n);
    for(int& x : h) {
        scanf("%d", &x);
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j : {i + 1, i + 2}) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,a,i;
set<int>t;
main(){
  for(cin>>n;i++<n;){
    cin>>a;
    if(t.find(a)!=t.end())t.erase(a);
    else t.insert(a);
  }
  cout<<t.size()<<endl;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef pair<int,int> PII;
int a,b;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define MAX(a,b) a>b? a:b
#define MIN(a,b) a>b? b:a

int MINN(vector<int>a,int k){
int min=1e9;
REP(i,k){
  if(a[i]<=min)min=a[i];
}
return min;
}

int main(){
int n;
cin>>n;
vector<int> v(n);
set<int> s;
REP(i,n){
  cin>>v[i];
  s.insert(v[i]);
}
cout<<s.size()<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){

    vector<long long> Lines;
    long long N;

    cin >> N;

    for(long long i = 0; i < N; i++){
        long long tmp;
        cin >> tmp;
        Lines.push_back(tmp);
    }

    sort(Lines.begin(), Lines.end());

    long long sum = 0;

    for(long long i = 0; i < N - 1; i++){
        sum += Lines[i];
    }

    if(Lines[N - 1] < sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
ans=[0]*M
a=0
for i in range(N):
  A=list(map(int,input().split()))
  for j in range(1,A[0]+1):
    ans[A[j]-1]+=1
for x in range(M):
  if ans[x]==N:
    a+=1
print(a)

Measured memory_bytes: 9180
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,{chars :$base :expr } ) =>{read_value !($iter ,String ) .chars () .map (|c |(c as u8 -$base as u8 ) as usize ) .collect ::<Vec <usize >>() } ;($iter :expr ,{char :$base :expr } ) =>{read_value !($iter ,{chars :$base } ) [0 ] } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,char ) =>{read_value !($iter ,chars ) [0 ] } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .unwrap () } ;}
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,mut $var :ident :$t :tt $($r :tt ) *) =>{let mut $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;($iter :expr ,mut $var :ident $($r :tt ) *) =>{input_inner !{$iter ,mut $var :usize $($r ) *} } ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;($iter :expr ,$var :ident $($r :tt ) *) =>{input_inner !{$iter ,$var :usize $($r ) *} } ;}
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;(iter =$iter :ident ,$($r :tt ) *) =>{let s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut $iter =s .split_whitespace () ;input_inner !{$iter ,$($r ) *} } ;($($r :tt ) *) =>{let s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut iter =s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;}
fn main() {
    input!(n, a: [i64; n]);
    let ans = a.into_iter().fold(1i64, |acc, x| acc.saturating_mul(x));
    println!("{}", if ans > 10i64.pow(18) { -1 } else { ans });
}


Measured memory_bytes: 4716
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
#include <string>
#include <limits>
using namespace std;
int gcd(int a, int b)//最大公約数
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
vector<int> v;
class Calc
{
    // 宣言
    long long a;

    public:
        // 素因数分解
        void decompositPrime(long long a);
};

/*
 * 素因数分解
 */
void Calc::decompositPrime(long long n)
{
    // 割る数の初期値
    a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            //printf("%d * ", a);
             v.push_back(a);
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    v.push_back(n);
    //printf("%d\n", n);
}
vector<int> divisor(int n) {//約数発見
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    std::sort(ret.begin(), ret.end());
    return ret;
}
long nc2(long n){
    return n*(n-1)/2;
}
template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
	static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string ret;
	static numeric_limits<TypeInt> t;
	TypeInt n = v;
	if (t.is_signed) {
		if (v < 0) n *= -1;
	}

	while (n >= base) {
		ret += table[n%base];
		n /= base;
	}
	ret += table[n];
	if (t.is_signed) {
		if (v < 0 && base == 10) ret += '-';
	}
	// 文字列の順番を逆にする
	std::reverse(ret.begin(), ret.end());

	return ret;
}
int main(){
    //std::stack<int> stack;
    int n,q;
    cin >> n;
    vector<long> a(n);
    vector<long> cnt(1000000,0);
    long sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
        cnt[a[i]] ++;
    }
    cin >> q;
    vector<long> b(q);
    vector<long> c(q);
    for(int i = 0; i < q; i++){
        cin >> b[i] >> c[i];
    }
    for(int i = 0; i < q; i++){
        if(cnt[b[i]] != 0){
            sum += c[i]*cnt[b[i]];
            sum -= b[i]*cnt[b[i]];
            cnt[c[i]] += cnt[b[i]];
            cnt[b[i]] = 0;
        }
        cout << sum << endl;
    }
    //cout << ans << endl;
    return 0;
}






Measured memory_bytes: 13472
n, y = map(int, input().split())
money = y
flag = False
for i in range(money // 10000 + 1):
    money = y - 10000 * i
    if i + money // 1000 < n: continue
    for j in range(money // 5000 + 1):
        tmp = money - 5000 * j
        k = tmp // 1000
        if i + j + k == n:
            print('{} {} {}'.format(i, j, k))
            flag = True
            break
    if flag: break
if not flag: print('-1 -1 -1')

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

int main(){
	int n,m,c;
	cin>>n>>m>>c;
	int a[n][m];
	int b[m];
	int res = 0;
	for(int i=0;i<m;i++)cin>>b[i];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	int sum=0;
	for(int i=0;i<n;i++){
		sum=0;
		for(int j=0;j<m;j++){
			sum += a[i][j]*b[j];
		}
		if(sum+c>0)res++;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,i,ans=0;
    cin>>a;
    for(i=1;i<=a;i++)
    {
        if(i%3!=0 && i%5!=0)
            ans+=i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3624
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>

#pragma warning( disable: 4996 )

using namespace std;

typedef long long ll;

#define INF 1000000000
#define EPS 1e-10

#define MAX_N 256
#define MAX_M 256

int N, M;
map<string, bool> m;

vector<string> ans_list;

int main(){

	cin >> N;
	for (int i = 0; i < N; i++){
		string str;
		cin >> str;
		m[str] = true;
	}
	cin >> M;
	string ans[3];
	ans[0] = "Closed by ";
	ans[1] = "Opened by ";
	ans[2] = "Unknown ";
	int count = 0;

	for (int i = 0; i < M; i++){
		string tmp;
		cin >> tmp;
		if (m[tmp]){
			count++;
			ans_list.push_back(ans[count % 2] + tmp);
		}
		else{
			ans_list.push_back(ans[2] + tmp);
		}
	}


	for (int i = 0; i < ans_list.size(); i++){
		cout << ans_list[i] << endl;
	}

	return 0;

}

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

char  grid[1005][1005];
long long int  mem[1005][1005];

long long int  n,m;

long long int  dp(long long int  i,long long int  j)
{
	if(i==n-1 && j==m-1){
		return 1;
	}
	if(mem[i][j]!=-1)
	{
		return mem[i][j];
	}
	long long int  x=0;
	if(i+1<n && grid[i+1][j]=='.'){
		x = (x+dp(i+1,j))%1000000007;
	}
	if(j+1<m && grid[i][j+1]=='.')
	x = (x+dp(i,j+1))%1000000007;
	mem[i][j]=x;
	//cout<<"i: "<<i<<" j: "<<j<<" = "<<x<<endl;
	return x;
}

int  main(){
	
	cin>>n>>m;
	for(long long int i=0;i<n;i++)
	{
		for(long long int j=0;j<m;j++)
		{
			cin>>grid[i][j];
		}
	}
	memset(mem,-1,sizeof(mem));
	long long int  ans = dp(0,0)%1000000007;
	cout<<ans;
	return 0;
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

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

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;


int main() {
    ll X;
    cin >> X;

    ll limit = 400;

    for (ll a = -limit; a < limit; ++a) {
        for (ll b = -limit; b < limit; ++b) {
            if (X == pow(a, 5) - pow(b, 5)) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    cout << "aaa" << endl;
}

Measured memory_bytes: 4100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

 
int main() {
    int n;
    cin>>n;
    int a[n];
    map<int,int> m;
    rep(i,n){
        cin>>a[i];
        m[a[i]]++;
    }
    
    ll sum=0;
    for(auto u : m){
        ll x=u.second;
        sum+=(x*(x-1)/2);
    }
    rep(i,n){
        ll x=m[a[i]];
        ll ans=sum-(x*(x-1)/2)+((x-2)*(x-1)/2);
        cout<<ans<<endl;
    }
}

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

int main(){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  for(int i=1; i<=K; i++){
    if(A == max({A,B,C})) A = A*2;
    if(B == max({A,B,C})) B = B*2;
    if(C == max({A,B,C})) C = C*2;
  }
  cout << A+B+C << endl;
}


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

int main()
{
    int N;
    string S;

    cin >> N;
    cin >> S;

    if (N % 2 == 0)
    {
        string S1, S2;

        for (int i = 0; i < N / 2; i++)
        {
            S1 += S[i];
        }

        for (int i = N / 2; i < N; i++)
        {
            S2 += S[i];
        }

        if (S1 == S2)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
const double eps = 1e-9;
const double inf = 1e18;

int n,m;
vector<bool> used(20,false);
double dist[20][20];

double search(int step, int prev, double total){
	if(step == 0){
		return total;
	}
	if(step+prev > n){
		return 0;
	}
	
	double ret = 0;
	for(int i=prev+1; i<n; i++){
		if(used[i]) continue;
		double add_dist=0;
		for(int j=0; j<n; j++){
			if(used[j]) add_dist += dist[i][j];
		}
		used[i] = true;
		ret = max(ret, search(step-1, i, total+add_dist) );
		used[i] = false;
	}
	return ret;
}

int main(){
	cin >> n >> m;
	
	vector<double> L(n),a(n),b(n);
	for(int i=0; i<n; i++){
		cin >> L[i] >> a[i] >> b[i];
	}
	
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			dist[i][j] = dist[j][i] =
			(L[i]-L[j])*(L[i]-L[j]) +(a[i]-a[j])*(a[i]-a[j]) +(b[i]-b[j])*(b[i]-b[j]);
		}
	}
	
	cout << fixed;
	cout << setprecision(6);
	cout << search(m,-1,0) << endl;
	return 0;
}

Measured memory_bytes: 3288
S = input()[::-1]
n = len(S)

cnt = [0] * 2019
cnt[0] = 1
m = 0
d = 1
for i in S:
  m += int(i) * d
  m %= 2019
  cnt[m] += 1
  d *= 10
  d %= 2019

ans=0
for i in cnt:
  ans += int(i*(i-1)/2)
print(ans)

Measured memory_bytes: 68340
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  char c=s[0];
  bool b=true;
  for(int i=1; i<4; i++){
    if(c==s[i]){b=false; break;}
    c=s[i];
  }
  if(b) cout << "Good";
  else cout << "Bad";
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a,b,c,d int
	fmt.Scan(&a,&b,&c, &d)

	for i:= 0; i < 100; i++ {
		c = c-b
		a =a-d
		if c <=0 {
			fmt.Println("Yes")
			return

		}
		if a <=0 {

			fmt.Println("No")
			return
		}
	}

}



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


int main(){
  long long n,k,ans;
  cin >> n >> k;
  ans=0;
  if(n%k!=0){
  while(n>=1){
    n=n/k;
    ans++;
  }
}else{
  while(n>=1){
    n=n/k;
    ans++;
  }
}
  cout << ans << endl;
  return 0;
}


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

namespace q3
{
    class Program
    {
        static void Main(string[] args)
        {
            var input1 = Console.ReadLine().Split(' ').Select(x => Convert.ToInt64(x)).ToArray();
            var N = input1[0];
            var K = input1[1];

            var v = N % K;

            v = Math.Min(Math.Abs(v - K), v);
            Console.WriteLine(v);
        }
    }
}


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

int solution(){
    string s,t;
    getline(cin, s);
    getline(cin, t);
    ll n = s.length(); 
    ll m = t.length();
    
    vector<vector<ll> > dp(n+1, vector<ll> (m+1, 0) );
    for(ll i = 1;i <= n;i++){
        for(ll j  = 1;j <= m;j++){
            if(s[i-1] == t[j-1])
                dp[i][j] = dp[i-1][j-1]+1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    string ans = "";
    ll i = n,j = m;
    while(i > 0 && j > 0){
        if(s[i-1] == t[j-1]){
            ans.insert(ans.begin(), s[i-1]);
            i--; j--;
        }
        else if(dp[i-1][j] > dp[i][j-1])
            i--;
        else
            j--;
    }
    cout<<ans<<"\n";
    return 0;
}

int main(){
    int T = 1; //cin>>T;
    while(T--)
        solution();
    return 0;
}

Measured memory_bytes: 73608
import sys
from collections import defaultdict
from itertools import groupby

read = sys.stdin.read

N, *C = map(int, read().split())
C = [i for i, _ in groupby(C)]
mod = 10 ** 9 + 7
cnt = defaultdict(int)
dp = 1
for i in C:
    prev = dp
    dp = (cnt[i] + dp) % mod
    cnt[i] = (cnt[i] + prev) % mod

print(dp)


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


void solve(long long A, long long B, long long C){
  cout << min(B/A, C) << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


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

using namespace std;

int main(){
  int N;
  int X[100010];
  int L[100010];
  cin >> N;
  int ans=N;
  long long num[100010];
  for(int i=0; i<N; i++){
    cin >> X[i] >> L[i];
    num[i]=i;
  }
  sort(num, num+N, [&X](size_t i1, size_t i2){
    return X[i1]<X[i2];
  });
  sort(X, X+N);
  for(int i=0; i<N-1; i++){
    if(X[i]+L[num[i]]>X[i+1]-L[num[i+1]]){
      ans--;
      if(X[i]+L[num[i]]<X[i+1]+L[num[i+1]]){
        X[i+1]=X[i];
        L[num[i+1]]=L[num[i]];
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys
INF = float("inf")


def Run_length_encoding(S: str):
    """AAABBC -> [(A, 3), (B, 2), (C, 1)]
    """
    ans = []
    curr = S[0]
    counter = 0
    for c in S:
        if c == curr:
            counter += 1
        else:
            ans.append((curr, counter))
            curr = c
            counter = 1
    ans.append((curr, counter))
    return ans


def solve(N: int, S: str):
    print(len(Run_length_encoding(S)))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()


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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

const int R = 1000000;
const int mod = 998244353;

int n;
int freq[R + 5], multi[R + 5];
long long sum[R + 5];
bool isp[R + 5];
int mu[R + 5];
int f[R + 5]; // 1 / N = sum(d | N) f(d)
// so that ab / gcd(a, b) = ab * sum(d | a, d | b) f(d)

int expo(int a, int b){
	int c = 1, d = a;
	while(b){
		if(b & 1){
			c = 1LL * c * d % mod;
		}
		d = 1LL * d * d % mod;
		b >>= 1;
	}
	return c;
}

void compute_mu(){
	for(int i = 1; i <= R; i++){
		mu[i] = 1;
		isp[i] = true;
	}
	for(int i = 2; i <= R; i++){
		if(isp[i]){
			for(int j = i; j <= R; j += i){
				isp[j] = false;
				if((j / i) % i == 0){
					mu[j] = 0;
				}else{
					mu[j] *= -1;
				}
			}
		}
	}
}

int inv(int num){
	return expo(num, mod - 2);
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		int a;
		scanf("%d", &a);
		freq[a]++;
	}
	
	for(int i = 1; i <= R; i++){
		for(int j = i; j <= R; j += i){
			multi[i] += freq[j];
			sum[i] += 1LL * freq[j] * j;
		}
	}
	
	compute_mu();
	for(int i = 1; i <= R; i++){
		for(int j = i; j <= R; j += i){
			f[j] = (f[j] + mu[i] * i) % mod;
		}
		f[i] = (1LL * f[i] * inv(i)) % mod;
		if(f[i] < 0){
			f[i] += mod;
		}
	}
	
	// sum over all (i, j), w/o i < j restriction
	int ans = 0;
	for(int i = 1; i <= R; i++){
		sum[i] %= mod;
		ans = (ans + 1LL * sum[i] * sum[i] % mod * f[i]) % mod;
	}
	// subtract those duplicate indices: LCM(x, x) = x.
	for(int i = 1; i <= R; i++){
		ans = (ans - 1LL * i * freq[i]) % mod;
	}
	
	// divide answer by 2
	ans = (1LL * ans * inv(2)) % mod;
	if(ans < 0) ans += mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 24704
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

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

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int N;
    cin >> N;
    vector<double> v(N, 0.0);
    for (int i = 0; i < N; i++)
        cin >> v[i];

    sort(all(v));

    double value = v[0];
    while (!v.empty()) {
        value = (value + v[0])/2.0;
        v.erase(v.begin());
    }

    printf("%.5lf\n", value);
    return 0;
}


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

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
   
    int n,m; cin>>n>>m; int c[m],dp[n+1]; dp[0]=0;
    for (int j = 0; j < m; j++) cin>>c[j];
    for (int i = 1; i <= n; i++){
        dp[i]=i;
        for (int j = 0; j < m; j++){
            if(i>=c[j]){
                dp[i]=min(dp[i],1+dp[i-c[j]]);
            }
        }
    }
    cout<<dp[n]<<'\n';
}


Measured memory_bytes: 3368
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 998244353
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
ll digitpower(ll a,ll b){//aのb乗を計算
  if(b==1){
    return a;
  }else if(b==0){
    return 1;
  }
  if(b%2==1){
    ll tmp = digitpower(a,(b-1)/2);
    tmp%=d9_7;
    tmp*=tmp;
    tmp%=d9_7;
    tmp*=a;
    return (tmp)%d9_7;
  }else{
    ll tmp = digitpower(a,(b)/2);
    tmp%=d9_7;
    tmp*=tmp;
    tmp%=d9_7;
    return (tmp)%d9_7;
  }
}
int main(void){
  ll n;
  cin>>n;
  vl d(n);
  rep(i,n)cin>>d[i];
  if(d[0]!=0){
    cout<<0;
    return 0;
  }
  rep(i,n){
    if(i!=0 && d[i]==0){
      cout<<0;
      return 0;
    }
  }
  sort(d.begin(),d.end());
  vl d2(n+1,0);
  rep(i,n){
    d2[d[i]]++;
  }
  ll ans=1;
  int begin=0;
  rep(i,n){
    if(begin==0 && d2[n-i]==0)continue;
    begin=1;
    ans*=digitpower(d2[n-i-1],d2[n-i]);
    //if(d2[n-i-1]==0 && d2[n-i]==0)ans=0;
    ans%=d9_7;
  }
  cout<<ans%d9_7<<endl;
  return 0;
}


Measured memory_bytes: 1792
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

gap = a[1] - a[0]
minv = a[0]
for j in range(1, n):
    gap = max(gap, a[j] - minv)
    minv = min(minv, a[j])

print(gap)


Measured memory_bytes: 13588
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N,M;
	cin >> N>>M;
	ll A[N];
	REP(i,N)cin>>A[i];
	P CB[M];
	for (ll i = 0; i < M; ++i){
		ll b,c;cin>>b>>c;
		CB[i] = make_pair(c,b);
	}
	// 解法
	sort(A, A+N);
	sort(CB, CB+M, greater<P>());
	// REP(i,M){
	// 	printf("%lld, %lld\n", CB[i].second, CB[i].first);
	// }
	// printf("------------------\n");
	// REP(i,N)printf("%lld\n", A[i]);
	// printf("------------------\n");
	ll idx_BC = 0;
	ll idx_slide = 0;
	ll ans = 0;
	bool stop_flag = false;
	while (idx_BC<M and stop_flag==false){
		
		for (ll i = idx_slide; i < idx_slide+CB[idx_BC].second; ++i){
			if (i>=N or A[i]>CB[idx_BC].first){
				stop_flag = true;
				idx_slide = i;
				break;
			}
			else{
				ans += CB[idx_BC].first;
				
				// printf("i: %lld, idx_BC; %lld, ans: %lld\n",
				// 	i, idx_BC, ans);
			}
		}
		if (stop_flag==false){
			idx_slide += CB[idx_BC].second;
			idx_BC++;
		}
	}
	while (idx_slide<N){
		ans += A[idx_slide];
		// printf("idx: %lld, ans: %lld\n",
		// 	idx_slide, ans);
		idx_slide++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const long long inf = 1LL<<60;

bool is_prime(int n) {
  if(n <= 1) return false;
  else if(n == 2) return true;
  else if(n % 2 == 0) return false;
  else {
    for(int i = 3; i*i <= n; i+=2) {
      if(n % i == 0) return false;
    }
    return true;
  }
}

int main() {
  int q; cin >> q;
  vector<int> s(100010, 0);
  for(int i = 1; i < 100010; i++) {
    if(is_prime(i) && is_prime((i+1)/2)) s[i] = s[i-1] + 1;
    else s[i] = s[i-1];
  }
  for(int i = 0; i < q; i++) {
    int l, r; cin >> l >> r; l--;
    cout << s[r] - s[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 3788
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, Q, ans = 0, x;
	vector<int> a;
	
	cin>>N>>Q;
	
	
	a.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>a[i];
	}
	
	a.push_back(INF);
	
	for(int z = 0; z < Q; z++){
		cin>>x;
		ans = 0;
		for(int i = 0, j = 0, sum = 0; i < N; i++){
			for(; j < N+1; j++){
				if(sum > x) break;
				sum += a[j];
			}
			// cout<<i<<" "<<j<<" "<<sum<<endl;
			ans += j-i-1;
			sum -= a[i];
		}
		cout<<ans<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 4444
import java.util.Scanner;
import java.util.Arrays;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a[] = new int [3];
    for(int i = 0;i < 3;i++){
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    int count = 0;

    if(a[2] % 2 != (a[0] + a[1] + a[2]) % 2){
      a[0]++;
      a[2]++;
      count++;
    }

    while(a[0] != a[2] || a[1] != a[2]){
      if(a[1] != a[2]){
        a[0]++;
        a[1]++;
        count++;
      }else{
        a[0] += 2;
        count++;
      }
    }


    System.out.println(count);
  }
}

Measured memory_bytes: 23636
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};const isPrime=(n:number):boolean=>{if(n<2)return false;const suq=Math.sqrt(n);for(let i=2;i<=suq;i++){if(n%i==0){return false;}}return true;};
const main=()=>{
  let [n,s]=[tn(),ts()],c=0
  for(let i=0;i<n-2;i++){
    if(s[i]=='A'&&
    s[i+1]=='B'&&
    s[i+2]=='C')c++
  }
  to(c)
}
main()


Measured memory_bytes: 11468
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	N := scanInt(sc)
	K := scanInt(sc)
	hs := make([]int, N)
	for i := 0; i < N; i++ {
		hs[i] = scanInt(sc)
	}

	costs := make([]int, N)
	costs[0] = 0
	costs[1] = abs(hs[1] - hs[0])
	for i := 2; i < N; i++ {
		minCost := math.MaxInt32
		for j := 1; j <= K && j <= i; j++ {
			cost := costs[i-j] + abs(hs[i]-hs[i-j])
			if cost < minCost {
				minCost = cost
			}
		}
		costs[i] = minCost
	}
	fmt.Println(costs[N-1])
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int a, b;
	cin >> a >> b;
	a--; b--;

	cout << a * b << endl;
}

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

	solve();
}


Measured memory_bytes: 384
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from copy import deepcopy
#import heapq
#import math
#import string

setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
a=[int(i) for i in input().split()]
card=sum(a)
snuke=0
ans=10**10
for i in range(n-1):
    snuke+=a[i]
    ans=min(ans,abs(snuke-(card-snuke)))
print(ans)

Measured memory_bytes: 23792
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+7
#define MOD 1000000007
using namespace std;



int main(){
    int x;
    cin >> x;
    if(x==3 || x==5 || x==7){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#define FASTIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//#define BZ
//#define PBDS
//#define POINT

#ifndef BZ
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("no-stack-protector")
#pragma GCC target ("tune=native")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize ("conserve-stack")
//#pragma GCC optimize ("no-stack-limit")
#endif

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using str = string;
using pll = pair<ll, ll>;

#ifdef POINT
using point = complex<ll>;
#define x real
#define y imag
#endif

#ifdef PBDS
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//using namespace __gnu_pbds::detail;
template <class T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#endif

#define INF 0x7fffffffffffffffLL
#define BASE 1000000007LL // 3 * 10**9 + 19 // 998244353 - rev == pow(n + m, BASE - 2)
#define MAX(type) std::numeric_limits<type>::max()
#define MIN(type) std::numeric_limits<type>::min()

#define LOG(v) cout << #v << " " << v << "\n";

#define pb push_back
#define eb emplace_back
//#define all(c) c.begin(), c.end()
//#define rall(c) c.rbegin(), c.rend()
#define F first
#define S second
#define forEach(c) for (auto &it : c)
#define loop while (true)
#define mp make_pair
#define mt make_tuple

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

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

inline ll divUp(ll a, ll b) {
	return (a + b - 1)/b;
}

void solve() {
	ll a, b;
	cin >> a >> b;
	if (b % a == 0) {
		cout << a + b << "\n";
	} else {
		cout << b - a << "\n";
	}
}

//#define LOCAL

int main() {
	FASTIO
#ifdef LOCAL
	auto start = std::chrono::system_clock::now();
#endif
	solve();
#ifdef LOCAL
	auto end = std::chrono::system_clock::now();
	std::chrono::duration<ld> elapsed_seconds = end - start;
	cerr << "\ntime: " << elapsed_seconds.count() << " s\n";
#endif
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,vl>;
using Tu = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
const ll INF=1LL<<60;
const ll MOD=1000000007;


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

    for(ll i=0;i<M;i++){
        if(1+i<M-i){
            cout<<1+i<<" "<<M-i<<endl;
        }
        else break;
    ;}
    for(ll i=0;i<M;i++){
        if(M+1+i<2*M+1-i){
            cout<<M+1+i<<" "<<2*M+1-i<<endl;
        }
        else break;
    ;}



    return 0;
}


Measured memory_bytes: 3644
<?php
$arr1 = [
     0 => 'A',  1 => 'B',  2 => 'C',  3 => 'D',  4 => 'E',
     5 => 'F',  6 => 'G',  7 => 'H',  8 => 'I',  9 => 'J',
    10 => 'K', 11 => 'L', 12 => 'M', 13 => 'N', 14 => 'O',
    15 => 'P', 16 => 'Q', 17 => 'R', 18 => 'S', 19 => 'T',
    20 => 'U', 21 => 'V', 22 => 'W', 23 => 'X', 24 => 'Y', 25 => 'Z'
]; 

while($tmp = fgets(STDIN)){
    $str[] = trim($tmp);
}

$arr2 = str_split($str[1]);

for($i=0; $i<count($arr2); $i++){
    $res[] = array_search($arr2[$i], $arr1);
}

for($i=0; $i<count($res); $i++){
    
    if(($res[$i] + $str[0]) > 25){
        $arr3[] = $res[$i] + $str[0] - 26;
    } else {
        $arr3[] = $res[$i] + $str[0] ;
    }

    
}

for($i=0;$i<count($arr3);$i++){
    $ans[] = $arr1[$arr3[$i]];
}

$res = implode($ans);

echo $res;

Measured memory_bytes: 6648
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (A, B) = nextIntList()
    println((A + B) % 24)
}

Measured memory_bytes: 35984
#include <bits/stdc++.h>
using namespace std;
long long f[3005][3005],pre[3005][3005];
int a[3005];
const int mod=998244353;
int main() {
  int N,V;
  cin>>N>>V;
  for(int i=1;i<=N;i++) {
    cin>>a[i];
  }
  for(int i=1;i<=N;i++) {
	for(int j=1;j<=V;j++) {
      if(j==a[i]) {
        f[i][j]=i;
      }else {
        if(j>=a[i]) {
          f[i][j]=pre[i-1][j-a[i]]%mod;
        }
      }
      pre[i][j]=(pre[i-1][j]+f[i][j])%mod;
    }
  }
  long long ans=0;
  for(int i=1;i<=N;i++) {
    ans=(ans+(N-i+1)*f[i][V]%mod)%mod;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 141184
def f(s):
    return len(s) != len(set(s)) or s[-1] >= 123


st = input()
if st == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit(0)
s = list(map(ord, st))
s += [97]
while f(s):
    if s[-1] == 123:
        s.pop()
    s[-1] += 1
print(''.join(map(chr, s)))

Measured memory_bytes: 3064
N, C, K = [int(i) for i in input().split()]
t_list = [0]*N

for i in range(N):
    t_list[i] = int(input())

t_list.sort()

bus_cnt = 0
bus_member = []
for t in t_list:
    if len(bus_member) != 0 and K < t - bus_member[0]:
        bus_member.clear()
        bus_cnt += 1

    bus_member.append(t)

    if C <= len(bus_member):
        bus_member.clear()
        bus_cnt += 1

if len(bus_member) != 0:
    bus_cnt += 1

print(bus_cnt)

Measured memory_bytes: 7468
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
struct UnionFind {
    vector<int> A;
    UnionFind(int n) : A(n, -1) {}
    int find(int x) {
        if (A[x] < 0) return x;
        return A[x] = find(A[x]);
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (A[x] > A[y]) swap(x, y);
        A[x] += A[y];
        A[y] = x;
    }
};
void okay() { cout << "Yes\n"; exit(0); }
void fail() { cout << "No\n"; exit(0); }
int main() {
    Int N, M, Q; cin >> N >> M >> Q;
    vector<int> A(Q), B(Q), C(Q);
    for (int i = 0; i < Q; i++) cin >> A[i] >> B[i] >> C[i];
    if (M == N - 1) {
        for (int i = 0; i < Q; i++) if (C[i] == 1) fail();
        okay();
    }
    UnionFind uf(N);
    for (int i = 0; i < Q; i++) if (C[i] == 0) {
        uf.unite(A[i], B[i]);
    }
    for (int i = 0; i < Q; i++) if (C[i] == 1) {
        if (uf.find(A[i]) == uf.find(B[i])) {
            fail();
        }
    }
    Int k = 0;
    for (int i = 0; i < N; i++) {
        if (uf.A[i] < 0) k++;
    }
    if (M <= N + k * (k - 3) / 2) {
        okay();
    } else {
        fail();
    }
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void) {
    int a[101],num,i,j,temp,count;
    while (scanf("%d",&num)!=EOF&&num!=0) {
        for (i=0; i<num; i++) scanf("%d",&a[i]);
        count=0;
        for (i=0; i<num-1; i++) {
            for (j=0; j<num-1-i; j++) {
                if (a[j]>a[j+1]) {
                    temp=a[j];
                    a[j]=a[j+1];
                    a[j+1]=temp;
                    count++;
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 600
ii = lambda : int(input())
li = lambda : list(map(int, input().split()))

n = ii()
h = li()

h2 = h[::-1]

if n==1:
    cnt = 0
else:
    cnt = 0
    for i in range(n-1):
        if h2[i] < h2[i+1]:
            h2[i+1] -= 1
            if h2[i] < h2[i+1]:
                cnt += 1

if cnt==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
#define ffor(n) for(int i = 0; i < n; i++)
#define fffor(n) for(int j = 0; j < n; j++)
int INF = 1e9 + 7;

int main(void) {
  int n, m;
  cin >> n >> m;
  vector <string> grid(	n);
  ffor(n) cin >> grid[i];
  vector <vector <int>> dp(n, vector <int>(m));
  dp[0][0] = 1;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      if (i + 1 < n && grid[i + 1][j] != '#') {
        dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % INF;
      }
      if (j + 1 < m && grid[i][j + 1] != '#') {
        dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % INF;
      }
    }
  }
  cout << dp[n - 1][m - 1] << '\n';
}

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

const ll MOD = 998244353;

ll box[200001];

void init(){
    box[0] = 1;
    for(int i = 1; i < 200001; i++){
        box[i] = box[i-1]*i;
        box[i] %= MOD;
    }
}

ll modpow(ll x, ll n){
  x %= MOD;
  if(n == 0) return 1; //再帰終了

  else if(n % 2 == 1){
    return  (x * modpow(x, n-1)) % MOD; //nが奇数ならnを1ずらす
  }else{
    return  modpow((x*x) % MOD, n/2) % MOD; //nが偶数ならnは半分になる
  }
}

ll comb(ll n, ll k){


    return box[n] * modpow(box[k] * box[n-k] % MOD, MOD-2)%MOD;
}


int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    init();
    ll ans = 0LL;
    //cout << box[10101] << endl;
    rep(i, k + 1){
        ans = ans + ((((m * comb(n-1, i))%MOD) * (modpow(m-1, n-1-i)) %MOD)% MOD) % MOD;
    }
    while(ans < 0){
        ans += MOD;
    }
    cout << ans%MOD << endl;
}

Measured memory_bytes: 5208
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100005;
int n,m,x,y,cnt[3],cntn,cntm,flag;
std::vector<int>e[N],er[N];
int col[N],ans=0;
void dfs(int x,int c){
	if (col[x]!=-1){
		if (col[x]!=c)flag=1;
		return;
	}
	cntn++;
	col[x]=c;
	cnt[col[x]]++;
	cntm+=e[x].size();
	for (int i=0;i<e[x].size();i++)dfs(e[x][i],(c+1)%3);
	for (int i=0;i<er[x].size();i++)dfs(er[x][i],(c+2)%3);
}
signed main(){
	scanf("%lld%lld",&n,&m);
	while (m--){
		scanf("%lld%lld",&x,&y);
		e[x].push_back(y);
		er[y].push_back(x);
	}
	memset(col,-1,sizeof col);
	for (int i=1;i<=n;i++)
		if (col[i]==-1){
			cnt[0]=cnt[1]=cnt[2]=0;
			cntn=cntm=flag=0;
			dfs(i,1);
			if (flag)ans+=cntn*cntn;
			else if (cnt[0]&&cnt[1]&&cnt[2])
				ans+=cnt[0]*cnt[1]+cnt[1]*cnt[2]+cnt[2]*cnt[0];
			else ans+=cntm;
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 18176
#include"bits/stdc++.h"
using namespace std;

int main(){
	int tmp[3];
	for(int i=0; i<3; i++){
		cin >> tmp[i];
		tmp[i] %= 2;
	}
	sort(tmp, tmp+3);
	if(tmp[1] == 1) cout << "Hom" << endl;
	else cout << "Tem" << endl;
}


Measured memory_bytes: 3140
#include <iostream>
#include <sstream>

using namespace std;

int main() {
  string tmp;
  while (cin >> tmp) {
    stringstream ss(tmp);
    char c;
    int status = 0;
    int a = 1;
    while (ss >> c) {
      switch (status) {
        case 0:
          if (c == '@')
            status = 1;
          else
            cout << c;
          break;
        case 1:
          a = c - '0';
          status = 2;
          break;
        case 2:
          for (int i = 0; i < a; ++i)
            cout << c;
          status = 0;
          break;
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll K,A,B;
    cin >> K >> A >> B;
    if(A+2 >= B || K+1 < A) cout << K+1 << endl;
    else {
        ll rest = K+1-A;
        if(rest%2 == 0) cout << rest/2*B-(rest/2-1)*A << endl;
        else cout << rest/2*B-(rest/2-1)*A+rest%2 << endl;
    }
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int mod = 1e9+7;
/*
ll GCD(ll a,ll b){return (a)?GCD(b%a,a):b;}
ll LCM(ll a, ll b){return a*b/GCD(a,b);}
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
*/
int dx[] = { -1,-1,-1,0,+1,+1,+1,0 };   // directional array
int dy[] = { -1,0,+1,+1,+1,0,-1,-1 };

ll GCD(ll a,ll b){return (a)?GCD(b%a,a):b;}
ll LCM(ll a, ll b){return a*b/GCD(a,b);}

int main()
{
    ios::sync_with_stdio(0);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    clock_t START_TIME = clock();
#endif*/
    ll n,m;
    cin>>n>>m;
    string s,t;
    cin>>s>>t;
    ll g=GCD(n,m);
    ll ans=LCM(n,m);
    bool ok=true;
    n/=g,m/=g;
    for(int i=0;i<g;i++)
    {
        if(s[i*n]!=t[i*m])
        {
            ok=false;
            break;
        }
    }
    if(!ok)
      cout<<-1<<endl;
    else
        cout<<ans<<endl;
/*#ifndef ONLINE_JUDGE
    cout << endl << "// Time taken = " << fixed << setprecision(5) << (clock() - START_TIME) * 1e3 / CLOCKS_PER_SEC << " ms";
#endif*/
}


Measured memory_bytes: 640