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

int main() {
int s[13] = {}, h[13] = {}, c[13] = {}, d[13] = {};
int n;
cin >> n;
string suit; 
int number;
for(int i = 0; i < n; i++) {
cin >> suit >> number;
if(suit == "S") {
s[number-1] = 1;
} else if (suit == "H") {
h[number-1] = 1;
} else if (suit == "C") {
c[number-1] = 1;
} else {
d[number-1] = 1;
}
}
for (int a = 0; a < 13; a ++ ) {
if(s[a] == 0) {
cout << "S " << a+1 << endl;
}
}
for (int b = 0; b < 13; b ++ ) {
if(h[b] == 0) {
cout << "H " << b+1 << endl;
}
}
for (int k = 0; k < 13; k ++ ) {
if(c[k] == 0) {
cout << "C " << k+1 << endl;
}
}
for (int l = 0; l < 13; l ++ ) {
if(d[l] == 0) {
cout << "D " << l+1 << endl;
}
}
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  int ans = 0;
  for (int i = A; i < B+1; i++) {
    if (i%10 == i/10000 && (i%10000)/1000 == (i%100)/10) {
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main (void) {
	int n, t, a;
	int h;
	double min=10000.0;
	int min_idx = -1;

	scanf ("%d", &n);
	scanf ("%d %d", &t, &a);
	
	for (int i=0; i<n; i++) {
		scanf ("%d", &h);
		double tmp = fabs ((double) a - (double)t + h*0.006);
		if (min > tmp) {
			min = tmp;
			min_idx = i+1;
		}
	}
	printf ("%d\n", min_idx);
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*y/gcd(x,y);
}

int main(){
	ll N; cin>>N;
  ll ans=0;
  vector<ll> a(N);
    rep(i,N){
    	cin>>a[i];
      a[i]-=i;
    }
  sort(a.begin(),a.end());
  ll d=(N-1)/2;
  d=a[d];
  rep(i,N){
  	ans+=abs(a[i]-d);
  }
  printf("%lld",ans);
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < b && b < c)System.out.print("Yes");
        else{System.out.print("No");}
        System.out.println();
    }
}


Measured memory_bytes: 26272
#include<bits/stdc++.h>
using namespace std;
#define IOS cin.tie(NULL);iosbase::sync_with_stdio(false);
#define pb push_back
string s;

int32_t main(){
    long long n,ans=0;
    cin>>n;
    ans += (n/500)*1000;
    ans += ((n%500)/5)*5;
    cout<<ans;
    

}

Measured memory_bytes: 256
#![allow(unused_macros, unused_imports, dead_code)]

use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
            assert!(_it.next().is_none());
        }
    };
}

fn main() {
    from_line!(a: u32, b: u32);

    println!("{}",
             if a * b % 2 == 0 {
                 "Even"
             } else {
                 "Odd"
             });
}

Measured memory_bytes: 4352
import numpy as np

H, W = list(map(int, input().split()))

A = []
B = []

max_bias = 80
bias = max_bias * (H + W - 1) + 1

for i in range(H):
    A.append(list(map(int, input().split())))

for i in range(H):
    B.append(list(map(int, input().split())))

A = np.array(A, dtype=np.int)
B = np.array(B, dtype=np.int)
D = np.abs(A - B)

dp = np.zeros([H, W, bias * 2 + 1], dtype=bool)
dp[0][0][bias - D[0][0]] = True
dp[0][0][bias + D[0][0]] = True

for i in range(H):
    for j in range(W):
        diff = D[i][j]
        
        if i > 0:
            dp[i, j, diff:] |= dp[i - 1, j, :bias * 2 + 1 - diff]
            dp[i, j, : bias * 2 + 1 - diff] |= dp[i - 1, j, diff:]

        if j > 0:
            dp[i, j, diff:] |= dp[i, j - 1, :bias * 2 + 1 - diff]
            dp[i, j, : bias * 2 + 1 - diff] |= dp[i, j - 1, diff:]

idx = dp[H - 1][W - 1][:].nonzero()[0]
print(np.abs(idx - bias).min())


Measured memory_bytes: 172104
n , m = map(int, input().split())
ipy = []

