akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
	
  int n; cin >> n;
  long long sum = 0;
  for(int i = 0; i < n; i++) {
  	int t; cin >> t;
  	sum += t - 1;
  }
  cout << sum << endl;
  
	return 0;
}	


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
 
  int n,i;
long num,sum=0,max,min;
  cin>>n;
  if(n==0)return 0;
 
  for(i=0; i<n; i++){
 
    cin>>num;
    if(i==0)max=min=num;
    if(num>max)max=num;
    if(num<min)min=num;
    sum+=num;
  
  }
 
  cout<<min<<" "<<max<<" "<<sum<<"\n";
 
}

Measured memory_bytes: 1168
import java.util.Scanner;
//
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
		int n= sc.nextInt();
		boolean isTimeTable =false;
		for (int i=1;i<=9;i++) {
			for (int j=1;j<=9;j++) {
				if (i*j==n) {
					isTimeTable =true;
				}
			}
		}
		if (isTimeTable) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	}
	//----------------------------------------
	//置き場
	
	//----------------------------------------
}

Measured memory_bytes: 22996
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

a,b = inm()
if a >= 13:
    print(b)
elif a >= 6:
    print(b//2)
else:
    print(0)


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;cin >> a >> b >> c;
	if(a>=b && a>=c) cout << b+c << endl;
	else if(b>=a && b>=c) cout << a+c << endl;
	else cout << a+b << endl;
}

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

#define NMAX 100001

using namespace std;

