akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;

const int N = 100005;

int n, s[N];
long long ans = 0, le[N], ri[N];

void upd(long long bit[N], int u, int v)
{
    for (++u; u <= n; u += u & -u)
        bit[u] += v;
}

long long que(long long bit[N], int u)
{
    long long ret = 0;
    for (++u; u > 0; u -= u & -u)
        ret += bit[u];
    return ret;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> s[i];
    for (int ab = 1; ab < n; ab++)
    {
        for (int i = 0; i < n; i += ab)
            upd(le, i, s[i]);
        for (int i = n - 1; i >= 0; i -= ab)
            upd(ri, i, s[i]);
        for (int i = 0; i < n; i += ab)
        {
            int a = n - 1 - i;
            if (a <= ab)
                continue;
            if (a % ab == 0)
            {
                int tmp = a / ab;
                if (1LL * tmp * a - 1LL * (tmp - 1) * (a - ab) < n - 1)
                    continue;
            }
            ans = max(ans, que(ri, n - 1) - que(ri, a - 1) + que(le, i));
        }
        for (int i = 0; i < n; i += ab)
            upd(le, i, -s[i]);
        for (int i = n - 1; i >= 0; i -= ab)
            upd(ri, i, -s[i]);
    }
    cout << ans;
}


Measured memory_bytes: 2304
use std::collections::BTreeMap;

fn solve(a: &Vec<usize>, color: usize) -> bool {
    let n = a.len();
    let mut big = Big {
        map: BTreeMap::new(),
        color: color,
    };
    let mut start = 0;
    for i in 1..n {
        if a[i] <= a[i - 1] {
            big.increment(a[i]);
            start = i + 1;
            break;
        }
    }

    for i in start..n {
        if a[i] <= a[i - 1] {
            big.resize(a[i]);
            if !big.increment(a[i]) {
                return false;
            }
        }
    }
    true
}

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let n: usize = sc.read();
    let a: Vec<usize> = sc.read_vec(n);

    if (1..n).all(|i| a[i] > a[i - 1]) {
        println!("1");
        return;
    }

    let mut ng = 0;
    let mut ok = n;
    while ok - ng > 1 {
        let mid = (ok + ng) / 2;
        if solve(&a, mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    println!("{}", ok + 1);
}

struct Big {
    map: BTreeMap<usize, usize>,
    color: usize,
}

impl Big {
    fn increment(&mut self, index: usize) -> bool {
        if let Some(&v) = self.map.get(&index) {
            if v == self.color {
                self.map.remove(&index);
                if index == 1 {
                    false
                } else {
                    self.increment(index - 1)
                }
            } else {
                *self.map.get_mut(&index).unwrap() += 1;
                true
            }
        } else {
            self.map.insert(index, 1);
            true
        }
    }

    fn resize(&mut self, s: usize) {
        while let Some(&key) = self.map.keys().next_back() {
            if key > s {
                self.map.remove(&key);
            } else {
                break;
            }
        }
    }
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main() {
    int n;
    cin >> n;
    vector<int> p(n),q(n),r(n);
    for (int i = 0; i < n; ++i)cin >> p[i];
    for (int i = 0; i < n; ++i)cin >> q[i];

    r = min(p,q);
    p = max(p,q);
    int ans = 0;
    while(r != p) {
        next_permutation(r.begin(),r.end());
        ++ans;
    }
    cout << ans << endl;
    return 0;
}

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

constexpr int K = 18;
constexpr int Lm = 1e5;
constexpr int M = 1 << K;
constexpr int H = 1 << (K / 2);

int V[M+1], W[M+1], D[H+1][Lm+1]; 

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

    int N; cin >> N;
    for (int i = 1; i <= N; i++) cin >> V[i] >> W[i];
    for (int i = 1; i <= H; i++) {
        int p = i / 2;
        for (int j = 1; j <= Lm; j++) {
            D[i][j] = D[p][j];
            if (j >= W[i]) {
                D[i][j] = max(D[i][j], D[p][j-W[i]] + V[i]);
            }
        }
    }

    int Q; cin >> Q;
    for (int qi = 0; qi < Q; qi++) {
        int v, L; cin >> v >> L;
        if (v <= H) cout << D[v][L] << "\n";
        else {
            int Ans = 0;
            vector<pair<int, int>> P;
            while (v > H) {
                P.emplace_back(V[v], W[v]);
                v /= 2;
            }
            int Sz = P.size();
            for (int i = 0; i < (1 << Sz); i++) {
                int Vsum = 0, Wsum = 0;
                for (int j = 0; j < Sz; j++) {
                    if (i & (1 << j)) Vsum += P[j].first, Wsum += P[j].second;
                }
                if (Wsum > L) continue;
                Ans = max(Ans, D[v][L-Wsum] + Vsum);
            }
            cout << Ans << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 205716
#include<stdio.h>

#define N 101
#define INFTY 100000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
int M[N][N];

void dijkstra(void);

int main(){
  int i, j;
	int u, k, a, b;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      M[i][j] = INFTY;
    }
  }
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k);

    for(j = 0 ; j < k ; j++){
      scanf("%d%d",&a,&b);
      M[u][a] = b;
    }
  }
  dijkstra();

  return 0;
}

