akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, X, ans, minn;

int main()
{
	in >> N >> X;
	std::vector<int>m(N);
	minn = 112345;
	rep(i, N)
	{
		in >> m[i];
		X -= m[i];
		minn = std::min(minn, m[i]);
	}
	ans = N + X / minn;
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#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;
int a, b;

int main() {
    while (cin >> n >> m) {
        bool error = false;
        
        int res = m;
        for (int i = 0; i < n; ++i) {
            cin >> a >> b;
            m += a; m -= b;
            if (m < 0) error = true;
            chmax(res, m);
        }
        
        if (error) cout << 0 << endl;
        else cout << res << endl;
    }
    return 0;
}


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

int i, n, a[200005], aibmin[200005], aibmax[200005], L[200005], R[200005];
long long rs;

void updatemin(int poz, int val) {
  while(poz <= n) aibmin[poz] = min(aibmin[poz], val), poz += -poz & poz;
}

int querymin(int poz) {
  int ans = 1e9 + 69;
  while(poz) ans = min(ans, aibmin[poz]), poz -= -poz & poz;
  return ans;
}

void updatemax(int poz, int val) {
  while(poz <= n) aibmax[poz] = max(aibmax[poz], val), poz += -poz & poz;
}

int querymax(int poz) {
  int ans = 0;
  while(poz) ans = max(ans, aibmax[poz]), poz -= -poz & poz;
  return ans;
}

int main()
{
  ios_base::sync_with_stdio(0);

  for(i = 1; i <= 200001; ++i) aibmin[i] = 1e9 + 69;

  cin >> n;
  for(i = 1; i <= n; ++i) {
    cin >> a[i];

    L[i] = querymax(a[i] - 1);
    if(!L[i]) L[i] = 1;
    if(a[L[i]] < a[i]) ++L[i];
    updatemax(a[i], i);
  }

  for(i = n; i; --i) {
    R[i] = querymin(a[i] - 1);
    if(R[i] > 1e9) R[i] = n;
    if(a[R[i]] < a[i]) --R[i];
    updatemin(a[i], i);

    rs += 1LL * a[i] * (i - L[i] + 1) * (R[i] - i + 1);
  }

  cout << rs << '\n';

  return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long a, long long b){
    if (a==1){
        cout << 1 << endl;
    } else {
        if(b >= a){
            cout << a << endl;
        } else {
            cout << a-1 << endl;
        }
    }
}

int main(){

    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}



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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

// π M_PI
// deg = rad*180/M_PI

int main() {
    int64_t n, k;
    cin >> n >> k;
    std::vector<int64_t> p(n);
    rep(i, n) {
        cin >> p[i];
    }
    Sort(p);
    int64_t ans = 0;
    rep(i, k) {
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

bool mp[21][21];

int main(){
  int n,m,num,cn;
  char dir;
  while(cin >> n && n){
    cn = 0;
    fill(mp[0],mp[21],0);
    int x,y,i,j;
    for(i=0;i<n;i++){
      cin >> x >> y;
      mp[x][y] = true;
    }
    cin >> m;
    x = y = 10;
    for(i=0;i<m;i++){
      cin >> dir >> num;
      if(dir == 'N'){
        for(j=0;j<num;j++){
          y++;
          if(mp[x][y]==true){
            cn++;
            mp[x][y] = false;
          }
        }
      }else if(dir == 'S'){
        for(j=0;j<num;j++){
          y--;
          if(mp[x][y]==true){
            cn++;
            mp[x][y] = false;
          }
        }
      }else if(dir == 'E'){
        for(j=0;j<num;j++){
          x++;
          if(mp[x][y]==true){
            cn++;
            mp[x][y] = false;
          }
        }
      }else if(dir == 'W'){
        for(j=0;j<num;j++){
          x--;
          if(mp[x][y]==true){
            cn++;
            mp[x][y] = false;
          }
        }
      }
    }
    if(cn == n)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N,Q;
    string S;
    cin>>N>>Q>>S;
    int l[Q],r[Q];
    rep(i,Q){
        cin >> l[i]>>r[i];
    }
    int  z[N];
    z[0]=0;
    for(int i=1;i<N;i++){
        z[i]=z[i-1];
        if(S[i-1]=='A'&&S[i]=='C') z[i]++;
    }
    rep(i,Q){
        cout << z[r[i]-1]-z[l[i]-1]<<endl;
    }






}


Measured memory_bytes: 3408
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader inReader = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter outWriter = new BufferedWriter(new OutputStreamWriter(System.out));
		String finalOutput = "";
		String line;
		char[] charSet = null;
		int count = 0;
		int times = 0;
		HashMap<Character, Integer> mMap1 = new HashMap<>();
		HashMap<Integer, Character> mMap2 = new HashMap<>();
		mMap1.put('a', 97);

		mMap1.put('b', 98);
		mMap1.put('c', 99);
		mMap1.put('d', 100);
		mMap1.put('e', 101);
		mMap1.put('f', 102);
		mMap1.put('g', 103);
		mMap1.put('h', 104);
		mMap1.put('i', 105);
		mMap1.put('j', 106);
		mMap1.put('k', 107);
		mMap1.put('l', 108);
		mMap1.put('m', 109);
		mMap1.put('n', 110);
		mMap1.put('o', 111);
		mMap1.put('p', 112);
		mMap1.put('q', 113);
		mMap1.put('r', 114);
		mMap1.put('s', 115);
		mMap1.put('t', 116);
		mMap1.put('u', 117);
		mMap1.put('v', 118);
		mMap1.put('w', 119);
		mMap1.put('x', 120);
		mMap1.put('y', 121);
		mMap1.put('z', 122);
		for (Entry<Character, Integer> e : mMap1.entrySet()) {
			mMap2.put(e.getValue(), e.getKey());
		}

		finalOutput += " ";

		while ((line = inReader.readLine()) != null) {
			if (line.trim().compareTo("") == 0 || line == null || count == 3)
				break;

			switch (count) {
			case 0:
				// noPair = Integer.parseInt(line.trim());
				charSet = line.trim().toLowerCase().toCharArray();
				break;
			case 1:
				times = Integer.parseInt(line.trim());

				break;
			}

			if (count == 1)
				break;
			++count;
		}

		for (int i = 0; i < charSet.length - 1; i++) {
			if (mMap1.get(charSet[i]) + times > mMap1.get('z') && charSet[i] != 'a') {

				times = times - (mMap1.get('z') - mMap1.get(charSet[i]) + 1);
				charSet[i] = 'a';
			}

		}
		times %= 26;
		if (mMap1.get(charSet[charSet.length - 1]) + times > mMap1.get('z')) {

			
			times = times - (mMap1.get('z') - mMap1.get(charSet[charSet.length - 1]) + 1);
			charSet[charSet.length - 1] = 'a';
		}
		charSet[charSet.length - 1] = mMap2.get(mMap1.get(charSet[charSet.length - 1]) + times);
		
		System.out.println(new String(charSet));

		inReader.close();
		outWriter.close();

	}

}


Measured memory_bytes: 14544
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    int i,len,p,x,s;
    double a,b;
    while(scanf("%lf%lf",&a,&b)==2)
    {
        p=1;
        len=(int)log10(b)+1;
        for(i=1;i<=len;i++)
        {
            p=p*10;
        }
        s=(int)(a*p+b);
        x=(int)sqrt(s);
        if(x*x==s)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 45;

int n;
char tmp[N];
int a[N][N];

long long f[N][N][N][N], g[N][N][N][N];

long long DPf(int l, int r, int L, int R);
long long DPg(int l, int r, int L, int R);

long long DPf(int l, int r, int L, int R) {
	if (l > r || L > R) {
		return l > r && L > R;
	}
	if (~f[l][r][L][R]) {
		return f[l][r][L][R];
	}
	long long ans = DPg(l, r, L, R);
	for (int i = l; i < r; ++i) {
		for (int j = L + 1; j <= R; ++j) {
			ans += DPf(l, i, j, R) * DPg(i + 1, r, L, j - 1);
		}
	}
	return f[l][r][L][R] = ans;
}

long long DPg(int l, int r, int L, int R) {
	if (l > r || L > R) {
		return 0;
	}
	if (~g[l][r][L][R]) {
		return g[l][r][L][R];
	}
	long long ans = 0;
	for (int i = l; i <= r; ++i) {
		for (int j = L; j <= R; ++j) {
			if (a[i][j]) {
				ans += DPf(l, i - 1, i + 1, r) * DPf(L, j - 1, j + 1, R);
			}
		}
	}
	return g[l][r][L][R] = ans;
}

int main() {
	read(n), n *= 2;
	for (int i = 1; i <= n; ++i) {
		readStr(tmp + 1);
		for (int j = 1; j <= n; ++j) {
			a[i][j] = tmp[j] ^ '0';
		}
	}
	memset(f, -1, sizeof f);
	memset(g, -1, sizeof g);
	long long ans = 0;
	for (int i = 2; i <= n; ++i) {
		if (a[1][i]) {
			ans += DPf(2, i - 1, i + 1, n);
		}
	}
	print(ans);
}


Measured memory_bytes: 67700
#include <stdio.h>
#include <algorithm>
#define LL long long
using namespace std;

int main(){
    LL n,x;

    scanf("%lld %lld",&n,&x);

    LL a=x,b=n-x,sum=n;
    if(a<b) swap(a,b);

    while(b){
        sum+=b*(a/b)*2; a%=b;
        swap(a,b);
    }
    sum-=a;

    printf("%lld",sum);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int A,B;
	int K;
	
	cin >> A >> B;
	cin >> K;
	
	int cnt=0;
	for(int i=110;i>0;i--)
	{
		if(A%i==0 && B%i==0)
			cnt++;
		
		if(cnt==K)
		{
			cout << i << endl;
			break;
		}
	}
	return 0;
}



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

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))

#define INF 1000000000

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int gcd(int a, int b)
{
	if (a < b)
		swap(&a, &b);

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

int lcm(int a, int b)
{
	return a*b/gcd(a, b);
}

void bubble_sort(int* p, int n)
{
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n - i - 1; j++)
		{
			if (p[j] > p[j + 1])
				swap(&p[j], &p[j + 1]);
		}
	}
}