for i in range(m):
    p, y = map(int, input().split())
    ipy.append([i, p, y])

city_count = {}
order = {}

for i, p, y in sorted(ipy, key=lambda x: x[2]):
    if not p in city_count:
        city_count[p] = 0
    city_count[p] += 1
    order[p, i] = city_count[p]
    
for i, p, y in ipy:
    print('{:06}{:06}'.format(p, order[p, i]))

Measured memory_bytes: 44484
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
typedef pair<int, int> pa;
vector<pa> g[N];
int mn, ans[N];
void dfs(int fa, int u, int d) {
    int i = 1;
    for(auto e : g[u]) {
        if(e.first == fa) continue;
        for(; i <= mn; )  {
            if(i == d) {
                i++;
                continue;
            }
            ans[e.second] = i++;
            break;
        }
    }
    for(auto e : g[u]) {
        if(e.first == fa) continue;
        dfs(u, e.first, ans[e.second]);
    }
}

int main() {
    int n;
    cin >> n;
    for(int i = 1, u, v; i < n; i++) {
        cin >> u >> v;
        g[u].push_back(pa(v, i));
        g[v].push_back(pa(u, i));
    }
    mn = 0;
    for(int i = 1; i <= n; i++) {
        mn = max(mn, int(g[i].size())); 
    }
    dfs(1, 1, 0);
    cout << mn << endl;
    for(int i = 1; i < n; i++) {
        cout << ans[i] << '\n';
    }
    return 0;
}

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

int main() {
	int N;
  int seged=0;
  vector<int> szamok5alma;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> seged;
    szamok5alma.push_back(seged);
  }
  seged=0;
  for(int j=0;j<N;j++){
    if(szamok5alma[seged]<szamok5alma[j]){
      seged=j;
    }
  }
  int seged2=0;
  szamok5alma[seged]/=2;
  for(int k=0;k<N;k++){
    seged2+=szamok5alma[k];
  }
  cout << seged2;
	return 0;
}

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

