akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int ans = 0;
	while (n--)
	{
		int x;
		cin >> x;
		while (x % 2 == 0) ans++, x /= 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int g[5][5];
int main(){
  int r, g, b, n, cnt=0;
    cin >> r >> g >> b >> n;
    for(int i=0; i<=n; i++){
      for(int j=0; r*i+g*j<=n; j++){
        int k = n - (r*i+g*j);
        //cout << k << endl;
        if(k%b==0 && 0<=k){
          cnt += 1;
          //cout << i << j << k << endl;
        }
      }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
s=list(input())
K=int(input())
for i in range(len(s)):
    if i==len(s)-1:
        K=K%26
        x=ord(s[i])
        for j in range(K):
            x+=1
            if x==123:
                x=97
        s[i]=chr(x)
    else:
        if K<=0 or s[i]=='a':
            continue
        dif=123-ord(s[i])
        if dif<=K:
            s[i]='a'
            K-=dif
print(''.join(s))

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

using namespace std;

typedef long long ll;
const int mab = 40;

int main(void)
{
    ll n, k; cin >> n >> k;
    ll x;
    int p[mab] = {};
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        for(int j = 0; j < mab; j++)
            p[j] += ((x >> j) & 1);
    }

    // for(int j = 0; j < mab; j++) cout << p[j];
    // cout << endl;

    ll s = (n / 2) + (n % 2);
    ll ca = 0;
    ll an = 0;

    for(int i = mab - 1; i >= 0; i--)
    {
        if((k >> i) & 1)
        {
            // cout << i << endl;
            ca = 0;
            for(int j = mab - 1; j >= i + 1; j--)
            {
                // cout << j << " ";
                if((k >> j) & 1) ca += ((n - p[j]) * (1LL << j));
                else ca += (p[j] * (1LL << j));
            }
            // cout << " : ";
            ca += (p[i] * (1LL << i));
            for(int j = i - 1; j >= 0; j--)
            {
                // cout << j << " ";
                if(p[j] >= s) ca += (p[j] * (1LL << j));
                else ca += ((n - p[j]) * (1LL << j));
            }
            // cout << ca << endl;
            an = max(an, ca);
        }
        if(i == 0)
        {
            ca = 0;
            for(int j = mab - 1; j >= 0; j--)
            {
                if((k >> j) & 1) ca += ((n - p[j]) * (1LL << j));
                else ca += (p[j] * (1LL << j));
            }
            an = max(an, ca);
        }
    }

    cout << an << "\n";
    return 0;
}


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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)


int main(){
    int d,n;
    cin>>d>>n;
    if(n==100)n++;
    cout<<n;
    REP(i,d){
        cout<<"00";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    string n;
    int sum=0;
    cin>>n;
    for(int i=0;i<n.length();i++){
        sum+=n[i]-'0';
    }
    if(sum%9==0){
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
} 

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();
	long long int n, k;
	cin >> n >> k;
    for(int i = 1; i <= k; i++){
    	cout << COM(k-1,i-1) * COM(n-k+1,i) % MOD << endl;
    }
}

Measured memory_bytes: 12160
#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 200'009;

int a[N];
int b[N];
int f[N];
long long suff[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    b[i] = -1;
    for (int j = 0; j <= 29; ++j) {
      if (a[i] >> j & 1) {
        b[i] = j;
      }
    }
    a[i] <<= 29 - b[i];
  }
  f[n] = 0;
  suff[n] = 0;
  for (int i = n - 1; i >= 0; --i) {
    f[i] = b[i];
    suff[i] = suff[i + 1];
    for (int j = i + 1; j < n; ++j) {
      if (f[j] > f[j - 1] || (f[j] == f[j - 1] && a[j] >= a[j - 1])) {
        break;
      }
      int v = (f[j - 1] - f[j] + 1) / 2 * 2;
      if (f[j] + v == f[j - 1] && a[j] < a[j - 1]) {
        v += 2;
      }
      if (f[j] < 35) {
        f[j] += v;
        suff[i] += v;
      } else {
        suff[i] += (long long)v * (n - j);
        break;
      }
    }
  }
  long long ans = suff[0];
  long long pref = 0;
  for (int i = 0; i < n; ++i) {
    f[i] = b[i] + 1;
    pref += 1;
    for (int j = i - 1; j >= 0; --j) {
      if (f[j] > f[j + 1] || (f[j] == f[j + 1] && a[j] >= a[j + 1])) {
        break;
      }
      int v = (f[j + 1] - f[j] + 1) / 2 * 2;
      if (f[j] + v == f[j + 1] && a[j] < a[j + 1]) {
        v += 2;
      }
      if (f[j] < 35) {
        f[j] += v;
        pref += v;
      } else {
        pref += (long long)v * (j + 1);
        break;
      }
    }
    ans = min(ans, pref + suff[i + 1]);
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define int long long
#define zmrl(x) (int)((x).size())
#define ahen(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin>>n;
    int cnt = 0;
    bool flag = false;
    for (int i=1; i<=n; i++) {
        int a,b; cin>>a>>b;
        if (a==b) cnt++;
        else cnt=0;
        if (cnt>=3) flag = true;
    }

    cout << (flag ? "Yes" : "No") << '\n';
    return 0;
}

Measured memory_bytes: 3648
S = input()
N = len(S)
Q = int(input())
sign = 1
L = ["" for i in range(N + 2 * Q)]
for i in range(N):
  L[i+Q] = S[i]
x, y = Q - 1, N + Q
for i in range(Q):
  T = list(map(str, input().split()))
  if T[0] == "1":
    sign *= -1
  else:
    F = int(T[1]) * 2 - 3
    if sign * F == 1:
      L[y] = T[2]
      y += 1
    else:
      L[x] = T[2]
      x -= 1
newS = ""
for i in range(N+2*Q):
  newS = newS[:] + L[i]
if sign == 1:
  print(newS)
else:
  M = len(newS)
  for i in range(M):
    print(newS[M-i-1], end = '')
  print()

Measured memory_bytes: 9184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a >= 13) {
			System.out.println(b);
		}else if(a <= 12 && a >=6) {
			System.out.println(b/2);
		}else {
			System.out.println(0);
		}
	}
}

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

