akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
#define int long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define endl '\n'
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define inf 1e18
#define pf push_front
#define pob pop_back
#define pof pop_front
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

typedef pair<int,int> pi;
typedef pair<int,pair<int,int>> piii;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;

int32_t main()
{
   // boost
    int t=1;
   // cin>>t;
    while(t--)
    {
        int n;
        cin>>n;

        int ans=1000-n%1000;
        if(ans==1000)
        cout<<"0"<<endl;
        else
        {
            cout<<ans<<endl;
        }
        


    }


    

}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main() {
  int n,m;
  cin>>n>>m;
  int ans1 = n*(n-1)/2;
  int ans2 = m*(m-1)/2;
  
  cout<<ans1 + ans2<<endl;
  return 0;
}

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

using namespace std;
using lli = long long int;

int main() {
	int A, B;
	cin >> A >> B;
	A -= 1;
	B -= 1;
	int Grid[100][100];
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 50; j++) Grid[i][j] = 0;
		for (int j = 50; j < 100; j++) Grid[i][j] = 1;
	}
	int i = 0;
	int j = 0;
	while (A != 0) {
		while (A != 0 && j < 50) {
			Grid[i][j] = 1;
			A--;
			j += 2;
		}
		j = 0;
		i += 2;
	}
	i = 0;
	j = 51;
	while (B != 0) {
		while (B != 0 && j < 100) {
			Grid[i][j] = 0;
			B--;
			j += 2;
		}
		j = 51;
		i += 2;
	}
	cout << 100 << " " << 100 << endl;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++)cout << (Grid[i][j] == 0 ?"#" :".");
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#include<typeinfo>
#define R(i, n) for(int i = 0;i < n; i++)
#define R1(i, n) for(int i = 1; i <= n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SC(a) scanf("%c", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("YES")
#define PN printf("NO")
#define Py printf("Yes")
#define Pn printf("No")
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

int main() {
	ll n, a, b;
	SL3(n, a, b);
	if ((b - a) % 2 == 0) PL((b - a) / 2);
	else PL(min(a - 1, n - b) + (b - a - 1) / 2 + 1);
}

Measured memory_bytes: 3780
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io, flush := NewIO()
	defer flush()

	n := io.ScanInt()
	heights := io.ScanInts(n)
	var curHeight, curCount, max int
	curHeight = heights[0]
	for _, h := range heights[1:] {
		if curHeight >= h {
			curCount++
		} else {
			if curCount > max {
				max = curCount
			}
			curCount = 0
		}
		curHeight = h
	}
	if curCount > max {
		max = curCount
	}
	fmt.Println(max)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 1000005), 1000005)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 4096
#include <stdio.h>

int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if (a == 1) {
		a = 14;
	}
	if (b == 1) {
		b = 14;
	}
	if (a > b) {
		printf("Alice\n");
	}
	else if (b > a) {
		printf("Bob\n");
	}
	else {
		printf("Draw\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N;
  cin >> N;
  int count = 0;
  bool ok = false;
  rep(i, N)
  {
    int a, b;
    cin >> a >>  b;
    if (a == b)
    {
      count++;
    }
    else
    {
      count = 0;
    }
    if (count >= 3)
    {
      ok = true;
    }
  }


  if (ok)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int n = 0;
  cin >> N;
  while (n < N){
    string s;
  	cin >> s;
    if (s == "Y") {
      cout << "Four" << endl;
      break;
    }
    n++;
  }
  if (n == N) {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll h,w;
    cin>>h>>w;
    vector<string>v(h);
    for(int i=0;i<h;i++)
        cin>>v[i];

    // left array computation
    vector<vector<int>>left(h,vector<int>(w,0));
    for(int i=0;i<h;i++)
    {
        if(v[i][0]=='.'){
        left[i][0]=1;
        }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=1;j<w;j++)
        {
            if(v[i][j]=='.')
            {
                left[i][j]=left[i][j-1]+1;
            }
            else if(v[i][j]=='#')
            {
                left[i][j]=0;
            }
        }
    }


     vector<vector<int>>right(h,vector<int>(w,0));
    for(int i=0;i<h;i++)
    {
        if(v[i][w-1]=='.'){
        right[i][w-1]=1;
        }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=w-2;j>=0;j--)
        {
            if(v[i][j]=='.')
            {
                right[i][j]=right[i][j+1]+1;
            }
            else if(v[i][j]=='#')
            {
                right[i][j]=0;
            }
        }
    }


    //up

     vector<vector<int>>up(h,vector<int>(w,0));
    for(int i=0;i<w;i++)
    {
        if(v[0][i]=='.'){
        up[0][i]=1;
        }
    }
    for(int i=1;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(v[i][j]=='.')
            {
                up[i][j]=up[i-1][j]+1;
            }
            else if(v[i][j]=='#')
            {
                up[i][j]=0;
            }
        }
    }

    // down


     vector<vector<int>>down(h,vector<int>(w,0));
    for(int i=0;i<w;i++)
    {
        if(v[h-1][i]=='.'){
        down[h-1][i]=1;
        }
    }
    for(int i=h-2;i>=0;i--)
    {
        for(int j=0;j<w;j++)
        {
            if(v[i][j]=='.')
            {
                down[i][j]=down[i+1][j]+1;
            }
            else if(v[i][j]=='#')
            {
                down[i][j]=0;
            }
        }
    }


    int  res=INT_MIN;
    vector<vector<int>> ans(h,vector<int>(w,0));
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(v[i][j]=='.')
            {
               ans[i][j]=left[i][j]+right[i][j]+down[i][j]+up[i][j]-3;
               res=max(res,ans[i][j]);
            }
            else
            {
                continue;
            }
        }
    }
    cout<<res;
}