int main() {
    int N, Q;
    ll K;
    cin >> N >> K >> Q;
    vector<ll> P(N, 0);
    rep(i,Q) {
        int q;
        cin >> q;
        P[q-1]++;
    }
    rep(i, N) {
        if (P[i]-Q+K <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    ans = float("inf")
    m = int(n**0.5)+1
    for i in range(1,m+1):
        if n%i == 0:
            j = n//i
            s = i+j-2
            if s < ans:
                ans = s
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 40048
while True:
    l=input()
    if l=='-':
        break
    else:
        for i in range(int(input())):
            h=int(input())
#            print(f"l[{h}:]={l[h:]},l[:{h}]={l[:h]}")
            l=l[h:]+l[:h]
#            print(l)
    print(l)


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

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

    ll ans = 100 * (N - M) + 1900 * M;
    ll n = 1LL << M;
    
    ans *= n;

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

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

int main(){
  int H, W;
  while(true){
    cin >> H >> W;
    if(H == 0 && W == 0){
      break;
    }
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3104
//tenka1_2018_b.cpp
//Sat Oct 27 20:32:15 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int a,b,k;
	cin >> a >> b >> k;

	int flag = 0;
	for (int i=1;i<=k;i++){
		if (flag == 0){
			if (a%2==1){
				a--;
			}
			b = b+a/2;
			a = a/2;
			flag = 1;
		}else{
			if (b%2==1){
				b--;
			}
			a=a+b/2;
			b=b/2;
			flag = 0;
		}
	}
	cout << a << " " << b << endl;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T& ref, const T  value) {
	if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
	if (ref < value) ref = value;
}


struct BIT {
	vector<ll> bit_;
	const ll n_;

	BIT(ll n) :n_(n) {
		bit_.resize(n + 1LL, 0);
	}

	ll sum(int i) {
		ll s = 0;
		while (i > 0) {
			s += bit_[i];
			i -= i & (-i);
		}
		return s;
	}

	void add(int i, ll x) {
		while (i <= n_) {
			bit_[i] += x;
			i += (i & (-i));
		}
	}
};

int main() {
	ll n, q;
	cin >> n >> q;
	vector<int> cs(n);
	vector<int> prev(n+1, -1);
	vector<int> cols(n+1, -1);
	rep(i, n) {
		cin >> cs[i];
		prev[i] = cols[cs[i]];
		cols[cs[i]] = i;
	}
	vector<vector<P>> rs(n);
	rep(i, q) {
		int left, right;
		cin >> left >> right;
		left--;
		right--;
		rs[right].emplace_back(left, i);
	}
	BIT b(n+1);
	vector<int> ans(q);
	rep(i, n) {
		auto p = prev[i];
		if (p >= 0) {
			b.add(p+1, -1);
			b.add(i+1, 1);
		}
		else {
			b.add(i+1, 1);
		}
		for (auto f : rs[i]) {
			auto left = f.first;
			auto d = b.sum(i + 1) - b.sum(left);
			ans[f.second] = d;
		}
	}
	for (auto p : ans) {
		cout << p << endl;
	}
	return 0;
}


Measured memory_bytes: 40280
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if((n-i)*j+i*(m-j)==k){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i< (int)(n); i++)
#define rep2(i,x,n) for(int i = (int)x; i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	ll ans = 1;
	rep(i, n){
		ans *= (ll)(i+1);
		ans %= 1000000007;
	}
	cout << ans << endl;
	return 0;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
 
/*** Template Begins ***/
 
typedef long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
// #define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x = x % p;
  while (y > 0)
  { 
    if (y & 1) 
      res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
  } 
  return res; 
} 
const int MAXN = 1e5+7;

// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
// #define trace6(a, n,i;b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

// Constants //
 
/*** Template Ends ***/

void solve()
{
  ll a[3][3];
  ll i,j;
  set<ll> s;
  ll n;
  for(i=0;i<3;i++)
    for(j=0;j<3;j++)
      cin>>a[i][j];
  cin>>n;
  for(i=0;i<n;i++)
  {
    ll num;
    cin>>num;
    s.insert(num);
  }
  for(i=0;i<3;i++)
  {
    ll ans = 1;
    for(j=0;j<3;j++)
      ans &= (s.find(a[i][j])!=s.end());
    if(ans)
    {
      cout<<"Yes";
      return;
    }    
  }
  for(i=0;i<3;i++)
  {
    ll ans = 1;
    for(j=0;j<3;j++)
      ans &= (s.find(a[j][i])!=s.end());
    if(ans)
    {
      cout<<"Yes";
      return;
    }    
  }
  ll ans=1;
  for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
      if(i==j)
        ans &= (s.find(a[i][j])!=s.end());
  }
  if(ans)
  {
    cout<<"Yes";
    return;
  }  
  ans = 1; 
  for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
      if(i+j==2)
        ans &= (s.find(a[i][j])!=s.end());
  }
  if(ans)
  {
    cout<<"Yes";
    return;
  }  
  cout<<"No";
}
int main()
{ 
  // ios;
  // fxreopen("inputt.txt", "w", stdout);
  ll t;
  // cin >> t;
  t=1;
  while(t--)
    solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n;
	int sum;

	while(cin >> n, n)
	{
		n /= 4; sum = 0;
		int tmp;
		for(int i=0; i < n; i++) {
			cin >> tmp;
			sum += tmp;
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}


int main() {
	int n;
	cin >> n;
	map<string, int>s;
	int ans = 0;
	rep(i, n) {
		string temp;
		cin >> temp;
		s[temp]++;
		if (s[temp] == 1)ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 19224
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
o = []
e = []
for k in range(n):
    if k%2 == 0:
        e.append(a[k])
    else:
        o.append(a[k])

C1 = Counter(e).most_common()
C2 = Counter(o).most_common()
if C1[0][0] != C2[0][0]:
    print(n-C1[0][1]-C2[0][1])
else:
    if len(C1) == len(C2) == 1:
        print(n//2)
    elif len(C1) == 1 and len(C2) > 1:
        print(n//2 - C2[1][1])
    elif len(C1) > 1 and len(C2) == 1:
        print(n//2 - C1[1][1])
    else:
        print(min(n-C1[1][1]-C2[0][1],n-C1[0][1]-C2[1][1]))


Measured memory_bytes: 65388
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>

using namespace std;

const int MAX = 1000001;
const int MOD = 1000000007;

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

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

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

int main()
{
  int X, Y;
  cin >> X >> Y;

  int n = X+Y;
  int nb = 2*X-Y;
  if (n%3!=0 || nb%3!=0) {
    cout << 0 << endl;
    return 0;
  }

  nb /= 3;
  n /= 3;
  int na = n - nb;

  int r = min(na,nb);

  cerr << n << ',' << r << endl;
  COMinit(n);
  cout << COM(n,r) << endl;

  return 0;
}


Measured memory_bytes: 22784
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

void solve() {
    int n;
    cin >> n;

    vector<int> v(n);
    for(int i = 0; i < n; i++)cin >> v[i];

    sort(v.begin(), v.end());
    cout << v.back() << " ";
    double find = v.back()/2.0;
    double diff = LLONG_MAX;
    int ans = 0;
    for(int i = 0; i < n - 1; i++){
        if(diff > abs(v[i] - find)){
            ans = v[i];
            diff = abs(v[i] - find);
        }
    }
    cout << ans << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

int func(int a, int b, int c, int d){
    return abs(a-c) + abs(b-d);
}

signed main() {

    int W, a, b;
    cin>>W>>a>>b;
    
    if(a<b)
        cout << max(0LL,b-a-W) << endl;
    else
        cout << max(0LL, a-b-W) << endl;
    
    
    return 0;
}


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

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

int main(){
  ll n, k;
  cin >> n >> k;
  vdb p(n);
  vrep(i, p){
    cin >> i;
    i++;
    i /= 2;
  }

  vdb sum(n + 1);
  sum.at(0) = 0;
  rep(i, 1, n + 1) sum.at(i) = sum.at(i - 1) + p.at(i - 1);
  vdb psum(n - k + 1);
  rep(i, 0, n - k + 1) psum.at(i) = sum.at(k + i) - sum.at(i);
  sort(all(psum));
  db ans = psum.at(n - k);
  cout << fixed << setprecision(1);
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int s(ll n){
  int ans=0;
  while(n)
    ans+=n%10,n/=10;
  return ans;
}
ll f(ll n){
  ll ans=n,d=1,v; ld mn=(ld)n/s(n),sum;
  while(d<n){
    d*=10,v=n/d*d+d-1,sum=(ld)v/s(v);
    if (sum<mn)
      mn=sum,ans=v;
  }
  return ans;
}
int main(){
  int k; cin>>k;
  for (ll n=1; k--; n=f(n+1))
    printf("%lld\n",n);
  return 0;
}

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

int main(){

    int n=0,point=0;
    std::cin>>n;
    std::vector<int> vec(n);
    for(int i=0;i<vec.size();i++){

        std::cin>>vec[i];

    }


    std::sort(vec.begin(),vec.end());
    std::reverse(vec.begin(),vec.end());

    for(int i=0;i<vec.size();i++){
        if(i%2==0){
            point+=vec[i];
        }else{
            point-=vec[i];
        }

    }

    std::cout<<point<<std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
#define fi first
#define se second
#define lc T[p].l
#define rc T[p].r
#define mid (l+r>>1)
#define lson lc,l,mid
#define rson rc,mid+1,r
#define sum T[p].val
#define pii pair<int,int>
const int MX=1e7+7;
const int mod=998244353;
const double pi=3.1415926535897932384;
double isp=1e-13;
using namespace std;
ll qpow(ll a,ll b,ll MOD=mod){for(ll ans=1;;a=a*a%MOD,b>>=1){if(b&1)ans=ans*a%MOD;if(!b)return ans;}}
ll inv(ll a,ll MOD=mod){return qpow(a,MOD-2,MOD);}//要求MOD为质数
ll exgcd(ll a,ll b,ll &x,ll &y){if(b==0){x=1,y=0;return a;}ll ret=exgcd(b,a%b,y,x);y-=a/b*x;return ret;}
ll getInv(int a,int mod){ll x,y;ll d=exgcd(a,mod,x,y);return d==1?(x%mod+mod)%mod:-1;}//求a在mod下的逆元，不存在逆元返回-1，不要求MOD为质数
ll mx[MX],a[10];
ll dis(ll a,ll b)
{
    return a*a+b*b;
}
void solve()
{
    int k;
    cin>>k;
    ll ans=0;
    for(int i=1;i<MX;i++)
    {
        ans=ans*10+7;
        ans%=k;
        if(ans==0)
        {
            cout<<i<<endl;
            return ;
        }
    }
    cout<<-1<<endl;
    return ;
}
int main()
{
  ios::sync_with_stdio(0),cin.tie(0);
  int t;
 // cin>>t;
  t=1;
  while(t--)
  {
      solve();
  }
}


Measured memory_bytes: 3648
#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <cmath>

using namespace std;

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

typedef long long ll;
typedef unsigned int uint;
typedef long double ld;

const int INT_INF=1e9;
const ll LONG_INF=1e18;
const double pi = acos(-1);
const int MAXN = 1e6;
const int MAXM = 1e6;

int dfs(int vert, vector<vector<int> >& graph, vector<bool>& used) {
    used[vert] = true;
    int ans = 1;
    for (int to : graph[vert]) {
        if (!used[to]) {
            ans += dfs(to, graph, used);
        }
    }
    return ans;
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > graph(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    vector<bool> used(n, false);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            ans = max(ans, dfs(i, graph, used));
        }
    }
    cout << ans << '\n';
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(9);
#ifdef LOCAL
    freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
#endif
    solve();

#ifdef LOCAL
    cout << "Time:\n";
    cout << static_cast<double>(clock()) / CLOCKS_PER_SEC << '\n';
#endif

}


Measured memory_bytes: 26612
# -*- coding: utf-8 -*-

A, B, C, X, Y = map(int, input().split())

ans = 9999999999
for z in range(0, 1000001, 2):
    result = A * max(0, int(X - (z / 2))) + B * max(0, int(Y - (z / 2))) + C * z
    ans = min(ans, result)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

vector<string> split(string &s) {
    vector<string> splitted;
    string buf;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != ',') buf.push_back(s[i]);
        else {
            splitted.push_back(buf);
            buf.clear();
        }
    }
    if (!buf.empty()) splitted.push_back(buf);
    return splitted;
}

int to_i(string &s) {
    istringstream is(s);
    int i; is >> i;
    return i;
}

int main() {
    string str;
    vector< vector<int> > rhombic;
    while (getline(cin, str)) {
        vector<string> l = split(str);
        vector<int> r(l.size());
        transform(l.begin(), l.end(), r.begin(), to_i);
        rhombic.push_back(r);
    }

    vector< vector<int> > cost(rhombic.size());
    cost[0].resize(1);
    cost[0][0] = rhombic[0][0];

    int m = rhombic.size() / 2;
    for (int i = 1; i <= m; i++) {
        cost[i].resize(rhombic[i].size());
        for (int j = 0; j < rhombic[i].size(); j++) {
            if (j > 0 && j < rhombic[i].size()-1) {
                cost[i][j] = max(cost[i-1][j-1], cost[i-1][j]) + rhombic[i][j];
            } else if (j == 0) {
                cost[i][j] = cost[i-1][j] + rhombic[i][j];
            } else {
                cost[i][j] = cost[i-1][j-1] + rhombic[i][j];
            }
        }
    }
    for (int i = m+1; i < rhombic.size(); i++) {
        cost[i].resize(rhombic[i].size());
        for (int j = 0; j < rhombic[i].size(); j++) {
            cost[i][j] = max(cost[i-1][j], cost[i-1][j+1]) + rhombic[i][j];
        }
    }

    cout << cost[rhombic.size()-1][0] << endl;

//    for (int i = 0; i < rhombic.size(); i++) {
//        for (int j = 0; j < rhombic[i].size(); j++) {
//            cout << rhombic[i][j] << ' ';
//        }
//        cout << endl;
//    }
//
//    for (int i = 0; i < cost.size(); i++) {
//        for (int j = 0; j < cost[i].size(); j++) {
//            cout << cost[i][j] << ' ';
//        }
//        cout << endl;
//    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	rep(i, N) {
		cin >> A.at(i);
	}
	for (ll i = K; i < N; i++) {
		if (A.at(i) > A.at(i - K)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	
}


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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, X, T;
    cin >> N >> X >> T;
    cout << ((N+X-1)/X)*T << "\n";
}

Measured memory_bytes: 3648
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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



#define rep(n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
const int MOD = 1000000007;
const int INF = 1 << 29;




int main() {
	int n, m;
	cin >> n >> m;
	vector<bool>a(n+1,false);
	vector<ll>dp(n+1);
	dp[1] = 1; dp[0] = 1;
	rep(m) { 
		int b;
		cin >> b;
		a[b] = true;
		
	}
	
	
	for (int i = 1; i <= n; i++) {
		
		if(i>=2)dp[i] = (dp[i - 1] + dp[i - 2])%MOD;
		if (a[i])dp[i] = 0;
	}

	cout << dp[n]<< endl;
	return 0;
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BBishop {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll h, w; cin >> h >> w;
      if (h==1 || w==1) {
        cout << 1 << endl;
        return;
      }
      cout << (h*w+1)/2 << endl;
    }
};

signed main() {
  BBishop solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    long long int n,a,b;
    scanf("%lld %lld %lld\n",&n,&a,&b);
    long long int x[100005]={};
    long long int dis[100005]={};
    long long int ans=0;
    REP(i,n)scanf("%lld ",&x[i]);
    REP(i,n-1)
    {
        dis[i]=x[i+1]-x[i];
        if(dis[i]*a>b)ans+=b;
        else ans+=dis[i]*a;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

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

		int area = a * b;
		int length = 2 * (a + b);
		System.out.println(area+ " " +length);
	}

}

Measured memory_bytes: 26052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    ll n,m;
    cin>>n>>m;
    ll dp[1005][1005];
    rep(i,1005)rep(j,1005) {
        if(i==j) dp[i][j] = 0;
        else dp[i][j] = -INF;
    }
    ll a,b,c;
    rep(i,m) {
        cin>>a>>b>>c;
        a--;
        b--;
        dp[a][b] = c;
        // dp[b][a] = c;
    }
    // 経由 // 始点 // 終点
    rep(k,n+1) rep(i,n+1) rep(j,n+1) dp[i][j] = max(dp[i][j], dp[i][k]+dp[k][j]);
    if(dp[0][0]>0) cout<<"inf"<<endl;
    else cout<<dp[0][n-1]<<endl;
    return 0;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    ve<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(), h.end());
    int ans = h[k-1] - h[0];
    int i = k;
    while(i < n){
        ans = min(ans,h[i] - h[i-k+1]);
        i++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3784
#include <stdio.h>

int main(){
	
	int a,b,c, soma=0;
	
	scanf("%d", &a);		
	scanf("%d", &b);
	scanf("%d", &c);
	
	for(; a <= b; a++){
		if(c % a == 0)
			soma++;
	}
	printf("%d\n",soma);
	return 0;
}

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

int main(){
  int n ,a,b,c,d;
  cin >>n;
  a=n/1000;
  b=(n%1000)/100;
  c=(n%100)/10;
  d=(n%10);
  if(!(a-b||a-c)){
    cout<<"Yes"<<endl;
  }else if(!(d-b||d-c)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
    
  

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

int main(){
  int K;
  cin >> K;
  string S;
  cin >> S;
  int len = S.size();
  if(len <= K){
    cout << S << endl;
  }
  else{
    for(int i=0;i<K;i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

int N, K;
ll x[60], y[60];

int main() {
   cin >> N >> K;
   rep (i, 0, N) {
      cin >> x[i] >> y[i];
   }

   ll area = 1LL << 62;
   // 4つの点を選ぶ
   rep (i, 0, N) {
      rep (j, 0, N) {
         rep (k, 0, N) {
            rep (l, 0, N) {
               if (x[i] <= x[j] && y[k] <= y[l]) {
                  int cnt = 0;
                  rep (p, 0, N) {
                     if (x[i]<=x[p] && x[p]<=x[j] && y[k] <=y[p] && y[p]<=y[l]) {
                        cnt++;
                     }
                  }
                  if (cnt >= K) {
                     area = min(area, 1LL*(x[j]-x[i]) * (y[l]-y[k]));
                  }
               }
            }
         }
      }
   }
   cout << area << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  int a = 0;
  int z = 0;
  int len = s.size();
  for (int i = 0; i < len; i++) {
    if (s[i] == 'A') {
      a = i;
      break;
    }
  }
  for (int i = len - 1; i > 0; i--) {
    if (s[i] == 'Z') {
      z = i;
      break;
    }
  }
  cout << z - a + 1 << endl;
  return 0;
}


Measured memory_bytes: 3372
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

ll ans = 0;
int n;
vi a;

void process(int l, int r) {
    ans += a[r];
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n; a.resize(n);
    F0R(i,n) cin >> a[i];
    if (a[0] != 0) {
        cout << -1;
        exit(0);
    }
    FOR(i,1,n) if (a[i] > a[i-1]+1) {
        cout << -1;
        exit(0);
    }
    int st = 0;
    FOR(i,1,n) {
        if (a[i] != a[i-1]+1) {
            process(st-1,i-1);
            st = i;
        }
    }
    process(st,n-1);
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

Measured memory_bytes: 1024
#include<iostream>
#include<bits/stdc++.h>
#define rep(a,b) for(int i=a;i<b;i++)
typedef long long ll;
using namespace std;
ll dfs(ll n)
{
    if(n==0) return 0;
    return 1+2*dfs(n/2);
}
int main()
{
    ll h;
    cin>>h;
    cout<<dfs(h)<<endl;
}


Measured memory_bytes: 256
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define ll 		int
#define int 		long long
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define vpi 		vector<pii>
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define fori(a,b,c) for(register int i=a;i<b;i+=c)
#define ford(a,b,c) for(register int i=a;i>=b;i-=c)
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl()
{
	cout<<"Control\n";
}
signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	int n,x;
 cin>>n>>x;
 int A[n];
 fori(0,n,1)
   cin>>A[i];
 
 int cnt=0;
 int xt=0,i=0;
 	while(xt<=x)
    {
      cnt++;
      xt=xt+A[i];
      i++;
    }
    cout<<cnt;
return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <list>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	int n;
	while(cin >> n, n) {
		vvi h(n, vi(2));
		REP(i, n) {
			REP(j, 2) {
				cin >> h[i][j];
			}
		}

		int m;
		cin >> m;
		vvi hr(n+m, vi(2));
		REP(i, n) {
			REP(j, 2) {
				hr[i][j] = h[i][j];
			}
		}
		REP(i, m) {
			REP(j, 2) {
				cin >> hr[n+i][j];
			}
		}

		sort(ALL(hr));
		vi dp(n+m, 1);
		int res = 0;
		REP(i, n+m) {
			REP(j, i) {
				if(hr[j][0] < hr[i][0] && hr[j][1] < hr[i][1]) {
					dp[i] = max(dp[i], dp[j]+1);
				}
			}
			res = max(res, dp[i]);
		}

		cout << max(res, max(n, m)) << endl;;
	}
}

Measured memory_bytes: 1232
#include <iostream>

int main(){
  int w, h, x, y, r;
  std::cin >> w >> h >> x >> y >> r;

  if(x+r<=w && x-r>=0 && y+r<=h && y-r>=0){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3088
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<iostream>

using  namespace std;


int main(){
	int n,h,y;	
	scanf("%d",&n);
	if(n>=15){
		h=n/15*200;
		y=n*800-h;
		}
		else if(n<15){
			y=n*800;
			}
			printf("%d\n",y);
			return 0;
		}

Measured memory_bytes: 256
n,m,l=map(int,input().split())

a=[list(map(int,input().split())) for i in range(n)]
b=[list(map(int,input().split())) for i in range(m)]
ans=[[0]* l for i in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            ans[i][j]+=b[k][j]*a[i][k]
    print(*ans[i])


Measured memory_bytes: 7032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n, k, a;
    cin>>n>>k;
    a = 99999999999;
    vector<ll> v(n);
    for(int i=0; i<n; i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(int i=0; i<n - k + 1; i++)
        {a = min(a, v[i+k- 1]-v[i]);}

    cout<<a<<endl;

}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 19 21:12:01 2020

@author: black
"""


N, K = map(int, input().split())
List = [n for n in range(N)]

total = 1
for k in range(K, N+1):
    total += N*k-(k-1)*k+1
    total = total%(10**9+7)
print(total)


Measured memory_bytes: 17052
#include <stdio.h>

#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 10000000

void prim(void);

int M[MAX][MAX],colr[MAX],P[MAX],D[MAX],mincost,minsam,n;

int main(){
  int i,j;

  scanf("%d",&n);

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

  
    prim();

    printf("%d\n",minsam);

    return 0;
}
    

void prim(void){
  int i,u,v;

  for(u=0;u<n;u++){
    colr[u] = WHITE;
    D[u] = INF;
  }

  D[0] = 0;
  P[0] = -1;

  while(1){
    mincost = INF;

    for(i=0;i<n;i++){
      if(colr[i] != BLACK && D[i] < mincost){
	mincost = D[i];
	u = i;
      }
    }

    

    if(mincost == INF)break;

    minsam = minsam + mincost;

    colr[u] = BLACK;

    for(v=0;v<n;v++){

      if(colr[v] != BLACK && M[u][v] != -1){
	if(M[u][v] < D[v]){
	  D[v] = M[u][v];
	  P[v] = u;
	  colr[v] = GRAY;
	}
      }
    }
  }
}



Measured memory_bytes: 2052
#include <stdio.h>

int parentNode(int i);
int leftChild(int i);
int rightChild(int i);
void maxHeapify(int i);
void buildMaxHeap(void);

int A[500001];
int n;

main(){

	int i;

	scanf("%d", &n);

	for(i=1; i<=n; i++){
		scanf("%d", &A[i]);
	}
	
	buildMaxHeap();
	
	for(i=1; i<=n; i++){
		printf(" %d", A[i]);
	}
	
	printf("\n");
	
	return 0;
	
}

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

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

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

void maxHeapify(int i){
	int l = leftChild(i);
	int r = rightChild(i);
	int largest, tmp;
	
	if(l <= n && A[l] > A[i]){
		largest = l;	
	}else{
		largest = i;
	}
	if(r <= n && A[r] > A[largest]){
		largest = r;	
	}
	if(largest != i){
		tmp = A[i];
		A[i] = A[largest];
		A[largest] = tmp;
		maxHeapify(largest);
	}
}

void buildMaxHeap(void){
	int i;
	for(i=(int)n/2; i>0; i--)
		maxHeapify(i);
}

Measured memory_bytes: 2356
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1001001001;
const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, -1, 0, 1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(si,h) rep(sj,w) {
    if (s[si][sj] == '#') continue;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<P> q;
    auto update = [&](int i, int j, int x) {
      if (dist[i][j] != INF) return;
      dist[i][j] = x;
      q.push(P(i,j));
    };
    update(si, sj, 0);
    while (q.size()) {
      int i = q.front().first;
      int j = q.front().second;
      q.pop();
      rep(dir,4) {
        int ni = i+di[dir], nj = j+dj[dir];
        if (ni<0||ni>=h||nj<0||nj>=w) continue;
        if (s[ni][nj] == '#') continue;
        update(ni, nj, dist[i][j]+1);
      }
    }
    rep(i,h) rep(j,w) {
      if (dist[i][j] == INF) continue;
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","-funroll-loops","-fdelete-null-pointer-checks")
#pragma GCC target("ssse3","sse3","sse2","sse","avx2","avx","popcnt")
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define endl '\n'

const ll MOD = 1e9 + 7;

void solve() {
	int n, x, t;
	cin >> n >> x >> t;
	int ans = ceil(n/(double)x) * t;
	cout << ans;
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll t=1;
	for(ll tt=1; tt <= t; tt++) {
		//cout << "case #" << tt << ":\n";
		solve();
	}

	return 0;
}



Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

int main(){
    int N;
    cin >> N;
    vi A(N), B(N);

    for(int i=0; i<N-1; i++) cin >> B.at(i);

    int sum = 0;
    for(int i=0; i<N-1; i++){
        if(i==0){
            A.at(0) = B.at(0) ;
        }
        if(A.at(i) >= B.at(i)){
            A.at(i) = B.at(i);
        }
        A.at(i+1) = B.at(i) ;

    }

    for(int i=0; i<N; i++){
        sum += A.at(i);
    }

    cout << sum << endl;
}

Measured memory_bytes: 256