akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////



int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int H,W; cin >> H >> W;
    vector<string> S(H);
    rep(i,H) cin >> S[i];

    const vector<int> dy = {-1,0,0,1};
    const vector<int> dx = {0,-1,1,0};
    vector<vector<int>> dist(H, vector<int>(W,-1));
    queue<pii> que;

    int ans = 0;
    rep(i,H) {
        rep(j,W) {
            if (S[i][j] == '#') continue;
            rep(k,H) rep(l,W) dist[k][l] = -1;
            dist[i][j] = 0;
            que.emplace(i,j);
            while (!que.empty()) {
                int y,x;
                tie(y,x) = que.front(); que.pop();
                rep(k,4) {
                    int ny = y + dy[k];
                    int nx = x + dx[k];
                    if (ny<0||ny>=H||nx<0||nx>=W) continue;
                    if (S[ny][nx] == '#') continue;
                    if (dist[ny][nx] != -1) continue;
                    dist[ny][nx] = dist[y][x]+1;
                    que.emplace(ny,nx);
                }
            }
            rep(k,H) rep(l,W) chmax(ans,dist[k][l]);
        }
    }

    cout << ans << endl;
}

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

priority_queue<lint, vector<lint>, greater<lint>> prime;

int main() {
  lint N;
  cin >> N;

  lint n = sqrt(N);
  for (int i=n+1; 1 < i; --i) {
    while (N % i == 0) {
      N /= i;
      prime.push(i);
    }
  }
  if (N > 1) {
    prime.push(N);
  }

  if (prime.size() == 1) {
    cout << prime.top() -1 << endl;
  } else {
    while (prime.size() > 2)
    {
      lint a = prime.top();
      prime.pop();
      lint b = prime.top();
      prime.pop();
      prime.push(a * b);
    }
    lint a = prime.top();
    prime.pop();
    cout << a + prime.top() - 2 << endl;
  }
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll w,h,n;
  cin >> w >> h >> n;
  ll x1 = 0,y1 = 0,x2 = w,y2 = h;

  rep(i,n){
    ll a,b,c;
    cin >> a >> b >> c;
    if(c == 1){
      x1 = max(x1,a);
    }
    if(c == 2){
      x2 = min(x2,a);
    }
    if(c == 3){
      y1 = max(y1,b);
    }
    if(c == 4){
      y2 = min(y2,b);
    }
  }
  ll ans = (x2 - x1) * (y2 - y1);
  if(x2 - x1 > 0 && y2 - y1 > 0){
    std::cout << ans << std::endl; 
  }
  else{
    std::cout << 0 << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n,k,i,min=300000000;
  scanf("%d%d",&n,&k);
  int a[n+1];
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(i=0;i<=n-k;i++){
    if(a[i]<0 && a[i+k-1]<0){
      if(min>abs(a[i]))
        min=abs(a[i]);
    }
    else if(a[i]>0 && a[i+k-1]>0){
      if(min>a[i+k-1])
        min=a[i+k-1];
    }
    else if(a[i]==0){
      if(min>a[i+k-1])
        min=a[i+k-1];
    }
    else if(a[i+k-1]==0){
      if(min>abs(a[i]))
        min=abs(a[i]);
    }
    else{
      if(abs(a[i])<a[i+k-1] && min>2*abs(a[i])+a[i+k-1])
        min=2*abs(a[i])+a[i+k-1];
      else if(abs(a[i])>=a[i+k-1] && min>abs(a[i])+2*a[i+k-1])
        min=abs(a[i])+2*a[i+k-1];
    }
  }
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string.h>
using namespace std;

int main(void)
{
	string S, message[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	int N, k;
	cin >> N;
	while (N--) {
		cin >> S;
		int count = -1, k = S[0] - '0';
		for (int i = 0; i < S.size(); i++) {
			if (S[i] == '0') {
				if (k != 0) {
					count %= message[k].size();
					cout << message[k][count];
				}
				k = S[i + 1] - '0';
				count = -1;
			}else {
				count++;
			}
		}
		cout << endl;
	}	
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
const int MOD = 1e9+7;
const int INF = 1e9+10;
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Edge{int to,weight;};
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 dp[110][101010]; 
int w[110],v[110];

signed main(){
  int n,W;
  cin>>n>>W;
  rep(i,n) cin>>w[i]>>v[i];
  rep(i,110)rep(j,101010) dp[i][j]=INF;
  
  dp[0][0]=0;
  rep(i,n+1)rep(j,101010){
    if(j>=v[i]) chmin(dp[i+1][j],dp[i][j-v[i]]+w[i]);
    chmin(dp[i+1][j],dp[i][j]);
  }

  int ans=0;
  rep(j,101010) if(dp[n][j]<=W) ans=j;
  cout<<ans<<endl;
  // rep(i,n+1){
  //   rep(j,101010) if(dp[i][j]<INF) cout<<dp[i][j]<<"/"<<j<<" ";
  //   cout<<endl;
  // }
  return 0;
}


Measured memory_bytes: 87168
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

#[allow(unused_imports)]
use input::*;

fn main() {
    let (x, y, z): (usize, usize, usize);
    input!(x, y, z);
    p((x - z) / (y + z));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main()
{
	ll N,M,A,B;
	cin >> N >> M;
	vector<ll> H(N+1);
	H[0] = -10;

	for(int i = 1;i<=N; i++){
		cin >> H[i];
	}

	set<ll> a;

	for(int i = 1; i<=M; i++){
		cin >> A >> B;
		if(H[A]>H[B]){
			a.insert(B);
		}
		else if(H[A]<H[B]){
			a.insert(A);
		}
		else{
			a.insert(A);
			a.insert(B);
		}
	}


	cout << N-a.size();


	cin >> N;
	
	return 0;	
}

Measured memory_bytes: 6664
from fractions import gcd
n,x=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]=abs(a[i]-x)
if n==1:
  print(a[0])
else:
  ans=gcd(a[0],a[1])
  for i in range(2,n):
    ans=gcd(ans,a[i])
  print(ans)

Measured memory_bytes: 16296
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;

#define INF (1LL<<31)-1
typedef struct RAQ{
ll n;
	vector<ll> a;
	//vector<bool> f;
	void init(int size){
		n = 1;
		while(n<size) n*=2;
		a = vector<ll> (2*n-1,0);
		//f = vector<bool> (2*n-1,true);
	}
	
	void init(vector<ll> &b){
		int size = b.size();
		n = 1;
		while(n<size)n*=2;
		a = vector<ll> (2*n-1,0);
		//f = vector<bool> (n,true);
		for(int i=0;i<size;i++) a[i+n-1] = b[i];
	}
	//
	void update(ll aa,ll b ,ll k,ll l,ll r ,ll x){
		if(r<= aa|| b<= l)return ;
		if(aa<=l && r<=b ) a[k] += x*(r-l);
		else{
			a[k*2+1] += a[k]/2;
			a[k*2+2] += a[k]/2;
			a[k] = 0;
			update(aa,b,k*2+1,l,(l+r)/2,x);
			update(aa,b,k*2+2,(l+r)/2,r,x);
		}
		return ;
	}
	ll find(ll aa,ll b,ll k,ll l,ll r){
		if(r<=aa|| b<=l) return 0;
		if(aa<=l && r<= b) return a[k];
		a[k*2+1] += a[k]/2;
		a[k*2+2] += a[k]/2;
		a[k] = 0;
		return find(aa,b,k*2+1,l,(l+r)/2) + find(aa,b,k*2+2,(l+r)/2,r) ;
	}
	//[s,t]
	void update(ll s,ll t,ll x){
		update(s,t+1,0,0,n,x);
	}
	ll find(ll s){
		return find(s,s+1,0,0,n);
	}
	
}RAQ;





int main(){
 ll n,k;
 cin>>n>>k;
 vector<ll> a(n,0);
 for(ll i=0;i<n;i++)cin>>a[i];
 RAQ  s;
 s.init(n);
 vector<ll> b(n+1,0);
 
 for(ll t=0;t<min(k,201ll);t++){
  for(ll i=0;i<n;i++){
   ll left = max( 0ll , i-a[i] );
   ll right = min( n , i+a[i]+1);
   b[left]++;
   b[right]--;
  }
  //for(ll i=0;i<n;i++)cout<<b[i]<<' ';
  //cout<<endl;
  for(ll i=0;i<n;i++) b[i+1] += b[i];
  a = b;
  b = vector<ll>(n+1,0);
 }
 cout<<a[0];
 for(int i=1;i<n;i++)cout<<' '<<a[i];
 cout<<endl;
    return 0;
}


Measured memory_bytes: 11916
var
  n,m,i,j,s:longint;
  ch:char;
begin
  readln(n,m);
  for i:=1 to n do
    begin
      for j:=1 to m do begin read(ch);if ch='#' then inc(s);end;
      readln;
    end;
  if s=n+m-1 then writeln('Possible') else writeln('Impossible');
end.

Measured memory_bytes: 128
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10**7)

t = int(input())
for _ in range(t):
    n, a, b, c, d = map(int, input().split())
    memo = {0: 0, 1: d}
    def cost(N):
        if N in memo:
            return memo[N]
        ans = N * d
        ks = [2, 3, 5]
        abc = [a, b, c]
        for i in range(3):
            k = ks[i]
            coin = abc[i]
            div, mod = divmod(N, k)
            pay = mod * d + coin

            # D枚コインを払って1だけ増減させる。
            # その際に行き着く先として、div(減らす場合) or div+1(増やす場合)
            # 増やす場合は、現在の状態から、最寄りの倍数まで足す必要があり、これはmodからkまでの距離と等しい。
            ans = min(ans, pay + cost(div))
            if mod == 0:
                continue
            pay = (k - mod) * d + coin
            ans = min(ans, pay + cost(div + 1))
        memo[N] = ans
        return ans
    print(cost(n))

Measured memory_bytes: 10852
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
vector<int> v;
int mx = 3234566667;
void solve (int num){
    if(num>mx)
        return;
    if(num>0)
        v.pb(num);
    int d = num%10;
    for(int i = max((int)0,d-1);i<=min((int)9,d+1);i++)
        solve(num*(int)10 + i);
}
signed main(){
    fast;
    int k;
    cin>>k;
    for(int i = 1;i<=9;i++){
        solve(i);
    }
    sort(all(v));
    cout<<v[k-1];
}

Measured memory_bytes: 1400
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
A = []
B = []
if n % 2 == 0:
    for i in range(0, n-1, 2):
        A.append(a[i])
    for j in range(1, n, 2):
        B.append(a[j])
else :
    for i in range(0, n, 2):
        A.append(a[i])
    for j in range(1, n-1, 2):
        B.append(a[j])

print(abs(sum(A)-sum(B)))

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

// {days, reward}
vector<pair<int, int>> jobs;

int main(void) {
    int N, M;
    cin >> N >> M;

    jobs.resize(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        jobs[i] = {a, b};
    }

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

    priority_queue<int> que;
    int ans = 0;
    int i_jobs = 0;
    for (int day = 1; day <= M; day++) {
        while (i_jobs < N && jobs[i_jobs].first <= day) {
            que.push(jobs[i_jobs].second);
            i_jobs++;
        }

        if (!que.empty()) {
            auto reward = que.top();
            que.pop();
            ans += reward;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4616
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
typedef string::const_iterator State;

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


int main(void) {


	ll n, k;
	ll result = 0;
	ll dp[12][6];
	ll total = 0;

	FOR(i, 1, 11) {
		FOR(j, 1, 5) {
			total = (21 * (i - 1) + 3 * j + 3) + (21 * i + 3 * j + 3) + (21 * (i + 1) + 3 * j + 3);
			dp[i][j] = total % 11;
		}
	}

	cin >> n >> k;

	n -= 2;
	
	result += (n / 11) * 5;

	n %= 11;

	FOR(i, 1, n) {
		FOR(j, 1, 5) {
			if (dp[i][j] == k) {
				result++;
			}
		}
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
C - Five Transportations
https://atcoder.jp/contests/abc123/tasks/abc123_c

"""
import sys

from math import ceil

def solve(N, passengers):
    passengers.insert(0, 0)
    res = [-1] * 7
    res[0], res[1] = 0, 0
    res[2] = ceil(N / passengers[1])
    for i in range(3, 7):
        if passengers[i-1] >= passengers[i-2]:
            res[i] = res[i-1] + 1
        else:
            res[i] = max((i-2) + ceil(N / passengers[i-1]), res[i-1] + 1)
    return res[-1]


def main(args):
    N = int(input())
    passengers = [int(input()) for _ in range(5)]
    ans = solve(N, passengers)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#define INF 0x3f3f3f3f
#define mod 1000000007
using namespace std;
int a[55];
int main()
{
	
	int n,sum=0,b;
	scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
    	scanf("%d",&a[i]);
	}
	for(int i=0;i<n-1;i++)
    {
    	for(int j=i+1;j<n;j++)
    	{
    	b=a[i]*a[j];
		sum+=b;	
		}
    	
	}
	printf("%d\n",sum);
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
const ld pi = acos(-1);
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int r; cin >> r;
    cout << 3 * r * r << "\n";
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int a, b;
int main() {
    std::cin >> a >> b;
    std::cout << std::ceil((1.*a+b) /2) << std::endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    
    uint N, K; cin >> N >> K; --K;
    vector<int> vH(N);
    for(uint i=0; i<N; ++i){ cin >> vH[i]; }
    sort(vH.begin(), vH.end());
    
    int diff_min=INT_MAX;
    for(uint i=0; i<N-K; ++i){
        diff_min = min(diff_min, vH[i+K] - vH[i]);
    }
    
    cout << diff_min << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int mincost(int n,int *h){
    int dp[n+1];
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(h[1]-h[0]);
    for(int i=3;i<=n;i++){
        int val=INT_MAX;
        for(int j=i-2;j<i;j++){
            val=min(val,abs(h[j-1]-h[i-1])+dp[j]);
        }
        dp[i]=val;
    }
    return dp[n];
}
int main() {
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    cout<<mincost(n,h)<<endl;
    
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll n;
	vector<ll> v;
	string s[3] = { "3", "5", "7" };
	string ss[6] = { "357", "375", "537", "573", "735", "753" };
	stack<string> st[2][3];
	string sss, ssss;

	cin >> n;

	REP(i, 6) {
		v.push_back(stoll(ss[i]));
		st[0][0].push(ss[i]);
		st[0][1].push(ss[i]);
		st[0][2].push(ss[i]);
	}

	REP(i, 6) {
		vector<string> vv;
		REP(j, 3) {
			while (!st[i % 2][j].empty()) {
				sss = st[i % 2][j].top();
				st[i % 2][j].pop();
				REP(k, sss.size() + 1) {
					ssss = "";
					ssss += sss.substr(0, k);
					ssss += s[j];
					ssss += sss.substr(k);
					v.push_back(stoll(ssss));
					vv.push_back(ssss);
				}
			}
		}
		sort(vv.begin(), vv.end());
		vv.erase(unique(vv.begin(), vv.end()), vv.end());
		REP(j, vv.size()) {
			st[(i + 1) % 2][0].push(vv[j]);
			st[(i + 1) % 2][1].push(vv[j]);
			st[(i + 1) % 2][2].push(vv[j]);
		}
	}

	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());

	auto itr = upper_bound(v.begin(), v.end(), n);

	cout << itr - v.begin() << endl;
}

Measured memory_bytes: 11192
def main():
    import sys
    input = sys.stdin.readline

    # comb init
    mod = 1000000007
    nmax = 4 * 10 ** 5 + 10  # change here
    fac = [0] * nmax
    finv = [0] * nmax
    inv = [0] * nmax
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, nmax):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

    def comb(n, r):
        if n < r:
            return 0
        else:
            return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod

    N, K = map(int, input().split())

    ans = 0
    for m in range(min(K+1, N)):
        ans = (ans + (comb(N, m) * comb(N-1, m))%mod)%mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 48752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = (int) Math.pow(10, 5);
		for (int i = 0; i < n; i++) {
			m *= 1.05;
			int range = 1000;
			if (m % range != 0)
				m = (m / range + 1) * range;
		}
		System.out.println(m);
		sc.close();

	}
}

Measured memory_bytes: 26140
import bisect
from collections import Counter
import sys
input = sys.stdin.buffer.readline

N = int(input())
a = list(map(int, input().split()))
c = sorted(list(Counter(a).values()))
M = len(c)
cs = [0]*(M+1)
for i in range(M):
    cs[i+1] = cs[i] + c[i]

kmax = [0] * (N+1)
for i in range(1, N+1):
    j = bisect.bisect_left(c, i) if i <= c[-1] else M
    kmax[i] = (cs[j] + i * (M-j)) // i

idx = N
for k in range(1, N+1):
    while k > kmax[idx]:
        if idx == 0:
            break
        idx -= 1
    print(idx)


Measured memory_bytes: 102616
int mn, mx, cnt, a[99], b[99], i;
f(long n) {
	if (n == 1) return mn = 1;
	int tt = n & 1 ? f(n ^ 1), --mn : (f(n >> 1), ++mx);
	a[i++] = tt;
}

long n;
int j;
int main() {
	scanf("%ld", &n), f(n + 1);
	printf("%d\n", i * 2);
	for (; j < i;) b[a[j++] - mn] = j;
	for (j = 0; j < i;) printf("%d ", b[j++]);
	for (i = 0; i <= mx - mn;) printf("%d ", ++i);
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vii f(n, vi(10)), p(n, vi(11));
  rep(i,n)rep(j,10) cin >> f[i][j];
  rep(i,n)rep(j,11) cin >> p[i][j];
  int ans = -inf;
  rep(bit,(1<<10)) {
    bitset<10> b(bit);
    if(b.count() == 0) continue;
    int tmp = 0;
    rep(i,n) {
      int cnt = 0;
      rep(j,10) {
        if(b[j] && f[i][j]) cnt++;
      }
      tmp += p[i][cnt];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

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

using namespace std;

int A_1, A_2, A_3;

int main(){
    cin >> A_1 >> A_2 >> A_3;
    cout << max({A_1, A_2, A_3}) - min({A_1, A_2, A_3}) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

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

#define DEBUG
#undef DEBUG

using ll  = long long;
using ull = unsigned long long;

int N, M;
int G[9][9] = {};

bool visited[9] = {};
int cnt = 0;

void dfs(int v)
{
    if(visited[v]) return;
    visited[v] = true;

    //cout << v << "\n";

    if(all_of(visited+1, visited+N+1, [](bool x) { return x; })) {
        visited[v] = false;
        ++cnt;
        return;
    }

    FOR(dst, 1, N+1) {
        if(G[v][dst]) {
            dfs(dst);
        }
    }

    visited[v] = false;
}

void solve()
{
    dfs(1);

    cout << cnt << "\n";
}

int main()
{
    cin >> N >> M;
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        G[a][b] = G[b][a] = 1;
    }

    solve();

    return 0;
}


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

int main() {

  string s;
  vector<int> count(26);

  while (getline(cin, s)) {
    for (int i = 0; i < s.size(); i++) {
      int v = (int) s[i];
      if (65 <= v && v <= 90) {
        count[(v - 65)]++;
      } else if (97 <= v && v <= 122) {
        count[(v - 97)]++;
      }
    }
  }

  for (int i = 0; i < 26; i++) {
    cout << char(i + 97) << " : " << count[i] << endl;
  }

  return 0;

}


Measured memory_bytes: 3188
#include <stdio.h>
int binarySearch(int);
int n,s[100000];
int main(){
	int q,t[50000],i,cnt=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&s[i]);

	scanf("%d",&q);
	for(i=0;i<q;i++) scanf("%d",&t[i]);
	
	for(i=0;i<q;i++){
		if(binarySearch(t[i])==1) cnt++;
	}
	
	printf("%d\n",cnt);
	
	return 0;
}

int binarySearch(int key){
	int left=0,right=n,mid;
	
	while(left<right){
		mid=(left+right)/2;
		if(s[mid]==key) return 1;
		else if(key<s[mid]) right=mid;
		else left=mid+1;
	}
	return 0;
}
	


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

ll n, e;

priority_queue<ld, std::vector<ld>, greater<ld>> q;

int main() {
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> e;
        q.push(e);
    }
    for (ll i = 0; i < n - 1; i++) {
        ld e1 = q.top();
        q.pop();
        ld e2 = q.top();
        q.pop();
        ld newe = (e1 + e2) / 2.0;
        q.push(newe);
    }
    cout << q.top() << endl;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 2 * 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int n;
string s;
int pre[N];
int suf[N];
int res = INF;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    cin >> n >> s;
    s = " " + s;
    FOR(i, 1, n)
    {
        pre[i] = pre[i - 1];
        if(s[i] == '#') pre[i]++;
    }
    //pre[n + 1] = pre[n];
    FORd(i, n, 1)
    {
        suf[i] = suf[i + 1];
        if(s[i] == '.') suf[i]++;
    }
    FOR(i, 1, n + 1)
    {
        res = min(res, suf[i] + pre[i - 1]);
        //cout << i << " " << res << endl;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 2128
require 'matrix'

max_row, _, const = STDIN.gets.split.map(&:to_i)
vec_B = Vector.elements(STDIN.gets.split.map(&:to_i), copy=false)

cnt = 0
max_row.times do |_|
  vec_A = Vector.elements(STDIN.gets.split.map(&:to_i), copy=false)
  cnt += 1 if vec_A.dot(vec_B) + const > 0
end

STDOUT.puts cnt

Measured memory_bytes: 4604
import java.util.Scanner;

public class Main {
	static int and[][] = { { 0, 0, 0 }, { 0, 1, 1 }, { 0, 1, 2 } };// i*j
	static int or[][] = { { 0, 1, 2 }, { 1, 1, 2 }, { 2, 2, 2 } };

	static boolean isNum(char c) {
		return '0' <= c && c <= '9';
	}

	static void replace(StringBuilder sb, int p, int q, int r) {
		for (int i = 0; i < sb.length(); i++) {
			if (sb.charAt(i) == 'P') {
				sb.setCharAt(i, (char) (p + '0'));
			} else if (sb.charAt(i) == 'Q') {
				sb.setCharAt(i, (char) (q + '0'));
			} else if (sb.charAt(i) == 'R') {
				sb.setCharAt(i, (char) (r + '0'));
			}
		}
	}

	static void negRemove(StringBuilder sb) {
		int past = sb.length() + 10, now;
		while (true) {
			now = sb.length();
			if (past == now) {
				return;
			}
			for (int i = 0; i + 1 < sb.length(); i++) {
				if (sb.charAt(i) == '-' && sb.charAt(i + 1) == '-') {
					sb.delete(i, i + 2);
				}
			}
			past = now;
		}
	}

	static void negate(StringBuilder sb) {
		for (int i = 0; i + 1 < sb.length(); i++) {
			if (sb.charAt(i) == '-' && isNum(sb.charAt(i + 1))) {
				// -0 -> 2
				// -1 -> 1
				// -2 -> 0
				char c = sb.charAt(i + 1);
				if (c == '0') {
					sb.setCharAt(i + 1, '2');
					sb.delete(i, i + 1);
				} else if (c == '1') {
					sb.delete(i, i + 1);
				} else {
					sb.setCharAt(i + 1, '0');
					sb.delete(i, i + 1);
				}
			}
		}
	}

	static void calc(StringBuilder sb) {
		for (int i = 0; i + 2 < sb.length(); i++) {
			char l, m, r;
			l = sb.charAt(i);
			m = sb.charAt(i + 1);
			r = sb.charAt(i + 2);
			char c;// ティツィツ暗ァツョツ療ァツオツ静ヲツ楪? c=l+r, c=l*r
			if (isNum(l) && isNum(r)) {
				if (m == '+') {
					c = (char) (or[l - '0'][r - '0'] + '0');
					sb.setCharAt(i, c);
					sb.delete(i + 1, i + 1 + 2);
				} else if (m == '*') {
					c = (char) (and[l - '0'][r - '0'] + '0');
					sb.setCharAt(i, c);
					sb.delete(i + 1, i + 1 + 2);
				}
			}
		}
	}

	static void removeNest(StringBuilder sb) {
		for (int i = 0; i + 2 < sb.length(); i++) {
			char l, m, r;
			l = sb.charAt(i);
			m = sb.charAt(i + 1);
			r = sb.charAt(i + 2);
			char c;// ティツィツ暗ァツョツ療ァツオツ静ヲツ楪? c=l+r, c=l*r
			if (l == '(' && r == ')' && isNum(m)) {
				sb.delete(i, i + 1);
				sb.delete(i + 1, i + 1 + 1);
			}
		}
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (true) {
			StringBuilder f = new StringBuilder(in.next());
			StringBuilder origin = new StringBuilder(f.toString());
			if (f.toString().equals(".")) {
				return;
			}
			int ans = 0;
			for (int p = 0; p <= 2; p++) {
				for (int q = 0; q <= 2; q++) {
					for (int r = 0; r <= 2; r++) {
						f = new StringBuilder(origin.toString());
						// System.out.printf("p q r = %d %d %d\n", p, q, r);
						replace(f, p, q, r);
						while (f.length() > 1) {
							replace(f, p, q, r);

							negRemove(f);

							negate(f);

							calc(f);

							removeNest(f);

						}

						if (f.charAt(0) == '2') {
							ans++;
						}
					}
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 29580
#include <stdio.h>

int main(void){
	int a,b,c,t,n;
	scanf("%d",&n);
	for(;n>0;n--){
		scanf("%d %d %d",&a,&b,&c);
		if(a>b) t=a, a=b, b=t;
		if(b>c) t=c, c=b, b=t;
		if(c*c!=b*b+a*a) printf("NO\n");
		else printf("YES\n");
	}
	return 0;
}

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

#define N 105

using namespace std;

int a,b; 

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();bool f=1;
	while(!isdigit(ch)){
		if(ch=='-')f^=1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=(2*f-1);
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

void init(){
	read(a);read(b);
}

int main(){
	init();
	if(a*b==15)
	puts("*");
	if(a+b==15)
	puts("+");
	if(a+b!=15&&a*b!=15)
	puts("x");
	return 0;
}

Measured memory_bytes: 256
fn main(){
  let abk: Vec<u32> = read_vec();
  let mut a = abk[0];
  let mut b = abk[1];
  let k = abk[2];
  
  for i in 0..k {
    if i % 2 == 0 {
      a /= 2;
      b += a;
    } else {
      b /= 2;
      a += b;
    }
  }
  
  println!("{} {}", a, b);
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x, y) memset(x, y, sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = a; i >= (b); --i)
using namespace std;
int dt[][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {0, 0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;

const int N = 20020,up=4000;

char a[N], b[N], c[N];
bool ab[N], bc[N], ac[N];

bool cmp(char a, char b)
{
    return a == '?' || b == '?' || a == b;
}

int main()
{
    scanf("%s", a);
    scanf("%s", b);
    scanf("%s", c);
    int A = strlen(a), B = strlen(b), C = strlen(c);
    rep(i, 0, A - 1)
    {
        rep(j, 0, B - 1)
        {
            if (!cmp(a[i], b[j]))
                ab[i - j + 4000] = true;
        }
        rep(j, 0, C - 1)
        {
            if (!cmp(a[i], c[j]))
                ac[i - j + 4000] = true;
        }
    }
    rep(i, 0, B - 1)
    {
        rep(j, 0, C - 1)
        {
            if (!cmp(b[i], c[j]))
                bc[i - j + 4000] = true;
        }
    }

    int ans = INF;

    rep(i, -4000, 4000)
    {
        rep(j, -4000, 4000)
        {
            if (!ab[i + 4000] && !ac[j + 4000] && !bc[j - i + 4000])
            {
                int L = min({0, i, j});
                int R = max({A, B + i, C + j});
                ans = min(ans, R - L);
            }
        }
    }
        rep(i, -4000, 4000) rep(j, -4000, 4000)
        if(!ab[i + 4000] && !ac[j + 4000] && !bc[j - i + 4000]) { ///b相对于a偏移了i，c相对于i偏移了j，c相对于b偏移了j - i
            int L = min({0, i, j});
            int R = max({A, B + i, C + j});
            ans = min(ans, R - L);
        }
    cout << ans << endl;
}


Measured memory_bytes: 3796
#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(){
    ios::sync_with_stdio(false);
    int w,h;
    char c;
    cin >> w >> h >> c;
    REP(i,h){
        REP(j,w){
            if(i==0&&j==0 || i==0&&j==w-1 || i==h-1&&j==0 || i==h-1&&j==w-1){
                cout << "+" ;
            }else if(i==h/2&&j==w/2){
                cout << c;
            }else if(i==0 || i==h-1){
                cout << "-";
            }else if(j==0 || j==w-1){
                cout << "|";
            }else{
                cout << ".";
            }
        }
        cout << endl;
    }
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a;
  b=a/100;
  c=a%100;
  if(c<=b*5){
    cout<<1<<endl;
  }
  else {
    cout<<0<<endl;
  }
}

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

int main() {
  int N; cin >> N;
  int L[N]; for (int i = 0; i < N; i++) cin >> L[i];
  sort(L, L+N);
  int c = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      for (int k = j+1; k < N; k++) {
        if (L[i] + L[j] > L[k] && L[i] != L[j] && L[j] != L[k] && L[k] != L[i])
          c++;
      }
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 3544
a, b, c = map(int, input().split())

if a == b :
    if b == c :
        print('No')
    else :
        print('Yes')
elif b == c :
    if b == a :
        print('No')
    else :
        print('Yes')
elif c == a :
    if c == b :
        print('No')
    else :
        print('Yes')
else :
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector <ll> v
#define vii vector<pair<ll,ll>>v
#define pb push_back
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define while_ int t;cin>>t;while(t--)
#define vmax 100000
using namespace std;
 
 
 ll dp[101][vmax+1];
ll maxP(ll W, ll n, ll w[], ll v[])
{
  
  for(int i=0;i<=vmax;i++)
  dp[0][i]=1e18;
  dp[0][0] = 0;
  for(ll an=1;an<=n;an++)
  {
      for(ll av=0;av<=vmax;av++)
      {
          if(v[an-1]>av) dp[an][av]=dp[an-1][av];
          else
          dp[an][av]=min(dp[an-1][av],w[an-1]+dp[an-1][av-v[an-1]]);
      }
  }
  ll ans=0;
  f(i,0,vmax+1)
  if(dp[n][i]<=W)
   ans=i;
  return ans;
 
}
 
int main() {
    fastio
   
    ll n,W;
    cin>>n>>W;
    ll w[n],v[n];
    f(i,0,n) cin>>w[i]>>v[i];
    cout<<maxP(W,n,w,v);
   
}

Measured memory_bytes: 79232
N = int(input())
array = list(map(int, input().split()))
dic = {}
ans = 0
for item in array:
    if item in dic:
        dic[item] += 1
    else:
        dic[item] = 1
# print(dic)
for key in dic.keys():
    item = dic[key]
    if item == 0:
        continue
    else:
        if item > key:
            ans += abs(item-key)
        elif item < key:
            ans += item
print(ans)

Measured memory_bytes: 17780
a=[]
b=0
c=[]
d=[]
i=0
b=int(input())
aa=input()
for x in aa:
    a.append(x)
if len(a)%2==1:
    print("No")
else:
    while i<len(a)//2:
        c.append(a[i])
        i+=1
    while i<len(a):
        d.append(a[i])
        i+=1
    if c==d:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
from collections import Counter
S = input()
n = len(S)
mod = 2019
s = [0]*(n+1)
X = [1]*n
for i in range(n-1):
    X[i+1] = X[i]*10%mod
for i in range(n):
    s[i+1] = (s[i]+int(S[n-i-1])*X[i])%mod
c = Counter(s)
ans = 0
for x in c.values():
    ans += (x-1)*x//2
print(ans)

Measured memory_bytes: 77592
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    BSubstring solver = new BSubstring();
    solver.solve(1, in, out);
    out.close();
  }

  static class BSubstring {

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      String s = in.next();
      String t = in.next();
      int ans = Integer.MAX_VALUE;
      for (int start = 0; start + t.length() <= s.length(); ++start) {
        int diff = 0;
        for (int i = 0; i < t.length(); ++i) {
          if (s.charAt(i + start) != t.charAt(i)) {
            ++diff;
          }
        }
        ans = Math.min(diff, ans);
      }
      out.println(ans);
    }

  }

  static class InputReader {

    private InputStream stream;
    private static final int DEFAULT_BUFFER_SIZE = 1 << 16;
    private static final int EOF = -1;
    private byte[] buf = new byte[DEFAULT_BUFFER_SIZE];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (this.numChars == EOF) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return EOF;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public String next() {
      int c;
      while (isSpaceChar(c = this.read())) {
      }

      StringBuilder result = new StringBuilder();
      result.appendCodePoint(c);

      while (!isSpaceChar(c = this.read())) {
        result.appendCodePoint(c);
      }

      return result.toString();
    }

    public static boolean isSpaceChar(int c) {
      return c == 32 || c == 10 || c == 13 || c == 9 || c == EOF;
    }

  }
}



Measured memory_bytes: 32620
a,b,c,d = input().split()
a,b,c,d = int(a),int(b),int(c),int(d)

from fractions import gcd

def div(x):
    if(a%x == 0):
        return (b//x-a//x)*(x-1)+(b%x)
    else:
        return (b//x-a//x)*(x-1)+(b%x)-(a%x-1)

ans = div(c)+div(d)-div(int(c*d//gcd(c,d)))
print(ans)

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

using namespace std;

int main() {
  int length, n, m, k, p;
  int d[100000];
  while (true) {
    long long total = 0;
    cin >> length;
    if (length == 0) {
      return 0;
    }
    cin >> n >> m;
    d[0] = 0;
    for (int i = 1; i < n; ++i) {
      cin >> d[i];
    }
    sort(d, d + n);
    for (int i = 0; i < m; ++i) {
      cin >> k;
      p = lower_bound(d, d + n, k) - d;
      if (p == 0) {
        total += min(d[0] - k, k + length - d[n - 1]);
      } else if (p == n) {
        total += min(k - d[n - 1], d[0] + length - k);
      } else {
        total += min(d[p] - k, k - d[p - 1]);
      }
    }
    cout << total << endl;
  }
}

Measured memory_bytes: 1564
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
li = input().split()
#print(li)
if len(set(li))==2:
    print("Yes")
else:
    print("No")
    
    





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

typedef long long lint;

int main(){
    lint N,L;
    cin >> N >> L;
    lint *A;
    A=new lint[N+1];
    vector<lint> O;

    A[0]=0;
    for(int i=1;i<=N;i++){
        cin >> A[i];
        A[i]+=A[i-1];
    }

    for(int i=0;i<=N-2;i++){
        if(A[i+2]-A[i]>=L){
            cout << "Possible" << endl;
            for(int j=1;j<=i;j++) cout << j << endl;
            for(int j=N-1;j>=i+2;j--) cout << j << endl;
            cout << (i+1) << endl;
            return 0;
        }
    }

    cout << "Impossible" << endl;

    delete[] A;
    return 0;
}

Measured memory_bytes: 1664