int array_max(int* p, int n)
{
	int max = 0;
	for (int i = 0; i < n; i++)
	{
		if (p[i] > max)
			max = p[i];
	}
	return max;
}

int main()
{
	int N;
	int p[10];
	int sum = 0;

	scanf("%d", &N);

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &p[i]);
		sum += p[i];
	}
	
	printf("%d\n", sum - array_max(p, N) / 2);
}

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

using namespace std;

int main() {
  long long int N;
  cin >> N;
  vector<long long int> T(5);
  cin >> T[0] >> T[1] >> T[2] >> T[3] >> T[4];
  long long int min_t = *min_element(T.begin(), T.end());
  long long int waiting = (N + min_t - 1) / min_t;
  cout << 5 + waiting - 1 << endl;
  return 0;
}

Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N, X;
    scan(N, X);
    auto L = aryread();
    long x = 0;
    long ans;
    foreach (l; L)
    {
        x = x + l;
        ans += (x <= X);
    }
    writeln(ans + 1);
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int i;
	for(i=0; i<3; i++)
    {
        if(s[i]=='1'){cout<<'9';}
        else {cout<<'1';}
    }
}

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

using namespace std;

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

int getBlock(vector<int> &r, int fd) {
    if(r.empty())return -1;
    auto tp = upper_bound(r.begin(), r.end(), fd);
    if (tp == r.begin())return -1;
    tp--;
    return *tp;
}

