akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let a:f64 = sc.read();
    let pi:f64 = std::f64::consts::PI;
    let area = format!("{:.*}", 5, a*a*pi);
    let circumference = format!("{:.*}", 6, 2 as f64 *pi*a);
    println!("{} {}", area, circumference);
}

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
 
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 5052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,M,work;
	cin >> N >> M;
	vector<int> R(N,0);
	
	for(int i=0; i<M*2; i++){

		cin >> work;
		R.at(work-1)++;
	}
	
	for(int i=0; i<N; i++){
		cout << R.at(i) << endl;
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int N, int M) { 
    VVI st(M + 1, VI(1300, 0));
    int r; cin >> r;
    REP(i, r) {
        int t, n, m, s;
        cin >> t >> n >> m >> s;
        if (s) {
            st[m][t]++;
        } else {
            st[m][t]--;
        }
    }
    REP(i, M + 1)REP(j, 1299) {
        st[i][j + 1] += st[i][j];
    }
    int q; cin >> q;
    REP(i, q) {
        int s, e, m;
        cin >> s >> e >> m;
        int ans = 0;
        FOR(i, s, e) {
            if (st[m][i]) ans++;
        }
        cout << ans << endl;
    }
    return;
}

signed main(void) {
    int n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    while (cin >> n >> m, n) {
        solve(n, m);
        //return 0;
    }
}

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