int main() {
    ll n, k;
    cin >> n >> k;
    map<ll, ll> m;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        m[a] += b;
    }

    int ans = 0;
    ll cnt = 0;
    for (auto e : m) {
        cnt += e.second;
        if (cnt >= k) {
            ans = e.first;
            break;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7524
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> v(n + 1);
    v[0] = 0;
    for (int i = 1; i < n + 1 ; ++i) {
        if (s[i - 1] == 'I'){
            v[i] = v[i - 1] + 1;
        } else{
            v[i] = v[i - 1] - 1;
        }
    }
    int res = 0;
    for (int j = 0; j < v.size(); ++j) {
        res = max(res, v[j]);
    }
    cout << res;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2e3+5;
int n,f[N][12],p[N][12];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=0;j<10;j++)
			cin>>f[i][j];
	for(int i=1;i<=n;i++)
		for(int j=0;j<=10;j++)
			cin>>p[i][j];
	//O(2^10 * n*10)
	int ans=-1e9;
	for(int i=1;i<(1<<10);i++)
	{
		int res=0;
		for(int j=1;j<=n;j++)
		{
			int cnt=0;
			for(int k=0;k<10;k++)
			{
				if(f[j][k]==0)
					continue;
				if(i&(1<<k))
					cnt++;	
			}	
			res+=p[j][cnt];
		}
		ans=max(ans,res);
	}
	cout<<ans<<endl;
	 
	return 0;	
} 

