akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 2010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

char A[maxn],B[maxn];

int mx[maxn],mn[maxn],r[maxn];

int ans;

void solve(){
	REP(i,0,n-1){
		mx[i]=mn[i]=0;
		while(B[(i+mx[i])%n]!='1')mx[i]++;
		while(B[(i+mn[i]+n)%n]!='1')mn[i]--;
	}
	REP(s,0,n-1){
		REP(i,0,n-1)r[i]=0;
		int t=0;
		REP(i,0,n-1)if(A[i]!=B[(i+s)%n])t++,r[-mn[i]]=max(r[-mn[i]],mx[i]-s);
		int t2=0,res=MAX;
		RREP(i,n-1,0)res=min(res,t2+i),t2=max(t2,r[i]);
//		cout<<res<<' '<<t<<' '<<s<<endl;
		ans=min(ans,res*2+t+s);
	}
}

void Work(){
	ans=MAX;
	solve();
	reverse(A,A+n);reverse(B,B+n);
	solve();
	iout(ans);
}

void Init(){
	scanf("%s%s",A,B);n=strlen(A);
	bool ok=0;
	REP(i,0,n-1)if(B[i]=='1')ok=1;
	if(!ok){
		ok=0;
		REP(i,0,n-1)if(A[i]=='1')ok=1;
		if(!ok)puts("0");else puts("-1");
		exit(0);
	}
}

int main(){
	Init();
	Work();
	return 0;
}


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

using namespace std;

int A, B, C, X, Y;

long long first() {
    return (long long) A * X + B * Y;
}

long long second() {
    return (long long) C * 2 * max(X, Y);
}

long long third() {
    if (X > Y) {
        return (long long) C * 2 * Y + A * (X - Y);
    } else {
        return (long long) C * 2 * X + B * (Y - X);
    }
}


