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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> vec){ return (ll)vec.size(); }
ll sz(string s){ return (ll)s.size(); }

ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }

int main(){
    ll n,m;
    cin >> n >> m;
    priority_queue<ll,llVEC> pq[8];
    rep(i,0,n){
        ll x[3];
        cin >> x[0] >> x[1] >> x[2];
        rep(j,0,8){
            ll temp = j;
            ll sum = 0;
            rep(k,0,3){
                if((temp >> k) & 1){
                    sum += x[k];
                }
                else{
                    sum -= x[k];
                }
            }
            pq[j].push(sum);
        }
    }

    ll ans = 0;
    rep(i,0,8){
        ll memo = 0;
        rep(j,0,m){
            memo += pq[i].top();
            pq[i].pop();
        }
        ans = max(ans,memo);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

int main() {
	string K = "keyence";
	string S;
	cin >> S;
	bool flg = false;
	for(int i = 0; i < S.size(); i++) {
		for(int j = i; j < S.size(); j++) {
			string ss = string(S.begin(), S.begin()+i) + string(S.begin()+j, S.end());
			if(ss == K)
				flg = true;
		}
	}
	if(flg)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};
use std::collections::BTreeMap;

#[fastout]
fn main() {
    input! {
        n: i32,
    }

    let mut map = BTreeMap::new();

    for x in 1..=100 {
        for y in 1..=100 {
            for z in 1..=100 {
                let tmp = x * x + y * y + z * z + x * y + y * z + z * x;
                map.entry(tmp).and_modify(|e| *e += 1).or_insert(1);
            }
        }
    }

    for i in 1..=n {
        println!("{}", map.get(&i).unwrap_or(&0));
    }
}


Measured memory_bytes: 2680
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    string s; cin >> s;
    int si = (int)s.size();
    if(si % 2 == 0){
        cout << "No" << endl;
        return 0;
    }
    rep(i,si/2+1) if(s[i] != s[si-1-i]){
        cout << "No" << endl;
        return 0;
    }
    rep(i,si/2/2+1) if(s[i] != s[si/2-1-i]){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz size
#define pb push_back
#define er erase
#define in insert
#define fr first
#define sc second
#define mp make_pair
#define pi pair
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
#define rc(s) return cout<<s,0
const int mod=1e9+7;
const int inf=1e5;
using namespace std;

int n,a[10000],sum;
int main(){
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];

    }
    sort(a+1,a+n+1);
    for(int i=n;i>=1;i--){
            sum+=a[i];
    i--;
    sum-=a[i];
    }
   cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6+7;
typedef long long ll;
int n, m, k;

char ch[maxn];

int twoNum(int x){
    int ans = 0;
    while(x > 0 && (x & 1) == 0){
        ans++;
        x >>= 1;
    }
    return ans;
}
int main()
{
    scanf("%d", &n);
    scanf("%s", ch);
    vector<int> v;
    for(int i=0;i<n-1;i++){
        v.push_back(abs((ch[i] - '0') - (ch[i+1] - '0')));
    }
    //for(int x : v)cout << x << ' '; cout << '\n';
    vector<int> cnt(3, 0);
    for(int x : v){
        cnt[x]++;
    }
    int coeff = 1;
    if(cnt[1] == 0){
        for(int & x : v){
            x >>= 1;
        }
        coeff = 2;
    }
    n = v.size();
    //for(int x : v)cout << x << ' '; cout << '\n';
    int res = 0, ans = 0;
    for(int i=0;i<n;i++){
        if(res <= 0){
            ans ^= v[i];
            //cout << i << ' ' << v[i] << '\n';
            assert(((n - 1) & i) == i);
        }
        else{
            assert(((n - 1) & i) != i);
        }
        res += twoNum(n - 1 - i) - twoNum(i + 1);
    }
    //cout << "ans = " << ans << '\n';
    ans = ans & 1;
    printf("%d\n", ans * coeff);
    return 0;
}


Measured memory_bytes: 7408
#include <iostream>

using namespace std;

int main()
{
   int n;
   int sum = 0;
   int a[100];
   int b[100];
   int c[100];

   cin >> n;
   for(int i = 1; i <= n; i++){
      cin >> a[i];
   }
   for(int i = 1; i <= n; i++){
      cin >> b[i];
   }
   for(int i = 1; i <= n - 1; i++){
      cin >> c[i];
   }


   for(int i = 1; i <= n; i++){
      sum += b[a[i]];
      if(a[i] + 1 == a[i + 1]){
         sum += c[a[i]];
      }
   }

   cout << sum;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;

ll ll_pow( int x , int y){
    return (ll)pow((float)x, y);
}
int main(){
    int x; cin >> x;
    if(x == 0){
        cout << 1 << " " << 1;
        return 0;
    }
    int ans_a = 0, ans_b = -1;
    bool breakable = false;
    for(int a = 0; a <= 1000; a++){
        for(int b = a-1; b >= -100; b--){
            if(x == ll_pow( a, 5 ) - ll_pow( b, 5) ){
                ans_a = a;
                ans_b = b;
                breakable = true;
                break;
            }
        }
        if(breakable) break;
    }
    cout << ans_a << " " << ans_b;
    return 0;
}

Measured memory_bytes: 4100
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>
#include <boost/math/common_factor.hpp>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    long a = get<long>(), b = get<long>();
    long c = get<long>(), d = get<long>();

    a -= 1;
    long t = a - a/c - a/d + a/boost::math::lcm(c,d);
    long u = b - b/c - b/d + b/boost::math::lcm(c,d);
    cout << u - t << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
Min,Max = min(x),max(x)
if Min == Max:
    print(0)
    exit()
s = [0] * (Max - Min)
k = 0

for i in range(Min,Max):
    for j in x:
        s[k] += (j - i) ** 2
    k += 1
print(min(s))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int a, b;
    cin >> a >> b;
    cout << (a - (a > b)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n, k;
    cin>>n>>k;
    if(2*n<k){
        cout<<"0\n";
        return 0;
    }
    ll val1 = 0;
    ll  tmp = k;
    if(k%2==0)
    while(tmp<=2*n){
        val1++;
        tmp+=2*k;
    }
    ll val2 = 0;
    tmp = 2*k;
    while(tmp<=2*n){
        val2++;
        tmp+=2*k;
    }
    cout<<val1*val1*val1+val2*val2*val2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll      long long int
#define MOD     1000000007
#define pb      push_back
#define mp      make_pair
#define all(v)  (v).begin(),(v).end();
#define T		int t;cin>>t;while(t--)
#define IOS     ios_base::sync_with_stdio(false);cin.tie(NULL);

int main() {

	int N;
	cin >> N;
	int k;
	cin >> k;
	int h[N];

	for (int i = 0 ; i < N ; i ++) cin >> h[i];

	int dp[N + 1];
	for (int i = 0 ; i < N + 1; i++)dp[i] = INT_MAX;

	dp[0] = 0;

	dp[1] = dp[0] + abs(h[1] - h[0]);

	for (int  i = 2 ; i < N ; i++ ) {

		//dp[i] = min ( dp[i] , min(dp[i - 1] + abs(h[i] - h[i - 1]) , dp[i - 2] + abs(h[i] - h[i - 2])));





		for (int  j = i - 1; j >= max(0, i - k) ; j --) {
			dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
		}


	}

	cout << dp[N - 1] << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
struct Match {
  vector<vector<Int> > G;
  int V;
  vector<int> match, used;
  Match(){}
  Match(int V):V(V), G(V), match(V, -1), used(V, 0){}
  void add_edge(int u, int v) {
    G[u].push_back(v);
    G[v].push_back(u);
  }
  bool dfs(int v) {
    used[v] = true;
    for(int i = 0; i < (int)G[v].size(); i++) {
      int u = G[v][i], w = match[u];
      if(w<0 || (!used[w]&&dfs(w))) {
	match[v] = u;
	match[u] = v;
	return true;
      }
    }
    return false;
  }
  int matching() {
    int res = 0;
    for(int v = 0; v < V; v++) {
      if(match[v] < 0) {
	fill(used.begin(), used.end(), 0);
	if(dfs(v)) {
	  res++;
	}
      }
    }
    return res;
  }
};
double tx[101], ty[101], v[101];
double bx[101], by[101];
double sq(double x) {
  return x*x;
}
signed main(){
  int N, M;
  while(cin >> N >> M, N+M) {
    for(int i = 0; i < N; i++) {
      cin >> tx[i] >> ty[i] >> v[i];
    }
    for(int i = 0; i < M; i++) {
      cin >> bx[i] >> by[i];
    }
    assert(N >= M);
    double lb = 0, ub = 1e9;
    for(int k = 0; k < 200; k++) {
      double mb = (lb+ub)/2;
      Match G(N+M);
      for(int i = 0; i < N; i++) {
	for(int j = 0; j < M; j++) {
	  if(sqrt(sq(tx[i]-bx[j])+sq(ty[i]-by[j])) <= v[i]*mb) {
	    G.add_edge(i, j+N);
	  }
	}
      }
      if(G.matching() == M) ub = mb;
      else lb = mb;
    }
    printf("%.8f\n", ub);
  }

  return 0;
}

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

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

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



int main(void){
    int input;
    int nums[4];
    char op[4];
    int i, j, k;
    int ans;
    scanf("%d", &input);
    for (i = 3; i > -1; i--){
        nums[i] = input%10;
        input /= 10;
    }

    for (i = 0; i < (1 << 3); i++){
        k = 1;
        ans = nums[0];
        for (j = 1; j < (1 << 3); j = j << 1){
            if ((i & j) == j){
                ans += nums[k];
                op[k] = '+';
            }else{
                ans -= nums[k];
                op[k] = '-';
            }
            k++;
        }
        if (ans == 7){
            break;
        }
    }

    printf("%d%c%d%c%d%c%d=%d", nums[0], op[1], nums[1], op[2], nums[2], op[3], nums[3], ans);
    
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void) {

  long x,y;
  scanf("%ld %ld", &x, &y);
  long number = x;
  int count = 0;
  while (number <= y) {
    count++;
    number *= 2;
  }
  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 128
import java.io.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] strargs;
		String grade;
		int m, f, r, score;

		do {
			grade = null;
			strargs = br.readLine().split("\\s+");
			m = Integer.parseInt(strargs[0]);
			f = Integer.parseInt(strargs[1]);
			r = Integer.parseInt(strargs[2]);
			score = Math.addExact(m, f);
			
			if (score >= 80) 		{	grade = "A";
			} else if (score >= 65) {	grade = "B";
			} else if (score >= 50) {	grade = "C";
			} else if (r >= 50)	 	{	grade = "C";
			} else if (score >= 30) {	grade = "D";
			} else					{	grade = "F";
			}
			if (m == -1 || f == -1) grade ="F";
			if (m == -1 && f == -1 && r == -1) break;
			sb.append(grade);
			sb.append("\n");
		} while(true);
		
		System.out.print(sb);
	}
}

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

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 58;

typedef tuple< int64, int, int, bool > Pi;

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

struct edge
{
  int to, cost;
};

int64 v[500][51][2];
int N, M, V, A, B, C;
vector< edge > g[500];

int main()
{


  cin >> N >> M;
  rep(i, M) {
    int x, y, t;
    cin >> x >> y >> t;
    --x, --y;
    g[x].push_back((edge) {y, t});
    g[y].push_back((edge) {x, t});
  }
  cin >> V;
  cin >> A >> B >> C;

  fill_n(**v, 500 * 51 * 2, INF);
  v[0][V][0] = 0;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  que.emplace(0, 0, V, false);

  while(!que.empty()) {
    int64 cost;
    int now, vv;
    bool flag;
    tie(cost, now, vv, flag) = que.top();
    que.pop();

    if(flag && now == 0) {
      cout << cost << endl;
      return (0);
    }

    for(auto &e : g[now]) {

      int64 nxtcost = cost + 1LL * vv * e.cost;
      int nxtvv = (A * vv + B) % C;
      bool nxtfg = flag | (e.to == N - 1);

      if(nxtcost < v[e.to][nxtvv][nxtfg]) {
        v[e.to][nxtvv][nxtfg] = nxtcost;
        que.emplace(nxtcost, e.to, nxtvv, nxtfg);
      }

    }
  }
}

Measured memory_bytes: 9628
#include <stdio.h>

int min(int a, int  b, int c){
   int min=a;
   if(min>b) min=b;
   if(min>c) min=c;
   return min;
}

int main(void)
{
   char map[1000][1001];
   int space[1000][1000];
   int N;
   int i, j;
   int max;
   
   while(1){
      scanf("%d", &N);
      if(N==0) break;

      for(i=0; i<N; i++) scanf("%s", map[i]);

      max=0;
      for(i=0; i<N; i++){
         if(map[i][0]=='.'){
            space[i][0]=1; max=1;
         }
         else space[i][0]=0;
      }
      for(i=0; i<N; i++){
         if(map[0][i]=='.'){
            space[0][i]=1;
            max=1;
         }
         else space[0][i]=0;
      }

      for(i=1; i<N; i++){
         for(j=1; j<N; j++){
            if(map[i][j]=='.') space[i][j]=min(space[i-1][j-1], space[i-1][j], space[i][j-1])+1;
            else space[i][j]=0;
            if(max<space[i][j]) max=space[i][j];
         }
      }
      printf("%d\n", max);
   }
   return 0;
}

Measured memory_bytes: 5488
#include<stdio.h>
int N,i,l,r,p;
int G[30][2],pc[30]={0};

char S[4][100]={"Preorder","Inorder","Postorder"};

void pre(int n)
{
	if(n==-1)return;
	printf(" %d",n);
	pre(G[n][0]);
	pre(G[n][1]);
	return;
}

void ino(int n)
{
	if(n==-1)return;
	ino(G[n][0]);
	printf(" %d",n);
	ino(G[n][1]);
	return;
}

void pos(int n)
{
	if(n==-1)return;
	pos(G[n][0]);
	pos(G[n][1]);
	printf(" %d",n);
	return;
}



int main()
{
	void (*funcs[])(int)={pre,ino,pos};
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d%d%d",&p,&l,&r);
		pc[l]=pc[r]=1;
		G[p][0]=l;
		G[p][1]=r;
	}
	for(i=0;i<N;i++)if(!pc[i])p=i;
	for(i=0;i<3;i++)
	{
		puts(S[i]);
		(*(funcs[i]))(p);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

template<class T> class rollinghash {
	const ull mask30 = (1LL << 30) - 1;
	const ull mask31 = (1LL << 31) - 1;
	const ull mod61 = (1LL << 61) - 1;
	vector<ull> base;
	vector<vector<ull>> hashvalue, basepower;
	int length;
	ull multiply(ull a, ull b) {
		ull au = a >> 31; ull ad = a & mask31;
		ull bu = b >> 31; ull bd = b & mask31;
		ull mid = ad * bu + au * bd;
		ull midu = mid >> 30; ull midd = mid & mask30;
		return au * bu * 2 + midu + (midd << 31) + ad * bd;
	}
	ull modulo(ull a) {
		ull au = a >> 61; ull ad = a & mod61;
		ull res = au + ad; if (res >= mod61) res -= mod61;
		return res;
	}
public:
	rollinghash(T s) {
		length = s.size();
		base = { 200004 };
		hashvalue = vector<vector<ull>>(length + 1, vector<ull>(1));
		for (int j = 0; j < 1; j++) {
			for (int i = 0; i < length; i++) {
				hashvalue[i + 1][j] = modulo(multiply(hashvalue[i][j], base[j]) + s[i]);
			}
		}
		basepower = vector<vector<ull>>(length + 1, vector<ull>(1));
		for (int j = 0; j < 1; j++) {
			basepower[0][j] = 1;
			for (int i = 1; i <= length; i++) {
				basepower[i][j] = modulo(multiply(basepower[i - 1][j], base[j]));
			}
		}
	}
	ull hash(ll l, ll r, ll i) {
		assert(l < r && 0 <= l && l < length && 0 < r && r <= length);
		return modulo(hashvalue[r][i] + mod61 * 3 - multiply(hashvalue[l][i], basepower[r - l][i]));
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	string s;
	cin >> s;
	rollinghash<string> rol(s);
	int ans = 0;
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			int ok = 0, ng = j - i + 1;
			while (ng - ok > 1) {
				int mid = (ok + ng) / 2;
				bool flag = true;
				rep(k, 1) {
					if (j + mid > n || rol.hash(i, i + mid, k) != rol.hash(j, j + mid, k)) flag = false;
				}
				if (flag) ok = mid;
				else ng = mid;
			}
			chmax(ans, ok);
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 768
import math

N = int(input())
A = list(map(int, input().strip().split(' ')))
B = []

sum_A = abs(A[0])
min_A = abs(A[0])
mins = 1 if A[0] < 0 else 0
for i in range(1, N):
    sum_A += abs(A[i])
    min_A = min(min_A, abs(A[i]))
    if A[i] < 0:
        mins += 1 if A[i] < 0 else 0

if mins % 2 == 0:
    print(sum_A)
else:
    print(sum_A-min_A*2)

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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    int a,b,c; cin>>a>>b>>c;
    if(a+b+c>=22) cout<<"bust";
    else cout<<"win";
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

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

int main() {
	while (1) {
		int n, m, l, k, a, h;
		cin >> n >> m >> l >> k >> a >> h;
		if (n == 0) return 0;
		vector<vector<int> > dist(n, vector<int>(n, 100000));
		l += 2;
		vector<int> fridge(l);
		for (int i = 1; i < l-1; ++i) cin >> fridge[i];
		fridge[0] = a, fridge[l-1] = h;
		for (int i = 0; i < k; ++i) {
			int x, y, t; cin >> x >> y >> t;
			dist[x][y] = t; dist[y][x] = t;
		}
		for (int k = 0; k < n; ++k) {
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < n; ++j) {
					dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
				}
			}
		}
		vector<vector<int> > reachable(l, vector<int>(l, 100000));
		for (int i = 0; i < l; ++i) {
			for (int j = i+1; j < l; ++j) {
				if (dist[fridge[i]][fridge[j]] <= m) {
					reachable[i][j] = dist[fridge[i]][fridge[j]];
					reachable[j][i] = dist[fridge[i]][fridge[j]];
				}
			}
		}
		for (int k = 0; k < l; ++k) {
			for (int i = 0; i < l; ++i) {
				for (int j = 0; j < l; ++j) {
					reachable[i][j] = min(reachable[i][j], reachable[i][k] + reachable[k][j]);
				}
			}
		}
		if (reachable[0][l-1] > 90000) cout << "Help!" << "\n";
		else cout << reachable[0][l-1] + max(0, reachable[0][l-1]-m) << endl;
	}
}


Measured memory_bytes: 3172
K = int(input())
a1 = 7
ai = 0
for i in range(K + 1):
  if i == 0:
    ai = a1 % K
  else:
    ai = (ai * 10 + 7) % K
  if ai == 0:
    break
else:
    i = -2
print(i + 1)

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

int x[100000], y[100000];
int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		int a, b; scanf("%d%d", &a, &b);
		x[i] = a - b; y[i] = a + b;
	}
	int X[2]{ -INF,INF }, Y[2]{ -INF,INF };
	rep(i, n) {
		X[0] = max(X[0], x[i]); X[1] = min(X[1], x[i]);
		Y[0] = max(Y[0], y[i]); Y[1] = min(Y[1], y[i]);
	}
	int ans[4]{};
	rep(k, n) {
		rep(i, 2)rep(j, 2) {
			ans[i * 2 + j] = max(ans[i * 2 + j], min(max(abs(x[k] - X[i]), abs(y[k] - Y[j])), max(abs(x[k] - X[!i]), abs(y[k] - Y[!j]))));
		}
	}
	printf("%d\n", *min_element(ans, ans + 4));
}

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

int main() {
    int A[3][3];
    bool ok[3][3];
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> A[i][j];
            ok[i][j] = false;
        }
    }
    int N;
    cin >> N;
    vector<int>b(N);
    for(int i = 0; i < N; i++) {
        cin >> b[i];
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                if(b[i] == A[j][k]) {
                    ok[j][k] = true;
                }
            }
        }
    }
    if(ok[0][0]) {
        if(ok[0][1]) {
            if(ok[0][2]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if(ok[1][0]) {
        if(ok[1][1]) {
            if(ok[1][2]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if(ok[2][0]) {
        if(ok[2][1]) {
            if(ok[2][2]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if(ok[0][0]) {
        if(ok[1][0]) {
            if(ok[2][0]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if(ok[0][1]) {
        if(ok[1][1]) {
            if(ok[2][1]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if(ok[0][2]) {
        if(ok[1][2]) {
            if(ok[2][2]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if(ok[0][0]) {
        if(ok[1][1]) {
            if(ok[2][2]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if(ok[0][2]) {
        if(ok[1][1]) {
            if(ok[2][0]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// n > 0 のとき
// sum_{r in [0,n]} binom(n,r)= (1+1)^n= 2^n
// sum_{r in [0,n]} (-1)^r binom(n,r)= (1-1)^n= 0 より、
// sum_{r:odd  in [0,n]} binom(n,r)= 2^{n-1}
// sum_{r:even in [0,n]} binom(n,r)= 2^{n-1}
int main(){
  int N,mod2;
  cin >> N >> mod2;
  
  int Nodd = 0;
  int Neven= 0;
  int buf;
  for(int i=0; i<N; i++){
    cin >> buf;
    if(buf%2==1){ Nodd++;  }
    else        { Neven++; }
  }

  int64_t ans= (Nodd==0) ? ((mod2==0) ? (1LL<<Neven)
                                      : 0)
                         : (1LL<<(Nodd-1))* (1LL<<Neven);

  cout << ans << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
int a[4][2];
int b,c;
int main(){
  for(int i=0;i<4;i++)scanf("%d",&a[(i-i%2)/2][i%2]);
  b=a[1][0]-a[0][0];
  c=a[1][1]-a[0][1];
  a[2][0]=a[1][0]-c;
  a[2][1]=a[1][1]+b;
  a[3][0]=a[2][0]-b;
  a[3][1]=a[2][1]-c;
  for(int i=4;i<8;i++)printf("%d ",a[(i-i%2)/2][i%2]);
  return 0;
}


Measured memory_bytes: 128
using System;
public class Hello{
    public static void Main(){
        // Your code here!
        var line = System.Console.ReadLine().Split(' ');
        int N = int.Parse(line[0]);
        int D = int.Parse(line[1]);
        int count = 0;
        for (int i = 0; i < N; i++)
        {
            line = System.Console.ReadLine().Split(' ');
            long x = int.Parse(line[0]);
            long y = int.Parse(line[1]);
            if (Math.Sqrt(x * x + y * y) <= D)
            {
                count++;
            }
        }
        System.Console.WriteLine(count);
    }
}


Measured memory_bytes: 40560
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int[] a = new int[n + 1];
		int[] b = new int[n + 1];
		int boxcnt = 0;
		for(int i = 1; i <= n; i++) {
			a[i] = ni();
		}		

		for(int i = n; i > 0; i--) {

			int ballcnt = 0;
			for(int j = 2 * i; j <= n; j += i) {
				ballcnt += b[j];
			}
			if(ballcnt % 2 != a[i]) {
				b[i]++;
			}
			if(b[i] > 0)boxcnt++;
		}

		System.out.println(boxcnt);
		for(int i = 1; i <= n; i++) {		
			if(b[i] > 0) {
				System.out.print(i + " ");
			}
		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 43852
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
 
int main(void){
   int a,b;
   std::cin >> a>>b;
   std::cout << max({a,b})+max({ max({a,b})-1,min({a,b})}) << std::endl;
   
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
	static int n;
	static int[] a;
	static long ans = 0;

	static void Main(){
		/* 入力の受取, aのソート */
		n = int.Parse(Console.ReadLine());
		a = new int[n];
		for (int i = 0;i < n;i++) a[i] = int.Parse(Console.ReadLine());
		Array.Sort(a);

		/* 計算 */
		Calc(true);
		Calc(false);

		/* 出力 */
		Console.WriteLine(ans);
	}

	static void Calc(bool f){ //trueで\,falseで/始まり
		int[] count = new int[n];
		for (int i = 0;i < n - 1;i++){
			if (f){
				count[i]++;
				count[i+1]--;
				goto END;
			}
			count[i]--;
			count[i+1]++;
			END:
			f = !f;
		}
		Array.Sort(count);
		long temp = 0;
		for (int i = 0;i < n;i++)
			temp += count[i] * a[i];
		ans = Max(ans,temp);
	}
}

Measured memory_bytes: 16220
#include <iostream>
#include <string>
#include <list>
#define llint long long

using namespace std;


llint n, k, m;
llint succ[10005], pre[10005];

void del(llint &p)
{
	pre[succ[p]] = pre[p];
	succ[pre[p]] = succ[p];
	p = succ[p];
}

int main(void)
{
	while(1){
		cin >> n >> k >> m;
		if(n == 0 && k == 0 && m == 0) break;
		m--;
		
		for(int i = 0; i < n; i++) pre[i] = (i+n-1)%n, succ[i] = (i+1)%n;
		llint p = m;
		del(p);
		
		for(int i = 1; i < n-1; i++){
			llint rem = k-1;
			rem %= (n-i);
			for(int j = 0; j < rem; j++) p = succ[p];
			del(p);
		}
		cout << p+1 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
int main(){
	int A, B, C, X, Y;
	std::cin >> A >> B >> C >> X >> Y;
	int result = A*X+B*Y;
	result -= std::max(((A+B)-C*2),0)*std::min(X,Y);
	result -= std::max(((X<Y?B:A)-C*2),0)*abs(Y-X);
	std::cout << result << std::endl;
}


Measured memory_bytes: 256
#if 1
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <random>
#include <cmath>
#include <cstring>
using namespace std; using i8 = int8_t; using i16 = int16_t; using i32 = int32_t; using i64 = int64_t; using u8 = uint8_t; using u16 = uint16_t; using u32 = uint32_t; using u64 = uint64_t; using f32 = float; using f64 = double; template <class T> inline T square(T a) { return a * a; } template <class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } return false; } template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; } void _u() { cerr << endl; } template <class H, class... T> void _u(H&& h, T&&... t) { cerr << h << ", "; _u(move(t)...); }
#define _overload4(a, b, c, d, name, ...) name
#define _rep4(i, a, b, c) for (i32 i = i32(a); i < i32(b); i += i32(c))
#define _rep3(i, a, b) _rep4(i, a, b, 1)
#define _rep2(i, b) _rep3(i, 0, b)
#define _rep1(i) for (i32 i = 0; ; ++i)
#define rep(...) _overload4(__VA_ARGS__, _rep4, _rep3, _rep2, _rep1)(__VA__ARGS__)
#define A(a) begin(a), end(a)
#define S(a) i32((a).size())
#define U(...) { cerr << #__VA_ARGS__ << ": "; _u(__VA_ARGS__); }
#define lin U(__LINE__)
#define ter terminate();
#endif

constexpr bool Deterministic = 0;

class rando {
    unsigned y;
public:
    rando(unsigned y) : y(y) {}
    unsigned next() {
        return y ^= (y ^= (y ^= y << 13) >> 17) << 5;
    }
    int next(int b) {
        return next() % b;
    }
    int next(int a, int b) {
        return next(b - a) + a;
    }
    double nextDouble(double b = 1) {
        return b * next() / 4294967296.0;
    }
    double nextDouble(double a, double b) {
        return nextDouble(b - a) + a;
    }
    int operator() (int b) {
        return next(b);
    }
} rando(Deterministic ? 2463534242 : random_device()());

i32 main() {
    int N, K;
    while (cin >> N >> K) {
        vector<int> a(N);
        for (int& i : a) cin >> i;
        long long mn = 1ll << 60;
        for (int i = 0; i + K - 1 < N; ++i) {
            long long k1 = (long long)abs(a[i]) + abs(a[i] - a[i + K - 1]);
            long long k2 = (long long)abs(a[i + K - 1]) + abs(a[i] - a[i + K - 1]);
            mn = min(mn, min(k1, k2));
        }
        cout << mn << endl;
    }
    return 0;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public List<Integer> list = new ArrayList<Integer>();
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int P[] = new int[N];
		int Q[] = new int[N];
		for (int i=0;i<N;i++) {
			P[i] = sc.nextInt();
		}
		int countP=0;
		int p =0;
		for (int j=0;j<N;j++) {
			p = p *10+P[j];
		}
		for (int i=0;i<N;i++) {
			Q[i] = sc.nextInt();
		}
		int countQ=0;
		int q =0;
		for (int j=0;j<N;j++) {
			q = q *10+Q[j];
		}
		Main main = new Main();
		main.makeArray(N, new int[N], 0);
		for (int i=0;i<main.list.size();i++) {
			if (main.list.get(i)==p) {
				countP =i;
			}
			if (main.list.get(i)==q) {
				countQ =i;
			}
		}
		System.out.println(Math.abs(countP-countQ));
	}

	public void makeArray(int N, int[] array,int now) {
		for (int i=1;i<=N;i++) {
			boolean b =true;
			for (int j=0;j<now;j++) {
				if (array[j]==i) {
					b = false;
					break;
				}
			}
			if (b==true) {
				if (now ==N-1) {
					array[N-1]=i;
					int result = 0;
					for (int j=0;j<N;j++) {
						result = result *10+array[j];
					}
					list.add(result);
				} else {
					array[now]=i;
					makeArray(N,array,now+1);
				}
			}
		}
	}
}

Measured memory_bytes: 38644
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;


template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
    arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
    for (auto& i : arr) {
        fill_all(i, v);
    }
}

using COST_T = int32_t;
constexpr int NMAX = 200;
constexpr COST_T INF = 100000000;
struct Edge {
    int to;
    COST_T max;
    size_t pair;
    Edge() = default;
    Edge(int to, COST_T max, size_t pair)
        :to(to), max(max), pair(pair) {}
};
std::vector<Edge> graph[NMAX];
void add_edge(int from, int to, COST_T max) {
    graph[from].emplace_back(to, max, graph[to].size());
    graph[to].emplace_back(from, 0, graph[from].size()-1);
}

bool used[NMAX];
COST_T dfs(int v, int t, int d) {
    if (v == t) {
        return d;
    }
    used[v] = true;
    for (auto& e : graph[v]) {
        if (used[e.to] || e.max <= 0) { continue; }

        auto dn = dfs(e.to, t, std::min(d, e.max));
        if (dn > 0) {
            e.max -= dn;
            graph[e.to][e.pair].max += dn;
            return dn;
        }
    }
    return 0;
}
COST_T max_flow(int s, int t) {
    COST_T res = 0;
    COST_T add = 1;
    while (add > 0) {
        fill_all(used, false);
        add = dfs(s, t, INF);
        res += add;
    }
    return res;
}

int32_t N, E;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> N >> E;
    for (size_t i = 0; i < E; i++)
    {
        int a, b, c;
        in >> a >> b >> c; //--a; --b;
        add_edge(a, b, c);
    }
    out << max_flow(0, N-1) << endl;


    return 0;
}
#endif



Measured memory_bytes: 3280
#include <iostream>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    bool a= S[0] == 'R',b = S[1] == 'R',c = S[2] == 'R';;
    if (a and b and c) {
        cout << 3 << endl;
    } else if ((a and b) or (b and c)) {
        cout << 2 << endl;
    } else if (a or b or c) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3568
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> a >> b;
	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));

	cout << a*b << endl;
	return 0;
}


Measured memory_bytes: 3628
//start of jonathanirvings' template v3.0.3 (BETA)

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

map<int,int> ada;
int risan = 0;
int n;
int x;

int main()
{
  scanf("%d",&n);
  TC(n)
  {
    scanf("%d",&x);
    ++ada[x];
  }
  for (pii a : ada)
  {
    if (a.se > a.fi) risan += a.se - a.fi;
    else if (a.se < a.fi) risan += a.se;
  }
  printf("%d\n",risan);
  return 0;
}











Measured memory_bytes: 4736
import java.util.*;

public class Main {

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

		int min = Math.min(A, B);
		int n = 0;

		for(int i=min; i>0; i--) {
			if(A % i == 0 && B % i == 0) {
				n++;
			}

			if(n==K) {
				System.out.println(i);
				break;
			}
		}

	}
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    vector<double> dp(n + 1, 0);
    rep(i, n) {
        ll p;
        cin >> p;
        double tmp = (1 + p) * p / 2;
        tmp /= p;
        dp[i + 1] = dp[i] + tmp;
    }
    double ans = 0;
    reps(i, k, n + 1) {
        ans = max(ans, dp[i] - dp[i - k]);
    }
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 1792
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
for i in range(1,n):
    if h[i-1] <= h[i]-1:
        h[i] -= 1
    elif h[i-1] > h[i]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 14252
#include<iostream>
#include<iomanip>
#include<vector>
#include<cmath>
using namespace std;

const double EPS = 1e-4;

#define x first
#define y second

void normalize(double &a, double &b){
    double norm = sqrt(a*a + b*b);
    a /= norm;
    b /= norm;
}

int main(){
    int n;
    while(cin >> n, n){
        int ans = 1;
        vector<pair<double,double>> v;
        for(int i = 0; i < n; i++){
            double a, b;
            cin >> a >> b;
            v.push_back({a,b});
        }
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                double dx = v[i].x-v[j].x, dy = v[i].y-v[j].y;
                if(sqrt(dx*dx+dy*dy) > 2.0000)    continue;
                double midx = (v[i].x+v[j].x)/2, midy = (v[i].y+v[j].y)/2;
                double ux = 0, uy = 0, cx, cy;
                if(dx == 0)         ux = 1;
                else if(dy == 0)    uy = 1;
                else                ux = 1, uy = -dx/dy;
                normalize(ux, uy);
                double scale = sqrt(1*1 - (v[i].x-midx)*(v[i].x-midx) - (v[i].y-midy)*(v[i].y-midy));
                for(int k = -1; k <= 1; k++){
                    if(k == 0)  continue;
                    cx = midx + scale * ux * k;
                    cy = midy + scale * uy * k;
                    int tmp = 0;
                    for(int l = 0; l < n; l++){
                        if((v[l].x-cx)*(v[l].x-cx)+(v[l].y-cy)*(v[l].y-cy) <= 1+EPS)    tmp++;
                    }
                    ans = max(ans, tmp);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


const int MAX_N = 10010, MAX_W = 10010, MAX_V = 10010;

int a[100] = {};

int n = 0;

int main()
{
	string S;
	cin >> S;

	for (int i = 0; i < S.length(); i++)
	{
		if (S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G')
		{
			a[n]++;

		}
		else
		{
			//a[n]のやつ切る
			n++;
		}
	}

	int ans = 0;

	for (int i = 0; i <= n; i++)
	{
		ans = max(ans, a[i]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
A = list(map(int, input().split()))

def hantei(list):
    #a + b = X and 2a + 4b = Y が存在するか
    #条件1 1 <= a <= 100 and 1 <= b <= 100

    a = 0
    count = 0
    while a <=100:
        for b in range(101):
            if a + b == list[0] and 2 * a + 4 * b == list[1]:
                print("Yes")
                count = 1
                break
        a += 1
        if count == 1:
            break
        elif count == 0 and a >= 100:
            print("No")
            break 

hantei(A)



Measured memory_bytes: 9140
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	int i=0;
	int x[10001];
	while (true) {
		cin >> x[i];
		if (x[i] == 0) break;
		++i;
	}

	for (int j = 1; j <= i; ++j) {
		cout << "Case " << j << ": " << x[j-1] << endl;
	}

	return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#define inf 1000000007
using namespace std;

int main(void){
    string s;
    cin >> s;
    long long int k;
    cin >> k;
    for(int i = 0; i < s.length(); i++){
        if(s[i]!='1'){
            cout << s[i] << endl;
            break;
        }
        if(i==k-1){
            cout << s[i] << endl;
            break;
        }
        if(i==s.length()-1)
            cout << s[i] << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;

    bool ans = 0;
    for (int i = 1; i < (int)s.size(); i++)
        if (s[i] == 'C' && s[i - 1] == 'A')
            ans = 1;

    if (ans) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 256
n,s=int(input()),input()
a=[1 if s[0]=="#"else 0]+[0]*(n-1)
b=[0]*(n-1)+[1 if s[-1]=="."else 0]
for i in range(1,n):
  if s[i]=="#":a[i]=1
  a[i]+=a[i-1]
  if s[-i-1]==".":b[-i-1]=1
  b[-i-1]+=b[-i]
ans=min(a[-1],b[0])
for i in range(n-1):ans=min(ans,a[i]+b[i+1])
print(ans)

Measured memory_bytes: 20560
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int> l(N);
  for(int i=0;i<N;i++){
    cin>>l[i];
  }
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int L=0;
  for(int i=0;i<K;i++){
    L+=l[i];
  }
  cout<<L<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0)
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;

#define N (1<<18)
ll t[2*N];
int n;
ll h[N], v[N];

ll getmax(int a, int b) {
  a += N; b += N;
  ll mx = 0;
  while (a <= b) {
    if (a % 2) mx = max(mx, t[a++]);
    if (!(b % 2)) mx = max(mx, t[b--]);
    a /= 2; b /= 2;
  }
  return mx;
}

void Set(int k, ll x) {
  t[k += N] = x;
  for (k /= 2; k >= 1; k /= 2) t[k] = max(t[2*k], t[2*k+1]);
}

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

  for (int i = 1; i <= n; i++) cin>>h[i];
  for (int i = 1; i <= n; i++) cin>>v[i];

  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ll best = getmax(0, h[i] - 1) + v[i];
    Set(h[i], best);
    ans = max(ans, best);
  }

  cout<<ans<<"\n";
}

Measured memory_bytes: 7936