Measured memory_bytes: 82816
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

ll solve(ll N, ll M) {
	ll ok = 0, ng = N + M / 2;
	while (ng - ok > 1) {
		ll mid = (ok + ng) / 2;
		bool mid_ok;
		if (N >= mid && M >= 2 * mid)
			mid_ok = true;
		else if (N < mid && (M - 2 * (mid - N)) >= 2 * mid)
			mid_ok = true;
		else mid_ok = false;
		if (mid_ok) ok = mid;
		else ng = mid;
	}
	return ok;
}

int main(void) {
	ll N, M; cin >> N >> M;
	cout << solve(N, M) << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<vector<ll>> dp(n+1, vector<ll>(n+1));
  for (int len = 1; len <= n; len++) {
    for (int i = 0; i+len <= n; i++) {
      int j = i+len;
      if ((n-len)%2 == 0)
        dp[i][j] = max(dp[i+1][j]+a[i], dp[i][j-1]+a[j-1]);
      else
        dp[i][j] = min(dp[i+1][j]-a[i], dp[i][j-1]-a[j-1]);
    }
  }
  cout << dp[0][n] << endl;
  return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <list>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <random>
#include <queue>
#include <fstream>
#include <iterator> // std::back_inserter
#include <chrono>
#include <string>
#include <stdio.h>
#include <iomanip>
#include <float.h>
#include <cassert>
#include <functional>
 
using namespace std;
 
int main(int argc, char *argv[])
{
    long long X,Y,Z,K;

    cin >> X >> Y >> Z >> K;

    //vector<long long> a,b,c;

    long long a[1009], b[1009], c[1009];

    long long int teki;

    for(int i=0; i<X; i++){
        cin >> teki;
        //a.push_back(teki);
        a[i] = teki;
    }

    for(int i=0; i<Y; i++){
        cin >> teki;
        //b.push_back(teki);
        b[i] = teki;
    }

    for(int i=0; i<Z; i++){
        cin >> teki;
        //c.push_back(teki);
        c[i] = teki;
    }

    sort(a, a+X, greater<long long>());
    sort(b, b+X, greater<long long>());
    sort(c, c+X, greater<long long>());

    vector<long long> ans;
    
    for(int i=0; i<X; i++){
        for(int j=0; j<Y; j++){
            for(int k=0; k<Z; k++){
                if((i+1)*(j+1)*(k+1) <= K) ans.push_back(a[i]+b[j]+c[k]);
                else break;
            }
        }
    }

    sort(ans.begin(), ans.end(), greater<long long>());

    for(int i=0; i<K; i++){
        cout << ans[i] << endl;
    }
 
    return 0;
}


Measured memory_bytes: 1400
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();
        sc.close();

        if (K >= S.length()) {
            System.out.println(S);
        } else {
            for (int i = 0; i < K; i++) {
                System.out.print(S.charAt(i));
            }
            System.out.println("...");
        }

    }
}


Measured memory_bytes: 35708
#include <iostream>
#include <vector>

using namespace std;