int getBlockB(vector<int> &r, int fd) {
    if(r.empty())return -1;
    auto tp = lower_bound(r.begin(), r.end(), fd);
    if (tp == r.end())return -1;
    return *tp;
}

void solve() {
    int h, w;
    cin >> h >> w;

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

    vector<int> row[h], col[w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (v[i][j] == '#')row[i].push_back(j);
        }
    }
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            if (v[j][i] == '#')col[i].push_back(j);
        }
    }
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int pans = 0;
            if (v[i][j] == '#')continue;
            int block = getBlock(row[i], j - 1);
            pans += j - block;
            block = getBlock(col[j], i - 1);
            pans += i - block;

            block = getBlockB(row[i], j + 1);
            if (block == -1)block = w;
            pans += block - j;
            block = getBlockB(col[j], i + 1);
            if (block == -1)block = h;
            pans += block - i;

            ans = max(ans, pans - 3);
        }
    }
    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: 68736
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll X;
  cin >> X;
  if (400 <= X && X <= 599) {
    cout << 8 << endl;
  } else if (600 <= X && X <= 799) {
    cout << 7 << endl;
  } else if (800 <= X && X <= 999) {
    cout << 6 << endl;
  } else if (1000 <= X && X <= 1199) {
    cout << 5 << endl;
  } else if (1200 <= X && X <= 1399) {
    cout << 4 << endl;
  } else if (1400 <= X && X <= 1599) {
    cout << 3 << endl;
  } else if (1600 <= X && X <= 1799) {
    cout << 2 << endl;
  } else if (1800 <= X && X <= 1999) {
    cout << 1 << endl;
  }
  return 0;
}

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

