akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
using namespace std;

int getnum()
{
	char ch = getchar();
	int x = 0, f = 1;
	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -1; ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0'; ch = getchar();
	}
	return x * f;
}

const int N = 500010;
int n, k;
int cnt;
int head[N];
struct edge
{
	int v, nxt;
}vec[N << 1];
int ind[N];
int A[N];
int P[N];
int minn[N << 2];
priority_queue<int, vector<int>, greater<int> >Q;
int tot;
int ans[N];

void addedge(int u, int v)
{
	vec[++cnt] = (edge){v, head[u]}; head[u] = cnt; ++ind[v];
}

void get_read()
{
	n = getnum(); k = getnum();
	for (int i = 1; i <= n; ++i) A[P[i] = getnum()] = i;
}

void TOPSORT()
{
	for (int i = 1; i <= n; ++i) if (!ind[i]) Q.push(i);
	while (!Q.empty()) {
		int u = Q.top(); Q.pop();
		ans[u] = ++tot;
		for (int i = head[u]; i; i = vec[i].nxt) {
			int v = vec[i].v;
			--ind[v];
			if (!ind[v]) Q.push(v);
		}
	}
}

#define lson (o << 1)
#define rson (o << 1 | 1)

int query(int o, int l, int r, int L, int R)
{
	if (L > R) return minn[0];
	if (L == l && r == R) return minn[o];
	int mid = (l + r) >> 1;
	if (R <= mid) return query(lson, l, mid, L, R);
	if (L > mid) return query(rson, mid + 1, r, L, R);
	return min(query(lson, l, mid, L, mid), query(rson, mid + 1, r, mid + 1, R));
}

void modify(int o, int l, int r, int p, int w)
{
	if (l == r) {
		minn[o] = w; return;
	}
	int mid = (l + r) >> 1;
	if (p <= mid) modify(lson, l, mid, p, w);
	else modify(rson, mid + 1, r, p, w);
	minn[o] = min(minn[lson], minn[rson]);
}

void get_work()
{
	memset(minn, 63, sizeof(minn));
	for (int i = n; i >= 1; --i) {
		int t;
		t = query(1, 1, n, A[i] + 1, min(n, A[i] + k - 1));
		if (t < 1e9) addedge(A[i], A[t]);
		t = query(1, 1, n, max(1, A[i] - k + 1), A[i] - 1);
		if (t < 1e9) addedge(A[i], A[t]);
		modify(1, 1, n, A[i], i);
	}
	TOPSORT();
	for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
}

int main()
{
	get_read();
	
	get_work();
	
	return 0;
}

Measured memory_bytes: 29432
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 1e5;

vi p(4);

int main() {

    REP (i, 3) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        p[a]++; p[b]++;
    }
    sort(ALL(p));
    bool ans = (p[0] == 1 && p[1] == 1 && p[2] == 2 && p[3] == 2);
    cout << (ans?"YES":"NO") << endl;
    

}