int main(void){
    int n, m;
    cin>>n>>m;
    vector<int> v(m);
    rep(i, m) cin>>v[i];

    sort(v.begin(), v.end());
    int ans=v[m-1]-v[0];
    priority_queue<int> que;
    rep(i, m-1) que.push(v[i+1]-v[i]);
    while(!que.empty()&&n-1>0) {
        ans-=que.top();
        //cout<<ans<<endl;
        que.pop();
        n--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL x,y;
LL cnt(LL x, LL y){
	if(y<x)return 1e11;
	return y-x;
}

int main(){
	cin>>x>>y;
	LL ans=1e11;
	if(x<y){
		ans=min(cnt(x,y),cnt(-x,y)+1);
		ans=min(ans,cnt(y,-x)+1);
	}else{
		ans=min(cnt(y,x)+2,cnt(-x,y)+1);
		ans=min(ans,cnt(x,-y)+1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 505
using namespace std;
typedef long long ll;
int a[maxn][maxn];
inline int in()
{
    int res=0;
    char c=getchar();
    if (c>='0'&&c<='9') res=c-48;
    while((c=getchar())>='0'&&c<='9') res=res*10+c-48;
    return res;
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m, q;
    n = in(), m = in(), q = in();
    while (m--){
        int l, r;
        l = in(), r = in();
        ++a[l][r];
    }
    for (int i = n; i >= 1; --i){
        for (int j = 1; j <= n; ++j){
            a[i][j] += a[i + 1][j] + a[i][j - 1] - a[i + 1][j - 1];
        }
    }
    while (q--){
        int l, r;
        l = in(), r = in();
        cout << a[l][r] << '\n';
    }
    return 0;
}


Measured memory_bytes: 1920
#include <cstdio>
#include <algorithm>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using usize = std::size_t;

auto dfs(i32 k, i32 r, i32 g, i32 b) -> bool {
	bool ok = (g > r) && (b > g);
	if (!ok && k > 0) {
		ok |=
			dfs(k - 1, 2 * r, g, b) |
			dfs(k - 1, r, 2 * g, b) |
			dfs(k - 1, r, g, 2 * b);
	}
	return ok;
}

auto main() -> i32 {
	i32 r, g, b, k;
	scanf("%d%d%d%d", &r, &g, &b, &k);
	bool ok = dfs(k, r, g, b);
	puts(ok ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 1652
# -*- coding: utf-8 -*-
import bisect
import sys
input = sys.stdin.readline
 
 
def main():
    n = int(input())
    l = list(map(int, input().split()))
    l = sorted(l)
 
    result = 0
    for i in range(n-2):
        for j in range(i + 1, n - 1):
            result += bisect.bisect_left(l, l[i] + l[j]) - (j + 1)
 
    print(result)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 42204
#include <cstdio>
#include <vector>
using namespace std;

typedef vector<int> v;
typedef v::iterator vi;

static inline int in()
{
    int c, n = 0;
    while ((c = getchar_unlocked()) >= '0' && c <= '9')
		n = 10 * n + (c - '0');
    return n;
}

#define pcu putchar_unlocked
static inline void out(int n)
{
	static char buf[20];
	char *p = buf;
	if (!n)
		*p++ = '0';
	else
		while (n)
			*p++ = n % 10 + '0', n /= 10;
	while (p != buf)
		pcu(*--p);
}

int main()
{
	v A(in());

	for (int &x : A)
		x = in();

	vi x = A.end() - 1, i = A.begin(), j = i;

	for (;j != x;j++)
		if (*j <= *x)
			swap(*j, *i++);
	swap(*i, *x);

	for (int &x : A) {
		if (&x != &A[0])
			pcu(' ');
		if (&x == &*i)
			pcu('['), out(x), pcu(']');
		else
			out(x);
	}
	puts("");
}



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

int main()
{
    int n, w;
    cin >> n >> w;
    vector<int> weights(n), profits(n);
    for(int i = 0; i < n; i++)
        cin >> weights[i] >> profits[i];
    vector<long> dp(w + 1), dp1;
    for(int i = 0; i < n; i++)
    {
        for(int j = w; j >= weights[i]; j--)
        {
            dp[j] = max(dp[j], dp[j - weights[i]] + (long)profits[i]);
        }
    }
    cout << dp[w];
    return 0;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<vector>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long N; cin >> N;
	long F[200][20]; for (int i = 0; i < N; i++) for (int j = 0; j < 10; j++) cin >> F[i][j];
	long P[200][20]; for (int i = 0; i < N; i++) for (int j = 0; j <= 10; j++) cin >> P[i][j];
	long res = INT_MIN;

	//bit全探索か。
	for (long mybit = 1; mybit < (1 << 10); mybit++) {  //営業時間ごとの(mybit != 0)
		long bitres = 0;                                //利益の
		for (long shop = 0; shop < N; shop++) {         //店ごとの
			long Pcount = 0;
			for (long keta = 0; keta < 10; keta++) {    //時間帯ごとの
				if ((mybit & (1 << keta)) != 0 && F[shop][keta] == 1) Pcount++; 
			}
			bitres += P[shop][Pcount];
		}
		res = max(res, bitres);                         //最大値をとる。
	}

	cout << res << endl;
}

Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline().strip())
A = list(map(int, sys.stdin.readline().strip().split()))


ans = 1
state = -1
for i in range(1, N):
    if state == -1:
        if A[i] < A[i-1]:
            state = 0
        elif A[i] > A[i-1]:
            state = 1
    elif (state == 0 and A[i] > A[i-1]) or (state == 1 and A[i] < A[i-1]):
        ans += 1
        state = -1
 
print(ans)

Measured memory_bytes: 62788
H,W=map(int,input().split())
l=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
a=b=''
for i in range(H):
  l2=list(map(str,input().split()))
  for j in range(W):
    if l2[j]=='snuke':
      a=l[j]
      b=str(i+1)
print(a+b)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();

      int[] p = new int[n];
      for(int i = 0; i < n ; i++) {
        p[i] = sc.nextInt();
      }
      
      int cnt = 0;
      for(int i = 1; i <= n; i++) {
        if(p[i-1] != i) 
          cnt++;
      }
      
      if((cnt==0)|| (cnt==2)) {
        System.out.println("YES");
      } else {
        System.out.println("NO");
      }
      

    
    }
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

int main(){
	int n;
	cin>>n;
	int a[n];
	for (int i = 0; i < n; ++i){
		cin>>a[i];
	}


	int cnt=0;
	bool flag = true;
	while(flag){
		flag=false;
		for (int i = n-1; i > 0 ; --i){
			if(a[i]<a[i-1]){
				swap(a[i],a[i-1]);
				cnt++;
				flag=true;
			}
		}
	}

	for (int i = 0; i < n; ++i){
		if(i!=n-1){
			cout<<a[i]<<" ";
		}else{
			cout<<a[i]<<endl;
			cout<<cnt<<endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3108
n, x = map(int, input().split())
a = list(map(int,input().split()))
a.sort()
c = 0
while x-a[c] >= 0:
    x -= a[c]
    c += 1
    if x == 0:
        break
    elif c == n:
        c -= 1
        break
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <climits>
#include <cmath>

int main(void) {
  int A, B, C, D, E, F;
  std::cin >> A >> B >> C >> D >> E >> F;

  // maximize(100b/(a+b))[%]
  // s.t : a + b <= F
  //           b <= E * a / 100
  //       a = 100A * w1 + 100B * w2
  //       b =    C * s1 +    D * s2
  //       1 <= A < B <= 30
  //       1 <= C < D <= 30
  //       1 <= E <= 100
  //       100A <= F <= 3000

  int res_a = 0;
  int res_b = 0;
  double max = 0.0;
  int max_w1 = F / 100 / A + 1;
  for (int w1 = 0; w1 <= max_w1; w1++) {
    //std::cout << "W1:" << w1 << std::endl;
    int max_w2 = (F - 100 * A * w1) / 100 / B + 1;
    for (int w2 = 0; w2 <= max_w2; w2++) {
      //std::cout << "W2:" << w2 << std::endl;
      int a = 100*A*w1 + 100*B*w2;
      int max_b = F - a;
      int max_s1 = max_b / C + 1;
      for (int s1 = 0; s1 <= max_b; s1++) {
        int max_s2 = (max_b - C * s1) / D + 1;
        for (int s2 = 0; s2 <= max_b; s2++) {
          int b = C * s1 + D * s2;
          if (b > E * a / 100 || a + b > F) {
            break;
          }
          double den = 100.0 * b / (a + b);
          if (den >= max) {
            max = den;
            res_a = a + b;
            res_b = b;
          }
        }
      }
    }
  }

  std::cout << res_a << " " << res_b << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::string S){
  set<ll> R,G,B;
  REP(N){
    switch (S[i])
    {
    case 'R':
      R.insert(i);
      break;
    case 'G':
      G.insert(i);
      break;
    default:
      B.insert(i);
      break;
    }
  }
  ll ans=0;
  for (auto &&r : R)
  {
    for (auto &&g : G)
    {
      ans+=B.size();
      if(B.count(abs(r-g)+max(r,g))){
        --ans;
      }
      if(B.count(min(r,g)-abs(r-g))){
        --ans;
      }
      if(abs(r-g)%2==0&&B.count((r+g)/2)){
        --ans;
      }
    }
  }
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 3884
import java.util.*;
import static java.lang.Math.*;

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

		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}

		// 計算
		String result = "NO";
		int[] b = Arrays.copyOf(a, n);
		Arrays.sort(b);
		//System.out.println(Arrays.toString(b));
		int cnt = 0;
		for(int i = 0; i < n; i++){
		    if(a[i] != b[i]) cnt++;
		}
		if(cnt == 0 || cnt == 2) result = "YES";
		// 出力
		System.out.println(result);
	}
	
}


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

int
main(int argc, char** argv) {
    int n;
    std::cin >> n;

    std::vector<int> v;
    std::vector<int> sortv;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        v.emplace_back(a);
        sortv.emplace_back(a);
    }
    std::sort(sortv.begin(), sortv.end());


    for (int i = 0; i < n; i++) {
        if (v[i] < sortv[sortv.size()-1]) {
            std::printf("%d\n", sortv[sortv.size()-1]);
        } else {
            std::printf("%d\n", sortv[sortv.size()-2]);
        }
    }

    return 0;
}

Measured memory_bytes: 3436
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;
const ll INF = 1LL << 60;
const double PI = acos(-1.0);



int main() {

	int n, k;
	cin >> n >> k;
	vector<ll>a(n);
	for (int i = 0; i < n; i++)cin >> a[i];

	vector<ll> maa(n); maa[0] = a[0];
	for (int i = 1; i < n; i++) {
		maa[i] = max(a[i], maa[i - 1]);
	}

	ll ans = 1e15;
	for (int i = 0; i < (1 << n); i++) {
		vector<int> idx;
		vector<ll> pma(n);
		for (int i = 0; i < n; i++)pma[i] = maa[i];
		for (int j = 0; j < n; j++) {
			if (i >> j & 1)idx.push_back(j);
		}
		if (idx.size() < k)continue;
		ll tmp = 0;
		for (int ii = 0; ii < idx.size(); ii++) {
			if (idx[ii] == 0)continue;
			ll leftmx = *max_element(pma.begin(), pma.begin() + idx[ii]);
			if (a[idx[ii]] <= leftmx) {
				tmp += (ll)leftmx - a[idx[ii]] + 1;
				pma[idx[ii]] = (ll)leftmx + 1;
			}
		}
		ans = min(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var h, a int
  fmt.Scanf("%d", &h)
  fmt.Scanf("%d", &a)
  
  if (h % a == 0){
  	fmt.Println(h / a)
  }else{
    fmt.Println( (h / a) + 1)
  }
}

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

int main() {
  ll n;cin>>n;
  ll mod=1e9+7;
  if(n==1)cout<<0<<endl;
  else if(n==2)cout<<2<<endl;
  else{
    ll cnt1=1,cnt2=1,cnt3=1;
    rep(i,n){
      cnt1*=10;
      cnt1%=mod;
      cnt2*=9;
      cnt2%=mod;
      cnt3*=8;
      cnt3%=mod;
    }
    ll ans=(cnt1-2*cnt2%mod+cnt3)%mod;
    if(ans<0)ans+=mod;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep1(i,n) for(int i = 1;i<=n;i++)
#define unrep(i,n) for(int i = n;i>0;i++)
using namespace std;
int n,q,S[10000],T[500];
int ans = 0;
int MyLinearSearch(int a){
  rep(i,q){
    if(a == T[i]){
     ans++;
     break;
   }
  }
}

int main(){
  cin >>n;
  rep(i,n)cin >>S[i];
  cin >>q;
  rep(i,q)cin >>T[i];
  sort(S,S+n);
  int oldnum = -1;
  rep(i,n){
    if(oldnum != S[i])MyLinearSearch(S[i]);
    oldnum = S[i];
  }
  cout << ans <<endl;
}



Measured memory_bytes: 3140
#include <iostream>

using namespace std;

int main(){
 long long n,i,a[100010],b[100010],sum=0,mx=0;
 cin >> n;
 for(i=0;i<n;i++){
     cin >> a[i];
     sum += a[i];
 }

if(sum%(n*(n+1)/2)!=0){
    cout << "NO" << endl;
    return 0;
}
long long k = sum/(n*(n+1)/2);

 for(i=0;i<n;i++){
     b[i] = a[0]+i*k-a[i];
     if(b[i]%n!=0){
         cout <<"NO" << endl;
         return 0;
     }
 }

for(i=0;i<n-1;i++){
    if(b[i]>b[i+1] ){
        cout << "NO" << endl;
        return 0;
    }
}

if(b[n-1]/n>k){
    cout << "NO" << endl;
    return 0;
}
    
    cout <<"YES" << endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int main(){
  int x,y;
  cin >> x >> y;
  if(y%2!=0){
    cout << "No\n";
    return 0;
  }
  int a = y/2 - x;
  if(a<0){
    cout << "No\n";
    return 0;
  }
  int b = 2*x-y/2;
  if(b<0){
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 3628
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
ans = []

while N != 0:
    N -= 1
    p, r = divmod(N, 26)
    ans.append(ascii_lowercase[r])
    N = p

print("".join(ans[::-1]))


Measured memory_bytes: 10048
N,K = map(int,input().split())
list = []
m = -1
for i in range(N):
    list.append(int(input()))
List = sorted(list)
for i in range(N-K+1):
    mt = List[i+K-1]-List[i]
    if m == -1 or m > mt:
        m = mt
print(m)


Measured memory_bytes: 8280
#include<cstdio>
#include<math.h>

using namespace std;

int A[1000000];
int Eratosthenes(int n)
{
	int mama = 0;
	for (int i = 0; i < n; i++)
	{
		A[i] = 1;
	}
	for (int i = 2; i < sqrt(n); i++)
	{
		if (A[i])
		{
			for (int j = 0; i*(j + 2) < n; j++)
			{
				A[i*(j + 2)] = 0;
			}
		}
	}

	for (int i = 2; i < n; i++)
	{
		if (A[i])
		{
			mama++;
		}
	}
	return mama;
}

int main()
{
	int n;

	while ((scanf("%d",&n))!= -1)
	{
		printf("%d\n", Eratosthenes(n+1));
	}
	return 0;
}

Measured memory_bytes: 6584
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;

static class P
{
    static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var s = Console.ReadLine();

        List<int> streaks = new List<int>();
        if (s[0] != '1') streaks.Add(0);
        int current = 1;
        for (int i = 1; i < s.Length; i++)
        {
            if (s[i - 1] == s[i]) current++;
            else
            {
                streaks.Add(current);
                current = 1;
            }
        }
        streaks.Add(current);
        if (s.Last() != '1') streaks.Add(0);

        int res = 0;
        int currentSum = 0;
        var end = Min(streaks.Count, nk[1] * 2 + 1);
        for (int i = 0; i < end; i++)
        {
            currentSum += streaks[i];
        }
        res = currentSum;
        for (int i = end; i < streaks.Count;)
        {
            currentSum += streaks[i];
            currentSum -= streaks[i - end];
            i++;
            currentSum += streaks[i];
            currentSum -= streaks[i - end];
            i++;
            res = Max(res, currentSum);
        }
        Console.WriteLine(res);
    }
}



Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

ll h, a, b, ans;
/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();

    cin >> h >> a >> b;

    for (int i=a; i<=b; i++) {
        ans += h % i == 0;
    }

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



Measured memory_bytes: 3212
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

bool judge(int[] A, int[] B, int C, int M) {
  int sum = C;

  foreach (i; 0..M) {
    sum += A[i] * B[i];
  }

  return sum > 0;
}

void main() {
  int[] NMC = readln.chomp.split.to!(int[]);
  int N = NMC[0],
      M = NMC[1],
      C = NMC[2];
  int[] B = readln.chomp.split.to!(int[]);

  int[][] As;
  As.length = N;

  foreach (i; 0..N) {
    As[i] = readln.chomp.split.to!(int[]);
  }

  writeln(As.count!(A => A.judge(B, C, M)));
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int n;
  scanf("%d", &n);

  typedef struct {
    int vn;
    int num;
  } cnt;

  cnt c1[100000 / 2];
  cnt c2[100000 / 2];
  int c1_idx = 0;
  int c2_idx = 0;
  for(int i = 0; i < n; i++)  {
    int v;
    scanf("%d", &v);

    cnt *c;
    int *idx;
    if(i % 2 == 0) {
      c = c1;
      idx = &c1_idx;
    } else {
      c = c2;
      idx = &c2_idx;
    }

    int flag = 0;
    for(int j = 0; j < *idx; j++) {
      if(c[j].vn == v) {
	c[j].num++; 
	flag = 1;
	break;
      }
    }

    if(flag == 0){
      c[*idx].vn = v;
      c[*idx].num = 1;
      *idx = *idx + 1;
    }
  }

#ifdef DEBUG  
  for(int i = 0; i < c1_idx; i++) {
    printf("c1[%d].vn == %d, num == %d\n", i, c1[i].vn, c1[i].num);
  }
  for(int i = 0; i < c2_idx; i++) {
    printf("c2[%d].vn == %d, num == %d\n", i, c2[i].vn, c2[i].num);
  }
#endif

  // Search Maximum Number
  int c1_max1 = 0;
  int c1_max2 = 0;
  int c1_idx1;
  for(int i = 0; i < c1_idx; i++) {
    if(c1[i].num >= c1_max1) {
      c1_max2 = c1_max1;
      c1_max1 = c1[i].num;
      c1_idx1 = i;
    } else if(c1[i].num > c1_max2) {
      c1_max2 = c1[i].num;
    }
  }

  int c2_max1 = 0;
  int c2_max2 = 0;
  int c2_idx1;
  for(int i = 0; i < c2_idx; i++) {
    if(c2[i].num >= c2_max1) {
      c2_max2 = c2_max1;
      c2_max1 = c2[i].num;
      c2_idx1 = i;
    } else if(c2[i].num > c2_max2) {
      c2_max2 = c2[i].num;
    }
  }

  if(c1[c1_idx1].vn == c2[c2_idx1].vn) {// same number..
    if((c1_max1 + c2_max2) < (c2_max1 + c1_max2)) {// c1 will be modified.
      c1_max1 = c1_max2;
    } else {// c2 will be modified.
      c2_max1 = c2_max2;
    }
  }

  // c1 and c2 is different number
  printf("%d\n", n - (c1_max1 + c2_max1));

  return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] c = { 125, 140, 160 };
        while (true) {
            int n = sc.nextInt();
            int d = 3130;
            if (n == -1) {
                break;
            }
            for (int i = 30; i > 0; i -= 10) {
                if (n > i) {
                    d-= (n - i) * c[i / 11];
                    n = i;
                }
            }
            System.out.println(d);
        }
    }
}


Measured memory_bytes: 26308
#include <stdio.h>
#include <time.h>

int main ()
{
    int initial,j,max,minv;
    scanf("%d",&initial);
    int *p;
    p = (int *)malloc(initial*sizeof(int));
    for(j = 0;j < initial;j++)
    {
        scanf("%d",&p[j]);
    }
    minv = p[0];
    max = p[1] - p[0];
    for(j = 1;j < initial;j++)
    {
        if(max < (p[j] - minv))
            max = p[j] - minv;
        if(minv>p[j])
            minv = p[j];
    }
    printf("%d\n",max);
    free(p);
    return 0;
}



Measured memory_bytes: 2288
s = list(input())
t = list(input())

flag=0
if len(t) > len(s):
    print("UNRESTORABLE")
else:
    index = len(s)-len(t)
    while index > -1:
        index2=0
        while index2 < len(t):
            if s[index+index2] == t[index2] or s[index+index2] == "?":
                index2+=1
            else:
                break
        if index2!=len(t):
            index-=1
        else:
            flag=1
            index2=0
            while index2 < len(t):
                if s[index+index2] == "?":
                    s[index+index2] = t[index2]
                index2+=1
            index3=0
            while index3 < len(s):
                if s[index3] == "?":
                    s[index3] = "a"
                index3+=1
            break
    if index == -1 and flag==0:
        print("UNRESTORABLE")
    else:
        print("".join(s))

Measured memory_bytes: 3064
N = int(input())
x = []
y = []
h = []
for i in range(N) :
    p, q, r = map(int,input().split())
    x.append(p)
    y.append(q)
    h.append(r)

for Cx in range(101) :
    for Cy in range(101) :
        for i in range(N) :
            if h[i] :
                H = h[i] + abs(x[i] - Cx) + abs(y[i] - Cy)
                break
        ans = True
        for i in range(N) :
            if h[i] != max(H - abs(x[i] - Cx) - abs(y[i] - Cy), 0) :
                ans = False
        if ans :
            print(Cx, Cy, H)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 6010, mod = 998244353;
int fac[N+10],ifac[N+10];
inline int Mod(int x){
	return x>=mod?x-mod:x;
}
inline int power(int a,int b){
	int ret=1;
	for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) ret=1ll*ret*a%mod;
	return ret;
}
inline void init(int n){
	fac[0]=1;
	For(i,1,n) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=power(fac[n],mod-2);
	Dow(i,n-1,0) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
}
inline int C(int n,int m){
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int n,m,f[N][N],g[N][N],cnt[N],s[N];

int main(){
	n=read(),m=read(),init(N);
	f[0][0]=1;
	For(i,0,m) g[i][0]=1;
	For(i,1,m)
		For(j,1,n) f[i][j]=Mod(f[i-1][j-1]+f[i-2][j-1]),g[i][j]=Mod(g[i-1][j]+f[i][j]);
	int ans=0;
	for (int i=0,k=2;i<=m-2;i+=2,k++){//强制选 i 和 i+1
		For(j,0,m-1-(i+1)) cnt[k+j]=Mod(cnt[k+j]+g[m-1-(i+1)][j]);
		For(j,0,m-1-(i+1)) if (f[m-1-(i+1)][j]){
			int l=k+j;
			//For(p,1,k-2) cnt[l+p]=Mod(cnt[l+p]+f[m-1-(i+1)][j]);
			s[l+1]=Mod(s[l+1]+f[m-1-(i+1)][j]);
			s[l+(k-1)]=Mod(s[l+(k-1)]+mod-f[m-1-(i+1)][j]);
		}
	}
	For(i,1,n+1) s[i]=Mod(s[i]+s[i-1]),cnt[i]=Mod(cnt[i]+s[i]);
	if (m&1){
		For(k,1,n+1) cnt[k]=Mod(cnt[k]+1);
	} else {
		For(i,1,m/2) cnt[i]=Mod(cnt[i]+1);
	}
	For(i,1,n+1) if (cnt[i]) ans=(ans+1ll*cnt[i]*C(n,i-1))%mod;
	printf("%d\n",ans);
}

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

int main() {
    int c[3];
    while (cin >> c[0] >> c[1] >> c[2]) {
        int under20 = 0;
        int sum = c[0] + c[1];
        for (int i = 1; i <= 10; i++) {
            if (i != c[0] && i != c[1] && i != c[2] && sum + i <= 20) {
                under20++;
            }
        }
        if (under20 > 3.5) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++)
    cin >> a[i];
  ll ans = 0;
  for(int i=0;i<n;i++) {
    ans += a[i] / 2;
    if(i < n-1 && a[i+1] != 0)
      a[i+1] += a[i] % 2;
  }
  cout << ans << endl;

}


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

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library
//

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    ll L, R; cin >> L >> R;
    if (R - L >= 2019){
        cout << 0 << endl;
        return 0;
    }
    
    ll ans = INF64;
    for (ll i = L; i < R; ++i){
        for (long long j = i + 1; j <= R; ++j){
            ans = min(ans, (i * j) % 2019);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P  = pair<int, int>;
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; }

int main()
{
    ll a;
    string  b;
    cin >> a >> b;
    auto pos = b.find('.');
    int prod = b.size()-pos -1;
    string c = b.substr(0, pos) + b.substr(pos+1, prod+1);
    

    ll t10 = 1;
    rep(i, prod) t10 *= 10;
    ll B = stoll(c);
    ll C = a*B;
    cout << C/t10 << endl;


    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
 
#define INF 1120000000
 
int main(){
  int a,b;
  cin>>a>>b;
  if(a%3==0 || b%3==0 || (a+b)%3==0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
 
  return 0;
}

Measured memory_bytes: 256
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
//#include <unordered_set>
//#include <unordered_map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;

class SplitStream {
	typedef basic_ostream<char, char_traits<char> > BaseOst;
	std::ostream& ost_m;
	bool line_is_empty_m;
public:
	SplitStream(std::ostream& ost);
	template <typename T>
	SplitStream& operator<<(T right);
	SplitStream& operator<<(BaseOst& (*right)(BaseOst&));
};
SplitStream::SplitStream(std::ostream& ost) : ost_m(ost), line_is_empty_m(true) {}
template <typename T>
SplitStream& SplitStream::operator<<(T right) {
	if (!line_is_empty_m) ost_m << ' ';
	line_is_empty_m = false;
	ost_m << right;
	return *this;
}
/* std::endl のみ */
SplitStream& SplitStream::operator<<(BaseOst& (*right)(BaseOst&)) {
	ost_m << '\n';
	ost_m.flush();
	line_is_empty_m = true;
	return *this;
}
SplitStream Scout(cout);

template <typename T, int Begin, int End>
class OffsetArray {
	T arr_m[End - Begin];
public:
	OffsetArray();

	T& operator[](int index);
	T operator[](int index) const;
};
template<typename T, int Begin, int End>
OffsetArray<T, Begin, End>::OffsetArray() : arr_m() {}

template<typename T, int Begin, int End>
T & OffsetArray<T, Begin, End>::operator[](int index) {
	return arr_m[index - Begin];
}

template<typename T, int Begin, int End>
T OffsetArray<T, Begin, End>::operator[](int index) const {
	return arr_m[index - Begin];
}


LL N, A, X[50];
OffsetArray<LL, -2501, 2501> DP[51];

int main() {
	cin >> N >> A;
	REP(i, 0, N) {
		cin >> X[i];
		X[i] -= A;
	}
	DP[0][0] = 1;
	REP(i, 0, N) {
		REP(j, -N * 50, N * 50) {
			DP[i + 1][j] = DP[i][j] + DP[i][j - X[i]];
		}
	}
	cout << DP[N][0] - 1 << endl;
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;

vector<ll> divisor(ll n) {
	vector<ll> ret;
	for(ll i=1; i*i<=n; i++) {
		if(n%i==0) {
			ret.push_back(i);
			if(i*i != n) ret.push_back(n/i);
		}
	}
	sort(begin(ret), end(ret));
	return ret;
}


int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	ll sum = 0;
	rep(i, N) {
		cin >> A[i];
		sum += A[i];
	}

	// 候補 Aの和の約数
	vector<ll> divs = divisor(sum);
	vector<ll> q(N);
	ll max_p = 1;
	for(int i=1; i<divs.size(); i++) {
		ll p = divs[i];
		rep(i, N) {
			q[i] = A[i]%p;
		}
		sort(q.begin(), q.end());

		ll move = 0;
		ll q_sum = 0;
		ll id;
		for(id=0; id<N; id++) {
			move += q[id];
			if(move>K) {
				move -= q[id];
				id--;
				break;
			}
		}
		ll rest = 0;
		id++;
		for(;id<N; id++) {
			rest += p - q[id];
		}
		//cout << p << ": " << move << ' ' << rest << endl;
		if(move>=rest) {
			if(p>max_p) max_p = p;
		}
	}
	
	cout << max_p << endl;

  return 0;
}

Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define mp make_pair
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=200000+10;

int n,k,l;
struct DSU {
	int f[N];
	int find(int x) { return x==f[x]?x:f[x]=find(f[x]); }
	void merge(int x,int y) {
		x=find(x),y=find(y);
		if (x!=y) f[x]=y;
	}
} A,B;
map<pair<int,int>,int> M;

int main() {
	n=read(),k=read(),l=read();
	for (int i=1;i<=n;++i) A.f[i]=B.f[i]=i;
	for (int i=1;i<=k;++i) A.merge(read(),read());
	for (int i=1;i<=l;++i) B.merge(read(),read());
	for (int i=1;i<=n;++i) ++M[mp(A.find(i),B.find(i))];
	for (int i=1;i<=n;++i) printf("%d ",M[mp(A.find(i),B.find(i))]);
	return 0;
}


Measured memory_bytes: 16580
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scanner()
	x := make([][]int, 1)
	x[0] = make([]int, 0)
	for i := 0; i < len(s); i++ {
		if i+2 <= len(s) {
			if s[i:i+2] == "BC" {
				x[len(x)-1] = append(x[len(x)-1], 0)
				i++
				continue
			}
		}
		if string(s[i]) == "A" {
			x[len(x)-1] = append(x[len(x)-1], 1)
		} else {
			x = append(x, make([]int, 0))
		}
	}
	ans := 0
	for _, v := range x {
		for i := 1; i < len(v); i++ {
			if v[i] == 0 {
				ans += v[i-1]
			}
			v[i] = v[i-1] + v[i]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 19328
s=input()
ll=list(s.split("?"))
l=[]
cnt=0
for i in range(len(s)):
  if s[i]=="?":
    c=""
    if i+1<len(s):
      if s[i+1]=="D":
        c="P"
    if i>0:
      if s[i-1]=="P":
        c="D"
    if c=="":
      c="D"
    l.append(ll[cnt])
    l.append(c)
    cnt+=1
l.append(ll[-1])
print("".join(l))

Measured memory_bytes: 15380
n = int(input())
ms = list(map(int, input().split()))

a = sum(ms) - 2 * sum(ms[1::2])
vv = ['%d' % a]
for m in ms[:-1]:
  a = 2 * m - a
  vv.append('%d' % a)
print(' '.join(vv))


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

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000;
const LL LINF = 1LL * INF*INF;
const int MAX = 100010;
const long double PI = acos(-1.);
const double EPS = 1e-6;
LL mod = 1000LL*1000*1000 + 7;

int arr[100*1000+7];
int main()
{
	ios_base::sync_with_stdio(0); double startClock = clock();

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	FOR(i,0,n)
		cin >> arr[i+1];
	LL ans0 = 0;
	FOR(i,0,n+1)
		ans0 += abs(arr[i+1]-arr[i]);
	FOR(i,1,n+1)
	{
		LL tmp = ans0 - abs(arr[i+1]-arr[i])-abs(arr[i]-arr[i-1])+abs(arr[i+1]-arr[i-1]);
		cout << tmp << endl;
	}

	cerr << endl << (clock() - startClock)/CLOCKS_PER_SEC << endl;return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define REP(i, n) for(int i=1; i<=(int)(n); i++)

using namespace std;

int main(){
    double n;
    double sum=0;
    priority_queue<
        double,
        vector<double>,
        greater<double>
    > que;

    cin >> n;
    vector<int> A(n);
    rep(i, n){
        cin >> A[i];
        que.push(A[i]);
    }

    while (que.size() != 1){
        sum += que.top(); que.pop();
        sum += que.top(); que.pop();
        sum /= 2;
        que.push(sum);
        sum = 0;
    }

    cout << que.top() << endl;

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N;
long long ans = -1e12;

int main(){
    cin>>N;
    int P[N][10],F[N][10];
    rep(i,N){
        rep(j,10){
            cin>>F[i][j];
        }
    }
    rep(i,N){
        rep(j,11){
            cin>>P[i][j];
        }
    }
    repi(i,1,(1<<10)){
        long long temp=0;
        rep(k,N){
            int cou=0;
            rep(j,10)if(((i>>j)&1)&&F[k][j])cou++;
            temp+=P[k][cou];
        }
        ans=max(ans,temp);
    }
    out(ans);
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int n, p;

	while(cin >> n >> p, n, p) {
		vi players(n, 0);

		int i = 0;
		int wan = p;
		while(true) {		
			if(wan == 0) {
				wan = players[i];
				players[i] = 0;
			} else {
				players[i] += 1;
				wan -= 1;
			}

			if(players[i] == p) {
				break;
			}

			i = (i+1)%n;
		}

		cout << i << endl;
	}
}

Measured memory_bytes: 908