int main() {
    cin >> A >> B >> C >> X >> Y;

    cout << min(first(), min(second(), third())) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  ll n; cin >> n;
  ll ans=0;
  ll cnt=0;
  ll mini=1000000000;
  rep(i,n){
    ll a; cin >> a;
    if(a<0) cnt++;
    ans+=abs(a);
    mini=min(mini,abs(a));
  }
  if(cnt%2==1) ans-=2*mini;
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int red[200005], whi[200005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int l = 0, r = n-1;
    int ans = 0;
    while(l < r){
        while(s[l] == 'R' && l < r) ++l;
        while(s[r] == 'W' && l < r) --r;
        if(l != r){
            swap(s[l], s[r]);
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3768
n = int(input())
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

m = num2alpha(n).lower()
print(m)

Measured memory_bytes: 9184
#include <iostream>
using namespace std;
 
int main(){
  int n,s;
  long long a[100000],b[100000],ko;
  cin>>n>>s;
  for (int i=0;i<n;i++) {
    cin>>a[i]>>b[i];
  }
	int x=0,y=n-1;
	while (x<=y){
      if (s<=a[x]){
        ko+=a[y]-s;
        break;
      }
      if (s>=a[y]){
        ko+=s-a[x];
        break;
      }
      if (b[x]>=b[y]){
        ko+=a[y]-a[x];
        while (x<y && b[x]>=b[y]){
          b[x]+=b[y--];
        }
      }
      else{
        ko+=a[y]-a[x];
        while (x<y && b[x]<b[y]) {
          b[y]+=b[x++];
        }
      }
    }
  cout<<ko;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
//char Input[40*1024*1024+5],*pos;
//#define Read() (strtol(pos,&pos,10))
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	//fread(Input,40*1024*1024,1,stdin);
	//pos=Input;
	double x,a,b;
	scanf("%lf%lf%lf",&x,&a,&b);
	if(abs(a-x)<abs(b-x))
		printf("A\n");
	else printf("B\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define R(i, n) for(int i = 0;i < n;i++)
#define RR(i, n) for(int i = n;i >= 0;i--)
#define F(i, m, n) for(int i = m;i < n;i++)
#define FR(i, m, n) for(int i = m; i >= n; i--)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define P(a) printf("%d", a)
using namespace std;


int N;
string S, T;

int main() {
	cin >> N;
	cin >> S >> T;
	string ans;
	R(i, N) {
		ans.push_back(S[i]);
		ans.push_back(T[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	answer := fizzbuzzSum(n)
	fmt.Println(answer)
}

func fizzbuzzSum(n int) int {
	sum := 0
	for i := 1; i <= n; i++ {
		if i%3 != 0 && i%5 != 0 {
			sum += i
		}
	}
	return sum
}


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

int main(){
  int n;
  cin>>n;
  vector<int>vals(n);
  for(int i=0;i<n;i++){
    cin>>vals[i];
  }
  vector<int>dp(n,0);
  int ans = 0;
  for(int i=1;i<n;i++){
    if(vals[i]<=vals[i-1]){
      dp[i]=dp[i-1]+1;
    }
    ans=max(ans,dp[i]);
  }
  cout<<ans<<endl;
}    


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int k, a, b; cin >> k >> a >> b;
    int c = k;
    while(k < b + 1000){
        if(a <= k && b >= k){
            cout << "OK" << endl;
            return 0;
        }
        k += c;
    }
    cout << "NG" << endl;
}

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

typedef long long ll;
using namespace std;
int memo[100001];
int calc(int ar[], int n) {
	if(n==1) {
		return 0;
	}
	
	if(n==2) {
		return abs(ar[n]-ar[n-1]);
	}
	
	if(memo[n]!=-1) {
		return memo[n];
	}
	memo[n] = min(calc(ar, n-1) + abs(ar[n-1]-ar[n]), calc(ar, n-2) + abs(ar[n-2]-ar[n]));
	return memo[n];
}

int main() {
 	int n;
 	cin>>n;
 	int ar[100001];
 	for(int i=1; i<=n; i++) {
 		cin>>ar[i];
 		memo[i] = -1;
 	}
 	
 	cout << calc(ar, n);
 	
	return 0;
}

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

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

    vector<int> p(n);

    rep(i,n){
      int tmp;
      cin >> tmp;
      p.at(i) = tmp;
    }

    srt(p);
    int sum = 0;
    rep(i,k){
      sum += p.at(i);
    }
    
    cout << sum << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N,X,Y;
    cin>>N>>X>>Y;
    X--;Y--;
    vi ans(N,0);
    for(int i=0;i<N;i++){
        queue<int> Q;
        vi d(N,99999999);
        d[i]=0;
        Q.push(i);
        while(!Q.empty()){
            int qt=Q.front();
            Q.pop();
            if(0<qt){
                if(d[qt-1]>d[qt]+1){
                    d[qt-1]=d[qt]+1;
                    Q.push(qt-1);
                }
            }
            if(qt<N-1){
                if(d[qt+1]>d[qt]+1){
                    d[qt+1]=d[qt]+1;
                    Q.push(qt+1);
                }
            }
            if(qt==X){
                if(d[Y]>d[qt]+1){
                    d[Y]=d[qt]+1;
                    Q.push(Y);
                }
            }
            if(qt==Y){
                if(d[X]>d[qt]+1){
                    d[X]=d[qt]+1;
                    Q.push(X);
                }
            }
        }
        for(int i=0;i<N;i++){
            ans[d[i]]++;
        }
    }
    for(int i=1;i<=N-1;i++){
        cout<<ans[i]/2<<endl;
    }
}


Measured memory_bytes: 256
from math import gcd

N = int(input())
A = list(map(int, input().split()))

# L = [0, A_1のgcd, A_1~A_2のgcd, A_1~A_3のgcd, ..., A_1~A_Nのgcd]、len = N+1
L = [0]
for i in range(N):
    L.append(gcd(L[-1], A[i]))


# R = [A_1~A_Nのgcd, A_2~A_Nのgcd, ..., A_N-1~A_Nのgcd, A_Nのgcd, 0], len = N+1
R = [0]
for i in range(N):
    R.append(gcd(R[-1], A[-i - 1]))
R = R[::-1]

ans_list = []
# A_1を消す場合, A_2を消す場合, ..., A_Nを消す場合
for i in range(N):
    ans_list.append(gcd(L[i], R[i + 1]))

print(max(ans_list))


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<long long> ac(n + 1);
  ac[0] = 0;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a[i] = tmp;
    ac[i + 1] = ac[i] + tmp;
  }
  vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, 0));
  for (int i = 0; i < n; i++) {
    dp[i][i + 1] = 0;
  }
  for (int dif = 1; dif <= n; dif++) {
    for (int i = 0; i + dif <= n; i++) {
      int j = i + dif;
      dp[i][j] = ac[j] - ac[i] - min(dp[i][j - 1], dp[i + 1][j]);
    }
  }
  long long ans = 2 * dp[0][n] - (ac[n] - ac[0]);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 70784
#include<iostream>
using namespace std;
#include<iomanip>
#define _USE_MATH_DEFINES
#include<math.h>


int main()
{
	double r, S, s;
	cin >> r;

	S = r*r*M_PI;
	s = 2 * r*M_PI;

	cout << fixed << setprecision(6) << S << " ";
	cout << fixed << setprecision(6) << s << endl;
	
	return 0;
}


Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
short a,b;
int c[13]={12,0,1,2,3,4,5,6,7,8,9,10,11};
int main(){
    cin>>a>>b;
    if(c[a-1]>c[b-1])cout<<"Alice";
    if(c[a-1]==c[b-1])cout<<"Draw";
    if(c[a-1]<c[b-1])cout<<"Bob";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define pb push_back
#define all(v) (v).begin(), (v).end()

int main(){
  int N;cin>>N;
  vi d(N);
  for(int i=0; i<N; i++)cin>>d[i];

  sort(all(d));

  int L = d[N/2-1];
  int R = d[N/2];

  cout<<R-L<<endl;
}

Measured memory_bytes: 640
N=int(input())
H = list(map(int,input().split()))

ans=0
tmp=0
h=0
for i in range(N):
    if H[i]<=h:
        tmp+=1
        h=H[i]
    else:
        ans = max(ans,tmp)
        tmp=0
        h=H[i]
ans=max(ans,tmp)

print(ans)


Measured memory_bytes: 63856
#include<stdio.h>

int a,b;

int main(void){
  scanf("%d%d",&a,&b);
  if(a==b){
    printf("%d",a+b);
  }else if(a>b){
    printf("%d",a+a-1);
  }else{
    printf("%d",b+b-1);
  }
}


Measured memory_bytes: 128
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{h:i64, a:i64};
    println!("{}", if h%a==0 {h/a} else {h/a+1});
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;


/***************/
 #define amin main
/***************/

ll exp(ll x, ll n)
{if(n==0) return 1;if(n==1) return x%INF;if(n%2==0) return exp((x*x)%INF,n/2); else return(x*exp((x*x)%INF,n/2))%INF;}


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j,a;
	cin>>a;
	cout<<a+ a*a + a*a*a<<endl;
	
	


	
	

	
	


	
	return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;

vector<vector<pair<int, int>>> graph;
vector<int> dijkstra(int i,int n, vector<vector<pair<int, int>>> graph) {
  vector<int> d(n, INF);
  d[i] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
  q.push(make_pair(0, i));
  while (!q.empty()) {
    pair<int, int> p = q.top();
    q.pop();
    int v = p.second;
    if (d[v] < p.first) {
      continue;
    }
    for (auto x : graph[v]) {
      if (d[x.first] > d[v] + x.second) {
        d[x.first] = d[v] + x.second;
        q.push(pair<int, int>(d[x.first], x.first));
      }
    }
  }
  return d;
}

signed main() {
  int N, u, v;
  cin >> N >> u >> v;
  u--; v--;

  graph = vector<vector<pair<int, int>>>(N);
  int a, b;
  REP(i, N-1){
    cin >> a >> b;
    a--; b--;
    graph[a].push_back(make_pair(b, 1));
    graph[b].push_back(make_pair(a, 1));
  }

  vector<int> dist1 = dijkstra(u, N, graph);
  vector<int> dist2 = dijkstra(v, N, graph);

  int ans = 0;
  REP(i, N){
    if(dist1[i] <= dist2[i]) chmax(ans, dist2[i]-1);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 16800
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s,t;
    cin >> s >> t;
    int slen = s.size(), tlen = t.size();

    VLL sc(26), tc(26);
    REP(i,0,slen) ++sc[s[i]-'a'];
    REP(i,0,tlen) ++tc[t[i]-'a'];
    REP(i,0,26) if (tc[i] > 0 && sc[i] == 0) {
        cout << -1 << endl;
        return;
    }

    VI f(26,-1);
    REP(i,0,slen) if (f[s[i]-'a'] == -1) f[s[i]-'a'] = i+1;
    VVI a(26);
    REP(i,0,slen) a[s[i]-'a'].push_back(i+1);
    LL last = 0;
    for (auto &&c: t) {
        //dump(c);
        int m = last % slen;
        //if (m == 0) m = slen;
        auto it = upper_bound(all(a[c-'a']), m);
        //dump(distance(a[c-'a'].begin(), it));
        if (it == a[c-'a'].end()) {
            last += slen - m % slen;
            last += f[c-'a'];
        } else {
            last += *it - m;
        }
    }
    cout << last << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 1216
#include "bits/stdc++.h"

using namespace std;

using ll = long long int;
using ld = long double;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

bool solve(ll n, ll a, ll b, ll c, ll d) {
	ll diff = abs(a - b);

	for (ll i = 0; i * 2LL <= n - 1LL; i++) {
		ll ma = d * (n - 1LL - i * 2LL);
		ll mi = c * (n - 1LL - i * 2LL);
		ll mma = abs(c - d) * i;
		if (mi - mma <= diff && diff <= ma + mma) return true;
	}
	return false;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;

	cout << (solve(n, a, b, c, d) ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
(defun solve (pairs)
  (let ((zoros (mapcar (lambda (pair)
                         (= (car pair) (cadr pair)))
                       pairs))
        (cnt 0)
        (maxcnt 0))
    (dolist (a zoros)
      (if (null a)
          (setf cnt 0)
          (setf cnt (+ 1 cnt)))
      (if (< maxcnt cnt)
          (setf maxcnt cnt)))
    (if (>= maxcnt 3)
        (format t "Yes")
        (format t "No"))))

(let ((n (read))
      (results '()))
  (dotimes (i n)
    (push (list (read) (read)) results))
  (solve (reverse results)))


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

int N;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

const int MOD = 1e9 + 7;
using P = pair<int,int>;

signed main(){

  int n,m; cin >> n >> m;
  vector<int> x(n),y(m);
  for(int i = 0; i < n; i++) cin >> x[i];
  for(int i = 0; i < m; i++) cin >> y[i];
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());

  int k = 0,l = 0;
  for(int i = 0; i < n; i++){
    k += (x[i] * (i - (n-1-i)));
    k %= MOD;
  }
  for(int i = 0; i < m; i++){
    l += (y[i] * (i - (m-1-i)));
    l %= MOD;
  }
  cout << (k * l) % MOD << endl;

  return 0;
}


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

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int i,f=1;
    for(i=m/n;i>=1;i--)
        if(m%i==0)
        {
            printf("%d",i);
            f=0;
            break;
        }
    if(f)printf("%d",i);
    return 0;
}



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






void eratosthenes_plus(const vector<int> a)
{
	int n = a[a.size()-1];
	vector<bool> is_prime(n + 1, true);
	for (int i = 0; i < a.size(); i++)
	{
		if (is_prime[a[i]])
		{
			if (i < a.size() - 1)
			{
				if (a[i] == a[i + 1])
				{
					is_prime[a[i]] = false;
				}
			}

			for (int j = 2 * a[i]; j <= n; j += a[i])
			{
				is_prime[j] = false;
			}
		}
	}

	int res = 0;
	for (int i = 0; i < a.size(); i++)
	{
		if (is_prime[a[i]] == true)
		{
			++res;
		}
	}

	cout << res;
}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a.begin(),a.end());

	eratosthenes_plus(a);

}





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

int n;
int A[20000000];

bool solve(int m, int i) {
	if (m == 0)
		return true;
	if (i >= n)
		return false;
	return solve(m, i + 1) || solve(m - A[i], i + 1);
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> A[i];
	int q, m;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> m;
		cout << (solve(m, 0) ? "yes" : "no") << endl;
	}
	return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int num)
{
    if(num <= 1) return false;
    if(num!=2 && num%2==0) return false;
    int i = 3;
    while(i <= sqrt(num))
    {
        if(num%i == 0)
        {
            return false;
        }
        i+=2;
    }
    return true;
}
int main()
{
//    freopen("in.txt", "r", stdin);
    int c = 0;
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        int num;
        scanf("%d", &num);
        if(isPrime(num)) c++;
    }
    printf("%d\n", c);
}



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

string s;
long long ans;
int dp[200005];

int main(){

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

    cin>>s;
    if(s.size()<3){
        cout<<0<<endl;
        return 0;
    }
    for(int i=s.size()-2;i>=0;i--){
        dp[i]=dp[i+1];
        if(s[i]=='A'){
            ans+=dp[i];
            continue;
        }
        if(s[i]=='B'&&s[i+1]=='C'){
            dp[i]=dp[i+2]+1;
        }else{
            dp[i]=0;
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    int d[n];
    for (int i = 0; i < n; i++) {
        d[i] = a[i] - b[i];
    }
    ll s = 0;
    ll k = 0;
    for (int i = 0; i < n; i++) {
        if (d[i] >= 0) s += d[i];
        else k += -(d[i] / 2);
    }

    cout << ((s <= k) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int cnt[5];
int main(){
	int a,b;
  	for(int i=1;i<=3;i++){
    	cin>>a>>b;cnt[a]++;cnt[b]++;
    }
  	if(count(cnt+1,cnt+5,2)==2) cout<<"YES";
  	else cout<<"NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 100000000
using namespace std;
int main (){
    int h,w;
    int c[11][11]={};

    int g[10][10];


    cin >> h >> w;

    int a[h][w];


    for(int i=0;i<10;i++){
        for (int j = 0; j <10; j++){
            cin >> c[i][j];
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> a[i][j];
        }
    }
    



    for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                if(c[i][j]>c[i][k]+c[k][j]){
                    c[i][j]=c[i][k]+c[k][j];
                }
            }
        }
    }
    int ans =0;

for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        if(a[i][j]!=-1){
            ans += c[a[i][j]][1];
        }
    }
}
cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define N 100010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forv(i, n)	for(int i = n - 1; i >= 0; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
 
const int inf = 1e9 + 1;
const ll modw = 1e9 + 7;
 
using namespace std;

ll dp[110][N];
ll w[N], v[N];

int main() {
	barnarnar
	int n, k;
	cin >> n >> k;
	forn1(i, n)	cin >> w[i] >> v[i];
	forn1(i, n)
	{
		forn1(j, k)
		{
			dp[i][j] = dp[i - 1][j];
			if(j >= w[i])
			{
				dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
			}
		}
	}
	cout << dp[n][k];
	return 0;
}

Measured memory_bytes: 80128
#include <cstdio>
using namespace std;
int s[10005];
int n;
bool find (int x) {
	for (int i=0;i<n;i++) {
		if (s[i]==x) return true;
	}
	return false;
}
int main () {
	int q,cnt=0;
	scanf ("%d",&n);
	for (int i=0;i<n;i++) {
		scanf ("%d",&s[i]);
	}
	scanf ("%d",&q);
	for (int i=0;i<q;i++) {
		int tmp;
		scanf ("%d",&tmp);
		if (find(tmp)) cnt++;
	}
	printf ("%d\n",cnt);
    return 0;
}


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

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}



int main() {

  ll X;
  cin >>X;
  if(X>=30) {
cout<<"Yes"<<endl;
  }

  
  
  else {
cout<<"No"<<endl;
  }

  
}

Measured memory_bytes: 3624
def solve():
    input_line = input()
    N = int(input_line)
    for i in range(N):
        input_line = input()
        num = int(input_line)
        if i == 0:
            min_value = num
        elif i == 1:
            max_value = num-min_value
            min_value = min(num, min_value)
        else:
            max_value = max(max_value, num-min_value)
            min_value = min(num, min_value)
    print(max_value)

solve()


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

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

    ll h, w, p;
    h = 0;
    w = 0;
    p = 0;

    for(int i = 1; i <= 3500; i++){
        for(int j = i; j <= 3500; j++){
            ll k = n * i * j;
            ll t = 4 * i * j - n * (i + j);
            if(t > 0){
                if(k % t == 0){
                    h = i;
                    w = j;
                    p = k / t;
                    break;
                }
            }
        }

        if(h != 0){
            break;
        }
    }

    cout << h << " " << w << " " << p << endl;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<algorithm>

using namespace std;

int n,m,x,y,cur;
int A = -(1 << 30);
int B = 1 << 30;

int main()
{
	scanf("%d %d %d %d",&n,&m,&x,&y);
	for(int i = 1;i <= n; i++){
		scanf("%d",&cur);
		A = max(A,cur);
	}
	A = A + 1;
	for(int i = 1;i <= m; i++){
		scanf("%d",&cur);
		B = min(B,cur);
	}
	//int beg = min(A,B);
	//int endd = max(A,B);
	for(int i = A;i <= B; i++){
		if(i > x && i <= y) {
			printf("No War\n");
			return 0;
		}
	}
	printf("War\n");
}

Measured memory_bytes: 128
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            StringBuilder S = new StringBuilder(reader.readLine());

            do {
                S.setLength(S.length() - 2);

                boolean flg = true;

                int half = S.length() / 2;

                for (int i = 0; i < half; i++)
                    if (S.charAt(i) != S.charAt(half + i)) flg = false;

                if (flg) break;

            } while (2 < S.length());

            System.out.println(S.length());
        }
    }
}


Measured memory_bytes: 24532
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
 
        String sentence;
        int[] abc = new int[26];
 
        while ((sentence = input.readLine()) != null) {
            for (int i = 0; i < sentence.length(); i++) {
                char c = sentence.charAt(i);
                     c = Character.toLowerCase(c);
                char cc = 'a';
                for (int j = 0; j < abc.length; j++) {
                    if (cc == c)
                        abc[j]++;
                    cc++;
                }
            }
        }
 
        char cc = 'a';
        for (int i = 0; i < abc.length; i++) {
            System.out.println(cc + " : " + abc[i]);
            cc++;
        }
    }
 
}

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

int main() {
  int N;
  cin >> N;
  vector<int> V(N), K(100000), G(100000);
  for (int i = 0; i < N; i++) {
    cin >> V.at(i);
    if (i % 2 == 0) {
      G.at(V.at(i) - 1)++;
    }
    else {
      K.at(V.at(i) - 1)++;
    }
  }
  int M = 0, M2 = 0, S = 0, S2 = 0;
  int O, O2;
  for (int i = 0; i < 100000; i++) {
    if (M <= K.at(i)) {
      if (M2 <= M) {
        M2 = M;
      }
      M = K.at(i);
      O = i;
    }
    else if (M2 <= K.at(i)) {
      M2 = K.at(i);
    }
    if (S <= G.at(i)) {
      if (S2 <= S) {
        S2 = S;
      }
      S = G.at(i);
      O2 = i;
    }
    else if (S2 <= G.at(i)) {
      S2 = G.at(i);
    }
  }
  int ans;
  if (O == O2) {
    ans = min(N - M - S2, N - M2 - S);
  }
  else {
    ans = N - M - S;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4580
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin >> n;
  ll sum = 0;
  for (int i = 1; i <= n; ++i)
  {
    if (i % 3 == 0 || i % 5 == 0)
      continue;
    else
      sum += i;
  }
  cout << sum;

}


Measured memory_bytes: 3612
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;
    ll sum = 0;
    rep(i, s.size()) { sum += s[i] - '0'; }
    if (sum % 9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3352
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

std::unordered_map<char, i64> create_map(const std::string& S) {
  std::unordered_map<char, i64> S_map;
  for (const char& S_i : S) {
    if (S_map.find(S_i) == S_map.end()) {
      S_map.insert(std::make_pair(S_i, S_map.size()));
    }
  }
  return S_map;
}

std::vector<i64> regularize(const std::string& S, const std::unordered_map<char, i64>& map) {
  std::vector<i64> result;
  result.reserve(S.size());
  std::transform(S.begin(), S.end(), std::back_inserter(result), [&map](const char c) { return map.at(c); });
  return result;
}

int main() {
  std::string S, T;
  std::cin >> S >> T;

  const std::unordered_map<char, i64> S_map = create_map(S);
  const std::unordered_map<char, i64> T_map = create_map(T);

  std::cout << (regularize(S, S_map) == regularize(T, T_map) ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 3848
with open(0) as f:
    N, S = f.read().split()
N = int(N)
S += '_'
left = 0
right = 0
cnt = 0
for i in range(N):
    cnt += {'(':1, ')':-1}[S[i]]
    if S[i] == ')' and S[i+1] != ')':
        if cnt < 0:
            left += -cnt
            cnt = 0
    if i == N-1 and cnt > 0:
        right += cnt
ans = '(' * left + S[:N] + ')' * right
print(ans)

Measured memory_bytes: 9156
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<String> n = Arrays.asList(sc.next().split(""));
        for (String str : n) {
            if ("9".equals(str)) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }

}


Measured memory_bytes: 21844
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = sc.next();
		int count = 0;
		for(int i = 0; i < N - 2; i++){
			if(s.substring(i, i + 3).equals("ABC")){
				count++;
			}
		}
		System.out.println(count);
	}
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007; 

ll gcd(ll a, ll b){
  if(b == 0) return a;
  else return gcd(b, a % b); 
}

int main(){
  ll h, w;
  cin >> h >> w;
  cout << (h + w - 1) / w << endl;
}

Measured memory_bytes: 256
//#include <iostream>
//#include <vector>
//#include <algorithm>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main(){
  int n,m;
  cin >> n >> m;
  priority_queue<ll> que;
  rep(i,n){
    ll k;
    cin >> k;
    que.push(k);
  }
  rep(i,m){
    ll k = que.top()/(ll)2;
    que.pop();
    que.push(k);
  }
  ll sum = 0;
  while(!que.empty()){
    sum += que.top();
    que.pop();
  }
  cout << sum << endl;
  return 0;
}

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

#define N 50000

int main(){
	bool prime[N+1];
	
	for(long i=2; i<=N; ++i) prime[i]=true;

	for(long i=2; i<=N; ++i){
		if(prime[i]){
			for(long j=2; i*j<=N; ++j) prime[i*j]=false;
		}
	}
	
	while(1){
		long n, ans=0;
		
		scanf(" %ld", &n);
		if(n==0) break;
		
		for(long i=2; i<=n/2; ++i){		
			if(prime[i] && prime[n-i]) ++ans;	
		}
		
		printf("%ld\n", ans);	
	}
	
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<ll> Q(N);
  ll ple=512411*512411;
  ll mle=512411*512411;
  ll su=0;
  int cnt=0;
  for(int i=0;i<N;i++){
    cin>>Q[i];
    if(Q[i]<0){
      cnt++;
      mle=min(mle,0-Q[i]);
      su+=0-Q[i];
    }else{
      ple=min(ple,Q[i]);
      su+=Q[i];
    }
  }
  if(cnt%2)
    su-=2*min(ple,mle);
  cout<<su<<endl;
}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;
vector<int> Eratosthenes(int n);
int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int n;
    cin >> n;
    map<int, int> array; //index,count
    rep(i, n)
    {
        int a;
        cin >> a;
        if (array.count(a) == 1)
        {
            array[a]++;
        }
        else
        {
            array[a] = 1;
        }
        if (array.count(a - 1) == 1)
        {
            array[a - 1]++;
        }
        else
        {
            array[a - 1] = 1;
        }
        if (array.count(a + 1) == 1)
        {
            array[a + 1]++;
        }
        else
        {
            array[a + 1] = 1;
        }
    }
    int ans = 0;
    for (auto b = array.begin(); b != array.end(); b++)
    {
        if (ans < b->second)
        {
            ans = b->second;
        }
    }
    c(ans);
    return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>

using namespace std;
long N;
unordered_map<int, long> mp;
long mod = 1000000007;

int main() {
  cin >> N;
  for (int i=1; i<=N; i++) {
    int tmp = i;
    int j=2;
    while (tmp != 1) {
      if (tmp%j == 0) {
        tmp/=j;
        mp[j]++;
        // cout << "i: " << i << " j:" << j << endl;
      } else {
        j++;
      }
    }
  }
  long ans = 1;
  for (auto entry: mp) {
    ans *= (entry.second +1);
    ans = ans % mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O2")
#endif
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N, K;cin >> N >> K;
    vector<int> h(N);
    int h_count;
    int answer =0;

    for (int i=0; i<N; i++){
        cin >> h[i];
        if(h[i] >= K){
            answer += 1;
        } 
    }

//    h_count = count_if(h.begin(), h.end(), [](int i, int K)->bool{return ((i>K));});
    cout << answer;

}

Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

int main() {
    long N,K;
    cin>>N>>K;
    vector<long> l(N);
    for(int i=0;i<N;i++) cin>>l.at(i);
    sort(l.rbegin(),l.rend());
    cout<<accumulate(l.begin(),l.begin()+K,0)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int c[26];
int main()
{
    string s;
    cin >> s;
    for (char x : s)
        c[x-'a']++;
    long long ans = 1;
    for (int i = 0; i < 26; ++i)
        for (int j = i + 1; j < 26; ++j)
            ans += c[i] * 1LL * c[j];
    cout << ans << endl;
}


Measured memory_bytes: 640
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(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 size(self, x):
        return -self.parents[self.find(x)]




def program():
    N, M = map(int, input().split())
    uf = UnionFind(N)
    for i in range(M):
        a, b = map(int, input().split())
        uf.union(a - 1, b - 1)

    ans = max([uf.size(i) for i in range(N)])
    return ans


print(program())


Measured memory_bytes: 22656
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  REP(i, N) {
    cin >> l[i];
  }
  sort(ALL(l), greater<int>());
  int sum = 0;
  REP(i, K) {
    sum += l[i];
  }
  cout << sum << endl;
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    //cout << a <<" " << y << endl;
    ll sum[10]={};
    sum[0]=2*c*max(x,y);
    sum[1]=a*x+b*y;
    if(x-y>0)sum[2]=y*2*c+(x-y)*a;
    else sum[2]=sum[0];

    if(y-x>0)sum[3]=x*2*c+(y-x)*b;
    else sum[3]=sum[0];

    ll mi=sum[0];

    REP(i,4){
        //cout << sum[i] << endl;
        if(sum[i]<0)continue;
        mi=min(sum[i],mi);
    }
    cout << mi << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define mod 1000000007
#define inf (1ll<<60)
#define eps 1e-9
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
using namespace std;

int main() {
    
    
    fast();
    int t,n,m,sum=0;
    cin>>n;
    int a[n]={0};
    for(int i=1;i<n;i++)
    {
        cin>>t;
        a[t]++;
    }
    for(int i=1;i<n;i++)
    {
        cout<<a[i]<<endl;
    }
    cout<<"0\n";
	return 0;
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    string S[H];
    rep(i, H) {
        cin >> S[i];
    }
    int ans[H][W] = {};
    rep(i, H) {
        rep(j, W) {
            int x;
            int y;
            rep(k, 9) {
                x = i + k % 3 - 1;
                y = j + k / 3 - 1;
                if (x < 0 || x >= H || y < 0 || y >= W) continue;
                if (S[x][y] == '#') ans[i][j]++;
                //printf("S[%d][%d] = %c\n", x, y, S[x][y]);
            }
        }
    }
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '#') cout << '#';
            else cout << ans[i][j];
        }
        cout << '\n';
    }

    return 0;
}


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

int main(void){
    int n,q;
    string s;
    cin >> n >> q >> s;

    vector<bool> pos(n,false);
    for(int i=0;i<n-1;i++){
        if(s[i]=='A' && s[i+1]=='C') pos[i+1] = true;
    }

    vector<int> sum(n,0);
    for(int i=0;i<n-1;i++){
        sum[i+1] = sum[i];
        if(pos[i+1]) sum[i+1]++;
    }

    vector<int> ans(q);
    for(int i=0;i<q;i++){
        int l,r;
        cin >> l >> r;
        l--; r--;
        ans[i] = sum[r] - sum[l];
    }
    for(int i=0;i<q;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 1792