int main()
{
	int a[NMAX];
	a[0] = 0;
	a[1] = 0;
	for (int i = 2; i < NMAX; i++) {
		a[i] = 1;
	}
	for (int i = 2; i <= sqrt(NMAX); i++) {
		if (a[i] == 1) {
			for (int j = i + i; j < NMAX; j += i) {
				a[j] = 0;
			}
		}
	}

	int b[NMAX] = {};
	for (int i = 1; i < NMAX; i += 2) {
		if (a[i] == 1 && a[(i + 1) / 2] == 1) {
			b[i] = 1;
		}
	}
	for (int i = 1; i < NMAX; i += 2) {
		if (a[i] == 1 && a[(i + 1) / 2] == 1) {
			b[i] = 1;
		}
	}
	for (int i = 1; i < NMAX; i++) {
		b[i] += b[i - 1];
	}

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

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  if(N%2==1){
    cout << 0 << endl;
    return 0;
  }
  
  N/=2;
  
  ll ret = 0;
  ll p = 5;
  while(p<=N){
    ret += N/p;
    p*=5;
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

ll find_index(vector<ll> v, ll elm){
	vector<ll>::iterator it = find(v.begin(), v.end(), elm);
	int index;
	if (it != v.end()){
		index = distance(v.begin(), it);
	}
	else{
		index = -1;
	}
	return index;
}

int main(){
	ll N, K;
	cin >> N >> K;
	vector<pll> AB;
	ll i, j;
	for (i = 0; i < N; i++){
		ll a, b;
		cin >> a >> b;
		pll ab;
		ab.first = a;
		ab.second = b;
		AB.push_back(ab);
	}
	sort(AB.begin(), AB.end());
	for (i = 0; i < N; i++){
		ll a = AB[i].first;
		ll b = AB[i].second;
		if (K <= b){
			cout << a << endl;
			return 0;
		}
		else{
			K -= b;
		}
	}
}


Measured memory_bytes: 2420
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        x: usize,
        y: usize,
    }
    let mut ans = "No";

    for i in 0..x+1 {
        let j = x - i;
        if i * 2 + j * 4 == y {
            ans = "Yes";
            break;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    string s,t;
    cin>>s>>t;
    s = s+t;
    int k = stoi(s);
    bool sq = false;
    for(int i=1;i<=k;i++){
        if(i*i==k){
            sq = true;
        }
    }
    if(sq){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#86c
N = int(input())

now_x = 0
now_y = 0
now_t = 0

for i in range(N):
    t,x,y = map(int, input().split())
    margin = (t- now_t) - abs(x - now_x) - abs(y - now_y)
    
    if margin < 0 or margin%2!=0:
        print("No")
        break
    else:
        now_x = x
        now_y = y
        now_t = t
else:
    print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n, m, q;
int a, b;

int dist(pint p, pint q) {
	int dx = abs(p.first - q.first);
	int dy = abs(p.second - q.second);
	int dz = abs( (p.first+p.second) - (q.first+q.second) );
	int res = min(dx+dy, min(dx+dz, dy+dz));
	//cout << p << ", " << q << " : " << res << endl;
	return res;
}

int main() {
	while (cin >> n >> m >> q) {
		vector<pint> ord(q);
		for (int i = 0; i < q; ++i) {
			cin >> ord[i].first >> ord[i].second;
			ord[i].second = m+1-ord[i].second;
		}
		int res = 0;
		for (int i = 0; i < q-1; ++i) res += dist(ord[i], ord[i+1]);

		cout << res << endl;
	}
    return 0;
}


Measured memory_bytes: 1200
mod = 10**9 + 7
N = int(input())
A = [int(i) for i in input().split()]
M = [0]*10**5

ans = 1
for i, a in enumerate(A):
    if a == 0:
        ans *= 3-M[0]
        M[0] += 1
    else:
        ans *= M[a-1]-M[a]
        M[a] += 1
    ans %= mod

print(ans)


Measured memory_bytes: 53428
n,l= map(int, input().split())
lt=[]

for i in range(n):
    lt.append(i+1+l-1)

if lt[0] > 0:
    print(sum(lt[1:]))
elif lt[0] <=0 and lt[-1] >= 0:
    print(sum(lt))
else:
    print(sum(lt[:-1]))

Measured memory_bytes: 3060
#include <stdio.h>
int main() {
	bool RB[60000];int j,i;for (i=0;i<60000;RB[i++]=true);for (i=2;i*i<=60000;i++) if (RB[i]) for (j=i*i;j<=60000;j+=i) RB[j]=false;
	while (scanf("%d",&j)!=EOF) {for (i=j-1;!RB[i];i--);printf("%d ",i);for (i=j+1;!RB[i];i++);printf("%d\n",i);}return 0;}

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

using namespace std;

//#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

vector<int> t;

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  char tmp;

  REP(i, 4) {
    cin >> tmp;
    t.pb((int)(tmp - '0'));
  }
  int a, b, c, d;
  a = t[0];
  b = t[1];
  c = t[2];
  d = t[3];
  string s = "";

  if(a+b+c+d == 7) {
    s = "+++";
  } else if (a+b+c-d==7) {
    s = "++-";
  } else if (a+b-c+d==7) {
    s = "+-+";
  } else if (a+b-c-d==7) {
    s = "+--";
  } else if (a-b+c+d==7) {
    s = "-++";
  } else if (a-b+c-d==7) {
    s = "-+-";
  } else if (a-b-c+d==7) {
    s = "--+";
  } else {
    s = "---";
  }

  cout << a << s[0] << b << s[1]
       << c << s[2] << d << "=7" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(name, start, stop) for (auto(name) = (start); (name) < (stop); (name)++)
using ll = long long;
using vi = vector<ll>;

int main(void) {
    string s;
    cin >> s;
    string ans;
    if (s[2] == s[3] && s[4] == s[5])
        ans = "Yes";
    else
        ans = "No";
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
#include<bits/extc++.h>
using namespace __gnu_pbds;
using oset = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn = 1<<21, mod = 1e9 + 7;
vector<ll> owo;
void gen(ll len, ll cur) {
	if(len == 0) {
		owo.pb(cur);
		return;
	}
	for(ll i = 0; i < 10; i++) {
		if(cur == -1) {if(i!=0)gen(len-1, i);}
		else if(abs((cur%10)-i)<2) gen(len-1, cur*10ll+i);
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	for(int i = 1; i <= 10; i++) gen(i, -1);
	sort(all(owo));
	int k;
	cin >> k;
	//for(int i = 0; i < k; i++) cout << owo[i] << " ";
	cout << owo[k-1];
}


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

vector<pair<int, int>> g[1111][1111];
int d[1111][1111], v[1111][1111];
int f(int i, int j) {
	if (v[i][j])
		return d[i][j] ? d[i][j] : 1e9;
	v[i][j] = 1;
	int m = 0;
	for (auto p : g[i][j])
		m = max(m, f(p.first, p.second));
	return d[i][j] = m + 1;
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		pair<int, int> p, q;
		for (int j = 1; j < n; j++) {
			int a;
			scanf("%d", &a);
			q = minmax(i + 1, a);
			if (j > 1)
				g[p.first][p.second].push_back(q);
			p = q;
		}
	}
	int m = 0;
	for (int i = 1; i < n; i++)
		for (int j = i; j < n; j++)
			m = max(m, f(i, j + 1));
	cout << (m < 1e9 ? m : -1) << endl;
	return 0;
}


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


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

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n;
  cin >> n;
  list<int64_t> numbers;
  
  int64_t val;
  for(int64_t i=0;i<n;i++){
      cin >> val;
      numbers.push_back(val);
  }
  
  int64_t count = 0;
  numbers.reverse();
  for(auto number: numbers){
      cout << number;
      count++;
      if(count != n) cout << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3088
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long K = sc.nextInt();
		long S = sc.nextInt();
	//	int[]x = new int[S/3+1];
	//	int[]y = new int[K/3+1];
	//	int[]z = new int[K/3+1];
		long res = 0;
		for(long i = Math.min(K, S); i>=0; i--){
			long v = S-i;
			if(v < K )res+=(v+1);
			else if(v == K) res+=(K+1);
			else if(v <= 2*K){
				long a = v-K;
				res+=K-a+1;
			}

		}
		System.out.println(res);
	}
}

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

template <typename T>
void print(const T &v);

ll __lcm(ll a, ll b)
{
    return a / __gcd(a, b) * b;
}

ll lcm(vector<ll> vec)
{
    ll ret = vec[0];
    for (int i = 0; i < vec.size(); i++)
    {
        ret = __lcm(ret, vec[i]);
    }
    return ret;
}

ll solve(int N, ll M, vector<ll> &a)
{
    bool same = true;
    while (a[0] % 2 == 0)
    {
        for (int i = 0; i < N; ++i)
        {
            if (a[i] % 2 != 0)
            {
                return 0;
            }
            a[i] /= 2;
        }
        M /= 2;
    }
    for (int i = 0; i < N; ++i)
    {
        if (a[i] % 2 == 0)
        {
            return 0;
        }
    }

    // lcm
    ll l = lcm(a);
    return (M / l + 1) / 2;
}

int main()
{
    int N;
    ll M;
    cin >> N >> M;
    vector<ll> a(N);

    // あらかじめaは１回2で割っておく
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        a[i] /= 2;
    }
    cout << solve(N, M, a) << endl;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 4836
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
//#define MOD 1000000007
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/
 
int32_t main()
{
	fastio();
	int n;
	cin>>n;
	int k;
	cin>>k;
	int ar[n];
	for(int i=0;i<n;i++)cin>>ar[i];
	sort(ar,ar+n);
	int ans=0;
	for(int i=0;i<k;i++)ans+=ar[i];
	cout<<ans<<endl;	
}


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

int main()
{
	string s;

	while (cin >> s) {
		int i = 0, n = 0;

		while (i < s.size()) {
			if (s[i] == 'I') {
				if (s[i + 1] == 'V') {
					n += 4;
					i++;
				}
				else if (s[i + 1] == 'X') {
					n += 9;
					i++;
				}
				else
					n++;
			}
			else if (s[i] == 'V')
				n += 5;
			else if (s[i] == 'X') {
				if (s[i + 1] == 'L') {
					n += 40;
					i++;
				}
				else if (s[i + 1] == 'C') {
					n += 90;
					i++;
				}
				else
					n += 10;
			}
			else if (s[i] == 'L')
				n += 50;
			else if (s[i] == 'C') {
				if (s[i + 1] == 'D') {
					n += 400;
					i++;
				}
				else if (s[i + 1] == 'M') {
					n += 900;
					i++;
				}
				else
					n += 100;
			}
			else if (s[i] == 'D')
				n += 500;
			else if (s[i] == 'M')
				n += 1000;

			i++;
		}

		cout << n << endl;
	}

	return 0;
}



Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
//有向グラフのサイクルを1つ見つけてくる
class FindCycle{
private:
	int n;
	vector<vector<int> > g;
	vector<int> v,ans;
	vector<bool> used, end;
	void dfs(int now, int par){
		v.push_back(now);
		if(used[now] == true){
			if(end[now] == false){//サイクル検出完了
				ans.push_back(v.back());
				for(int i = v.size()-2; i >= 0; i--){
					ans.push_back(v[i]);
					if(v[i] == v.back())break;
				}
			}
			return;
		}else{
			used[now] = true;
			for(auto x: g[now])if(x != par){
				dfs(x,now);
				if(ans.size())return;
			}
		}
		v.pop_back();
		end[now] = true;
	}
public:
	FindCycle(int sz){
		n = sz;
		g.resize(n);
	}
	void add_edge(int a, int b){
		g[a].push_back(b);
	}
	vector<int> calc(){
		v.resize(0);
		used = end = vector<bool>(n,false);
		ans.resize(0);
		for(int i = 0; i < n; i++)if(!used[i]){
			dfs(i,-1);
			if(ans.size())break;
		}
		reverse(ans.begin(),ans.end());
		return ans;
	}
};

#include<set>
void AOJ2891(){
	int n;
	cin >> n;
	FindCycle f(n);
	for(int i = 0; i < n; i++){
		int a,b;
		cin >> a >> b;
		a--,b--;
		f.add_edge(a,b);
		f.add_edge(b,a);
	}
	vector<int> v = f.calc();
	set<int> st;
	for(auto x:v)st.insert(x);
	int q;
	cin >> q;
	while(q--){
		int a,b;
		cin >> a >> b;
		a--,b--;
		if(st.count(a) && st.count(b)){
			cout << 2 << endl;
		}else{
			cout << 1 << endl;
		}
	}
}
int main(){
	AOJ2891();
}



Measured memory_bytes: 18172
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size)scanf("%d",&(name)[i])

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    ll c=0;
    ll last_x;
    cin>>last_x;
    FOR(i,N-1){
        ll x;
        cin>>x;
        c+=min(A*(x-last_x),B);
        last_x=x;
    }
    print(c);
    return 0;
}

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

void solve() 
{
    int n,k;cin>>n>>k;double a[n];
    REP(i,n)cin>>a[i];
    double l=0,r=1000000010;
    REP(re,1000){
        int sum=0;
        double mid=(l+r)/2;
        REP(i,n)if(a[i]>mid)sum+=ceil(a[i]/mid)-1;
        if(sum<=k)r=mid;
        else l=mid;
    }
    cout<<setprecision(20)<<ceil(l)<<endl;
}

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

Measured memory_bytes: 5376
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int n = ni();
        int k = ni();
        
        double ans_n = 0;
        for (int i = 1; i <= n; i++) {
            if (i >= k) {
                ans_n += 1;
            } else {
                double p = Math.ceil(Math.log((k+i-1)/i) / Math.log(2));
                ans_n += Math.pow(0.5, p);
            }
        }
        
        so.println(ans_n / n);
    }
   
    private static int ni() {
        return sc.nextInt();
    }

    private static long nl() {
        return sc.nextLong();
    }

    private static String ns() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static int[] nints(int n) {
        return nints(n, 0);
    }

    private static int[] nints(int n, int padding) {
        int[] a = new int[padding + n];
        for (int i = 0; i < n; i++)
            a[padding + i] = ni();
        return a;
    }
}