int main() {
    vector<int> H, W;
    int i = 0, n, m;
    
    while(1) {
        cin >> n >> m;
        H.push_back(n);
        W.push_back(m);
        
        if(H[i] == 0 && W[i] == 0) break;
        
        i++;
    }
    
    for(i = 0; H.size(); i++) {
        if(i != 0) cout << endl;
        if(H[i] == 0 && W[i] == 0) break;
        
        for(int x = 0; x < H[i]; x++) {
            for(int y = 0; y < W[i]; y++) {
                if(x == 0 || x == H[i]-1 || y == 0 || y == W[i]-1) cout << "#";
                else cout << ".";
                
                if(y == W[i]-1) cout << endl;
            }
        }
    }
    
    
}

Measured memory_bytes: 1208
#include <iostream>
#include <set>
#include <algorithm>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define SORT(c) sort(begin(c),end(c))


using namespace std;
using ll = long long;

double dense(int a, int b){
  return 100*b/(a+b);
}

int
main(void){
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  ll sums = 0L;

  bool dp[3001][3001] = {};
  dp[0][0] = true;
  for(int i=0; i<3000; i++){
    for(int j=0; j<3000; j++){
      if(dp[i][j] == false) continue;
      if(i+j+100*a <= f) dp[i+100*a][j] = true;
      if(i+j+100*b <= f) dp[i+100*b][j] = true;
      if(i+j+c <= f) dp[i][j+c] = true;
      if(i+j+d <= f) dp[i][j+d] = true;
    }
  }

  double ans = 0;
  int w = 0, s = 0;
  for(int i=0; i<3000; i++){
    for(int j=0; j<3000; j++){  
      if (dp[i][j] == false) continue;
      if (i + j > f) continue;
      if(i * e < j * 100) continue;
      if(ans <= 100.0 * j / (i+j)){
	ans = 100.0 * j / (i+j);
	w = i;
	s = j;
      }
    }
  }

  cout << w + s << " " << s << endl;
  
  return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
const string r[] = { "402351", "310542", "152304", "215043" };
int n; string s;
int main() {
	while (cin >> n, n) {
		vector<int> a = { 1, 2, 4, 3, 5, 6 };
		for (int i = 0; i < n; i++) {
			cin >> s;
			int d = 0;
			if (s[0] == 'e') d = 1;
			if (s[0] == 's') d = 2;
			if (s[0] == 'w') d = 3;
			vector<int> b(6);
			for (int j = 0; j < 6; j++) b[j] = a[r[d][j] - 48];
			a = b;
		}
		cout << a[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 3172
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <stdexcept>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
  
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
  
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define fill(x, y) memset(x, y, sizeof(x))
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define itn int
#define re return
#define prev PREV
#define next NEXT
  
#define sz(x) ((int)x.size())
  
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 1e5;
#define FILENAME ""
const double eps = 1e-6;
const int maxn = 1001;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //freopen("unionday.in", "r", stdin);
    //freopen("unionday.out", "w", stdout);
    vector <ll> a;
   	for (int i = 0; i < 5; i++) {
   		ll x;
   		cin >> x;
   		a.pb(x);
   	} 
   	ll ans = 0;
   	for (int i = 0; i < sz(a); i++) {
   		for (int j = 0; j < sz(a); j++) {
   			ans = max(ans, abs(a[i] - a[j]));
   		}
   	}
   	ll k;
   	cin >> k;
   	if (ans <= k) {
   		cout << "Yay!";
   	}
   	else {
   		cout << ":(";
   	}
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 2000000
int A[N],B[N],C[N];
main()
{
  int j,n,k=0,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(k<A[i])k=A[i];
  }
  
  for(i=0;i<=k;i++){
    C[i]=0;
  }
  
  for(i=0;i<n;i++){
    C[A[i]]++;
  }
  for(i=1;i<=k;i++){
    C[i]=C[i]+ C[i-1];
  }
  for(j=n;j>=0;j--){
    B[C[A[j]]-1]=A[j];
    C[A[j]]--;
  }
  for(i=0;i<n;i++){
    printf("%d",B[i]);
    if(i!= n-1)printf(" ");
    else printf("\n");
  }
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    n;
    vector<int> C(n),S(n),F(n);
    for(int i=0; i<n-1; i++) cin>>C[i]>>S[i]>>F[i];

    for(int j=0; j<n; j++) {
        long long t=0;
        for(int i=j; i<n-1; i++) {
            if(t<S[i]) t = S[i];
            if(t%F[i]) t += F[i]-t%F[i];
            t += C[i];
        }

        cout << t << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, Y;
ll sum[305];
ll A[305];
ll dp[305][305][5];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> Y;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        sum[i+1] = sum[i] + A[i];
    }
    for(int i = 0; i <= N; i++) {
        dp[i][i][0] = 1;
    }
    for(int num = 1; num <= 4; num++) {
        for(int i = 0; i <= N; i++) {
            for(int j = i; j <= N; j++) {
                for(int k = i + 1; k <= j; k++) {
                    if(sum[k] - sum[i] + Y < sum[N] / 5) continue;
                    //cerr << i << " " << k << " " << j << " " << sum[k] << " " << sum[i] << endl;
                    dp[i][j][num] += dp[k][j][num-1];
                }
                //cerr << i << " " << j << " " << num << " " << dp[i][j][num] << endl;
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= N; j++) {
            if(i > j) continue;
            if(j == N && i != 0) continue;
            ll now = 0;
            for(int k = 0; k < N; k++) {
                if(k < i or k >= j) now += A[k];
            }
            if(now == 0) continue;
            //cerr << i << " " << j << " " << now << endl;
            if(now + Y >= sum[N] / 5) ans += dp[i][j][4];
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5968
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        //static long Mod = (long)1e9 + 7;
        static List<long>[] tree;
        static long[] query;
        static bool[] cmp;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var Ai = Sarray();
            Array.Sort(Ai);
            var thr = (Ai.Sum() + 1) / 2;
            var sum = Ai[0];
            var s = 0L;
            for (var i = 1; i < N; ++i)
            {
                if (2 * sum < Ai[i])
                    s = i;
                sum += Ai[i];
                if (thr <= 2 * sum)
                    break;
            }
            WriteLine(N - s);
            //Out.Flush();
        }
    }
}


Measured memory_bytes: 31580
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


 main()

{
    fast
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c)
    {
        if(a%2==0)cout<<"-1"<<endl;
        else cout<<"0"<<endl;
        return 0;
    }
    int cnt=0;
    while(1)
    {
        //cout<<a<<" "<<b<<" "<<c<<endl;
        if(a%2==1 || b%2==1 || c%2==1)
        {
            cout<<cnt<<endl;
            return 0;
        }
        int pa=a,pb=b,pc=c;
        a=(pb+pc)>>1;
        b=(pa+pc)>>1;
        c=(pb+pa)>>1;
         if(a==b && b==c)
        {
        if(a%2==0)cout<<"-1"<<endl;
        else cout<<cnt<<endl;
        return 0;
        }
      cnt++;

    }
    return 0;
}


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

int main()
{
    int n, k, m, x, a[51];
    bool b[51] = {};

    cin >> n >> k;

    for( int i = 0; i < k; i++ )
    {
        cin >> m;
        for( int j = 0; j < m; j++ )
        {
            cin >> x;
            a[x] = i;
        }
    }

    cin >> k;

    for( int i = 0; i < k; i++ )
    {
        cin >> m >> x;
        if( a[m] == a[x] )
        {
            b[m] = true;
            b[x] = true;
        }
    }

    int cnt = 0;
    for( int i = 1; i < 51; i++ )
        if( b[i] )
            cnt++;
            
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3124
[N,K]=[int(_) for _ in input().split()]
if K>(N-1)*(N-2)//2:
    print(-1)
else:
    edges=[(1,n) for n in range(2,N+1)]
    edges2=[(i,j) for i in range(2,N+1) for j in range(2,N+1) if i<j]
    for i in range((N-1)*(N-2)//2-K):
        edges.append(edges2[i])
    print(N-1+(N-1)*(N-2)//2-K)
    for e in edges:
        print(e[0],e[1])

Measured memory_bytes: 4120
import copy

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

n,m = ips()
a = []
s = 0
for i in range(m):
    x,y = ips()
    a.append([x,y])
connection = [[] for i in range(n+1)]
for i in range(m):
    [x,y] = a[i]
    connection[x].append(y)
    connection[y].append(x)
for loop in range(100):
    for i in range(1,n+1):
        if len(connection[i]) == 1:
            temp = connection[i][0]
            d = connection[temp].index(i)
            connection[temp].pop(d)
            s+=1
            connection[i].pop(0)
print(s)

Measured memory_bytes: 3444
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    s=chomp(readline())
    n=length(s)
    good=[ifelse(i%2==1,'0','1') for i in 1:n]
    cnt=0
    for i in 1:n
        if good[i]!=s[i]
            cnt+=1
        end
    end
    println(min(cnt,n-cnt))
end
main()

Measured memory_bytes: 117128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())



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



// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }




int main() {

  int a[5];
  rep(i,5){
    cin >> a[i];
  }

  int k;
  cin >> k;

  bool ans = false;

  rep(i,5){
    repf(j,i+1,5){
      if(abs(a[i]-a[j])>k){
        ans = true;
        break;
      }
    }
  }

  if(ans) cout << ":(" << endl;
  else cout << "Yay!" << endl;

}

















//


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

int main(void) {
	int N, T;
	int min = 1000;
	int count = 0;
	cin >> N >> T;
	vector <int>c(N);
	vector <int>t(N);
	for (int i = 0; i < N; i++) cin >> c[i] >> t[i];
	for (int i = 0; i < N; i++) {
		if (t[i] <= T&&c[i] < min) {
			min = c[i];
		}
		else if (t[i] > T) {
			count++;
		}
	}
	if (count == N) {
		cout << "TLE" << endl;
		return 0;
	}
	cout << min << endl;
	return 0;
}

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

fn main() {
    input! {
        a: f64, b: f64
    }

    println!("{}", ((a+b)/2.0).ceil());
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int digit_counter(int num) {
    int digit=0;
    while(num) {
        digit++;
        num /= 10;
    }
    return digit;
}

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

    int sum=0;

    int i;
    for(i=1; i<=n; i++) {
        if(digit_counter(i)%2==1) {
            sum += 1;
        }
    }

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

    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdlib.h>
using namespace std;

int main(){
  int n;
  vector<double> x;
  vector<double> y;
  double tmp;
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> tmp;
    x.push_back(tmp);
  }
  
  for (int i = 0; i < n; i++){
    cin >> tmp;
    y.push_back(tmp);
  }

  // p = 1
  double p1 = 0.0;
  for (int i = 0; i < n; i++){
    p1 += fabs(x[i] - y[i]);
  }
  
  // p = 2
  double p2 = 0.0;
  for (int i = 0; i < n; i++){
    p2 += pow(x[i] - y[i], 2);
  }
  p2 = pow(p2, 0.5);

  // p = 3
  double p3 = 0.0;
  for (int i = 0; i < n; i++){
    p3 += pow(fabs(x[i] - y[i]), 3);
  }
  p3 = cbrt(p3);

  // p = mugen
  double p4 = -100000;
  for (int i = 0; i < n; i++){
    if (fabs(x[i] - y[i]) > p4){
      p4 = fabs(x[i] - y[i]);
    }
  }

  cout << fixed;
  cout << setprecision(9) << p1 << endl;
  cout << setprecision(9) << p2 << endl;
  cout << setprecision(9) << p3 << endl;
  cout << setprecision(9) << p4 << endl;
}


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

using namespace std;

int main()
{
	string S;
	int A_flag = 0;
	int B_flag = 0;

	cin >> S;

	for(int i = 0; i < 3; i++){
		if(S[i] == 'A')
			A_flag = 1;
		else
			B_flag = 1;
	}

	if(A_flag && B_flag)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, M;
vector<pii> g[100];
int d[100][3];

int main() {
	while (cin >> N >> M, N || M) {
		REP(i, N) g[i].clear();
		
		REP(i, M) {
			int a, b, c;
			scanf("%d %d %d", &a, &b, &c);
			a--; b--;
			g[a].push_back(pii(b, c));
			g[b].push_back(pii(a, c));
		}
		
		fill(d[0], d[N], INF);
		
		priority_queue<pip, vector<pip>, greater<pip> > pq; // cost, pos, state
		pq.push(pip(0, pii(0, 0)));
		d[0][0] = 0;
		
		while (!pq.empty()) {
			pip now = pq.top(); pq.pop();
			
			int cost = now.fi;
			int u = now.se.fi;
			int s = now.se.se;
			
			if (d[u][s] < cost) continue;
			
			REP(i, g[u].size()) {
				int v = g[u][i].fi;
				
				if (s == 1) {
					if (chmin(d[v][2], cost)) pq.push(pip(cost, pii(v, 2)));
				}
				else {
					if (chmin(d[v][s], cost + g[u][i].se)) pq.push(pip(cost + g[u][i].se, pii(v, s)));
					if (s == 0 && chmin(d[v][1], cost)) pq.push(pip(cost, pii(v, 1)));
				}
			}
		}
		
		int ans = min(d[N - 1][0], d[N - 1][2]);
		cout << ans << endl;
	}

	
	return 0;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dst[1010][1010];
string s[1010];

bool good(int nx, int ny, int n, int m) {
  return 1 <= nx && nx <= n && 1 <= ny && ny <= m;
}

void solve() {
  int n, m; cin >> n >> m;
  int sx, sy, fx, fy; cin >> sx >> sy >> fx >> fy;
  for (int i = 1; i <= n; i++) {
    cin >> s[i]; s[i] = "#" + s[i];
  }
  memset(dst, -1, sizeof dst);
  dst[sx][sy] = 0;
  deque<pair<pair<int, int>, int> > q; q.push_front({{sx, sy}, 0});
  while (!q.empty()) {
    int x, y; tie(x, y) = q.front().first; int dist = q.front().second;
    q.pop_front();
    if (dst[x][y] != dist)
      continue;
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if (good(nx, ny, n, m) && s[nx][ny] == '.' && (dst[nx][ny] == -1 || dst[nx][ny] > dst[x][y])) {
        dst[nx][ny] = dst[x][y];
        q.push_front({{nx, ny}, dst[x][y]});
      }
    }
    for (int mx = -2; mx <= 2; mx++) {
      for (int my = -2; my <= 2; my++) {
        int nx = x + mx, ny = y + my;
        if (good(nx, ny, n, m) && s[nx][ny] == '.' && (dst[nx][ny] == -1 || dst[nx][ny] > dst[x][y])) {
          dst[nx][ny] = dst[x][y] + 1;
          q.push_back({{nx, ny}, dst[x][y] + 1});
        }
      }
    }
  }
  cout << dst[fx][fy];
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
    solve();
}


Measured memory_bytes: 9784
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll maxn=1e6+100;
ll h,w,a,b;
ll f[maxn],revf[maxn];
ll qpow(ll a,ll n){
	ll ans=1;
	while(n>0){
		if(n&1)	ans=(ans*a)%mod;
		n>>=1;
		a=(a*a)%mod;
	}
	return ans;
}
ll C(ll n,ll m){
	return (((f[n]*revf[m])%mod)*revf[n-m])%mod;
}
void init(){
	f[0]=1;
	revf[0]=qpow(f[0],mod-2);
	for(ll i=1;i<maxn;i++){
		f[i]=(f[i-1]*i)%mod;
		revf[i]=qpow(f[i],mod-2);
	}
}

ll count_ways(ll a,ll b,ll c,ll d){
	ll tot=(c-a)+(d-b);
	ll down=c-a;
	return C(tot,down);
}
int main(){
	init();
	scanf("%lld%lld%lld%lld",&h,&w,&a,&b);
	ll tol=count_ways(1,1,h,w);
	for(ll i=1;i<=b;i++){
		ll tmp=(count_ways(1,1,h-a,i)*count_ways(h-a+1,i,h,w))%mod;
		while(tmp>tol) tol+=mod;
		tol=(tol-tmp)%mod;
	}
	printf("%lld\n",tol);
	return 0;
}

Measured memory_bytes: 16000
#-*- coding: utf-8 -*-
"""
https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_a
"""

from collections import defaultdict
def sol(a1, b1, a2, b2, a3, b3):
    S = [a1, b1, a2, b2, a3, b3]
    d = defaultdict(int)
    for s in S:
        d[s] += 1
    if len(d) == 4:
        num2 = 0
        for k, v in d.items():
            if v == 2:
                num2 += 1
        if num2 == 2:
            return 'YES'
    return 'NO'


test = False
#test = True
if test:

    print(sol(4, 2, 1, 3, 2, 3))
    print(sol(3, 2, 2,4,1,2))
    print(sol(2,1,3,2,4,3))


    # n, k = 5, 5
    # #S =list( map(int, "7 4 0 3".split()))
    # print(sol(n, k))
    # #
    # n, k = 31, 10
    # #S =list( map(int, "1000000000000".split()))
    # print(sol(n, k))
    #
    # n, k = 10, 90
    # #S =list( map(int, "1000000000000".split()))
    # print(sol(n, k))

else:
    #n, k = map(int, input().split())
    a1, b1 =list( map(int, input().split()))
    a2, b2 =list( map(int, input().split()))
    a3, b3 =list( map(int, input().split()))
    print(sol(a1, b1, a2, b2, a3, b3))




Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <set>
#include <map>
#include <string>

using namespace std;

string getStr(int n)
{
    string res = std::to_string(n);
    while(res.length() != 6) res = "0" + res;
    return res;
}

bool sortVec(pair<int, int> p1, pair<int, int> p2)
{
    return p1.second < p2.second;
}

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

    int p[m];
    vector<pair<int, int>> vec[n + 1];

    for(int i=0; i<m; i++)
    {
        int y;
        cin >> p[i]; cin >> y;
        vec[p[i]].emplace_back(make_pair(i, y));
    }

    for(int i=0; i<=n; i++) sort(vec[i].begin(), vec[i].end(), sortVec);

    int order[m];
    for(int i=0; i<=n; i++)
    {
        for(int j=0; j<vec[i].size(); j++)
        {
            //cout << i << " " << j << " " << vec[i][j].first << " " << vec[i][j].second << endl;
            order[vec[i][j].first] = j + 1;
        }
    }

    for(int i=0; i<m; i++)
    {
        cout << getStr(p[i]) << getStr(order[i]) << endl;
    }


    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> l(2 * n,0);
	for(int i=0;i<2*n;i++)
	{
		cin >> l.at(i);
	}
	sort(l.begin(),l.end());
	int sm = 0;
	for(int i=0;i<2*n;i++)
	{
		if(i % 2 == 0)
		{
			sm += l.at(i);
		}
	}
    cout << sm << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int) (x.size())
#define fi first
#define se second

const int N = 1e5 + 1e3;
vector<int> h(N);
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, a, b;
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    int tl = 1, tr = 1e10;
    int  ans = 1e10;
    while (tl <= tr) {
        int tm = (tl + tr) / 2;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            int x = h[i] - tm * b;
            if (x > 0)
                cnt += (x + a - b - 1) / (a - b);
        }
        if (cnt <= tm) {
            ans = min(ans, tm);
            tr = tm - 1;
        } else {
            tl = tm + 1;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1024
-- module-summation.hs ---

-- author: Seong Yong-ju <sei40kr@gmail.com>

main :: IO ()
main = do
  n <- (read :: String -> Int) <$> getLine
  as <- map (read :: String -> Int) . take n . words <$> getLine
  print $ (sum . map (-1 +)) as


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod=10007;

int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  //cout<<endl;
  int64_t sum=0;
  for(int i=0;i<N;i++){
    sum+=A[i]/2;
    if(i<N-1&&A[i+1]!=0&&A[i]%2!=0){
      sum++;
      A[i]--;
      A[i+1]--;
    }
  }
  cout<<sum<<endl;
  return 0;  
}

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

#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define br cout<<"\n"
using namespace std;


int dr[]={1,-1,0,0};
int dc[]={0,0,1,-1};
ll mod=1000000007;
ll po(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n%2==1)
            res = ((res)*(x));
        x = (x*x);
        n = n/2;
    }
    return res;
}
ll ceil(ll x,ll y)
{
    if(x%y==0)
        return x/y;
    else
        return(x/y)+1;
}
ll binomialCoeff(int n, int k)
{
    ll res = 1;
    if (k > n - k)
        k = n - k;

    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    if(n>=400 && n<=599)
        cout<<8;
    else if(n>=600 && n<=799)
        cout<<7;
    else if(n>=800 && n<=999)
        cout<<6;
    else if(n>=1000 && n<=1199)
        cout<<5;
    else if(n>=1200 && n<=1399)
        cout<<4;
    else if(n>=1400 && n<=1599)
        cout<<3;
    else if(n>=1600 && n<=1799)
        cout<<2;
    else
        cout<<1;
	return 0;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            //var length = c2i(RL());
            var rl = spr(RL()).Select(x=>c2i(x)).ToList();
            var A=rl[0];
            var B=rl[1];
            var C = rl[2];
            var K = rl[3];
            long ret = 0;
            if (K <= A)
            {
                ret = K;
            }
            else if (K <= (A + B))
            {
                ret = A;
            }
            else
            {
                ret = A+((A+B) - K);
            }



            Console.WriteLine((ret));
            //Console.ReadLine();
        
        }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


Measured memory_bytes: 28256
/*
 * ALDS1_4_A.cpp
 *
 *  Created on: Apr 26, 2018
 *      Author: 13743
 */

#include<iostream>

using namespace std;

int main() {
	int cnt = 0;
	int n, q;
	int S[10000];
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> S[i];
	}
	cin >> q;
	for(int i=0; i<q; i++) {
		int x;
		cin >> x;
		for(int j=0; j<n; j++) {
			if(x == S[j]) {
				cnt++;
				break;
			}
		}
	}
	cout << cnt << endl;


}





Measured memory_bytes: 3088
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;

struct edge {
  pair<int,int> to;
  int cost;
};

const int NMAX = 108, MMAX = 108;
const int INF = 1e7;

// cost, node, life
typedef pair<int,pair<int,int>> P;

P make_tuple(int cost, int node, int life) {
  return make_pair(cost, make_pair(node, life));
}

int abs(int x) {
  return (x > 0 ? x : -x);
}


int main() {
  int N, M, L, K, A, H;
  while (cin >> N >> M >> L >> K >> A >> H and N) {
    vector<edge> G[NMAX][MMAX];
    set<int> freezers;
    for (int i = 0; i < L; i++) {
      int l;
      cin >> l;
      freezers.insert(l);
    }
    freezers.insert(A);
    freezers.insert(H);

    for (int i = 0; i < K; i++) {
      int x, y, t;
      cin >> x >> y >> t;
      for (int life = t; life <= M; life++) {
        G[x][life].push_back((edge){make_pair(y,life-t),t});
        G[y][life].push_back((edge){make_pair(x,life-t),t});
      }
    }

    for (int v = 0; v < N; v++) {
      if (freezers.find(v) == freezers.end()) continue;
      for (int life = 0; life < M; life++) {
        G[v][life].push_back((edge){make_pair(v,life+1),-1});
      }
    }

    int cost[NMAX][MMAX];
    for (int v = 0; v < N; v++) {
      for (int life = 0; life <= M; life++) {
        cost[v][life] = INF;
      }
    }
    priority_queue<P, vector<P>, greater<P>> que;
    cost[A][M] = 0;
    que.push(make_tuple(0, A, M));
    while (!que.empty()) {
      P p = que.top(); 
      que.pop();
      int now = p.first, here = p.second.first,
          remain = p.second.second;
//      cout << endl << "Here=(" << here << "," << remain 
//        << "), Now=" << now << endl;
      if (cost[here][remain] < now) {
        continue;
      }
//      cout << "push:";
      for (edge e : G[here][remain]) {
        pair<int,int> next = e.to;
        int next_time = now + abs(e.cost);
        if (cost[next.first][next.second] > next_time) {
          cost[next.first][next.second] = next_time;
          que.push(make_tuple(next_time, next.first, next.second));
//          cout << "(" << next.first << "," << next.second << ")";
        }
      }
//      cout << endl;
    }
    int ans = INF;
    for (int life = 0; life <= M; life++) {
      ans = min(ans, cost[H][life]);
    }
    if (ans == INF) {
      cout << "Help!" << endl;
    } else {
      cout << ans << endl;
    }
  }
}

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

int main() {
  int Q; cin >> Q;
  while (Q--) {
    ll A, B; cin >> A >> B;
    if (A > B) swap(A, B);

    ll ans;
    if (A == B) {
      ans = 2 * A - 2;
    } else if (A + 1 == B) {
      ans = 2 * A - 2;
    } else {
      ll C = sqrt(A * B);
      if (C * C == A * B) --C;
      if (C * (C + 1) < A * B) {
        ans = 2 * C - 1;
      } else {
        ans = 2 * C - 2;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}   

int main()
{                                  
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  int n;
  cin >> n;  

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int x; cin >> x;
    static int prev = 0;
    static int len = 0;

    if (prev == x)
      len++; 
    else
      len = 1;

    if (len == 2)
      ans++, len = 0;

    prev = x;
  }    
  cout << ans;

  return 0;
}






// Coded by Z..



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n, x;
    cin >> n >> x;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }
    Sort(a);
    lli i = 0;
    lli ans = 0;
    while (x>= a[i] )
    {
        ans++;

        x -= a[i];

        i++;
        if(i>=a.size())
        {
            if(x>0)
            {
                ans--;
            }
            
            break;
        }

    }
    out(ans);
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W;
    cin >> H>>W;
    if(H==1 || W==1)cout <<1<<endl;
    else if(H%2==1 && W%2==1)cout << (((H*W)/2)+1)<<endl;
    else cout << (H*W)/2<<endl;
    }

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

int main() {
  
  int a, b;
  cin >> a >> b;
  int ans;
  
  if (a >= b) {
    ans += a;
    a = a - 1;
  } else {
    ans += b;
    b = b - 1;
  }
  
  if (a >= b) {
    ans += a;
    a = a - 1;
  } else {
    ans += b;
    b = b - 1;
  }
  
  cout << ans;
  
}


Measured memory_bytes: 256