int main(){
  int N, D;
  cin >> N >> D;
  if (N % (D * 2 + 1) == 0) cout << N / (D * 2 + 1) << endl;
  else cout << N / (D * 2 + 1) + 1 << endl;
}

Measured memory_bytes: 256
using System;
using static System.Math;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        string[] input = ReadLine().Split(' ');
        int X = int.Parse(input[0]);
        int Y = int.Parse(input[1]);
        int ans = 0;

        if(X == 1 && Y == 1)
        {
            ans = 1000000;
        }
        else
        {
            ans += Max(0, 300000 - (X - 1) * 100000);
            ans += Max(0, 300000 - (Y - 1) * 100000);
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    fastio();
    ll N,M;
    ll ans=0;
    cin>>N>>M;
    if(N==1)
        ans+=300000;
    else if(N==2)
        ans+=200000;
    else if(N==3)
        ans+=100000;

    if(M==1)
        ans+=300000;
    else if(M==2)
        ans+=200000;
    else if(M==3)
        ans+=100000;
    if(ans==600000)
        ans+=400000;
    cout<<ans;
} 
/*
Powered by Buggy plugin
*/


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,x,i,ans = 0;cin >> n >> x;
  int a[n];
  for(i=0;i<n;i++) cin >> a[i];
  sort(a,a+n);
  for(i=0;i<n;i++){
    if(x >= a[i]){
      ans++;x -= a[i];
    } else break;
  }
  if(ans == n && x > 0) ans--;
  cout << ans << endl;
}

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

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

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  string s;
  set<string> st;
  bool flag = true;
  string p;
  for (int i = 0; i < N; i++) {
    cin >> s;
    st.insert(s);

    if (i == 0) {
      p = s;
      continue;
    }
    if (p[p.size()-1] != s[0]) flag = false;
    p = s;
  }

  cout << (flag && st.size() == N ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



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

    if(a<k){
        k=k-a;
        a=0;
        b=max(0LL,b-k);
        cout<<a<<" "<<b<<endl;
    }else{
        cout<<(a-k)<<" "<<b<<endl;
    }


    return 0;

}

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

int main() {
  int k, a, b;
  cin>>k>>a>>b;
  int i = 1;
  while (true) {
    int tmp = k * i;
    if (tmp >= a && tmp <= b) {
      cout<<"OK"<<endl;
      return 0;
    }
    if (tmp > b) {
      break;
    }
    ++i;
  }
  cout<<"NG"<<endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
 
public class Main {
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int K = scanner.nextInt();
    List<Integer> list = new ArrayList<>();
    if(N < K){
      list.add(N);
    }else{
      while(N >= K){
        list.add(N % K);
        N = N / K;
      }
      if(N != 0)list.add(N);
    }
    System.out.println(list.size());
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)

int main() {

	int n; cin >> n;
	int* a = new int[n];
	rep(i, 0, n) cin >> a[i];
	sort(a, a + n);

	// 一番でかい数字が直径

	// 直径が偶奇で別れる
	// 奇数の場合: 距離最小が2つ　(D + 1) / 2
	// 偶数の場合: 距離最小が1つ	D / 2
	vector<int> cnt(n, 0);
	int D = a[n - 1];
	rep(i, 0, n) ++cnt[a[i]];
	
	bool ok = cnt[D] > 1; // 端チェック
	ok &= cnt[(D + (D & 1)) / 2] == (D & 1) + 1; // 真ん中チェック
	rep(i, 0, (D + (D & 1)) / 2) ok &= cnt[i] == 0; // 距離が真ん中以下になることはない
	rep(i, (D + (D & 1)) / 2 + 1, D) ok &= cnt[i] > 1; // 2個以上あればつなげる？(木よくわからん)

	string ans = (ok ? "P" : "Imp");
	ans += "ossible";
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3564
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

const int mod = 1000000007;

struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n-k];
    }
};
// combination c(max);
// mint c(n, k)

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

    int n, k;
    cin >> n >> k;
    combination c(k);
    cout << c(k, n) << endl;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <boost/algorithm/string/join.hpp>
#include <boost/range/irange.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using boost::irange;
using boost::algorithm::join;

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
int N;

// pは最右+の要素のindex
void print(const vi& A, int p) {
  ll sum = accumulate(begin(A), begin(A)+p+1, 0) - accumulate(begin(A)+p+1, end(A), 0);
  cout << sum << endl;

  ll c = A[p+1];
  for (int i=p+1; i>=2; i--) {
    cout << c << " " << A[i-1] << endl;
    c = c - A[i-1];
  }
  cout << A[0] << " " << c << endl;
  c = A[0] - c;
  for (int i=p+2; i<N; i++) {
    cout << c << " " << A[i] << endl;
    c = c - A[i];
  }
}