Measured memory_bytes: 21204
h, w = gets.chomp.split.map(&:to_i)

canvas = []

h.times do
  canvas << gets.chomp.chars
end

w.times do |x0|
  h.times do |y0|
    next if canvas[y0][x0] == '.'
    count = 0
    count += 1 if x0 > 0 && canvas[y0][x0 - 1] == '#'
    count += 1 if y0 > 0 && canvas[y0 - 1][x0] == '#'
    count += 1 if x0 < w - 1 && canvas[y0][x0 + 1] == '#'
    count += 1 if y0 < h - 1 && canvas[y0 + 1][x0] == '#'

    if count == 0
      puts 'No'
      exit
    end
  end
end

puts 'Yes'

Measured memory_bytes: 3836
w = str(input())
check = int(0)
c = int(0)

for a in [chr(i) for i in range(97,97+26)]:
  c = w.count(a)
#  print(str(w)+"チェック"+str(a))
  if(c%2 == 1):
    check = check + 1

if(check == 0):
  print("Yes")
else:
  print("No")

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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;

    long long ans = 0;
    for (int i = 1; i < n; i++) {
        ans += (n - 1)/i;
    }

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


Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  long long int number_n = 0;
  int i;
  char str[7];
  char str_temp[4];
  scanf("%s %s", str, str_temp);
  strcat(str, str_temp);
  for(i = 0; i < strlen(str); i++) {
    number_n = number_n * 10 + (str[i] - '0');
  }
  for(i = 1; i < 317; i++) {
    if(number_n == i * i) {
      printf("Yes\n");
      break;
    }
  }
  if(i == 317) {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
// #define cerr if(false)cerr
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(s) (s).begin(), (s).end()
const ll MOD = 1e9 + 7;

inline void solve()
{
    int n, m, k;
    cin >> n >> m >> k;
    vll a(n), b(m);
    for (auto &it : a)  
        cin >> it;
    for (auto &it : b)
        cin >> it;
    for (int i = 1; i < n; i++)
        a[i] += a[i-1];
    for (int i = 1; i < m; i++)
        b[i] += b[i-1];
    ll ans = (ll)(upper_bound(all(b), k) - b.begin());
    for (int i = 0; i < n; i++)
    {
        if (k >= a[i])
        {
            ans = max(ans, (ll)(upper_bound(all(b), k - a[i]) - b.begin() + i + 1));
        }
    }
    cout << ans << endl;
}

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

    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 6368
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int N;
  cin >> N;
  vector<string> s(N);
  rep(i, N){
    cin >> s.at(i);
  }
  int M;
  cin >> M;
  vector<string> t(M);
  rep(i, M){
    cin >> t.at(i);
  }
  map<string, int> money;
  rep(i, N){
    money[s.at(i)]++;
  }
  rep(i, M){
    money[t.at(i)]--;
  }
  int score = 0;
  rep(i, N){
    chmax(score, money.at(s.at(i)));
  }
  cout << score << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N;
vector<int> a;

int bit[32];

int main(){
  cin>>N;
  ll res=0;
  for(int i=0;i<N;i++){
      int x;
      cin>>x;
      a.push_back(x);
      res^=x;
  }

  for(int i=0;i<=30;i++){
      int x=(1<<i);
      for(int j=0;j<N;j++){
          if(a[j]%x==0&&(a[j]&x)) bit[i]++;
      }
  }

  int ans=0;
  for(int i=30;i>=0;i--){
      if((res&(1<<i))==0) continue;
      if(bit[i]>0){
          ll mask=(1ll<<(i+1))-1;
          res=res^mask;
          ans++;
      }else{
          cout<<-1<<endl;
          return 0;
      }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 892
N = int(input())
ans = 10*5
for i in range(1,N//2+1):
    L=[]
    for x in range(len(str(i))):
        L.append(int(str(i)[x]))
    for y in range(len(str(N-i))):
        L.append(int(str(N-i)[y]))
    ans = min(ans,sum(L))
print(ans)
    

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n, l;
    cin >> n >> l;
    int h;
    vector<int> aji(n);
    int hoz, taihi;
    int min = 1000;
    int sum = 0;

    for(int i = 0; i < n; i++){
        aji.at(i) = l + i;
    }
    for(int j = 0; j < n; j++){
        taihi = aji.at(j);
        if(taihi < 0){
            taihi = taihi * -1;
        }
        if(taihi < min){
            hoz = j;
            min = taihi;
        }
    }
    for(int i = 0; i < n; i++){
        if(i != hoz){
            sum = sum + aji.at(i);
        }
    }
    cout << sum << endl;
}

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

int main() {
  int M,D,ans=0;
  cin >> M >> D;
  
  for(int i=1;i<=M;i++){
    for(int j=1;j<=D;j++){
      int d1 = j/10 , d2 = j%10;
      if(d1<2 || d2<2) continue;
      if(d1 * d2 == i) ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int N,M,K,L,R,H,W;
//long long int N,M,K,L,R,H,W;

//const long long int MOD=1000000007;
const long long int MOD=998244353;

int main(){
	
	cin>>N;
	vector<bitset<2000>>v(N);
	for(int i=1;i<N;i++){
		string s;
		cin>>s;
		for(int j=0;j<i;j++){
			if(s[j]=='1')v[i].flip(j);
			else v[j].flip(i);
		}
	}
	vector<bitset<2000>>l(N);
	vector<bitset<2000>>r(N);
	for(int i=0;i<N;i++){
		l[i].flip(i);
		r[i].flip(i);
	}
	for(int i=1;i<N;i++){
		for(int j=0;i+j<N;j++){
			l[i+j][j]=(l[i+j]&r[j+1]&v[j]).any();
			r[j][i+j]=(l[i+j-1]&r[j]&v[i+j]).any();
		}
	}
	int ans=(r[0]&l[N-1]).count();
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
    int A[5][4][11], n;
    for(int i = 1; i <= 4; i++)
        for(int j = 1; j <= 3; j++)
            for(int k = 1; k <= 10; k++) A[i][j][k] = 0;

    cin >> n;
    for(int i = 0; i < n; i++){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        A[b][f][r] += v;
    }

    for(int f = 1; f <= 4; f++){
        if(f > 1)cout << "####################\n";
        for(int b = 1; b <= 3; b++){
            for(int r = 1; r <= 10; r++){
                cout << " " << A[f][b][r];
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3076
#include <stdio.h>
int main()
{
  int i, j;
  long int h;
  scanf("%ld",&h);
  /* 判定フラグ */
  int flag;

  /* 素数かどうかを判定 */
  for( i=h;i<=1000000;++i ) {
    flag = 0;
    for( j=2;j<i;++j ){
      if( i%j==0 ) {
        flag = 1;
        break;
      }
    }
    /* 判定結果を出力 */
    if( flag==0 ){
      printf("%d ", i);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 128
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

i = 0

for y in range(h):
	grid = []
	for x in range(w):
		grid.append(i + 1)
		a[i] -= 1
		if a[i] == 0:
			i += 1
	
	if y % 2 == 0:
		print(*grid)
	else:
		print(*grid[::-1])



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

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

int main(void)
{
    int n,i,r=1,t;
    int arr[999];

    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",arr+i);

    qsort(arr,n,4,compare);
    t=arr[0];
    for(i=1;i<n;i++)
    {
        if(t!=arr[i])
        {
            t=arr[i];
            r++;
        }
    }
    printf("%d\n",r);
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace ConsoleApp15
{
    class Class6
    {
        static void Main()
        {
            var HW = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int H = HW[0], W = HW[1];

            string[] line = new string[H * W];
            int num = 0;
            for(int i = 0; i < N; i++)
            {
                for(int j = 0; j < a[i]; j++)
                {
                    line[num] = (i+1).ToString();
                    num++;
                }
            }
            
            for(int i = 0; i < H; i++)
            {
                string[] ans = new string[W];
                for (int k = 0; k < W; k++) ans[k] = line[i * W + k];
                if (i % 2 == 1) Array.Reverse(ans);
                Console.WriteLine(string.Join(" ", ans));
            }
        }
    }
}


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

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

    int64_t res = X;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            if (j == 0) res++;
            else if (j == 1 && A.at(i) + 1 <= D) res++;
            else if (j * A.at(i) + 1 <= D) res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3624
/**
 * author: moririn_cocoa       
**/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

int main(void) {
	
  string hy9r;
  
  cin >> hy9r;
  
  if ( hy9r == "a" || hy9r == "i" || hy9r == "u" || hy9r == "e" || hy9r == "o" ) {
    
    cout << "vowel" << endl;
  }
  
  else {
    
    cout << "consonant" << endl;
  }

  return 0;
}


Measured memory_bytes: 3552
import numpy as np
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with

#A = int(input())
N,K,Q= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
#S= str(input())
l=np.zeros(N)
l+=(K-Q)
#print(l)
for m in range(Q):
    A = int(input())
    l[A-1]+=1
#    print(l)
l=np.where(l<1,'No','Yes')
for i in l:
    print(i)


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

#include <iostream>
using namespace std;
#define LL long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, n) for (int i = 0; i <= (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, n) for (int i = (n)-1; i > 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define newl '\n'

const int dr[] = {0, 1, 0, -1};
const int dc[] = {1, 0, -1, 0};
int v[2005] = {0};
void solve() {
  int n;
  cin >> n;
  v[3] = v[4] = v[5] = 1;
  int mod = 1e9 + 7;
  for (int i = 6; i <= n; ++i) {
    v[i] = 1;
    for (int j = 3; j <= i - 3; ++j) {
      v[i] = (v[j] + v[i]) % mod;
    }
  }
  cout << v[n];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}


Measured memory_bytes: 3660
use proconio::input;

const MOD: usize = 998244353;

fn main() {
    input! {
        n: usize,
        k: usize,
        lr: [(usize, usize); k],
    }

    let mut dp = vec![0; 2*n+10];
    let mut imos = vec![0; 2*n+10];
    dp[0] = 1;
    for i in 0..n {
        dp[i] += imos[i];
        dp[i] %= MOD;
        for &(l, r) in lr.iter() {
            imos[i+r+1] = (imos[i+r+1] + MOD - dp[i]) % MOD;
            imos[i+l] = (imos[i+l] + dp[i]) % MOD;
        }
        imos[i+1] += imos[i];
        imos[i+1] %= MOD;
    }

    println!("{}", (dp[n-1]) % MOD);
}


Measured memory_bytes: 6644
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    r: i64,
    d: i64,
    x: i64,
  }
  let mut ans = x;
  for _ in 0..10 {
    ans = r * ans - d;
    println!("{}", ans);
  }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define y1 __zzd001
using namespace std;
const int N=2005;
int n,d,v[N][N],s[3][N][N];
int S(int x1,int y1,int x2,int y2,int t){
	return s[t][x2][y2]-s[t][x2][y1-1]-s[t][x1-1][y2]+s[t][x1-1][y1-1];
}
int check(int x){
	int r=x%d;
	for (int i=1;i<=d;i++)
		for (int j=1;j<=d;j++){
			int x1=i,y1=j,x2=x1+r,y2=y1+r,x3=x1+d-1,y3=y1+d-1;
			if (!S(x1,y2+1,x3,y3,1)&&!S(x2+1,y1,x3,y3,1)&&!S(x2+1,y2+1,x3,y3,0))
				return 1;
		}
	return 0;
}
int main(){
	scanf("%d%d",&n,&d);
	memset(v,0,sizeof v);
	while (n--){
		int x,y;
		scanf("%d%d",&x,&y);
		v[x%d+1][y%d+1]++;
	}
	int Mx=0,t;
	for (int i=1;i<=d;i++)
		for (int j=1;j<=d;j++)
			v[i+d][j]=v[i][j+d]=v[i+d][j+d]=v[i][j],Mx=max(Mx,v[i][j]);
	for (t=0;(t+1)*(t+1)<Mx;t++);
	int l[3]={t*t+1,t*(t+1)+1,(int)1e9};
	for (int i=1;i<=d*2;i++)
		for (int j=1;j<=d*2;j++)
			for (int t=0;t<2;t++){
				s[t][i][j]=s[t][i-1][j]+s[t][i][j-1]-s[t][i-1][j-1];
				if (l[t]<=v[i][j])
					s[t][i][j]++;
			}
	int L=t*d,R=t*d+d,ans=R,mid;
	while (L<=R)
		if (check(mid=(L+R)>>1))
			R=mid-1,ans=mid;
		else
			L=mid+1;
	cout << ans;
	return 0;
}


Measured memory_bytes: 48768
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b;
	cin >> a >> b;
	
	if( a <= 9 && b <= 9 ) cout << a * b << endl;
	else cout << -1 << endl;
	
	return 0;
}


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

using namespace std;

int order(const vector<int>& a){
    vector<int> c(a.size());
    for(int i=0;i<a.size();i++) c[i] = i+1;
    int res = 0;
    do {
        if(c == a) return res;
        ++res;
    } while(next_permutation(c.begin(), c.end()));
    return -1;
}

int main(){
    int N;
    while(cin >> N){
        vector<int> P(N), Q(N);
        for(auto& t : P) cin >> t;
        for(auto& t : Q) cin >> t;
        cout << abs(order(P) - order(Q)) << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int w, a, b;
    while (cin >> w >> a >> b) {
        int c = a + w, d = b + w;
        int x = b - c, y = a - d;
        if (a < b && x > 0)
            cout << x << endl;
        else if (a > b && y > 0)
            cout << y << endl;
        else cout << '0' << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int a;
int b;
int c;
int d;
int e;
int f;
int timel;
int main(){
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> e;
	if (a < 0){
		timel += (0 - a)*c;
		a = 0;
	}
	if (a == 0){
		timel += d;
		f = 1;
	}


	if (a >= 0){
		timel += (b - a)*e;

	}

	cout << timel << endl;

	return 0;
}

Measured memory_bytes: 3072
#import sys
#input = sys.stdin.readline
h,w=map(int,input().split())
S=[["."]*(w+2)]+[["."]+list(input())+["."] for _ in range(h)]+[["."]*(w+2)]

ans=[[0 for i in range(w)] for j in range(h)]
for i in range(1,h+1):
  for j in range(1,w+1):
    if S[i][j]=='#':
      ans[i-1][j-1]='#'
    else:
      cnt=(S[i-1][j-1]=="#")+(S[i-1][j]=="#")+(S[i-1][j+1]=="#")+(S[i][j-1]=="#")+(S[i][j+1]=="#")+(S[i+1][j-1]=="#")+(S[i+1][j]=="#")+(S[i+1][j+1]=="#")
      ans[i-1][j-1]=cnt

for i in range(h):
  print(*ans[i],sep="")

Measured memory_bytes: 3444
//B - Sum of Three Integers:
//Assunto:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int k, s, ans = 0, aux;
    cin >> k >> s;
    for(int i = 0; i <= k; i++) {
        for(int j = 0; j <= k; j++) {
            if((i + j) > s) continue;
            else {
                aux = s - (i+j);
                if(aux <= k) ans++;
            }
        }
    }
    cout << ans << '\n';
}

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

int main(){
    int H,W;
    while(cin >> H >> W,H!=0 && W!=0){
        for(int i=1;W>=i;i++){
            cout << "#";
            if(i==W) cout << endl;
        }
        for(int i=2;H>i;i++){
            for(int j=1;W>=j;j++){
                if(j==1||j==W){
                    cout << "#";                    
                } else {
                    cout << ".";
                }
                if(j==W) cout << endl;
            }
        }
        for(int i=1;W>=i;i++){
            cout << "#";
            if(i==W) cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3056
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	unordered_map<int,bool>a;
	for(int i=0;i<m;++i){
		int A; cin>>A;
		a[A]=true;
	}
	vector<int>dp(n+1,0); dp.at(0)=dp.at(1)=1;
	for(int i=2;i<=n;++i){
		if(!a[i-1])dp.at(i)+=dp.at(i-1);
		if(!a[i-2])dp.at(i)+=dp.at(i-2);
		dp.at(i)%=mod;
	}
	cout<<dp.back()<<"\n"s;
}


Measured memory_bytes: 7744
#include <stdio.h>

int main () {
    int cnt = 0;

    int N;
    scanf("%d", &N);

    int A[N];
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    while (1) {
        for (int i = 0; i < N; i++) {
            if (A[i] % 2 == 0) {
                A[i] /= 2;
            } else {
                goto OUT;
            }
        }

        cnt++;
    }
    OUT:

    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
/**
 *    author:  tourist
 *    created: 23.03.2019 14:14:57       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int d = n / 2 * 2;
  vector<pair<int, int>> edges;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (i + j == d + 1) {
        continue;
      }
      edges.emplace_back(i, j);
    }
  }
  int m = (int) edges.size();
  cout << m << '\n';
  for (auto &p : edges) {
    cout << p.first << " " << p.second << '\n';
  }
  return 0;
}


Measured memory_bytes: 384
h, w = gets.chomp.split(" ").map(&:to_i)

strings = []
h.times do
  strings << gets.chomp
end

dx = [-1,0,1, -1,1, -1,0,1]
dy = [-1,-1,-1, 0,0, 1,1,1]

h.times do |i|
  w.times do |j|
    next if strings[i][j] == '#'
    counter = 0
    
    8.times do |k|
      x = i + dx[k]
      y = j + dy[k]
      counter += 1 if x >=0 && x < h && y >= 0 && y < w && strings[x][y] == '#'
    end
    strings[i][j] = counter.to_s
  end
end

strings.each do |string|
  print "#{string}\n"
end

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,max;
    cin>>a>>b>>c;
    if (a>=b&&a>=c) max=a;
    if (b>=a&&b>=c) max=b;
    if (c>=a&&c>=b) max=c;
    cout<<a+b+c-max<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define length 2000
int match(int,int);
int A[length];
int n;

int main(){
  int i,j;
  int q,m;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&m);
    if(match(0,m)!=0){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }
  return 0;
}


int match(int x,int y){
  int sum;
  if(y==0)return 1;
  if(x>=n)return 0;

  sum = match(x+1,y)|| match(x+1,y-A[x]);
  return sum;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    
    string s2 = s + t.back();
    if (s2 == t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
    
using namespace std;
    
const int N = 305;
const long long INF = 1e18 + 5;
    
int n;
int A[N][N];
vector<pair<int, pair<int, int> > > dists;
vector<pair<int, int> > V[N];
long long dist[N];
bool vis[N];
long long realDist[N][N];
    
int calcDist(int a, int b) {
//     return realDist[a][b];
    int best = 1e9 + 5;
    for (int i = 1; i <= n; i++) {
        if (i == a || i == b) continue;
        best = min(best, A[a][i] + A[i][b]);
    }
    return best;
}
    
long long ans;
void addEdge(int a, int b, int dist) {
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            realDist[i][j] = min(realDist[i][j], realDist[i][a] + dist + realDist[b][j]);
        }
    }
    ans += dist;
}
    
int main() {
    
    scanf("%d", &n);
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            realDist[i][j] = INF;
            scanf("%d", &A[i][j]);
            dists.push_back({A[i][j], {i, j}});
        }
    }
    
//    for (int k = 1; k <= n; k++) {
//        for (int i = 1; i <= n; i++) {
//            for (int j = 1; j <= n; j++) {
//                A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
//         }
//     }
// }

for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
        cerr << A[i][j] << " ";
    }
    cerr << endl;
}
    
    sort(dists.begin(), dists.end());
    for (auto p : dists) {
        int dist = p.first;
        int a = p.second.first;
        int b = p.second.second;
        int d = calcDist(a, b);
//         cerr << d << endl;
        if (d == dist) {
            continue;
        } else if (d < dist) {
            printf("-1\n");
            return 0;
        } else {
            ans += dist;
        }
    }
    
    printf("%lld\n", ans / 2);
    
    return 0;
}

Measured memory_bytes: 2680