Measured memory_bytes: 256
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
#define MOD 1e9+7
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] ={-1,+1,0,0,+1,-1,+1,-1};
ll dy[] ={0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e5+123;
bool vis[mx];
vi adj[mx];
int main()
{
    speed();
    ll a,i,y = 0;
    string s;
    char c;
    set<string>x;
    cin>>a;
    for(i=0;i<a;i++)
    {
        cin>>s;
        if(i>0 && s[0]!=c)
        {
            y = -1;
        }
        c = s[s.size()-1];
        x.insert(s);
    }
    if(x.size()!=a || y==-1)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}



Measured memory_bytes: 5964
#include<iostream>
#include<algorithm>
#include<map>
#include<cassert>
#include<vector>
#define F first
#define S second
#define MAX 10000000
using namespace std;
typedef pair<int,bool> P;
map<string,P> material;
vector<string> vec[110];
map<string,P> index;


int rec(string target){
  
  int value = MAX;
  map<string,P>::iterator it = material.begin();
  while(it != material.end() ){
    if((*it).F == target)value = min(value,(*it).S.F);
    it++;
  }
  
  int X = 10000000;
  int id = -1,pre=X;
  if(index[target].S)id = index[target].F;

  if(id != -1){
    for(int i=0;i<vec[id].size();i++){
      pre += rec(vec[id][i]);
    }
  }

  value = min(id == -1?X:pre-X,value);
  
  return value;
}


int main(){
  int n,m;

  while(true){
    cin >> n;
    if(n == 0)break;
    
    material.clear();
    for(int i=0;i<n;i++){
      vec[i].clear();
      string s; int val;
      cin >> s >> val;
    
      material[s] = P(val,true);
    }
   
    index.clear();
    cin >> m;
    for(int i=0;i<m;i++){
      string s,ss; int cn;
      cin >> s >> cn;
      index[s] = P(i,true);
      for(int j=0;j<cn;j++){
	cin >> ss;
	vec[i].push_back(ss);
      }
    }
    
    string st;
    cin >> st;
    cout << rec(st) << endl;


  }
  return 0;
}

Measured memory_bytes: 1232
const main = (input) => {
  var inputs = input.trim().split(" ");
  var A = inputs[0]-0;
  var B = inputs[1]-0;
  var ans = 0;
  for(var i=0;i<2;i++){
    if(A>=B){
      ans += A;
      A--;
    }else{
      ans += B;
      B--;
    }
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 7372
#include <iostream>
#include <string>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b) { return (!b) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
    int n, m;
    string s, t;
    cin >> n >> m >> s >> t;
    int g = gcd(n, m);
    for (int i = 0; i < g; ++i) {
        if (s[i * (n / g)] != t[i * (m / g)]) {
            cout << -1 << '\n';
            return 0;
        }
    }
    cout << lcm(n, m) << '\n';
}

Measured memory_bytes: 512
#include <cstdio>

int main()
{
  long long n, m;
  scanf("%lld %lld", &n, &m);
  
  if (n >= 2 && m >= 2)
  {
    printf("%lld\n", (n - 2) * (m - 2));
  }
  else if (n == 1 && m == 1)
  {
    puts("1");
  }
  else
  {
    printf("%lld\n", n == 1 ? m - 2 : n - 2);
  }
  return 0;
}

Measured memory_bytes: 128
# 136_a
A, B, C = map(int, input().split())
if (A >= B) & (1 <= A & A <= 20) & (1 <= B & B <= 20) & (1 <= C & C <= 20):
    case1_rest = A - B
    if case1_rest < C:
        case2 = C - case1_rest
    elif case1_rest >= C:
        case2 = 0
    print(case2)

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

using namespace std;

int main()
{
   string a;
   cin>>a;
   string b;
   cin>>b;
   int k=0;
   for(int i=0;i<a.size();i++)
   {
       if(a[i]==b[i])
       {
           k++;
       }
   }
   cout<<k<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
typedef long long LL;
#define ms(a,b) memset(a,b,sizeof(a))

int main()
{
    int a,b,c;
    scanf("%d%d",&a,&c);
    b=2*c-a;
    printf("%d\n",b);
    return 0;
}


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

#define ct cout
#define in cin
#define el endl
#define rep(i, N) for (int i = 0; i < N; i++)
#define ol(N) cout << N << endl

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

	int a[128];
	rep(i, n){
		in >> a[i];
	}

	int sum = INT_MAX;
	for (int i = -100; i <= 100; i++){
		int cos = 0;
		for (int j = 0; j < n; j++){
		   cos += (a[j] - i) * (a[j] - i);
		}
		sum = min(sum, cos);
	}

	ol(sum);
		
	return (0);
}


Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let d: i64 = sc.read();
    let t: i64 = sc.read();
    let s: i64 = sc.read();
    if s * t >= d {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write_all(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn 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: 2148
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
l = IL()+[int(10e10)]

tmp,cnt,ans = 0,1,0
for i in range(N+1):
    if tmp == l[i]:
        cnt += 1
    else:
        ans += cnt//2
        cnt = 1
    tmp = l[i]

print(ans)

Measured memory_bytes: 12416
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




int main() {

    int N; cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        int cnt = 0;
        for (int j = 1; j <= N; ++j) {
            if (i % j == 0) ++cnt;
        }
        if (cnt == 8 && i % 2 == 1) ++ans;
    }
    out(ans);

    return 0;
}










Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

    public static void main(String args[]) throws Exception
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        System.out.print(Math.max(a*b,c*d));

        sc.close();
    }

}

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

int main()
{
    int n;
    cin >> n;
    int maxv = -1;
    int ans = 0;
    rep(i,n) {
        int p;
        cin >> p;
        ans += p;
        maxv = max(maxv, p);
    }

    cout << ans - maxv/2 << endl;    
    return 0;
}

Measured memory_bytes: 3600
# E - 1 or 2
from typing import Set


class UnionFind:
    """Union-Find: O(α(N))"""

    __slots__ = ["_data_size", "_first_idx", "_parents"]

    def __init__(self, data_size: int, is_zero_origin: bool = True) -> None:
        self._data_size = data_size
        self._first_idx = 0 if is_zero_origin else 1
        self._parents = [-1] * (data_size + self._first_idx)

    def __getitem__(self, x: int) -> int:
        """Find the group (root) of vertex x."""
        if self._parents[x] < 0:
            return x
        self._parents[x] = self[self._parents[x]]
        return self._parents[x]

    def __len__(self) -> int:
        """Count the number of groups (roots)."""
        return len(self.groups)

    @property
    def groups(self) -> Set[int]:
        """Return the set of groups (roots)."""
        return {
            self[x] for x in range(self._first_idx, self._data_size + self._first_idx)
        }

    def is_connected(self, x: int, y: int) -> bool:
        """Return whether two vertices x and y are connected or not."""
        return self[x] == self[y]

    def unite(self, x: int, y: int) -> None:
        """Unite two groups of vertices x and y."""
        x, y = self[x], self[y]
        if x == y:
            return
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x


def main():
    N, _, *X = map(int, open(0).read().split())
    tree = UnionFind(N, is_zero_origin=False)
    for x, y, _ in zip(*[iter(X)] * 3):
        tree.unite(x, y)
    print(len(tree))


if __name__ == "__main__":
    main()


Measured memory_bytes: 41204
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){

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

    int c = 1,ans = 0;
    while(c < b){
	c--;
	c += a;
	ans++;
    }
    P(ans);
    return  0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(z => double.Parse(z)).ToArray();
            double x1 = line[0], y1 = line[1], x2 = line[2], y2 = line[3];

            var ans = Math.Sqrt(Math.Pow(Math.Abs(x2 - x1), 2) + Math.Pow(Math.Abs(y2 - y1), 2));
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 18464
/* SANDEEP YADAV*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld double
#define intd long double
#define umap unordered_map<>
#define sz(x) ((int)((x).size()))
#define aint(x) (x).begin(),(x).end()
#define vi vector<int>
#define pi pair<int, int>
#define setp cout<<fixed<<setprecision(6)
#define loop(i,a,b)  for(int i=a;i<b;i++)
#define rloop(i,b,a) for(int i=b-1;i>=a;i--)
#define vl vector<int>
#define pl pair<int, int>
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int gcd(int a,int b){ if(a<b) { a=a+b; b=a-b; a=a-b;}while(b!=0){int r=a%b; a=b; b=r;} return a;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long power(long long a, long long b, long long m) {a %= m;long long res = 1;while (b > 0) {if (b & 1)res = res * a % m;a = a * a % m;b >>= 1;}return res;}
const int N=1000005;
void judge()
{
      #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
    #endif
}
// struct myhash
// {
//     static uint64_t fxn(uint64_t x)
//     {
//         x += 0x9e3779b97f4a7c15;
//         x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
//         x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
//         return x ^ (x >> 31);
//     }
 
//     size_t operator ()(uint64_t x) const
//     {
//         static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
//         return fxn(x + FIXED_RANDOM);
//     }
// };
void solve(int tc)
{
    
    int n,k;
    cin>>n>>k;

    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];

    int ans[n+1]={0};
    for(int i=1;i<n;i++)
    {
        ll x=1e9;
        int z=max(int(0),i-k);
        for(int j=z;j<i;j++)
        {
            x=min(x,ans[j]+abs(a[i]-a[j]));
        }
        ans[i]=x;
    }
    cout<<ans[n-1];
    return;
}
int main()
{
    fastio;
    //judge();

    int T=1;
    // cin>>T;
    for(int tc=1;tc<=T;tc++)
    {
        solve(tc);
    }
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

long long mod = 1000000007LL;
int n,t,a[100010];

int main(){
  scanf("%d %d",&n,&t);
  rep(i,n) scanf("%d",a+i);
  sort(a,a+n,greater<long long>());
  long long answer = 1;
  int L = 0;
  REP(i,1,n){
    while( L < i && a[L]-t > a[i] ) ++L;
    answer = ( answer * ( 1LL + (long long)(i-L) ) ) % mod;
  }
  cout << answer << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    long sum = 0;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        v.at(i) = a;
        sum += (long)a;
    }
    sort(v.begin(), v.end());
    cout << v.at(0) << " " << v.at(v.size()-1) << " " << sum <<endl;
}


Measured memory_bytes: 3208
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        Store[] s = new Store[n];
        for(int i = 0; i < n; i++){
            s[i] = new Store(scan.nextInt(), scan.nextInt());
        }
        Arrays.sort(s);
        long out = 0;
        int i = 0;
        for(i = 0; m > 0; i++){
            for(int j = 0; j < s[i].count && m > 0; j++){
                m--;
                out += s[i].price;
            }
        }
        System.out.println(out);
    }

    public class Store implements Comparable<Store>{
        int price, count;
        public Store(int price, int count){
            this.price = price;
            this.count = count;
        }

        @Override
        public int compareTo(Store s) {
            if(this.price == s.price) return Integer.compare(s.count, this.count);
            return Integer.compare(this.price, s.price);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 62192
A = list(map(int , input().split()))
x = []
for i in range(A[1]):
    X=list(input().split())
    x.append(X)
di = {}
for i in x:
    di[int(i[0])] = []
for i in x:
    di[int(i[0])].append(i[1])
sei = 0
go = 0
for k ,v in di.items():
    if 'AC' in v:
        sei += 1
    else:
        continue
    go += v.index('AC')
print('{} {}'.format(sei,go))

Measured memory_bytes: 46260
#include<bits/stdc++.h>
//#include <boost/lexical_cast.hpp>
using namespace std;

#define pb push_back
#define mp make_pair  //access values using v[i].first,v[i].second
#define mt make_tuple //access values using get<1>(v[i]),get<0>(v[i]) etc

#define MAX 1000000000
#define MOD 1000000007

#define FIN freopen("input.txt","r",stdin);
#define FOUT freopen("output.txt","w",stdout);

#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define sc(n) scanf("%c",&n)
#define sd(n) scanf("%lf",&n)

#define pin(n) printf("%d\n",n)
#define pln(n) printf("%lld\n",n)
#define pdn(n) printf("%lf\n",n)

#define pis(n) printf("%d ",n)
#define pls(n) printf("%lld ",n)

#define pn printf("\n")
#define ps(n) printf("%s",n)
#define psn(n) printf("%s\n",n)

#define fl(n) for(int i=0;i<n;i++)


int main()
{
    //FIN;
    long long a,b,c,k;
    sl(a);
    sl(b);
    sl(c);
    sl(k);
    long long ans;
    if(a>=k)pln(k);
    else if(a+b >= k)pln(a);
    else {
    	long long temp = k-(a+b);
    	pln(a-temp);
	}
}

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

int main() {
	int N;
	cin >> N;
	vector<int> v(N), dp(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		dp[i] = 1e9;
	}
	dp[0] = 0;
	for (int i = 1; i < N; i++) {
		if (i-1 >= 0)
			dp[i] = min(dp[i], abs(v[i]-v[i-1])+dp[i-1]);
		if (i-2 >= 0)
			dp[i] = min(dp[i], abs(v[i]-v[i-2])+dp[i-2]);
	}
	cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
//encoding:utf-8
#include <iostream> //c++
#include<time.h> //時間にかんして
#include<stack> //スタックに関して　最新のデータから捨てる
#include<queue> //キューに関して　最古のデータから捨てる
#include<math.h>
#include<vector>
#include<algorithm> //sort とかにいる

#define ll long long
using namespace std;

int n,m;
int N_MAX=30,M_MAX=30;
int k;
int a[31][31]={0};
int memo[31]={0};


int main(){
  cin>>n>>m;
  // memset(a,0,sizeof(a));
  // memset(memo,0,sizeof(memo));
  for(int i=0;i<n;i++){
    cin>>k;
    for(int j=0;j<k;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(a[i][j]!=0){
        memo[a[i][j]]++;
      }
    }
  }
  int ans=0;
  for(int i=0;i<31;i++){
    if(memo[i]==n){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int main(){
    ll N; cin >> N;
    string S; cin >> S;
    priority_queue<ll> queW, queR;
    REP(i, S.length()){
        if(S[i] == 'W') queW.push(-i);
        else queR.push(i);
    }
    if(queW.size()==0 || queR.size()==0) {cout<< 0 << endl; return 0;}
    ll cnt = 0;
    while((-queW.top()) < queR.top()){
        ll x = queW.top(), y = queR.top();
        queW.pop(); queR.pop();
        queR.push(-x);
        queW.push(-y);
        cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 5876
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int k = Integer.parseInt(str[1]);

		str = br.readLine().split("");
		ArrayList<Integer> nums = new ArrayList<>();

		if (str[0].equals("0"))
			nums.add(0);
		for (int i = 0; i < str.length;) {
			int j = i;
			while (j < str.length && str[j].equals(str[i]))
				++j;
			nums.add(j - i);
			i = j;
		}
		if (str[n - 1].equals("0"))
			nums.add(0);

		int s[] = new int[nums.size() + 1];

		for (int i = 0; i < nums.size(); i++) {
			s[i + 1] = s[i] + nums.get(i);
		}

		int ans = 0;
		for (int left = 0; left < nums.size(); left += 2) {
			int right = left + k * 2 + 1;
			if (right >= s.length)
				right = s.length - 1;
			ans = Math.max(ans, s[right] - s[left]);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 33480
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>

using namespace std;


int combart(int a) {
	int maisuu = 0;
	if (a >= 5) {
		maisuu++;
		a -= 5;
	}
	return maisuu + a;
}

int main(){

	int siharai;
	int oturi;

	while (1) {
		cin >> siharai;
		if (siharai == 0)break;

		oturi = 1000 - siharai;

		int hyaku = oturi / 100;
		int juu = (oturi % 100) / 10;
		int iti = oturi % 10;

		cout << combart(hyaku) + combart(juu) + combart(iti) << endl;
	}


//	system("pause");
    return 0;
}




Measured memory_bytes: 3012
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

#define bs(n) (1ull<<(ull)(n))
#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)

ll k, x, y, rx = 1, ry = 1, ss = 0;

int main() {
    cin >> k >> x >> y;
    if (x < 0) rx = -1;
    if (y < 0) ry = -1;
    x *= rx;
    y *= ry;
    if (x < y) {
        ss = 1;
        swap(x, y);
    }
    vector<pair<ll, ll>> f;
    ll n = 0;
    if (k % 2 == 0 && (x + y) % 2 == 1) {
        cout << -1 << endl;
        return 0;
    } else if (x + y < k && (x + y) % 2 == 1) {
        cout << 3 << endl;
        n = 3;
        f.emplace_back(1, -(k - x));
        f.emplace_back(0, x + (k + x - y) / 2);
        f.emplace_back(1, k - x + y);
        f.emplace_back(0, -(k + x - y) / 2);
    } else {
        if (x + y < k) n = 2;
        else if (((k - ((x + y) % k)) % k) % 2 == 0)n = (x + y + k - 1) / k;
        else n = (x + y + k - 1) / k + 1;
        cout << n << endl;
        f.emplace_back(1, -(k * n - x - y) / 2);
        f.emplace_back(0, x);
        f.emplace_back(1, (k * n - x + y) / 2);
    }
    ll tx = 0, ty = 0, xx = 0, yy = 0;
    for (auto i = f.begin(); i != f.end(); i++) {
        while (i->second != 0) {
            ll t = min(k - abs(tx) - abs(ty), abs(i->second));
            ll s = t * i->second / abs(i->second);
            if (i->first == 0)tx += s;
            else ty += s;
            i->second -= s;
            if (abs(tx) + abs(ty) == k) {
                if (ss)swap(tx, ty);
                xx += tx * rx;
                yy += ty * ry;
                cout << xx << ' ' << yy << '\n';
                tx = ty = 0;
            }
        }
    }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(int I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	//ifstream in("input.txt");
	//cin.rdbuf(in.rdbuf());
	ll N,K;
	cin >> N >> K;
	ll ans = 0;
	FOR(i,0,N){
		ll p;
		cin >> p;
		ans += min(abs(K-p),abs(p))*2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000

int parent(int i){
    return i/2;
}

int left(int i){
    return 2*i;
}

int right(int i){
    return 2*i+1;
}

int main(void){
    int H, i, A[MAX+1];
    scanf("%d", &H);
    for(i=1; i<=H; i++){
        scanf("%d", &A[i]);
    }

    for(i=1; i<=H; i++){
        printf("node %d: key = %d, ", i, A[i]);
        if(parent(i)>=1){
            printf("parent key = %d, ", A[parent(i)]);
        }
        if(left(i)<=H){
            printf("left key = %d, ", A[left(i)]);
        }
        if(right(i)<=H){
            printf("right key = %d, ", A[right(i)]);
        }
        printf("\n");
    }

    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(2));
    for(int i=0; i<N; i++){
        cin >> A.at(i).at(0);
        A.at(i).at(1)=i+1;
    }

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

    for(int i=0; i<N-1; i++){
        cout << A.at(i).at(1) << ' ';
    }
    cout << A.at(N-1).at(1) << endl;
}

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

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


int main(){
  int a,b,c,d,e,k; cin >> a >> b >> c >> d >> e >> k;
  int p = min(min(min(min(a,b),c),d),e);
  int q = max(max(max(max(a,b),c),d),e);
  
  if(q-p>k){
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
  return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 5e3+23;

char s[N];
int z[N];

void solve() {
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf(" %c", s+i);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    debug(i);
    for (int j = 1, l = 0, r = 0; j < n-i; ++j) {
      if (j <= r) z[j] = min(r-j+1, z[j-l]);
      while (j+z[j] < n-i && s[i+z[j]] == s[i+j+z[j]]) ++z[j];
      if (j+z[j]-1 > r) l = j, r = j+z[j]-1;
      if (z[j] <= j) ans = max(ans, z[j]);
    }
    for (int i = 0; i < n; ++i) z[i] = 0;
  }
  printf("%d", ans);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main(){
    ll n,k;cin>>n>>k;
    vl a(n);
    rep(i,n)cin>>a[i];
    rep(t,k){
        vl imos(n+1);
        rep(i,n){
            imos[max(i-a[i],0ll)]++;
            imos[min(i+a[i]+1,n)]--;
        }
        rep(i,n)imos[i+1]+=imos[i];
        imos.pop_back();
        if(imos==a)break;
        a=imos;
    }
    rep(i,n)cout<<a[i]<<" ";cout<<endl;
}

Measured memory_bytes: 6428
#include <iostream>

using namespace std;

int main(void){
  int k, b1;
  double a, b, k1;
  cin >> a >> b;
  if(b > a){
    swap(a, b);
  }
  k1 = (a - b)/ 2;
  k = (a - b)/ 2;
  b1 = b + k;
  if(k1 == k){
    cout << b1;
  }
  else{
    cout << "IMPOSSIBLE";
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string s;
    cin >> s;

    if (s[0] == s[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int n, m;

int main()
{
	cin >> n >> m;
	int a[m + 1];
	for(int i = 1; i <= m; i++)
	{
		cin >> a[i];
		n -= a[i];
	}
	
	if(n < 0) cout << -1;
	else cout << n;
	
//	system("pause");
	return 0;
}

Measured memory_bytes: 3644
n = int(input())
T = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  T[a].append(b)
  T[b].append(a)
C = sorted(map(int, input().split()))
print(sum(C[:-1]))
L = [-1]*n
stack = [0]
while stack:
  temp = stack.pop()
  L[temp] = C.pop()
  for v in T[temp]:
    if L[v] == -1:
      stack.append(v)
print(*L)

Measured memory_bytes: 5912
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<((long long)(n)); i++)
#define rrep(i, n) for(long long i=((long long)(n)-1); i>=0; i--)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define decimal cout << fixed << setprecision(15);
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9 + 7;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}

int N, dp[100000], deg[100000], r = -1;
vector<int> G[100000];

int dfs(int v, int p=-1){
	if(dp[v] != -1) return dp[v];
	int z = 0, sum = 0;
	rep(i, G[v].size()){
		int to = G[v][i];
		if(to == p) continue;
		if(dfs(to, v) == 0) z++;
		sum += dfs(to, v);
	}
	return (dp[v] = sum + max(z-1, 0));
}

int main(){
	cin >> N;
	rep(i, N-1){
		int a, b; cin >> a >> b;
		G[a].pb(b);
		G[b].pb(a);
		deg[a]++;
		deg[b]++;
		if(deg[a] > 2) r = a;
		if(deg[b] > 2) r = b;
	}
	fill(dp, dp+N, -1);
	if(r == -1) cout << 1 << endl;
	else cout << dfs(r) << endl;
	return 0;
}

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

int main()
{
    int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << A[K - 1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=101000;
int n,m,u,v,deg[N],f[N];
PII e[N];

int find(int x) {
	return f[x]==x?x:f[x]=find(f[x]);
}
bool check() {
	rep(i,1,n+1) if (deg[i]%2==1) return 0;
	rep(i,1,n+1) if (deg[i]>=6) return 1;
	int g4=0;
	VI v4;
	rep(i,1,n+1) if (deg[i]==4) g4++,v4.pb(i);
	if (g4>=3) return 1;
	if (g4<=1) return 0;
	rep(i,1,n+1) f[i]=i;
	rep(i,0,m) {
		int u=e[i].fi,v=e[i].se;
		if (u==v4[0]||v==v4[0]) continue;
		f[find(u)]=find(v);
	}
	int cc=0;
	rep(i,1,n+1) cc+=find(i)==i;
	return cc>=3;
}

int main() {
	scanf("%d%d",&n,&m);
	rep(i,0,m) {
		scanf("%d%d",&u,&v);
		++deg[u]; ++deg[v];
		e[i]=mp(u,v);
	}
	puts(check()?"Yes":"No");
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> 
 
using namespace std;
 
 template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 

LL sumx[52][52][2503];//i枚目まででj枚使って和をsにする組み合わせ
int main(){
    int N,A;cin>>N>>A;
    vector<int>x(N+1,0);
    int sum=0;
    REP(i,N){
        cin>>x[i+1];
        sum+=x[i+1];
    }
    CLR(sumx);
    sumx[0][0][0]=1;
    for(int i=1;i<=N;i++){
        for(int j=0;j<=i;j++)for(int s=0;s<=sum;s++){
            if(s<x[i]||j==0)sumx[i][j][s]=sumx[i-1][j][s];
            else sumx[i][j][s]=sumx[i-1][j][s]+sumx[i-1][j-1][s-x[i]];
        }
    }
    LL res=0;
    for(int k=1;k<=N;k++){
        res+=sumx[N][k][A*k];
        //cout<<A*k<<" "<<sumx[N][k][A*k]<<endl;
    }
    cout<<res<<endl;
    return 0;
}


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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(){
  int i,j=0,k=0,N,M;
  scanf("%d",&N);
  
  int D[N];
  for(i=0;i<N;i++)
    scanf("%d ",&D[i]);
  scanf("%d",&M);
  int T[M];
  for(i=0;i<M;i++)
    scanf("%d ",&T[i]);
  qsort(D,N,sizeof(int),compare_int);
  qsort(T,M,sizeof(int),compare_int);
  while(k!=M){
    if(j==N){
      puts("NO");
      return 0;
    }
    if(D[j] == T[k]){
      j++;
      k++;
    }
    else
      j++;
  }
  puts("YES");
  return 0;
}



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

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

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

using namespace std;

#define INP "solve"
#define OUT "solve"

const int QQ = 3e5 + 10;
const int maxN = 6005;
const int maxM = 3e5 + 10;
const long long oo = 1e15;
const int module = 1e9 + 7;
const long double du = 1e-9;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);
}

bool Used[maxN / 2][maxN * 2];
double DP[maxN / 2][maxN];
double a[maxN];
int n;
const int lm = 3000;
double F(int n, int x) {
    ///cout << n << " " << x << '\n';
    if (n < 0) {
        if (x == 0) return 1.0;
        return 0.0;
    }
    if (x > n + 1) return 0.0;
    if (x < -1 - n) return 0.0;
    if (Used[n][x + lm]) return DP[n][x + lm];
    Used[n][x + lm] = true;
    double L = F(n - 1, x - 1) * a[n];
    double R = F(n - 1, x + 1) * (1.0 - a[n]);
    ///cout << n << " " << x << " " << L << " " << R << '\n';
    DP[n][x + lm] = L + R;
    return DP[n][x + lm];
}
void solve() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    double Res = 0;
    for (int i = 1; i <= n; i++) Res += F(n - 1, i);
    cout << fixed << setprecision(10) << Res;
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    ///doc();
    solve();
}


Measured memory_bytes: 173824