int main(int argc, char** argv) {
  cin >> N;
  vi A(N);
  for (auto& a : A) {
    cin >> a;
  }

  sort(begin(A), end(A), greater<ll>());

  if (A[N-1] >= 0) {
    print(A, N-2);
    return 0;
  }

  if (A[0] <= 0) {
    print(A, 0);
    return 0;
  }

  REP(i, N) {
    if (A[i] < 0) {
      print(A, i-1);
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    ll d = 5;
    while (d <= n && n%2 == 0) {
        ans += (n/d)/2;
        d *= 5;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forna(i,a,n) for(int i =a; i < n; i++)
#define fornd(i,a) for (int i = (a)-1; i >= 0; i--)
#define endl '\n'
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(x) x.begin(), x.end()
typedef long long int unsigned lliu;
typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<vi> vvi;
typedef vector<pi> vpi;

lli mem[105][100005];
int pesos[105];
int n, W;
int valores[105];
lli inf = 1e15;

int main(){
	fastIO
	cin>>n>>W;
	forn(i, n)
		cin>>pesos[i]>>valores[i];
	forn(i, n+1){
		forn(j, W+1){
			if(i==0 || j==0)
				mem[i][j]=0;
			else 
				if(pesos[i-1]<=j){
					mem[i][j]=max(mem[i-1][j-pesos[i-1]]+valores[i-1], mem[i-1][j]);
				} else
					mem[i][j]=mem[i-1][j];
		}
	}
	cout<<mem[n][W]<<endl;

	return 0;
}

Measured memory_bytes: 82528
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#define ios std::ios::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define PI acos(-1.0)
#define EPS 1e-9 //epsilon 10^-9, checking for equality 
#define pb push_back
#define fi first
#define se second
#define go(i,a,n) for(int i=a;i<n;i++)
#define og(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(i,n) go(i,0,n)
#define per(i,n) og(i,0,n)
#define sz(x) (x.size())
#define isort(x) sort(x.begin(),x.end())
#define dsort(x) sort(x.rbegin(),x.rend())
#define all(x) x.begin(),x.end()
#define rall(x) (x).rbegin(),(x).rend()
#define pr(x) cout<<(x)<<endl
#define exist(e,s) ((s).find(e)!=(s).end()) //Element e in structure s
#define existstr(c,s) ((s).find(c) !=string::npos) //Character in structure
#define fo(x,s) for(auto &x:s) //for all x in structure s
typedef vector<int> vi;typedef vector<ll> vll;typedef vector< vector<int> > vvi;
typedef vector< vector<ll> > vvll;typedef pair<int,int> ii;typedef pair<int, pair<int,int> > iii;
typedef pair<ll,ll> pll;typedef vector<ii> vii;typedef vector<iii> viii;typedef map<int,int> mii;
const int inf=1e9+7; //10^9 +7
inline void rvi(vi& v, int n){int temp; go(i,0,n){cin>>temp;v.pb(temp);}}
inline void rvll(vll& v, int n){ll temp;go(i,0,n){cin>>temp;v.pb(temp);}}
inline void prvi(vi&a){go(i,0,a.size()){cout<<a[i]<<" ";}cout<<endl;}
inline void prvll(vll&a){go(i,0,a.size()){cout<<a[i]<<" ";}cout<<endl;}
inline void prmii(map<int,int>& m){for(auto x:m){cout<<x.fi<<" "<<x.se<<endl;}}
inline vll prefixsum(vi& a){vll b;b.pb(a[0]);go(i,1,a.size()){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vi& a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];og(i,0,sz(a)-1){b[i]=a[i]+b[i+1];}return b;}
inline vll prefixsum(vll& a){vll b;b.pb(a[0]);go(i,1,a.size()){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vll& a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];og(i,0,sz(a)-1){b[i]=a[i]+b[i+1];}return b;}
void solve();
int main(){ios;solve();return 0;}
//--------SOLVE---------------------------------------------------------------------
void solve()
{
 	int a,b;cin>>a>>b;
 	cout<<a*b+1-(b+a)<<endl;   
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define ill long long
#define rep(i, a, b) for(ill i = (ill)(a); i < (ill)(b); i++)
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int n;
  cin >> n;
  cout << "ABC" << n << "\n";
}

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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int K = 9, N = (1 << (K << 1)) + 5, L = 1e5 + 5;

int n, V[N], W[N], SumV[1 << K], SumW[1 << K], DP[2 << K][L];
vector<int> P;

void DFS(int v) {
	if (v > n || v >= (2 << K)) return;
	int p = v >> 1;
	for (int i = 0; i < L; i++) {
		DP[v][i] = DP[p][i];
		if (i >= W[v]) DP[v][i] = max(DP[v][i], DP[p][i - W[v]] + V[v]);
	}
	DFS(v << 1), DFS((v << 1) | 1);
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));
	
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> V[i] >> W[i];
	DFS(1);
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		int v, l; cin >> v >> l;
		P.clear();
		while (v >= (2 << K)) P.push_back(v), v >>= 1;
		int ans = DP[v][l];
		for (int mask = 1; mask < (1 << sz(P)); mask++) {
			SumV[mask] = SumV[mask - (mask & - mask)] + V[P[__builtin_ctz(mask)]];
			SumW[mask] = SumW[mask - (mask & - mask)] + W[P[__builtin_ctz(mask)]];
			if (SumW[mask] <= l) ans = max(ans, SumV[mask] + DP[v][l - SumW[mask]]);
		}
		cout << ans << endl;
	}

	return 0;
}


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

int main(void) {
  vector<int> xs(5);
  for (int &x : xs) cin >> x;

  for (int i = 0; i < 5; i++) {
    if (xs[i] == 0) {
      cout << i + 1 << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  int n,k; cin>>n>>k;
  vector<int> a(n);
  for(auto &i:a) cin>>i;
  deque<int> d;
  for(int i=0; i<k; i++){
    d.push_back(a.at(i));
  }
  for(int i=k; i<n; i++){
    auto b = d.front();
    if(b<a.at(i)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    d.pop_front();
    d.push_back(a.at(i));
  }
  
  
}


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

int main(){
  string S;
  int price = 700;
  cin >> S;
  for (int i = 0; i<S.size(); i++){
    if(S.at(i) == 'o'){
       price += 100;
    }
  }
  cout << price << endl;
}
     
       

Measured memory_bytes: 256
n = int(input())
t, a =  map(int,input().split())
h = list(map(int,input().split()))
b = 0

b = t-a
c = b-0.006*h[0]
best = 0
for i in range(0,len(h)):
    if min(abs(b-0.006*h[i]),abs(c)) == abs(b-0.006*h[i]):
        c = abs(b-0.006*h[i])
        best = i

print(best+1)

Measured memory_bytes: 3064
using System;
class P{
  static void Main(){
    int n =int.Parse(Console.ReadLine());
    var s = Console.ReadLine();
    int count=0;
    if(n%2==0){
      for(int i=0;i<n/2;i++){
        if(s[i]!=s[i+n/2]){count++;}
      }
    }
    else{count++;}
    Console.WriteLine(count==0?"Yes":"No");
  }
}
      

Measured memory_bytes: 13140
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt, nega, posi = 0, 0, []
for x, y in zip(a, b):
    if x < y:
        nega += y - x
        cnt += 1
    else:
        posi.append(x - y)
if nega > 0:
    posi.sort(reverse=True)
    for i, x in enumerate(posi):
        nega -= x
        if nega <= 0:
            cnt += i + 1
            break
    else:
        cnt = -1
print(cnt)

Measured memory_bytes: 24048
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let vs : Vec<String> = get_vec();
    let v : Vec<Vec<char>>= vs.iter().map(|e| e.chars().collect()).collect();
    let mut cur = v[0][0];
    let mut ans = true;
    for s in v {
        if s[0] != cur {
            ans = false;
            break;
        }
        cur = s[s.len()-1];
    }
    println!("{}", if ans {"YES"} else {"NO"});

}


Measured memory_bytes: 4352
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
	int n, p;
	while (cin >> n >> p) {
		if (n == 0 && p == 0) {
			break;
		}
		vector<string> hyou(n);
		for (int i = 0; i < n; i++) {
			cin >> hyou[i];
		}
		set<string> t;
		for (int i = 0; i < n; i++) {
			string b = hyou[i];
			for (int j = 0; j < n; j++) {
				if (i == j) {
					continue;
				}
				string c = b+hyou[j];
				if (p > 2) {
					for (int k = 0; k < n; k++) {
						if (i == k || j == k) {
							continue;
						}
						string d = c+hyou[k];
						if (p > 3) {
							for (int l = 0; l < n; l++) {
								if (i == l || j == l || k == l) {
									continue;
								}
								string e = d+hyou[l];
								if (t.find(e) == t.end()) {
									t.insert(e);
								}
							}
						} else {
							if (t.find(d) == t.end()) {
								t.insert(d);
							}
						}
					}
				} else {
					if (t.find(c) == t.end()) {
						t.insert(c);
					}
				}
			}
		}
		cout << t.size() << endl;
	}
	return 0;
}

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

int main(void){
    int n,k;
    cin >> n >> k;
    int p[n];
    double num[n];
    for(int i = 0;i < n;i++)cin >> p[i];
    num[0] = (double)(p[0]+1)/2;
    for(int i = 1;i < n;i++)num[i] = num[i-1]+((double)(p[i]+1)/2);
    double ans = num[k-1];
    for(int i = k;i < n;i++){
        ans = max(ans,(num[i]-num[i-k]));
    }
    cout << setprecision(12) << ans << endl;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll A, B, C;
    cin >> A >> B >> C;
    ll D = A - B;
    C -= D;
    cout << max(C, 0LL) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)

int main()
{
	while(1)
	{
		bool r[255][255]={};
		int num[255]={};
		int maxv,n;
		vector<int>edge[255];
		for(int i=0;i<255;i++) edge[i].clear();
		bool used[255][255]={};
		
		cin >> maxv;
		if(maxv == 0) return 0;
		cin >> n;
		for(int i=1;i<=n;i++) cin >> num[i];
		for(int i=0;i<=n;i++)
		{
			for(int j=1;j<=maxv;j++)
			{
				int d = i+j;
				if(d > n) r[i][n+1] = true;
				else
				{
					d += num[d];
					d = max(d,0);
					d = min(d,n+1);
					r[i][d] = true;
				}
			}
		}
		for(int i=0;i<=n;i++) for(int j=0;j<=n+1;j++) if(r[i][j]) edge[i].pb(j);
		for(int i=0;i<=n;i++)
		{
			//used[i][i] = true;
			queue<int>que; que.push(i);
			while(!que.empty())
			{
				int q = que.front(); que.pop();
				if(used[i][q]) continue;
				used[i][q] = true;
				for(int j=0;j<edge[q].size();j++)
				{
					if(!used[i][edge[q][j]])
					{
						que.push(edge[q][j]);
					}
				}
			}
		}
		for(int i=0;i<=n;i++)
		{
			if(used[0][i] && !used[i][n+1])
			{
				puts("NG"); goto nxt;
			}
		}
		puts("OK"); nxt:;
	}
}

Measured memory_bytes: 1324
#include<stdio.h>
int main(void)
{
    int t,n,s,f,i;
	while(1)	{
		scanf("%d",&t);
		if(t==0)	break;
		scanf("%d",&n);
		for (i=1;i<=n;i++){
			scanf("%d",&s);
			scanf("%d",&f);
			t=t-(f-s);
		}
		if (t<=0){
			printf("OK\n");
		}
		else {
			printf("%d\n",t);
		}
	}	
		
	return 0;
}
	
	

Measured memory_bytes: 1040
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int n;
  cin >> n;
  
  vector<int>length(n);
  
  for(int i=0;i<n;i++){
    cin >> length[i];
  }
  
  int max = 0;
  for(int i=0;i<n;i++){
    if(length[i] > max)
      max = length[i];
  }
  
  int sum = 0;
  for(int i=0;i<n;i++){
    sum = sum + length[i];
  }
  
  if(sum - max > max)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 764
[n, q] = [int(x) for x in input().split()]
qs = []
for _ in range(n):
    al = input().split()
    qs.append([al[0], int(al[1])])

t = 0
while len(qs) > 0:
    task = qs.pop(0)
    if task[1] <= q:
        t += task[1]
        print(task[0], t)
    else:
        t += q
        task[1] -= q
        qs.append(task)


Measured memory_bytes: 13016
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 998244353

int main(){
	int N;
	cin >> N;
	if (N % 2) {
		cout << N / 2 << endl;
	}
	else {
		cout << N / 2 - 1 << endl;
	}
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N+2);
    A[0] = 0;
    A[N+1] = 0;
    vector<int> D(N+1);
    vector<int> D2(N);
    int total = 0;
    for (int i = 1; i <= N; i++){
        cin >> A[i];
        D[i-1] = abs(A[i] - A[i-1]);
        total += D[i-1];
        if(i != 1){
            D2[i-2] = abs(A[i] - A[i-2]);
        }
    }
    D[N] = abs(A[N+1] - A[N]);
    total += D[N];
    D2[N-1] = abs(A[N+1] - A[N-1]);

    for (int i = 1; i <= N; i++){
        int ans = total - D[i-1] - D[i] + D2[i-1];
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 4580
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000001;
const long long LINF = 1e18;
const int MAX = 510000;

int main() {
	int n, m = 0, ans = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
		if (a.at(i) > m)m = a.at(i);
	}
	int k = 0;
	ans = 0;
	for (int i = 0; i < n; i++) {
		ans += a.at(i) - 1;
	}
		
	cout << ans << endl;
		return 0;
	}


Measured memory_bytes: 3616
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees//
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define int ll
const ll mod = 998244353;
int n, cnt[2][100010];
vector<pi> v1, v2;

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin>>n;
	for(int i=1, x; i<=n; i++){
		cin>>x;
		cnt[i%2][x]++;
	}
	for(int i=1; i<=100000; i++){
		if(cnt[0][i]) v1.pb({cnt[0][i], i});
		if(cnt[1][i]) v2.pb({cnt[1][i], i});
	}
	sort(v1.begin(), v1.end(), greater<pi>());
	sort(v2.begin(), v2.end(), greater<pi>());
	//v1.pb({0, 0}), v2.pb({0, 0});
	if(v1[0].y!=v2[0].y) return cout<<n-v1[0].x-v2[0].x, 0;
	cout<<min(n-v1[0].x-v2[1].x, n-v1[1].x-v2[0].x);
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)

int main() {
	ll n; cin >> n;
	ll a[100000] = {};
	ll maxV = 0;
	rep(i, 0, n) {
		cin >> a[i];
		maxV = max(maxV, a[i]);
	}
	rep(i, 0, n) {
		a[i] *= 2;
	}

	ll diff = 1e16;
	ll result = 0;
	rep(i, 0, n) {
		if (diff >= abs(a[i] - maxV)) {
			diff = abs(a[i] - maxV);
			result = a[i] / 2;
		}
	}

	cout << maxV << " " << result << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <inttypes.h>

int N;
char S[4096];

int id(char c) {
	switch (c) {
		case 'R': return 0;
		case 'G': return 1;
		case 'B': return 2;
	}
	return 3;
}

int rui[4][4096];

int main(void) {
	int i, j;
	uint64_t kotae = 0;
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%4095s", S) != 1) return 1;
	for (i = 0; i < N; i++) {
		rui[id(S[i])][i]++;
	}
	for (i = 0; i < 3; i++) {
		for (j = 1; j <= N; j++) rui[i][j] += rui[i][j - 1];
	}

	for (i = 0; i < N; i++) {
		for (j = i + 1; j < N; j++) {
			if (S[i] != S[j]) {
				int target = 3 - id(S[i]) - id(S[j]);
				int delta = rui[target][N] - rui[target][j];
				if (j + (j - i) < N && id(S[j + (j - i)]) == target) delta--;
				kotae += delta;
			}
		}
	}

	printf("%" PRIu64 "\n", kotae);
	return 0;
}


Measured memory_bytes: 1760
N, K = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)

dp = []
dp[0] = 0

1.upto(h.size - 1) {|i|
  min_cost = Float::INFINITY
  (1..K).each do |j|
    k = i - j
    break if k < 0

    cost = dp[k] + (h[i] - h[k]).abs
    min_cost = cost if cost < min_cost
  end

  dp[i] = min_cost
}

puts dp.last


Measured memory_bytes: 11524
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll nCm(ll n, ll m){
    if(m == 0 || m == n){
        return 1;
    } else if(m == 1){
        return n;
    }
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------

int main(void){
    ll n;
    cin >> n;
    
    ll ans = 0;

    for(ll i = 1; i < 100001; i++){
        if(n < i * i){
            cout << (i - 1) * (i - 1) << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
#!python3
import sys

def main():
    s = input()

    head = int(s[:2])
    tail = int(s[2:])

    if head > 0 and head <= 12:
        # head can be MM
        if tail > 0 and tail <= 12:
            print('AMBIGUOUS')
        else:
            print('MMYY')
    elif tail > 0 and tail <= 12:
        # tail can be MM
        if head > 0 and head <= 12:
            print('AMBIGUOUS')
        else:
            print('YYMM')
    else:
        print('NA')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060