void dijkstra(){
  int i;
  int min, u, v;
  int d[N], color[N];

  for(i = 0 ; i < n ; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;

  while(1){
    min = INFTY;
    u = -1;
    for(i = 0 ; i < n ; i++){
      if(min > d[i] && color[i] != BLACK){
	u = i;
	min = d[i];
      }
    }
    if(u == -1) break;

    color[u] = BLACK;
    for(v = 0 ; v < n ; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > d[u] + M[u][v]){
	  d[v] = d[u] + M[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }

  for(i = 0 ; i < n ; i++){
    printf("%d ",i);

    if(d[i] == INFTY) printf("-1\n");
    else printf("%d\n",d[i]);
  }
}



Measured memory_bytes: 2080
#include <cstdio>

using namespace std;

int main(void){
	int t[11][11], n, i, j, sum;
	while(1){
		scanf("%d",&n);
		if(!n) break;
		for(i = 0;i < n;i++){
			for(j = 0;j < n;j++){
				scanf("%d",&t[i][j]);
			}
		}
		for(i = 0;i < n;i++){
			sum = 0;
			for(j = 0;j < n;j++){
				sum += t[i][j];
			}
			t[i][j] = sum;
			sum = 0;
			for(j = 0;j < n;j++){
				sum += t[j][i];
			}
			t[j][i] = sum;
		}
		sum = 0;
		for(j = 0;j < n;j++){
			sum += t[i][j];
		}
		t[i][i] = sum;
		for(i = 0;i < n + 1;i++){
			for(j = 0;j < n + 1;j++){
				printf("%5d",t[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

vllvll dp(110, vll(11000, 0));
vll v(1000);
vll w(1000);

ll rec(ll x, ll wei)
{
    if (x == 0) return dp[x][wei];
    if (wei >= w[x]) {
        return dp[x][wei] = max(rec(x-1, wei-w[x-1]) + v[x-1], rec(x-1, wei));
    } else {
        return dp[x][wei] = rec(x-1, wei);
    }
}

int main()
{
    ll N, W;
    cin >> N >> W;
    rep(i, 0, N) {
        cin >> v[i] >> w[i];
    }   
    rep(i, 0, W+1) {
        dp[0][i] = 0;
    }
    rep(i, 0, N) {
        rep(j, 0, W+1) {
            if (j - w[i] >= 0) {
                dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j]);
            } else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    /*
    rep(i, 0, N+1) {
        rep(j, 0, W+1) {
            cout << dp[i][j] << ' ';
        }
        cout << endl;
    }
    */
   ll mx = -1;
   rep(i, 0, W+1) {
       mx = max(mx, dp[N][i]);
   }
   cout << mx << endl;   
}


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

int main(){
  long x;
  cin >> x;
  long ans = x/11;
  ans*=2;
  if(x-11*(ans/2)>0){
    x=x-11*(ans/2);
    if(x<=6) ans++;
    else ans+=2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz(a) a.size()
#define INF 0x3f3f3f3f
#define de(x) cout<<#x<<"="<<x<<endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
using namespace std;
int main()
{
	int i,flag=0;
	string num;
	cin>>num;
	int len=num.size();
	for(i=0;i<len;i++){
		if(num[i]=='9'){
			flag=1;
			break;
		}
		else flag=0;
	}
	if(flag)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
def main():
  import sys
  buf=sys.stdin.buffer
  h,w=map(int,buf.readline().split())
  s=buf.readline()
  a=b=x=y=s[0]==35
  d,e=[b],[a]
  d_add,e_add=d.append,e.append
  for i in range(1,w):
    f=s[i]==35
    b+=a^f
    a=f
    d_add(b)
    e_add(a)
  for s in buf.read().split():
    f=s[0]==35
    y+=x^f
    b=y
    a=x=f
    p,q=[b],[a]
    p_add,q_add=p.append,q.append
    for i in range(1,w):
      f=s[i]==35
      b+=a^f
      c=d[i]+(f^e[i])
      if b>c:b=c
      a=f
      p_add(b)
      q_add(a)
    d,e=p,q
  print(b+1>>1)
main()

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

int main() {
	int N, l, r;
	cin >> N;
	int total = 0;
	for (int i = 0; i < N; i++) {
		cin >> l >> r;
		total += r - l + 1;
	}
	cout << total << endl;
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main (){
	int n;
	int m;
	cin>>n>>m;
	int MATR[n][m];
	for (int i=0; i<n; i++)
		for (int j=0; j<m; j++)
			cin>>MATR[i][j];
	int vector[m];
	for(int i=0; i<m; i++)
		cin>>vector[i];
		
	for(int i=0; i<n; i++){
		int res=0;
		for (int j=0; j<m; j++){
		res+=MATR[i][j]*vector[j];
		}
	cout<<res<<endl;
	}
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    int a,b,c;cin >> a >> b >> c;
    if(b-a ==  c -b)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

string s;
int dp[200005];
int pre[200005];
map<int,int> kecil;

int main()
{
  s = GetString();
  int st = 0;
  REP(i,SIZE(s))
  {
    pre[i] = st;
    st ^= (1 << (s[i] - 'a'));
  }
  // VALUE(kanan[1 << 8]);
  // dp[SIZE(s)] = 0;
  kecil[st] = 0;
  FORD(i,SIZE(s)-1,0)
  {
    int &ret = dp[i];
    ret = INF;
    if (kecil.count(pre[i]))
      MIN(ret,kecil[pre[i]] + 1);
    REP(j,26)
    {
      int nxt = pre[i] ^ (1 << j);
      if (kecil.count(nxt))
        MIN(ret,kecil[nxt] + 1);
    }
    if (kecil.count(pre[i]) == 0)
      kecil[pre[i]] = ret;
    else MIN(kecil[pre[i]],ret);
    // debug("%d %d\n",i,dp[i]);
  }
  printf("%d\n",dp[0]);
  return 0;
}










Measured memory_bytes: 11520
import sys,math,collections,itertools
input = sys.stdin.readline

#大きいものから適当に決める。
#総和は最大数を除いた和になる選び方ができる。
#適当に最大数を置いて、周囲に大きい数字から順に置いていく
#BFSかな
N = int(input())
road = [[] for _ in range(N+1)]#1~N番までの道
number = [0]*(N+1)#indexに置く数字のメモ。BFSでは0なら行き先追加
for _ in range(N-1):
    a,b=map(int,input().split())
    road[a].append(b)
    road[b].append(a)
c = list(map(int,input().split()))

q = collections.deque([])
cSort=sorted(c)
number[1]=cSort.pop()
q.append(1)

while q:
    now = q.popleft()
    for idx in road[now]:
        if number[idx]==0:
            q.append(idx)
            number[idx]=cSort.pop()
print(sum(number[2:]))
print(*number[1:])
    


Measured memory_bytes: 12124
#include<iostream>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if(a < b){
        cout << "a < b" << endl;
    }
    else if(a > b){
        cout << "a > b" << endl;
    }
    else if(a == b){
        cout << "a == b" << endl;
    }

    return 0;
}


Measured memory_bytes: 3120
import math


max_rank, target_score = map(int, input().split())

problems = []
min_problems_count = 0
for i in range(max_rank):
	problems.append(list(map(int, input().split())))
	min_problems_count += problems[i][0]


def calc_score(answer_status):
	score = 0
	for i in range(max_rank):
		if answer_status[i] == '1':
			score += (problems[i][0] * 100 * (i + 1) + problems[i][1])
	return score


def calc_problems_count(answer_status):
	count = 0
	for i in range(max_rank):
		if answer_status[i] == '1':
			count += problems[i][0]
	return count


if __name__ == '__main__':
	for i in range(2 ** max_rank):
		is_clear = True
		answer_status = str(format(i, 'b')).zfill(max_rank)
		score = calc_score(answer_status)
		count = calc_problems_count(answer_status)
		if score < target_score:
			is_clear = False
			shortage_score = target_score - score
			min_counts = []
			for j in range(max_rank):
				if answer_status[j] == '0':
					needed_count = math.ceil(shortage_score / ((j + 1) * 100))
					if needed_count <= problems[j][0]:
						min_counts.append(needed_count)
						is_clear = True
			if is_clear:
				count += min(min_counts)
		if is_clear and count < min_problems_count:
			min_problems_count = count
	print(min_problems_count)


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
    int n,r[30],i,j,w,m[30],l[30],a[11];
    char t[11],k;
    while(scanf("%d",&n),n!=0){
        for(i=0;i<n;i++){
            m[i]=0;
            l[i]=0;
            scanf(" %c",&t[i]);
            a[i]=i;
            for(j=0;j<n-1;j++){
                scanf("%d",&r[j]);
                if(r[j]==0){
                    m[i]++;
                }
                else if(r[j]==1){
                    l[i]++;
                }
            }
        }
        for(i=0;i<n-1;i++){
            for(j=i+1;j<n;j++){
                if(m[i]<m[j]){
                    w=m[i];
                    m[i]=m[j];
                    m[j]=w;
                    w=l[i];
                    l[i]=l[j];
                    l[j]=w;
                    k=t[i];
                    t[i]=t[j];
                    t[j]=k;
                    w=a[i];
                    a[i]=a[j];
                    a[j]=w;
                }
                else if(m[i]==m[j]){
                    if(l[i]>l[j]){
                        w=m[i];
                        m[i]=m[j];
                        m[j]=w;
                        w=l[i];
                        l[i]=l[j];
                        l[j]=w;
                        k=t[i];
                        t[i]=t[j];
                        t[j]=k;
                        w=a[i];
                        a[i]=a[j];
                        a[j]=w;
                    }
                    else if(l[i]==l[j]&&a[i]>a[j]){
                        w=m[i];
                        m[i]=m[j];
                        m[j]=w;
                        w=l[i];
                        l[i]=l[j];
                        l[j]=w;
                        k=t[i];
                        t[i]=t[j];
                        t[j]=k;
                        w=a[i];
                        a[i]=a[j];
                        a[j]=w;
                    }
                }
            }
        }
        for(i=0;i<n;i++){
            printf("%c\n",t[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define X first
#define Y second
#define mp make_pair
#define eb emplace_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
    char c = getchar();
    bool f = false;
    for (x = 0; !isdigit(c); c = getchar()) {
        if (c == '-') {
            f = true;
        }
    }
    for (; isdigit(c); c = getchar()) {
        x = x * 10 + c - '0';
    }
    if (f) {
        x = -x;
    }
}

const int MAX_N = 1100;
const double eps = 1e-8;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;





int main() {
#ifdef ANONYM
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
const long long Mod=1e9+7;
long long n,f[1000005],s[1000005],ans;
int main()
{
    scanf("%lld",&n);
    f[1]=f[2]=f[0]=s[0]=1;s[1]=2;s[2]=3;
    for(long long i=3;i<=n;i++)
    {
        f[i]=(f[i-1]+s[i-3])%Mod;
        s[i]=(s[i-1]+f[i])%Mod;
    }
    long long ans=f[n];
    ans=(ans+1ll*f[n-1]*(n-1)%Mod)%Mod;
    for(int i=0;i<=n-2;i++) ans=(ans+1ll*f[i]*(1ll*(n-1)*(n-1)%Mod+i+1)%Mod)%Mod;
    printf("%lld\n",1ll*ans);
    return 0;
}

Measured memory_bytes: 15744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll INF = 1e10;
int main()
{
    string s;
    cin >> s;
    int n = s.size();

    int ans = n;
    for(int i = 0; i < n; i++)
    {
        char c = s[i];
        int tmp = i;
        int before = i;
        for(int j = i+1; j < n; j++)
        {
            if(s[j] == c)
            {
                int diff = j - before - 1;
                tmp = max(tmp, diff);
                before = j;
            }
            else if(j == n-1)
            {
                int diff = j - before;
                tmp = max(tmp, diff);
            }
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


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

#define ll unsigned long long int
#define pb push_back
#define mk make_pair
#define mod 1000000007
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;t=1;
    while(t--){
        ll n;cin>>n;
        ll arr[n];
        ll sum=0;
        ll a[100001];
        for(int i=0;i<100001;i++){
            a[i]=0;
        }
        for(int i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];a[arr[i]]++;
        }
        ll q;cin>>q;
        while(q--){
            ll c,d;cin>>c>>d;
            sum+=a[c]*d;
            sum-=a[c]*c;
            a[d]+=a[c];
            a[c]=0;
            cout<<sum<<"\n";
        }
    }
    return 0;
}


Measured memory_bytes: 5172
import math._
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, M = in.nextInt
  val Hs = Array.fill(N)(in.nextInt)
  val roots = Array.fill(M)((in.nextInt - 1, in.nextInt - 1))

  val lookouts = Array.fill(N)(true)
  roots.foreach{case (a, b) =>
    if (Hs(a) <= Hs(b)) lookouts(a) = false
    if (Hs(a) >= Hs(b)) lookouts(b) = false
  }
  println(lookouts.count(identity))
}

Measured memory_bytes: 62656
from itertools import combinations
import numpy as np

n, k = map(int, input().split())
arr = np.array(list(map(int, input().split())))

ans = 1 << 60
for x in list(combinations(range(1, n), k - 1)):
    h = 0
    tmp_arr = arr.copy()
    for i in x:
        big = tmp_arr[:i].max() + 1
        if big > tmp_arr[i]:
            h += big - tmp_arr[i]
            tmp_arr[i] = big
    ans = min(ans, h)

print(ans)

Measured memory_bytes: 27468
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
using namespace std;

int main() {
  int n;
  cin >> n;
  int min_ = 1000;
  for (int i = 0;i < n;i++){
    int a;
    cin >> a;
    if (a % 2 == 1){
      min_ = 0;
      break;
    }
    int count = 0;
    while(true){
      a = a/2;
      count++;
      if (a%2 == 1){
        min_ = min(min_, count);
        break;
      }
    }
  }
  cout << min_ << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n;
  scanf("%d",&n);
  int a[n],b[n],c[n-1];
  for(int i=0;i<n;i++)scanf("%d",&a[i]);
  for(int j=0;j<n;j++)scanf("%d",&b[j]);
  for(int k=0;k<n-1;k++)scanf("%d",&c[k]);

  int s=0;
  for(int l=0;l<n;l++){
    s=s+b[l];
    if(a[l+1]==a[l]+1) s=s+c[a[l]-1];
  }
  printf("%d\n",s);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100

int main(void){
  int x[N],i;
  char nyan[N];
  i=0;
  while(scanf("%s",nyan)!=EOF){
    if(nyan[0]=='+'){
      x[i-2] = x[i-1]+x[i-2];
      i--;
    }
    else if(nyan[0]=='-'){
      x[i-2] = x[i-2]-x[i-1];
      i--;
    }
    else if(nyan[0]=='*'){
      x[i-2] = x[i-1]*x[i-2];
      i--;
    }
    else {
      x[i] = atoi(nyan);
      i++;
    }
  }
  printf("%d\n",x[i-1]);
  
  
  
  return 0;
  
}

Measured memory_bytes: 548
n,m = map(int, input().split())
hl = list(map(int, input().split()))

e = [[] for _ in range(n)]
for _ in range(m):
    u,v = map(int, input().split())
    u -= 1
    v -= 1
    e[u].append(v)
    e[v].append(u)

res = 0
for u in range(n):
    flag = True
    h = hl[u]
    for v in e[u]:
        if hl[v]>=h:
            flag = False
            break
    # print(u,flag)
    if flag:
        res += 1
print(res)

Measured memory_bytes: 29416
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

// http://arc079.contest.atcoder.jp/tasks/arc079_b

vector<int64_t>
seq_find(const int64_t n, const int64_t k)
{
  const int64_t inf = 10000000000001000LL;

  vector<int64_t> out(n, 0);
  const int64_t hi = (k + n - 1) / n;
  const int64_t lo = k / n;

  for(int64_t i = 0; i < n; ++i)
    if(i < k % n)
    {
      // out[i] = (hi - (k - hi) / n) * n;
      out[i] = hi * n - (k - hi) + n - 1;
    }
    else
    {
      // out[i] = (lo - (k - lo) / n) * n;
      out[i] = lo * n - (k - lo) + n - 1;
    }

  // {
  //   int64_t r = k;
  //   for(auto & i: cnt)
  //   {
  //     int64_t lo = 0, hi = 1 + min(r, inf / n);
  //     while(lo < hi && n < k - lo + 1) lo = lo ? 2 * lo : 1;
  //     if(n < k - lo + 1) return {};
  //     if(!(lo < hi)) return {};
  //     while(lo + 1 < hi)
  //     {
  //       i = (lo + hi) >> 1;
  //       (k - i < n ? lo : hi) = i;
  //     }
  //     i = lo;
  //     r -= i;
  //   }
  // }

  if(inf < *max_element(begin(out), end(out))) return {};
  if(*min_element(begin(out), end(out)) < 0) return {};
  return out;
}

void solve()
{
  int64_t k;
  cin >> k;

  for(int64_t n = 2; n < 51; ++n)
  {
    auto out = seq_find(n, k);
    if(!out.empty())
    {
      const auto sup = *max_element(begin(out), end(out));
      if(10000000000001000LL < sup) continue;

      cout << n << '\n';
      dump(begin(out), end(out), " ");
#ifdef BUG
      cout << '\n';
      size_t count  = 0;
      while(true)
      {
        auto iter = max_element(begin(out), end(out));
        if(*iter < n) break;
        for(auto & i: out) ++ i;
        *iter -= n + 1;
        // DEBUG(out);
        ++count;
      }
      cout << count << '\n';
#endif
      return;
    }
  }
}

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <cstring>

using namespace std;

struct Edge {
	int to, next;
}es[400010];
int first[200010], te = 0;

void addE(int a, int b)
{
	te++;
	es[te].to = b;
	es[te].next = first[a];
	first[a] = te;
}

int n;
int d[200010];
queue<int> Q;

void bfs(int pos)
{
	Q.push(pos);
	memset(d, -1, sizeof d);
	d[pos] = 0;
	while (!Q.empty())
	{
		int p = Q.front();
		Q.pop();
		for (int e = first[p]; e; e = es[e].next)
		{
			int to = es[e].to;
			if (d[to] != -1) continue;
			d[to] = d[p] + 1;
			Q.push(to);
		}
	}
}

int getdist()
{
	bfs(1);
	int pos = 1;
	for (int i = 2; i <= n; i++)
		if (d[i] > d[pos])
			pos = i;
	bfs(pos);
	int ret = 0;
	for (int i = 1; i <= n; i++)
		ret = max(ret, d[i]);
	return ret;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		addE(a, b), addE(b, a); 
	}
	if (getdist() % 3 == 1)
		cout << "Second" << endl;
	else
		cout << "First" << endl;
	return 0;
}


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

int main(){
	int A, B;
	cin >> A >> B;
	if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>

/* template start */

using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;

#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << std::endl; }

template <typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
  std::cerr << " " << h;
  if (sizeof...(t) > 0) std::cout << " :";
  debug_out(t...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b) {
  return a > b && (a = b, true);
}

template <typename Num>
constexpr Num mypow(Num a, u64 b, Num id = 1) {
  if (b == 0) return id;
  Num x = id;
  while (b > 0) {
    if (b & 1) x *= a;
    a *= a;
    b >>= 1;
  }
  return x;
}

/* template end */

#include <atcoder/math>

using ll=long long;

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

  i64 n;
  std::cin >> n;

  if(n==1){
    std::cout<<1<<"\n";
    return 0;
  }

  std::vector<ll> prime;

  { 
    i64 tmp = n; 
    for(i64 i=2;i*i<=n;i++){
      if(tmp%i==0){
        prime.emplace_back(1);
        while(tmp%i==0){
          prime.back()*=i;
          tmp/=i;
        }
      }
    }
    if(tmp!=1){
      prime.emplace_back(tmp);
    }
  }

  if(prime[0]%2==0)prime[0]*=2;

  i64 ans=std::numeric_limits<i64>::max();

  i64 m=prime.size();
  
  debug(prime);
  rep(bit,0,1ull<<m){
    std::vector<ll> r(m);
    rep(i,0,m){
      if((bit>>i)&1){
        r[i]=0;
      }else{
        r[i]=prime[i]-1;
      }
    }
    debug(r);
    auto [val,lcm] = atcoder::crt(r,prime);
    debug(val,lcm);
    if(val!=0)chmin(ans,val);
  }

  std::cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 3660
d, g = map(int,input().split())
plist = [list(map(int,input().split())) for i in range(d)]

# map of {number of problems to achieve ps : ps}
basiclist = []

for i in range(len(plist)):
    tmplist = [plist[i][0], (plist[i][0])*(i+1)*100+plist[i][1]]
    # problem.append(plist[i][0])
    basiclist.append(tmplist)

# combination of perfect score cases: ps0, ps1, ps2, ps0 + ps1, ...
import itertools

problem = [i for i in range(d)]

combs = []

for i in range(1, d+1):
    els = [list(x) for x in itertools.combinations(problem, i)]
    # print(els)
    combs.extend(els)


mincount = 2**10+1

# case without perfect score
for i in range (d):
    for j in range (1, basiclist[i][0]):
        if j*(i+1)*100 >= g:
            mincount = min(mincount, j)

# case of with perfect score
for comb in combs:
    # find the best-valued question that is not in the combination
    best_remaining_num = -1
    for a in range(d):
        if a not in comb:
            best_remaining_num = max(a, best_remaining_num)
    best_remaining_score = (best_remaining_num+1)*100

    # total perfect score of the combination and attempts required to achieve the score
    total_ps = 0
    total_ps_count = 0
    for com in comb:
        total_ps += basiclist[com][1]
        total_ps_count += basiclist[com][0]

    if best_remaining_num == -1:
        mincount = min(mincount, total_ps_count)
        continue

# case ps comb + remaining best-valued question*0, ..., ps comb + remaining best-valued question*(max possible -1)
    for i in range(basiclist[best_remaining_num][0]):
        if total_ps + best_remaining_score*i >= g:
            # print(comb, total_ps_count, total_ps, best_remaining_score, i, total_ps + best_remaining_score * i)
            mincount = min(mincount, i + total_ps_count)
            # print(mincount)
            break

print(mincount)


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

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

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

    sort(l, l + n);
    int ans = 0;

    /*for(int i = 0; i < n - 2; i++){
        for(int j = i + 1; j < n - 1; j++){
            for(int k = j + 1; k < n; k++){
                if(l[j] + l[k] > l[i]){
                    ans++;
                }else{
                    break;
                }
            }
        }
    }*/

    for(int i = 0; i < n - 2; i++){
        for(int j = i + 1; j < n - 1; j++){
            auto m = lower_bound(l + j + 1, l + n, l[i] + l[j]);
            auto k = l + n;
            ans += (n - j - 1) - (k - m);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import math

while True:
  total_scores = int(input())

  if total_scores == 0:
    break
  
  scores = [int(x) for x in input().split()]

  average_of_scores = sum(scores) / total_scores

  deviation_total = 0

  for score in scores:
    deviation_total += math.pow((score - average_of_scores), 2)

  variance = deviation_total / total_scores

  standard_deviation = math.sqrt(variance)  
  standard_deviation = "{:.8f}".format(standard_deviation)

  print(standard_deviation)



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

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
int counter = 0;

void merge(int A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1 + 1], R[n2 + 1];
    REP(i, n1) L[i] = A[left + i];
    REP(i, n2) R[i] = A[mid + i];
    L[n1] = INT_MAX;
    R[n2] = INT_MAX;

    int i = 0, j = 0;
    FOR(k, left, right) {
        if (L[i] <= R[j]) {
            A[k] = L[i++];
            counter++;
        } else {
            A[k] = R[j++];
            counter++;
        }
    }
}

void mergeSort(int A[], int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main() {
    int n;
    cin >> n;
    int S[n];
    REP(i, n) cin >> S[i];

    mergeSort(S, 0, n);

    REP(i, n - 1) cout << S[i] << " ";
    cout << S[n - 1] << endl;
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 6904
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {

		int n = in.nextInt();

		while (n-- > 0) {
			int a = in.nextInt();
			int b = in.nextInt();
			int c = in.nextInt();

			if (a < b) {
				int t = a; a = b; b = t;
			}
			if (a < c) {
				int t = a; a = c; c = t;
			}

			out.println(a*a == b*b + c*c ? "YES" : "NO");
		}
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 32180
def solve(arr, n):
	a = [0 for _ in range(n)]

	for i in range(1,n):
		if arr[i] <= arr[i-1]:
			a[i] = a[i-1] + 1

	ret = max(a)

	return ret

def main():
	n = int(input())

	arr = list(map(int ,input().strip().split()))

	print (solve(arr, n))


if __name__ == "__main__":
	main()

Measured memory_bytes: 14228
process.stdin.resume();
process.stdin.setEncoding('utf8');
                     
var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', (line) => {
    // ここで入力を処理する
    lines.push(line);
});
reader.on('close', () => {
    // ここで出力する
  var S = lines[0];
  console.log(S.substring(0,3));
});


Measured memory_bytes: 30068
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    vector<int> num(1e4);
    rep1(count,1e4){
        int c = 0;
        for(int x=1;x*x<count;x++){
            for(int y=x;y*y<count;y++){
                for(int z=y;z*z<count;z++){
                    if(x*x+y*y+z*z+x*y+y*z+z*x == count){
                        if(x == y && y == z){
                            c++;
                        }
                        else if(x == y || y == z){
                            c += 3;
                        }
                        else{
                            c += 6;
                        }
                    }
                }
            }
        }
        num[count-1] = c;
    }
    int n;
    cin >> n;
    rep(i,n){
        cout << num[i] << endl;
    }
}

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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;

	lli a[310][310];
	REP(i,0,n)REP(j,0,n)cin>>a[i][j];

	/* ワーシャルフロイトやって、1回でも変わったらアウト*/
	REP(k,0,n)REP(i,0,n)REP(j,0,n){
		if(a[i][j] > a[i][k]+a[k][j]){
			cout<<-1<<endl;
			return 0;
		}
	}

	/*変わらなかった場合、もう1度ワーシャルフロイトを行う*/
	/*そして、a[i][j] == a[i][k] + a[k][j]を満たす要素のa[i][j]を取り除く*/
	REP(k,0,n)REP(i,0,n)REP(j,0,n){
		if(i==j || j==k || k==i)continue;
		if(a[i][j] == a[i][k]+a[k][j]){
			a[i][j] = INF;
		}
	}


	lli ans=0;
	if(DEBUG)cout<<endl;
	REP(i,0,n){
		REP(j,0,n){
			if(DEBUG)cout<<a[i][j]<<" ";
			if(a[i][j] != INF)ans += a[i][j];
		}
		if(DEBUG)cout<<endl;
	}

	cout<<ans/2<<endl;

	return 0;
}

Measured memory_bytes: 1024
import java.io.*
import java.util.*

fun solve(c: Array<String>){
    println(listOf(c[0][0], c[1][1], c[2][2]).joinToString(separator=""))
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val c = StringArray(3.toInt())
    for (i in 0 until 3.toInt()) {
        c[i] = sc.next()
    }
    solve(c)
}



Measured memory_bytes: 32160
#include<stdio.h>

int main(void)

{

int a, b, c;

int d;


scanf("%d %d %d", &a, &b, &c);

if(a > b)


{


d = a;


a = b;


b = d;


}





if(a > c)


{


d = a;


a = c;


c = d;


}





if(b > c)


{


d = b;


b = c;


c = d;


}


printf("%d %d %d\n", a, b, c);











return 0;

}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
int main(){
	int N, C, K, T[100000];
	cin >> N >> C >> K;
	for(int i = 0; i < N; i++) cin >> T[i];
	sort(T, T + N);
	int ans = 0;
	for(int i = 0; i < N; i++){
		int s = T[i];
		int cnt = 1;
		while(cnt < C && T[i + 1] - s <= K){
			cnt++;
			i++;
		}
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int a,b;
  cin >> a >> b;
  
  cout << (a+b)%24 << endl;

  return 0;
}

Measured memory_bytes: 256
a = 2, 3, 5
 
def f(n):
  m = memo.get(n)
  if m is None:
    m = d * n
    for p, c in zip(a, b):
      k, r = divmod(n, p);
      m = min(m, f(k) + r * d + c, r  and f(k + 1) + (p - r) * d + c or m)
    memo[n] = m
  return m
 
t = int(input())
for _ in range(t):
  n, *b, d = map(int, input().split())
  memo = {0: 0, 1: d}
  print(f(n))

Measured memory_bytes: 10868
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = 1e18+7;

constexpr int INF = 1e9+7;



vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

graph g;
vector<int> c;
vector<ll> ans,cnt;

ll dfs(int x, int p){
    int _size = 1;
    for(auto &nx: g[x]){
        if(nx==p) continue;
        ll k = cnt[c[x]];
        ll ret = dfs(nx,x);
        _size += ret;
        ll t = ret -(cnt[c[x]]-k);
        ans[c[x]] += t*(t+1)/2;
        cnt[c[x]] = k+ret;
    }
    cnt[c[x]]++;
    return _size;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    c.resize(n);
    rep(i,0,n){
        cin >> c[i];
        c[i]--;
    }
    g = graph(n);
    rep(i,0,n-1){
        int a,b; cin >> a >> b;
        a--; b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    ans.assign(n,0);
    cnt.assign(n,0);
    dfs(0,0);
    rep(i,0,n){
        ans[i] += (n-cnt[i])*(n-cnt[i]+1)/2;
        cout <<  n*(n+1)/2-ans[i] << endl;
    }
}

Measured memory_bytes: 33744
using System;
using System.Linq;

namespace abc061_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] ret = new int[x[0]];
            for (int i = 0; i < x[1]; i++)
            {
                int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                ret[a[0] - 1]++; ret[a[1] - 1]++;
            }
            for (int i = 0; i < x[0]; i++) Console.WriteLine(ret[i]);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
int a[100005];
int ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int k=1;
    int t=a[0];
    for(int i=1;i<n;i++){
            if(a[i]==t){
                k++;
            }else{
                if(k-t>=0){
                    ans+=(k-t);
                }else{
                    ans+=k;
                }
                k=1;
                t=a[i];
            }
    }
    //cout<<ans<<endl;
    if(k-t>=0){
        ans+=(k-t);
    }else{
        ans+=k;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define vpi vector<ppi>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
    fast


        
    int a,b;
    cin>>a>>b;

    int total = 1;    
    int count = 0;    

    while(total < b)
    {
        total -= 1;
        total += a;
        count++;
    }

    cout<<count;








    return 0;
}

Measured memory_bytes: 256