Measured memory_bytes: 256
#include <stdio.h>
    int  main() {
        double a,b;
        scanf("%lf %lf",&a,&b);
        if(a>b){
            printf("GREATER\n" );
        }else if(a<b){
            printf("LESS\n");
        }
        else{
        printf("EQUAL\n");
        }
        return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

    int n;
    cin >> n;
    int x[n];
    for(int i = 0; i < n; i++)  cin >> x[i];
    int ans = 0;
    for(int i = 1; i < 1<<n; i++){
        ll tmp = 1;
        for(int j = 0; j < n; j++)  if((i>>j)&1)    tmp = lcm(tmp, x[j]);
        bool valid = true;
        for(int j = 0; j < n; j++)  if(((i>>j)&1) == 0) valid &= tmp%x[j]!=0;
        if(valid)   ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int N;
int num[100];
long long int memo[100][21];

void init(){
	// memoを-1で初期化
	for (int i = 0; i < 100; i++){ for (int j = 0; j < 21; j++){
		memo[i][j] = -1;
	}}
}

long long int correctEq(int index, int sum){
	if (index == N-2) {
		if (sum == num[N-1]) return 1;
		else return 0;
	}
	if (memo[index][sum] >=0) return memo[index][sum];

	memo[index][sum] = 0;
	if (sum + num[index + 1] <= 20) memo[index][sum] += correctEq(index+1, sum+num[index+1]);
	if (sum - num[index + 1] >= 0)  memo[index][sum] += correctEq(index+1, sum-num[index+1]);

	return memo[index][sum];
}

int main(){
	init();

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

	cout << correctEq(0, num[0]) << endl;
	
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<vector<int>> memo(N, vector<int>(N, -1));
  for(int i=0; i<N; i++){
    int A;
    cin >> A;
    for(int j=0; j<A; j++){
      int x, y;
      cin >> x >> y;
      memo.at(i).at(x-1)=y;      
    }
  }
  int ans=0;
  for(int i=1; i<(1<<N); i++){
    vector<bool> check(N, false);    
    for(int k=0; k<N; k++){
      if(1& i>>k){
        check.at(k)=true;
      }
    }
    
    bool finish=false;
    for(int m=0; m<N; m++){
      for(int n=0; n<N; n++){
        if(check.at(m)){
          if(memo.at(m).at(n)==0 && check.at(n)==1){
            finish=true;
            break;
          }
          if(memo.at(m).at(n)==1 && check.at(n)==0){
            finish=true;
            break;
          }          
        }
//      cout <<"i:"<<i<<" m:"<<m<<" n:"<<n<<" memo.at(m).at(n):"<<memo.at(m).at(n)<<" check.at(n):"<<check.at(n)<<endl;        
      }
      if(finish) break;      
      if(m==N-1){
        int temp=0;
        for(int o=0; o<N; o++){
          if(check.at(o)) temp++;
        }
 //       cout <<"i:"<<i<<" temp:"<<temp<<endl;
        ans=max(ans, temp);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

int toint(int y,int m,int d)
{
	int res=0;
	repi(i,1,y){
		if(i%3==0)
			res+=200;
		else
			res+=195;
	}
	repi(i,1,m){
		if(y%3==0 || i%2==1)
			res+=20;
		else
			res+=19;
	}
	return res+d;
}

void solve()
{
	int y,m,d; cin>>y>>m>>d;
	cout<<toint(1000,1,1)-toint(y,m,d)<<endl;
}

int main()
{
	int tc; cin>>tc;
	while(tc--)
		solve();
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,Q;cin >> N >> Q;
  vector<ll> A(N+1,0);
  vector<ll> acc(N+1,0);
  vector<ll> cross(N+1,0);
  acc[0] = cross[0] = 0;
  vector<ll> X(Q,0);
  map<ll,ll> mp;
  rep(i,N)cin >> A[i+1];
  rep(j,Q) cin >> X[j];
  rep(i,N){
    acc[i+1] = acc[i] + A[i+1];
    cross[i+1] = cross[i];
    if((i+N)&1) cross[i+1] += A[i+1];
  }

  rep(i,N){
    //前からi枚は交互にとる．
    ll ans = cross[i];
    int j = i+(N-i)/2;
    ans += acc[N] - acc[j];
    ll x = (A[i+1]+A[j+1])/2;
    mp[x] = ans;
  }
  rep(j,Q){
    auto it = mp.lower_bound(X[j]);
    if(it==mp.end()) cout << cross[N] << endl;
    else cout << it->second << endl;
  }
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#define rep(i, j, k) for (int (i) = (j); (i) < (k); ++(i))
#define repr(i, j, k) for (int (i) = (j); (i) <= (k); ++(i))

using namespace std;

int main()
{
	int a, b, n;
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
long n,c;
string s,head,tail;
int main(){
  cin>>n>>s;
  rep(i,n){
    c+=s[i]=='('?1:-1;
    if(c<0){
      head+="(";
      c++;
    }
  }
  while(c){
    tail+=")";
    c--;
  }
  cout<<head<<s<<tail<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll; 
const int N = 2e5+5;

ll a[N],b[N];

int main()
{	
	ll n,m,x,k;
	scanf("%lld%lld%lld",&n,&m,&k);
	a[0] = b[0] = 0;
	
	for(int i = 1;i <= n;++i) scanf("%lld",&x),a[i] = a[i-1] + x;
	for(int i = 1;i <= m;++i) scanf("%lld",&x),b[i] = b[i-1] + x;
	
	ll res,num,ans = 0;
	for(int i = 1;i <= n;++i){
		if(a[i] > k){
			num = 0;
			res = k;
		}
		else{
			num = i;
			res = k-a[i];
		}
		
		ll pos = lower_bound(b+1,b+m+1,res)-b;
		while((b[pos] > res && pos > 0) || pos > m) pos--;
		ans = max(ans,num+pos);
	}
	for(int i = 1;i <= m;++i){
		if(b[i] > k){
			num = 0;
			res = k;
		}
		else{
			num = i;
			res = k-b[i];
		}
		
		ll pos = lower_bound(a+1,a+n+1,res)-a;
		while((a[pos] > res && pos > 0) || pos > n) pos--;
		ans = max(ans,num+pos);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6884
N = int(input())
A = [int(_) for _ in input().split()]


def color(n):
    if 1 <= n <= 399:
        return 0
    elif 400 <= n <= 799:
        return 1
    elif 800 <= n <= 1199:
        return 2
    elif 1200 <= n <= 1599:
        return 3
    elif 1600 <= n <= 1999:
        return 4
    elif 2000 <= n <= 2399:
        return 5
    elif 2400 <= n <= 2799:
        return 6
    elif 2800 <= n <= 3199:
        return 7
    else:
        return 8


x = [color(a) for a in A]
dora = x.count(8)
unique = len(set(x)) if dora == 0 else len(set(x)) - 1
min_ = max(1, unique)
max_ = unique + dora
print(min_, max_)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
 
const int maxn = 2e5 + 20;

int a[maxn] , val[maxn] , t[maxn] , res;

void add(int p)
{
	if(a[p] - t[a[p]] > 0)
	{
		res -= (val[a[p] - t[a[p]]] == 0);
		val[a[p] - t[a[p]]]++;
	}
	t[a[p]]++;
}

void rem(int p)
{
	t[a[p]]--;
	if(a[p] - t[a[p]] > 0)
	{
		res += (val[a[p] - t[a[p]]] == 1);
		val[a[p] - t[a[p]]]--;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n , q;
	cin >> n >> q;
	res = n;

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

	while(q--)
	{
		int p , x;
		cin >> p >> x;
		p--;

		rem(p);
		a[p] = x;
		add(p);

		cout << res << endl;
	}
}


















Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
 int n,d;
 cin >> n >> d;
 vector<vector<int> >x(n,vector<int>(d));
 rep(i,n){
     rep(j,d){
         cin >> x[i][j];
     }
 }
 int ans = 0;
 rep(i,n)rep(j,i){
         int sq = 0;
         rep(k,d){
             int s = x[i][k]-x[j][k];
             sq += s*s;
         }
         int s = sqrt(sq)+0.5;
         if(s*s==sq) ans++;
     }
 cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main() {
    int S;
    scanf("%d",&S);
    int h = S / 3600;//時間
    S %= 3600;// S = S % 3600
    int m = S / 60;//分
    int s = S % 60;//秒

    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2668
S = input().split()

l = 0
n = 0
L = "a"
N = "a"

for i in range(len(S)) :
    if S.count(S[i]) > n :
        n = S.count(S[i])
        N = S[i]
    
for i in range(len(S)) :
    if len(S[i]) > l :
        l = len(S[i])
        L = S[i]
        
print(N, L)



Measured memory_bytes: 5560
#include <stdio.h>

int main(){
  int n,i,num[200005],min,max,benefit=0;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
  }
  min=num[0];
  max =-2000000000000005;
    for(i=1;i<n;i++){    
      if(max < num[i]-min) max = num[i]-min;
      if(min > num[i]) min = num[i];
    }

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

  return 0;
}



Measured memory_bytes: 2576
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

LL N, A, B;

int main() {
	cin >> N >> A >> B;
	if ((B - A) % 2 == 0) {
		cout << (B - A) / 2 << endl;
	}
	else {
		cout << min(A - 1 + (B - A + 1) / 2, N - B + 1 + (B - A - 1) / 2) << endl;
	}
	return 0;
}


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


int main()
{
    int n;
    cin >> n;
    set<string> S;

    string command, str;
    for(int i=0; i<n; ++i){
        cin >> command >> str;
        if( command == "insert"){
            S.insert(str);
        }else if( command == "find"){
            auto itr = S.find(str);
            if( itr == S.end() ){
                cout << "no" << endl;
            }else{
                cout << "yes" << endl;
            }
        }
    }

}



Measured memory_bytes: 32608
#include<iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    
    int count(0);
    
    for(int i(N);i>0;i--){
        int tmp(i);
        int keta(1);
        while(tmp/10 > 0){
            keta++;
            tmp /=10;
        }
        if(keta%2 == 1) count++;
    }
    cout << count << endl;
    
    return 0;
}


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

#define MAX 100002

long long int a[MAX];

vector<int> v[MAX];
vector<int> r[MAX];

bool flag[MAX];
int dist[MAX];
int CC = 0;
vector<int> vis;
inline void dfs(int b){
	flag[b] = true;
	if (b){
		vis.push_back(b);
	}
	for (int i = 0; i < v[b].size(); i++){
		flag[v[b][i]] = true;
		dfs(v[b][i]);
	}
	CC++;
}
bool use[MAX];
inline void dfs2(int b,int d=0){
	use[b] = true;
	dist[b] = d;
	for (int i = 0; i < r[b].size(); i++){
		if (flag[r[b][i]]==false){
			if(flag[r[b][i]])dfs2(r[b][i],d+1);
		}
	}
}
int self[MAX];

int cnt[MAX];

int main(){
	int n;
	scanf("%d", &n);
	int k;
	scanf("%d", &k);
	for (int i = 0; i < n; i++){
		scanf("%lld", &a[i]);
		a[i]--;
		v[i].push_back(a[i]);
		r[a[i]].push_back(i);
	}
	//dfs(0);
	int ans2 = INT_MAX;
/*	if (k % 2 == 1){
		for (int i = 1; i < n; i++){
			int cnt = 0;
			for (int j = 0; j < n; j++){
				if (j == i || j == 0){
					continue;
				}
				if (a[j] == 0){

				}
				else{
					cnt++;
				}
			}
			if (a[0] != i){
				cnt++;
			}
			if (a[i] != 0){
				cnt++;
			}
			ans2 = min(ans2, cnt);
		}
	}*/
	queue<int> q;
	for (int i = 0; i < n; i++){
		cnt[i] = r[i].size();
	}
	if (a[0]){
		cnt[a[0]]--;
	}
	for (int i = 1; i < n; i++){
		if (cnt[i] == 0){
			q.push(i);
			dist[i] = k-1;
		}
		else{
			dist[i] = INT_MAX;
		}
	}
	while (!q.empty()){
		int b = q.front();
		q.pop();
		if (b == 0)continue;
		if (cnt[b] == 0){
			for (int i = 0; i < v[b].size(); i++){
				cnt[v[b][i]]--;
				if(cnt[v[b][i]]==0)q.push(v[b][i]);
				dist[v[b][i]] = min(dist[v[b][i]], (dist[b] + k - 1) % k);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++){
		if (dist[i] == 0 && i){
			ans++;
			if (a[i] == 0){
				ans--;
			}
		}
	}
	if (a[0] != 0){
		ans++;
	}
	ans = min(ans, ans2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12800
n = int(input())
a = list(map(int, input().split()))

dic = {}
for v in a:
  tmp = dic.get(v, 0) + 1
  dic[v] = tmp
  
ans_dic1 = {}
ans_dic2 = {}
for k in dic.keys():
  tmp = dic.get(k)
  ans_dic1[k] = tmp * (tmp-1) // 2
  ans_dic2[k] = (tmp-1) * (tmp-2) // 2
  
plus = sum(ans_dic1.values())


for i in range(n):
  ans = plus - ans_dic1[a[i]] + ans_dic2[a[i]]
  print(ans)
  


Measured memory_bytes: 41344
from heapq import heappush, heappop
import sys
r=sys.stdin.readline
def s(n,k):
 def g(S,G):
  F=[1e7]*-~n;F[S],H=0,[(0,S)]
  while H:
   c,u=heappop(H)
   if u==G:return c
   for f,v in E[u]:
    t=c+f
    if t<F[v]:F[v]=t;heappush(H,(t,v))
  return-1
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=r();p=map(int,f[2:].split())
  if'0'==f[0]:print(g(*p))
  else:c,d,e=p;E[c]+=[(e,d)];E[d]+=[(e,c)]
for e in iter(r,'0 0\n'):s(*map(int,e.split()))


Measured memory_bytes: 6276
#include <bits/stdc++.h>
#define ld          double
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
const int maxn = 307;
int n, m,x,y,z;
long double dp[maxn+5][maxn+5][maxn+5];
void solve()
{
    cin>>n;
    rep(i, 0, n)
    {
        cin>>m;
        if(m==1)x++;
        else if(m==2)y++;
        else z++;
    }
    for(int k = 0; k < maxn; k++)
    {
        for(int j = 0; j + k < maxn; j++)
        {
            for(int i = 0; i+j+k < maxn; i++)
            {
                if ((i == 0 && j == 0 && k == 0) || (i + j + k > maxn)) {
                    continue;
                }
                if (i) {
                    dp[i][j][k] += 1.0 * i / (i + j + k) * dp[i - 1][j][k];
                }
                if (j) {
                    dp[i][j][k] += 1.0 * j / (i + j + k) * dp[i + 1][j - 1][k];
                }
                if (k) {
                    dp[i][j][k] += 1.0 * k / (i + j + k) * dp[i][j + 1][k - 1];
                }
                dp[i][j][k] += 1.0 * n / (i + j + k);
            }
        }
    }

    cout<<setprecision(15)<<dp[x][y][z]<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 467200
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut a = vec![VecDeque::new(); n];
    for i in 0..n {
        let v = read_vec::<usize>();
        a[i] = v.into_iter().map(|x| x - 1).collect::<VecDeque<_>>();
    }
    let mut ans = 0;
    loop {
        let mut used_indexes = vec![];
        for i in 0..n {
            if a[i].is_empty() {
                continue;
            }
            let j = a[i][0];
            if a[j][0] == i && i < j {
                used_indexes.push(i);
                used_indexes.push(j);
            }
        }
        if a.iter().all(|x| x.is_empty()) {
            break;
        }
        if used_indexes.is_empty() {
            println!("-1");
            return;
        }
        for idx in used_indexes {
            a[idx].pop_front();
        }

        ans += 1;
    }
    println!("{}", ans);
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 10128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

ll dp[10001];

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

  ll n, m;
  cin >> n >> m;

  ll match[10] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  ll usednum[10] = {};

  ll a[m];
  REP(i, m){
    cin >> a[i];
    usednum[a[i]]++;
  }

  //和をiとするマッチの使い方でできる桁数のうち最大のものをdp[i]に構築
  REP(i, n + 1) dp[i] = -10000;
  dp[0] = 0;
  for(int i = 1; i <= 9; i++){
    if(usednum[i]) dp[match[i]] = 1;
  }

  for(int i = 2; i <= n; i++){
    for(int j = 9; j >= 1; j--){
      if(usednum[j] && i - match[j] >= 0){
        dp[i] = max(dp[i - match[j]] + 1, dp[i]);
      }
    }
  }

  //1桁あたりのマッチの本数に対し描画する数字が一意に定まるのでそれをnumに格納
  int num[8] = {-1, -1, 1, 7, 4, 2, 6, 8};
  if(usednum[3]) num[5] = 3;
  if(usednum[5]) num[5] = 5;
  if(usednum[9]) num[6] = 9;

  //経路復元:1桁ごとに各数字を使用可能かを降順で調べて出力
  ll tmp = n;
  REP(i, dp[n]){
    for(int j = 9; j >= 1; j--){
      if(usednum[j] && tmp - match[j] >= 0){
        if(dp[tmp - match[j]] == dp[tmp] - 1){
          cout << num[match[j]];
          tmp -= match[j];
          break;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;
public class Main {
    private static MyScanner scanner;

    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }

    private void solve() {
        try {
            long N = scanner.nextLong();
            long M = scanner.nextLong();
            long count = 0l;
            if (N * 2 <= M) {
                count += N;
                M -= N *2;
            } else {
                count += M/2;
                M -= M /2 * 2;
            }
            count += M/4;
            System.out.println(count);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int n,w,v;
    while(cin >> n >> w, n){
	int N = 0;
	double p[11] = {0},d = 0,ans = 0;
	for(int i = 0 ; i < n ; i++){
	    cin >> v; p[v/w]++;
	    N = max(N,v/w);
	    d = max(d,p[v/w]);
	}
	for(int i = 0 ; i < N ; i++){
	    ans += (p[i]/d)*((double)(N-i)/N);
	}
	printf("%f\n",ans+0.01);
    }
    return 0;
}

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

int main()
{
  int a,b,c,k,x,y;
  cin>>a>>b>>c>>k;
  x=max(a,max(b,c));
  y=a+b+c-x;
  for(int i=0;i<k;i++)
  {
    x*=2;
  }
  cout<<y+x<<endl;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A;
  rep(i,N){
    int a;
    cin >> a;
    A.push_back(a);
  }

  ll ret = 0;
  ll base = 0;
  map<ll,ll> memo;
  rep(i,N){
    base += A[i];
    base %= M;

    memo[((base%M) - (A[i]%M) + M)%M]++;

    ret += memo[base%M];
  }

  cout << ret << endl;
  
  return 0;
}



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

using namespace std;

int main() {
    while (true) {
        int h, w, n;
        cin >> h >> w >> n;
        if (h == 0)break;
        vector<vector<bool>> east(h, vector<bool>(w));
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int x;
                cin >> x;
                east[i][j] = x == 1;
            }
        }

        vector<vector<int>> dp(h, vector<int>(w));
        dp[0][0] = n - 1;
        for (int sum = 0; sum <= h + w - 2; sum++) {
            for (int i = 0; i < h; i++) {
                int j = sum - i;
                if (0 <= j && j < w) {
                    if (i + 1 < h) {
                        dp[i + 1][j] += dp[i][j] / 2;
                        if (!east[i][j])dp[i + 1][j] += dp[i][j] % 2;
                    }
                    if (j + 1 < w) {
                        dp[i][j + 1] += dp[i][j] / 2;
                        if (east[i][j])dp[i][j + 1] += dp[i][j] % 2;
                    }
                    east[i][j] = (east[i][j] == (dp[i][j] % 2 == 0));
                }
            }
        }

        int retx = 0, rety = 0;
        while (retx < h && rety < w) {
            if (east[retx][rety])rety++;
            else retx++;
        }

        cout << retx + 1 << " " << rety + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 6992
#include<bits/stdc++.h>
using namespace std;
char s[101]; 
int main(){
    cin>>s;
    int n=strlen(s);
	int flag=0;
    for(int i=0;i<n;i++){
    	if(s[i]=='C'){
    		for(int j=i;j<n;j++){
    			if(s[j]=='F'){
    				flag=1;
    				break;
				}
			}
			if(flag==1){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
    return 0;
}

Measured memory_bytes: 256
def solve():
  X = raw_input()
  Y = raw_input()
  a = len(X)
  b =len(Y)
  lcs = [0 for i in range(b+1)]
  
  for i in range(a):
    lcs2 = lcs + []
    for j in range(b):
      if X[i] == Y[j]:
        lcs[j+1] = lcs2[j] + 1
      elif lcs[j+1] < lcs[j]:
        lcs[j+1] = lcs[j]
  
  return lcs[-1]
  
n = input()
for k in range(n):
  print solve()

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

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

    int n; cin>>n;
    vector<ll> a(n);
    for(int i = 0; i<n; i++) cin>>a[i];
    
    sort(a.rbegin(), a.rend());

    ll sum = 0;
    for(int i = 1; i<n; i++) sum += a[i/2];
    cout<<sum<<"\n"; 
    return 0;
}

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

using namespace std;

#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define f first
#define se second
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#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))

typedef long long ll;
//#define MOD 1000000007

void solve()
{
    ll n,m;
    cin>>n>>m;
    if(n*2>=m){
        ll ans=m/2;
        cout<<ans<<endl;
    }
    else{
        if(2*n==m){
            cout<<n<<endl;
        }
        else{
            ll totalC=(2*n)+m;
            ll ans=totalC/4;
            cout<<ans<<endl;
        }
    }
}


int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n" 
using namespace std; 
typedef long long int ll; 
const int INF = 1e9 + 5;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int>h(n);
    for(auto &x : h)
    cin>>x;
    vector<int>dp(n,INF);
    dp[0]=0;
    for(int i=0; i<n; i++)
        for(auto j : {i+1,i+2})
            if(j<n)
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
    cout<<dp[n-1];        
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	. "fmt"
)
func main(){
	X:=" "
	Y:=" "
	Scan(&X,&Y)
	m:=make(map[string]int)
	m["A"]=1
	m["B"]=2
	m["C"]=3
	m["D"]=4
	m["E"]=5
	m["F"]=6

	if m[X]>m[Y]{
		Println(">")
	}else if m[X]<m[Y]{
		Println("<")
	}else{
		Println("=")
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    vector<ll> X(N);
    rep(i,N)cin >> X[i];
    ll res = 0;
    for(int i=1;i<N;i++){
        res += min(A*(X[i]-X[i-1]),B);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
List = [[] for k in range(K)]
for n in range(N):
    List[n % K].append(T[n])

point = {'r': P, 's': R, 'p': S}

score = 0
for k in range(K):
    L = List[k]
    count = 1
    length = len(L)
    for i in range(length):
        try:
            if L[i] == L[i+1]:
                count += 1
            else:
                score += point[L[i]]*((count+1)//2)
                count = 1
        except:
            score += point[L[i]]*((count+1)//2)
print(score)


Measured memory_bytes: 13428
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n, x;
    cin >> n >> x;
    if (x == 1 || x == 2 * n - 1) {
        cout << "No\n";
        return 0;
    }
    --x;
    vi a(2 * n - 1, -1);
    vi used(2 * n - 1);
    a[n - 1] = x;
    if (x > 1) {
        a[n - 2] = x + 1;
        a[n - 3] = x - 1;
        a[n] = x - 2;
    } else if (x < 2 * n - 3) {
        a[n - 2] = x - 1;
        a[n - 3] = x + 1;
        a[n] = x + 2;
    }
    forn(i, 2 * n - 1) if (a[i] >= 0) used[a[i]] = 1;
    int l = 0;
    forn(i, 2 * n - 1) {
        if (a[i] == -1) {
            while (used[l]) ++l;
            a[i] = l;
            used[l] = 1;
        }
    }
    cout << "Yes\n";
    for (int x: a) cout << x + 1 << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3072
n, k = gets.split(" ").map(&:to_i)
dis = gets.chomp.split
likes = ('0'..'9').to_a - dis

max = likes.max
l = n.to_s.size
l += 1 if (max * l).to_i < n
c = nil
likes.repeated_permutation(l) do |ary|
  c = ary.join.to_i
  break if n <= c
end
puts c

Measured memory_bytes: 2172
h,w=map(int,input().split())
list1=[[0 for i in range(w)]for j in range(h)]
for i in range(h):
    list1[i]=list(map(str,input().split()))
print('#'*(w+2))
for i in range(h):
    print('#'+str(''.join(list1[i]))+'#')
print('#'*(w+2))

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var Sd = ReadLine();
            var T = ReadLine();
            var N = Sd.Length;
            var nt = T.Length;
            var c = new string(Enumerable.Repeat('Z', N).ToArray());
            for (var i = 0; i <= N - nt; ++i)
            {
                var flg = true;
                var ct = Sd.Replace('?', 'a').ToArray();
                for (var t = 0; t < nt; ++t)
                {
                    if (Sd[i + t] != '?' && Sd[i + t] != T[t])
                        flg = false;
                    ct[i + t] = T[t];
                }
                if (!flg) continue;
                var cts = new string(ct);
                if (cts.CompareTo(c) < 0)
                    c = cts;
            }
            if (!c.Contains(T)) c = "UNRESTORABLE";
            WriteLine(c);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13408
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+500;
const int fix = 2e3+50;
#define int long long
int n;
int a[N], b[N];
map<int,int> num, used;
signed main(){
  	cin >> n;
  	for(int i=1;i<=n;i++){
    	cin >> a[i];
    	int x = a[i];
    	a[i] = b[i] = 1;
    	for(int j=2;j<=fix;j++){
      		if(x%j==0){
        		int cnt = 0;
        		while(x%j==0) {
          			x/=j;
          			cnt++;
        		}
        		if(cnt%3==1) {
          			a[i] *= j;
          			b[i] *= j*j;
        		}else if(cnt%3==2) {
          			a[i] *= j*j;
          			b[i] *= j;
        		}
      		}
    	}
		if(x!=1){
      		int y = ceil(sqrt(x));
      		a[i] *= x;
      		if(y*y == x) b[i] *= y;
			else b[i] *= (x*x);
    	}
    	num[a[i]]++;
  	}
  	int ans = 0;
  	for(int i=1;i<=n;i++) {
    	if(!used[a[i]]) {
      		used[a[i]] = used[b[i]] = 1;
      		if(a[i]==1) ans++;
      		else ans += max(num[a[i]], num[b[i]]);
    	}
  	}
  	cout << ans;
  	return 0;
}

Measured memory_bytes: 26752
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <numeric>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define INF 999999999
using namespace std;

int main(){
    int n; cin >> n;
    long long a[100005] = {0};
    int temp = 0;

    rep(i, 0, n){
        cin >> temp;
        a[temp] += 1;
    }

    int ans = 0;
    rep(x, 0, 100005){
        temp = 0;
        temp = a[x] + a[x + 1] + a[x + 2];
        if(ans < temp) ans = temp;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n,k;cin>>n>>k;
    vector<ll>p(n);
    for(int i=0;i<n;i++)
        cin>>p[i];
    double q[200001];
    for(int i=0;i<n;i++){
        ll sum=(p[i]+1)*p[i]/2;
        q[i]=(double)sum/p[i];
    }
    double sq[200001];
    for(int i=0;i<n;i++){
        sq[i]=0.0;
    }
    sq[0]=q[0];
    for(int i=1;i<n;i++){
        sq[i]=sq[i-1];
        sq[i]+=q[i];
    }
    double ans=0;
    for(int i=0;i<=n-k;i++){
        double now=sq[i+k-1]-sq[i]+q[i];
        //cout<<sq[i+k-1]<<" "<<sq[i]<<" "<<q[i]<<endl;
        chmax(ans,now);
    }
    printf("%.10lf\n",ans);
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------








Measured memory_bytes: 4992
H, W = map(int, input().split())
M = (H + W) * 80

A = [tuple(map(int, input().split())) for _ in range(H)]
B = [tuple(map(int, input().split())) for _ in range(H)]

dp = [[0] * W for _ in range(H)]
dp[0][0] = (1 << (M - abs(A[0][0] - B[0][0])))

for h in range(H):
    for w, (a, b) in enumerate(zip(A[h], B[h])):
        d = abs(a - b)
        mask = 0
        if h > 0:
            mask |= (dp[h - 1][w] << d)
            mask |= (dp[h - 1][w] >> d)
        if w > 0:
            mask |= (dp[h][w - 1] << d)
            mask |= (dp[h][w - 1] >> d)
        dp[h][w] |= mask

state = dp[-1][-1]
nums = []
for digit, b in enumerate(bin(state)[2:][:: -1]):
    if b == '1':
        nums.append(digit - M)
ans = min(abs(n) for n in nums)
print(ans)


Measured memory_bytes: 20468
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	String s = sc.next();
    if(s.equals("AAA") || s.equals("BBB")){
      System.out.println("No");
    }
    else
    {
      System.out.println("Yes");
    }
    //HashMap<String,Integer> map = new HashMap<String,Integer>();
    //LinkedList<String> array = new LinkedList<String>();
    //int max = 1;
    /*
    for(int i = 0; i < n; i++){
      String s = sc.next();
      int tmp = 1;
      if(map.containsKey(s)){
        tmp = map.get(s)+1;
      }
      map.put(s, tmp);
      
      if(tmp == max){
        array.add(s);
      } 
      else if(tmp > max){
        max = tmp;
        array.clear();
        array.add(s);
      }
    }
    */
    //array.sort(Comparator.naturalOrder());
    //for(String value : array)
	//{
      //System.out.println(value);
	//}
  }
}

Measured memory_bytes: 22480
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using V = vector<int>;
using Vll = vector<ll>;
using VV = vector<V>;
using VVV = vector<VV>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << '\n'; return os; }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;


int main() {
  int n; cin >> n;
  VV xy(2, V(n));
  Vll p(n);
  rep(i, n) cin >> xy[0][i] >> xy[1][i] >> p[i];

  int N = 1<<n;
  VVV dst(2, VV(n, V(N)));

  rep(i, 2) rep(S, N) {
    VV res(n, V(n+1, INF));
    rep(j, n) rep(k, n) if (S>>k&1) res[j][k] = abs(xy[i][j]-xy[i][k]);
    rep(j, n) res[j][n] = abs(xy[i][j]);
    rep(j, n) dst[i][j][S] = *min_element(all(res[j]));
  }

  Vll ans(n+1, INFll);

  rep(S, N) drep(T, S+1) {
    T &= S;
    int U = S^T;
    ll res = 0;
    rep(i, n) res += p[i] * min(dst[0][i][T], dst[1][i][U]);
    int k = popcount(S);
    chmin(ans[k], res);
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 9316
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int H, W, N;

int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  cin >> H >> W >> N;
  int lng = max(H, W);
  int cnt = (N+lng-1)/lng;
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
int N, tmp;

void solve(){
    tmp = N % 10;

    if(tmp == 3){
        cout << "bon" << endl;
    } else if(tmp == 0 || tmp == 1 || tmp == 6 || tmp == 8){
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
}

int main(){
    cin >> N;

    solve();
}


Measured memory_bytes: 3624
n=int(input())
s=[input() for i in range(2)]
mod=10**9+7

if s[0][0]==s[1][0]:
    ans=3
    i=1
    tate=True
else:
    ans=6
    i=2
    tate=False

while i<n:
    if s[0][i]==s[1][i]:
        if tate==True:
            ans*=2
        else:
            pass
        tate=True
        i+=1
    else:
        if tate==True:
            ans*=2
        else:
            ans*=3
        i+=2
        tate=False
    
    ans=ans%mod
print(ans)

Measured memory_bytes: 9116
object Main extends App {
  val s = scala.io.StdIn.readLine
  val t = scala.io.StdIn.readLine

  var cnt = 0
  (0 to (s.length - 1) ).foreach { i =>
    if (s(i) != t(i)) {
      cnt += 1
    }
  }
  println(cnt)
}

Measured memory_bytes: 56648
import java.util.*;

public class Main {

    public static List<List<Integer>> switchList;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double W = sc.nextDouble();
        double H = sc.nextDouble();
        double x = sc.nextDouble();
        double y = sc.nextDouble();
        sc.close();

        int judge = 0;
        double centerW = 0.000000;
        double centerH = 0.000000;
        if (W % 2 == 0) {
            centerW = W / 2;
        } else {
            centerW = W / 2 + 1;
        }

        if (H % 2 == 0) {
            centerH = H / 2;
        } else {
            centerH = H / 2 + 1;
        }

        if (centerH == y && centerW == x) {
            judge = 1;
        } else {
            judge = 0;
        }

        System.out.println(((double) W * (double) H) / 2 + " " + judge);
    }

}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define ull unsigned long long
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> dp(n, INT32_MAX);
    vector<int> V(n);
    for (int &v : V) cin >> v;
    dp[0] = 0;
    for (int i = 0; i < n; i++){
        for (int j : {i + 1, i + 2}){
            if (j < n) dp[j] = min(dp[j], dp[i] + abs(V[j] - V[i]));
        }
    }

    cout << dp.at(n - 1);

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    string s;
    cin >> s;

    int n = s.size();
    for (int i = 0; i < n; i++) {
        s[i] -= '0';
    }

    int dp[2] = { 0, 1 };
    for (int i = 0; i < n; i++) {
        int c = s[i];
        int d1[2];
        for (int h = 0; h < 2; h++) {
            d1[h] = min(dp[0] + c, dp[1] + (10 - c));
            c++;
        }
        for (int h = 0; h < 2; h++) {
            dp[h] = d1[h];
        }
    }

    cout << dp[0] << endl;

    return 0;
}

Measured memory_bytes: 1948