akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int H,W,ans;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};	//drul
bool cand[20][20][4];
bool done[20][20];
typedef vector<int> vi;
void ers_(int x,int y,int d,vi &vx,vi &vy,vi &vd){
	if(0<=x&&x<H&&0<=y&&y<W&&!done[x][y]&&cand[x][y][d]){
		cand[x][y][d]=0;
		vx.pb(x),vy.pb(y),vd.pb(d);
	}
}
void ers(int x,int y,int d,vi &vx,vi &vy,vi &vd){
	ers_(x,y,d,vx,vy,vd);
	ers_(x+dx[d],y+dy[d],(d+2)%4,vx,vy,vd);
}
bool ok(int x,int y){
	return 0<=x&&x<H&&0<=y&&y<W&&!done[x][y];
}
void dfs(int e,int f,int cnt){
	// printf("cnt=%d   %d,%d\n",cnt,e,f);
	// rep(i,H){
	// 	rep(j,W) cout<<done[i][j];
	// 	puts("");
	// }
	if(cnt==H*W/2){
		ans++;
		return;
	}
	rep(d,4) if(ok(e+dx[d],f+dy[d])&&cand[e][f][d]){
//		show(d);
		vector<int> vx,vy,vd;
		int E=e+dx[d],F=f+dy[d];
		int a=min(e,E),b=min(f,F),A=max(e,E),B=max(f,F);
		ers(a-1,b-1,2,vx,vy,vd);
		ers(a-1,b-1,3,vx,vy,vd);
		ers(a-1,B+1,2,vx,vy,vd);
		ers(a-1,B+1,1,vx,vy,vd);
		ers(A+1,b-1,0,vx,vy,vd);
		ers(A+1,b-1,3,vx,vy,vd);
		ers(A+1,B+1,0,vx,vy,vd);
		ers(A+1,B+1,1,vx,vy,vd);
		done[e][f]=1,done[E][F]=1;
		int nx=-1,ny=-1;
		{
			int mn=5;
			rep(x,H) rep(y,W) if(!done[x][y]){
				int cs=0;
				rep(di,4) if(cand[x][y][di]) cs++;
				if(mn>cs){
					mn=cs;
					nx=x,ny=y;
				}
			}
		}
		dfs(nx,ny,cnt+1);
		{	//rmv
			done[a][b]=0,done[A][B]=0;
			rep(i,vx.size()){
				cand[vx[i]][vy[i]][vd[i]]=1;
			}
		}
	}
}
int main(){
	while(true){
		cin>>H>>W;
		if(H==0) break;
		if(H*W%2){
			puts("0");
			continue;
		}
		ans=0;
		rep(i,H) rep(j,W){
			cand[i][j][0]=(i!=H-1);
			cand[i][j][1]=(j!=W-1);
			cand[i][j][2]=(i!=0);
			cand[i][j][3]=(j!=0);
		}
		dfs(0,0,0);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3152
q, h, s, d = map(int, input().split())
n = int(input())

cost_per_2l = min(q*8, h*4, s*2, d)
cost_per_1l = min(q*4, h*2, s)

a = n // 2
b = n % 2

print(a*cost_per_2l + b*cost_per_1l)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vector<int>>;

bool ispalindrome(string s){
    int m = s.size();
    int loopcount = m/2;
    bool kaibun = true;
    rep(0,i,m/2){
        if(s[i]!=s[m-1-i]) kaibun = false;
    }
    return kaibun;
}

int main(){
    string s; cin>>s;
    int n = s.size();
    bool b1,b2,b3;
    b1 = ispalindrome(s);
    b2 = ispalindrome(s.substr(0,(n-1)/2));
    b3 = ispalindrome(s.substr((n+3)/2-1,n));

    if(b1&&b2&&b3){
        cout << "Yes" <<endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
S = input()
if S[:2] == "00":
    if S[2:] == "00" or "12" < S[2:]:
        print("NA")
    elif "01" <= S[2:] <= "12":
        print("YYMM")
elif "01" <= S[:2] <= "12":
    if S[2:] == "00" or "12" < S[2:]:
        print("MMYY")
    elif "01" <= S[2:] <= "12":
        print("AMBIGUOUS")
else:
    if S[2:] == "00" or "12" < S[2:]:
        print("NA")
    elif "01" <= S[2:] <= "12":
        print("YYMM")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string> 
#include <cstring>

using namespace std;
const int inf=0x3f3f3f3f;
int dist[105][105];
struct edge{
	int a,b,c;
}e[1100];

int n,m;
void Floyd()
{
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);		
			}
		}
	}
}
int main()
{
	while(cin>>n>>m)
	{
		for(int i=1;i<=n;i++)
		{	
			for(int j=1;j<=n;j++)
			{
				if(i==j)
				dist[i][j]=0;
				else
				dist[i][j]=inf;
			}
		}
		for(int i=0;i<m;i++)
		{
			cin>>e[i].a>>e[i].b>>e[i].c;	
			dist[e[i].a][e[i].b]=e[i].c;
			dist[e[i].b][e[i].a]=e[i].c;
		}
		Floyd();
	
		int ans=m;   
		for(int i=0;i<m;i++)
		{
			bool flag=false;
			for(int s=1;s<=n;s++)
			{
				int u=e[i].a,v=e[i].b,w=e[i].c;
				if(dist[s][u]+w==dist[s][v])
				flag=true;
			}
			if(flag)
			ans--;
		} 
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
// priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
priority_queue<ll> PQ;

int main(){
  int n;
  scanf("%d", &n);
  int t;
  t = n % 1000;
  if(t == 0) printf("0\n");
  else printf("%d\n",1000 - t);

  return 0;
}


Measured memory_bytes: 3824
#include <iostream>
using namespace std;
int a[20005];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	a[i]=i*n+1;
	for (int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		a[x-1]+=i;
	}
	for (int i=0;i<n;i++)
	printf("%d ",a[i]);
	printf("\n");
	for (int i=0;i<n;i++)
	printf("%d ",(n-i-1)*n+1);
}

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

using namespace std;
const int N=3e5+5;
int near[N][30];
int lst[30];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    int n=(int)s.size();
    s+=s;
    memset(lst,-1,sizeof lst);
    for(int i=s.size()-1;i>=0;i--)
    {
        for(int j=0;j<26;j++)
            near[i][j]=lst[j];
        lst[s[i]-'a']=i%n;
    }
    string t;
    cin>>t;
    int a=0,b=0;
    int cur=0;
    long long ans=0;
    while(b<t.size()&&s[a%n]==t[b])
    {
        a++;b++;cur++;ans++;
        cur%=n;
    }
    bool f=0;
    for(int i=b;i<t.size();i++)
    {
        f=1;
        if(near[cur][t[i]-'a']==-1)
        {
            cout<<-1<<endl;
            return 0;
        }
        int v=(near[cur][t[i]-'a']-cur+n)%n;
        if(v==0) v=n;
        ans+=v;
        cur=near[cur][t[i]-'a'];
    }
    cout<<ans+f<<endl;
    return 0;
}


Measured memory_bytes: 25324
function f(inp) {
    inp = inp.split("\n");
    var N = +inp[0];
    var H = inp[1].split(" ").map(s => +s);
    var lf = H[0];
    for (var i = 1; i < N; i++) {
        var x = H[i];
        if (lf < x) {
            H[i] = --x;
        }
        else if (lf > x) {
            console.log("No");
            return;
        }
        lf = x;
    }
    console.log("Yes");
}
f(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17816
#include <stdio.h>

int main(void) {
  int N, M = 0;
  scanf("%d", &N);
  int a[N];
  int b[N] = {};
  for (int i = 0; i < N; ++i) scanf("%d", &a[i]);
  for (int i = N; i > 0; --i) {
    int sum = 0;
    for (int j = 1; j*i <= N; ++j) {
      sum += b[j*i-1];
    }
    if (sum%2 != a[i-1]) b[i-1] = 1;
    M += b[i-1];
  }
  printf("%d\n", M);
  if (M == 0) return 0;
  int first;
  for (int i = 1; i <= N; ++i) {
    if (b[i-1] == 1) {first = i; break;}
  }
  printf("%d", first);
  for (int i = first + 1; i <= N; ++i) {
    if (b[i-1]==1) printf(" %d", i);
  }
  puts("");
  return 0;
}


Measured memory_bytes: 2432
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int i;
try (Scanner sc = new Scanner(System.in)) {
while (true) {
int n = sc.nextInt();
if (n == 0) { break; }
int[] s = new int[n];
for (i = 0; i < s.length; i++) {
s[i] = sc.nextInt();
}
double average = 0, variance = 0, sum = 0;
for(i=0; i<n; i++){
    sum += s[i];
}
average = sum/n;
for(i=0; i<n; i++){
variance += (s[i]-average)*(s[i]-average);
}
variance = variance/n;
System.out.println(Math.sqrt(variance));
}
}
}
}


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

int n;
int a[23][23];
LL dp[1<<16];

LL doit(int bit) {
	if (dp[bit] != -1) return dp[bit];
	dp[bit] = 0;
	int p[16],cp = 0;
	for (int i=0; i<n; i++) {
		if ((1<<i) & bit) {
			p[cp++] = i;
		}
	}
	for (int i=0; i<cp; i++) {
		for (int j=i+1; j<cp; j++) {
			dp[bit] += a[p[i]][p[j]];
		}
	}
	//printf("Yo %d = %lld\n",bit,dp[bit]);
	for (int i=1; i<(1<<(cp-1)); i++) {
		int g1 = 0,g2 = 0;
		for (int j=0; j<cp; j++) {
			if ((1<<j) & i) {
				g1 |= (1<<p[j]);
			}
			else {
				g2 |= (1<<p[j]);
			}
		}
		//printf("  %d %d\n",g1,g2);
		dp[bit] = max(dp[bit],doit(g1)+doit(g2));
	}
	return dp[bit];
}

int main() {
	scanf("%d",&n);
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			scanf("%d",&a[i][j]);
		}
	}
	memset(dp,-1,sizeof(dp));
	printf("%lld\n",doit((1<<n)-1));
	return 0;
}


Measured memory_bytes: 768
#include<cstdio>
#include<queue>
#define MAX 100
#define INF 1000
using namespace std;
int n, g[MAX][MAX], labels[MAX], d[MAX];
queue<int> Q;

void bfs(int s) {
    int v,u;
    labels[s] = 1;
    d[s]=0;
    Q.push(s);
    while (!Q.empty()) {
	u = Q.front(); Q.pop();
	for (v=0; v<n; v++) {
	    if (g[u][v] && labels[v]==0) {
		labels[v] =1;
		d[v] = d[u] +1;
		Q.push(v);
	    }
	}
	labels[u] = 2;
    }
}

int main() {
    int i,u,k,v,j;
    scanf("%d",&n);
    for(i=0;i<n;i++){
	for(j=0;j<n;j++){
	    g[i][j]=0;
	}
    }

    for(i=0;i<n;i++){
	scanf("%d %d",&u, &k);
	for(j=0;j<k;j++){
	    scanf("%d",&v);
	    g[u-1][v-1]=1;
	}
    }

    for(i=0; i<n; i++) { labels[i]=0; d[i]=INF;}

    bfs(0);

    for(i=0; i<n; i++) {
	if (d[i] != INF) printf("%d %d\n", i+1, d[i]);
	else printf("%d -1\n", i+1);
    }
    return 0;
}
    

Measured memory_bytes: 1072
w = input()

def g(num):
   if num%2 == 0:
      return 1
   else:
      return 0

if g(w.count('a'))*g(w.count('b'))*g(w.count('c'))*g(w.count('d'))*g(w.count('e'))*g(w.count('f'))*g(w.count('g'))*g(w.count('h'))*g(w.count('i'))*g(w.count('j'))*g(w.count('k'))*g(w.count('l'))*g(w.count('m'))*g(w.count('n'))*g(w.count('o'))*g(w.count('p'))*g(w.count('q'))*g(w.count('r'))*g(w.count('s'))*g(w.count('t'))*g(w.count('u'))*g(w.count('v'))*g(w.count('w'))*g(w.count('x'))*g(w.count('y'))*g(w.count('z')) == 0:
   print("No")
else:
   print ("Yes")

Measured memory_bytes: 3188
n = int(input())
s = input()
ans = 0
for i in range(1, n):
    k = 0
    used = []
    a = s[0:i]
    b = s[i:n]
    l, r = len(a), len(b)
    if l <= r:
        for j in range(l):
            if not a[j] in used:
                used.append(a[j])
                if a[j] in b:
                    k += 1
    else:
        for j in range(r):
            if not b[j] in used:
                used.append(b[j])
                if b[j] in a:
                    k += 1
    ans = max(ans, k)

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    int a[110];
    cin >> n;
    imfor(i, n) {
        cin >> a[i];
    }
    sort(a, a + n);
    cout << a[n - 1] - a[0] << endl;
}

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

int main() {
    int n, m;
    while(cin >> n >> m, n) {
        vector<int> a(n);
        for(int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        int ans = -1;
        for(int i = 0; i < n; ++i) {
            for(int j = i + 1; j < n; ++j) {
                if(a[i] + a[j] <= m) {
                    ans = max(ans, a[i] + a[j]);
                }
            }
        }
        if(ans == -1) cout << "NONE" << endl;
        else          cout << ans << endl;
    }
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using db = double;
using vi = vector<int>;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define debug(x) cout << #x <<'	' << x <<endl
const int inf = 0x3f3f3f3f;
const db eps = 1e-8;
const int mod = 1e9+7;
ll qpow(ll a, ll b){
    ll ret = 1;
    while(b){
        if(b&1)ret = ret*a%mod;
        a = a*a%mod;
        b>>=1;
    }
    return ret;
}
const int maxn = 1e5+7;
ll a[maxn], b[maxn];int q[maxn]; 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, s;
	cin >> n >> s;
	int id=0;
	for(int i=1; i<=n; ++i){
		cin >> a[i] >> b[i];
		if(a[i]<s)id=i;
	}
	int cnt = 0, l=1, r=n;
	while((l<=id)^(r<=id)){
		if(b[l]>=b[r]){
			q[++cnt] = a[r];
			b[l] += b[r];
			r--;
		}else{
			q[++cnt] = a[l];
			b[r] += b[l];
			l++;
		}
	}
	if(r<=id){
		for(int i=l; i<=r; ++i)q[++cnt] = a[i];
	}else{
		for(int i=r; i>=l; --i)q[++cnt] = a[i];
	}
	q[cnt+1] = s;
	ll ans = 0;
	for(int i=1; i<=cnt; ++i){
		ans += abs(q[i]-q[i+1]);
	}
	cout << ans <<"\n";
}


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;
   
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n,k;
  cin>>n>>k;

  int sum=1;
  reps(i,n-1){
    sum*=(k-1);
  }
  cout<<sum*k<<'\n';
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(input())
stack = []
for i in range(n):
    if s[i] == "(":
        stack.append("(")
    elif len(stack) == 0 or stack[-1] == ")":
        stack.append(")")
    else:
        stack.pop()
stack = sorted(stack, reverse=True)
idx = 0
while idx < len(stack):
    if stack[idx] == "(":
        break
    else:
        print("(", end="")
    idx+=1
for ch in s:
    print(ch, end="")
for i in range(idx, len(stack)):
    print(")", end="")






Measured memory_bytes: 62652
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
using namespace std;
int main() {
    unordered_map<int, bool> H_tmp, W_tmp;
    int H, W; cin >> H >> W;
    vector<string> a(H, "");
    for (int i = 0; i < H; i++) cin >> a[i];

    for (int i = 0; i < H; i++) {
        bool T = true;
        for (int j = 0; j < W; j++) {
            if (a[i][j] == '#') {
                T = false; break;
            }
        }
        H_tmp[i] = T;
    }

    for (int i = 0; i < W; i++) {
        bool T = true;
        for (int j = 0; j < H; j++) {
            if (a[j][i] == '#') {
                T = false; break;
            }
        }
        W_tmp[i] = T;
    }

    for (int i = 0; i < H; i++) {
        if (H_tmp[i] == false) {
            for (int j = 0; j < W; j++) {
                if (W_tmp[j] == true) continue;
                cout << a[i][j];
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

int main(){
    int n, q;
    cin >> n >> q;
    ppi p[n];
    rep(i, n){
        int s, t, x;
        cin >> s >> t >> x;
        p[i] = make_pair(make_pair(max(0, s-x), max(0, t-x)), x);
    }
    sort(p, p+n);
    int cur = 0;
    priority_queue<pii, vector<pii>, greater<pii>> que;
    rep(i, q){
        int d;
        cin >> d;
        while(cur < n && p[cur].fi.fi <= d){
            que.push(make_pair(p[cur].se, p[cur].fi.se));
            cur++;
        }
        while(true){
            if(que.empty()){
                cout << -1 << endl;
                break;
            }
            pii v = que.top();
            if(v.se <= d){
                que.pop();
                continue;
            }
            cout << v.fi << endl;
            break;
        }
    }
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

int main() {
    int N, M;

    cin >> N >> M;

    dsu d(N);

    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        d.merge(A - 1, B - 1);
    }

    cout << d.groups().size() - 1 << endl;

    return 0;
}

Measured memory_bytes: 8884
//作者：中国江苏省南京市李硕睿
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
const int MAXN=2e5+10;
int Fa[2][MAXN],cnt[MAXN];
map<pair<int,int>,int> MP;
pair<int,int> A[MAXN];
int n;
void Init(){
	for (int k=0;k<2;k++)
		for (int i=0;i<n;i++){
			Fa[k][i]=i;
		}
}
int Getfa(int x,int z){
	return (Fa[z][x]==x?x:Fa[z][x]=Getfa(Fa[z][x],z));
}
void Union(int x,int y,int z){
	x=Getfa(x,z);
	y=Getfa(y,z);
	if (x==y)return;
		Fa[z][y]=x;
}
int main(){
	int kl[2];
	cin>>n>>kl[0]>>kl[1];
	Init();
	for (int tc=0;tc<2;tc++){
		for (int i=0;i<kl[tc];i++){
			int x,y;
			cin>>x>>y;
			x--,y--;
			Union(x,y,tc);
		}
	}
	for (int i=0;i<n;i++){
		int ii=Getfa(i,0);
		int iii=Getfa(i,1);
		A[i]=make_pair(ii,iii);
		MP[A[i]]++;
	}
	for (int i=0;i<n;i++)
		cout<<MP[A[i]]<<" ";

	cout<<endl;
	return 0;
}

Measured memory_bytes: 15104
a, b, c, x, y = gets().chomp.split("\s").map{|x| x.to_i}

sep_total = a * x + b * y

min = [x, y].min
max = [x, y].max
mix_total1 = min * c * 2 + (x - min) * a + (y - min) * b

mix_total2 = max * c * 2

puts [sep_total, mix_total1, mix_total2].min


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

double a[200007];
double sum[200007];

int main(){
  int n,k;
  int i,x;
  double max = -999999999;
  double t;

  scanf("%d %d", &n, &k);

  for(i = 1;i <= n;i++){
    scanf("%d", &x);

    a[i] = (double)(x + 1)/2;
  }

  sum[0] = 0;
  sum[1] = a[1];

  for(i = 2;i <= n;i++){
    sum[i] = sum[i - 1] + a[i];
  }

  for(i = 0;i <= n - k;i++){
    t = sum[i + k] - sum[i];

    if(max < t) max = t;
  }

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

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////




int main() {

	ll n,q;
	cin >> n >> q;
	string s;
	cin >> s;

	ll l[MAX], r[MAX];
	repn(i, q) cin >> l[i] >> r[i];

	ll ac[MAX];

	ac[0] = 0;

	repn(i, n-1) {
		if (s[i - 1]=='A'&&s[i]=='C') { ac[i] = ac[i - 1] + 1; }
		else { ac[i] = ac[i - 1]; }
	}

	repn(i, q) {
		cout << ac[r[i] - 1] - ac[l[i]-1]<<endl;
	}
	

	system("PAUSE");
}

Measured memory_bytes: 10232
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

maxVal = N + max(A)
ans = 0

candidatesL = defaultdict(int)
for i in range(1, N+1):
    candidatesL[i+A[i-1]] += 1

candidatesR = defaultdict(int)
for j in range(1, N+1):
    candidatesR[j-A[j-1]] += 1

ans = 0
for x in candidatesL.keys():
    ans += candidatesL[x] * candidatesR[x]

print(ans)


Measured memory_bytes: 151880
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int int64_t
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;

inline int64_t updiv(int64_t n,int64_t d){
    return ((n + d -1) / d);
}
/*
inline double Sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
*/
// }}}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<int> a(n),b(n),c(m),d(m);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    rep(i,m){
        cin >> c[i] >> d[i];
    }
    rep(i,n){
        int pnt,min_cost = LINF;
        rep(j,m){
            if(chmin(min_cost,abs(a[i]-c[j])+abs(b[i]-d[j]))) pnt = j;
        }
        cout << pnt + 1 << '\n';
    }
    return 0;
}


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

int main() {
  long long N; cin >> N;
  long long A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  long long A_[N];
  for (int i = 0; i < N; i++) A_[i] = A[i];
  
  long long count = 0;
  long long keta[20];
  for (long long i = 0; i < 20; i++) keta[i] = 0;
  long long now_L = 0;
  for (long long i = 0; i < N; i++){
    long long help = 0;
    while (A[i] > 0){
      keta[help] += A[i] % 2;
      help++;
      A[i] = A[i] >> 1;
    }
    while (1){
      bool flag2 = false;
      for (int j = 0; j < 20; j++){
        if (keta[j] > 1) flag2 = true;
      }
      if (flag2 == false) break;
      help = 0;
      for (int j = 0; j < 20; j++){
        keta[help] -= A_[now_L] % 2;
        help++;
        A_[now_L] = A_[now_L] >> 1;
      }
      now_L++;
    }
    count += i - now_L + 1;
  }
  cout << count << endl;
}

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

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


  int d1, d10;
  int ans = 0;
  for (int i = 1; i <= m; i ++) {
    for (int j = 1; j <= d; j ++) {
      int t = j;
      d1 = t % 10;
      t /= 10;
      d10 = t;
      if (d1 >= 2 && d10 >= 2 && d1 * d10 == i) ans ++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
#define Y first
#define X second
signed main(){
  int w,h;
  while(cin>>w>>h,w||h){
    string s[h][w];
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	cin>>s[i][j];
    vector<P> v[50000];
    int gy,gx,gd=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(s[i][j]==".") continue;
	if(s[i][j]=="S"){
	  v[0].push_back(P(i,j));
	  continue;
	}
	if(s[i][j]=="G"){
	  gy=i;gx=j;
	  continue;
	}
	int k=stoi(s[i][j]);
	v[k].push_back(P(i,j));
	gd=max(gd,k);
      }
    }
    v[++gd].push_back(P(gy,gx));
    int dp[h][w];
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	dp[i][j]=1LL<<55LL;
    dp[v[0][0].Y][v[0][0].X]=0;
    for(int i=0;i<gd;i++){
      for(int j=0;j<(int)v[i].size();j++){
	for(int k=0;k<(int)v[i+1].size();k++){
	  int cost=abs(v[i+1][k].Y-v[i][j].Y)+abs(v[i+1][k].X-v[i][j].X);
	  dp[v[i+1][k].Y][v[i+1][k].X]=
	    min(dp[v[i+1][k].Y][v[i+1][k].X],dp[v[i][j].Y][v[i][j].X]+cost);
	}
      }
    }
    cout<<dp[v[gd][0].Y][v[gd][0].X]<<endl;
  }
  return 0;
}

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

int pow(int n,int x)
{
  int ans=1;
  for(int i=0;i<x;i++) ans*=n;
  return ans;
}

int main()
{
  int d,n;
  cin >> d >> n;
  n=n+n/100;
  cout << pow(100,d)*n;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[200100],b[200100];
int main() {
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int l=0, r=n-1, cnt=0;
	for(int i=n-1;i>=0;i--){
		if(cnt%2==0)b[l++] = a[i];
		else	
          b[r--] = a[i];
		cnt++;
	}
	for(int i=0;i<n;i++){
		if(i) cout<<" ";
		cout<<b[i];
	}
	cout<<endl;
	return 0;
}


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

ll gcd(ll x,ll y){
  if(x%y==0) return y;
  else gcd(y,x%y);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, m;
  string s, t;
  cin >> n >> m >> s >> t;
  ll G = gcd(n,m);
  ll L = (n*m)/G;
  
  if(s[0]!=t[0]){
    cout << -1 << endl;
    return 0;
  }
  if(G==1){
    cout << L << endl;
    return 0;
  }
  if(n>=m){
    ll N = n/G;
    ll M = m/G;
    bool ok = true;
    for(ll i=1;i<G;i++){
      if(s[N*i]!=t[M*i]) ok = false;
    }
    
    if(ok){
      cout << L << endl;
    }
    else{
      cout << -1 << endl;
    }
  }
  else{
    ll N = n/G;
    ll M = m/G;
    
    bool ok = true;
    for(ll i=1;i<G;i++){
      if(s[N*i]!=t[M*i]) ok = false;
    }
    
    if(ok){
      cout << L << endl;
    }
    else{
      cout << -1 << endl;
    }
  }
  return 0;
  
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });
 
int main(){
    string S;
    cin >> S;
    ll min = 1e18;
    REP(i, S.size()-2) {
        ll n = stoi(S.substr(i,1) + S.substr(i+1,1) + S.substr(i+2,1));
        chmin(min, abs(753-n));
    }
    cout << min << "\n";
}


Measured memory_bytes: 256
def rle(s):
    n = len(s)
    if n == 0:
        return []
    res = []
    prev = s[0]
    count = 1
    index = 0
    while index < n:
        index += 1
        if index < n:
            if s[index] == prev:
                count += 1
                continue
        res.append([prev, count])
        if index < n:
            prev = s[index]
            count = 1
    return res


s = input().rstrip()
k = int(input())
counts = rle(s)
if len(counts) == 1:
    res = (counts[0][1] * k) // 2
else:
    res = counts[0][1] // 2
    res += counts[-1][1] // 2
    for c, v in counts[1:-1]:
        res += v // 2 * k
    if counts[0][0] == counts[-1][0]:
        res += (counts[0][1] + counts[-1][1]) // 2 * (k - 1)
    else:
        res += counts[0][1] // 2 * (k - 1) + counts[-1][1] // 2 * (k - 1)
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int cnt=0;
  string s;
  cin>>s;
  string c;
  while(cin>>c)
  {
    if(c=="END_OF_TEXT")
    {
      break;
    }
    for(int i=0; i<c.size(); i++)
    {
        if(c[i]>='A' && c[i]<='Z')
        c[i]=c[i]-'A'+'a';
    }
       if(s==c)
       {
         cnt++;
       }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3196
#include <stdio.h>

int main(void) {
  int m, nmin, nmax, p[200], i, dif[200], max, ans;
  while (1) {
    scanf("%d %d %d", &m, &nmin, &nmax);
    if (m == 0 && nmin == 0 && nmax == 0) return 0;
    for (i = 0; i < m; i++)
      scanf("%d", &p[i]);
 
    for (i = 0; i < 200; i++)
      dif[i] = 0;
 
    for (i = nmin - 1; i < nmax; i++)
      dif[i] = p[i] - p[i + 1];
 
    max = dif[nmin - 1];
    ans = nmin;
    for (i = nmin; i < nmax; i++)
      if (dif[i] >= max) {
    max = dif[i];
    ans = i + 1;
      }
    printf("%d\n", ans);
  }
  return 0;
  
}


Measured memory_bytes: 2036
#include<stdio.h>
int main(){
	int R,L,F,B,W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	R = x-r;
	L = x+r;
	F = y+r;
	B = y-r;
	if(0 <= R&& L <= W&&0 <= B&&F <= H)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 2592
#include <bits/stdc++.h>
using namespace std;
int main() {
     int a,b,c,d;
     cin >> a >> b >> c >> d;
     int x = c - a; int y = d - b;
     cout << c - y << " " << d + x << " " << a - y << " " << b + x << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(s: str):
    print(s.rindex("Z") - s.index("A") + 1)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3520
import sys
sys.setrecursionlimit(10000)

n, m = map(int, input().split())
edges = [set() for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    edges[a - 1].add((b - 1, c))

NINF = float('-inf')
dists = [NINF for _ in range(n)]
dists[0] = 0


def trace(v, updated):
    updated[v] = True
    for b, c in edges[v]:
        if not updated[b]:
            trace(b, updated)


def bellman_ford():
    for i in range(n - 1):
        updated = False
        for j in range(n):
            dj = dists[j]
            if dj == NINF:
                continue
            for b, c in edges[j]:
                if dists[b] >= dj + c:
                    continue
                dists[b] = dj + c
                updated = True
        if not updated:
            return dists[-1]

    n_updated = [False] * n
    for j in range(n):
        if n_updated[j]:
            continue
        dj = dists[j]
        if dj == NINF:
            continue
        for b, c in edges[j]:
            if dists[b] < dj + c:
                trace(b, n_updated)

    return 'inf' if n_updated[-1] else dists[-1]


print(bellman_ford())


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

int main(){
  int a, b, c, ans;
  
  cin >> a >> b >> c;
  
  ans = c- (a - b);
  
  if(ans < 0){
    cout << 0 << endl;
  }
  else{
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  int p = s.size();
  int ans = 0;
  for(int i=0;i<p/2;i++){
    if(s.at(i) != s.at(p-i-1)){ans++;}
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    sort(a.rbegin(), a.rend());
    ll ans = a[0];
    int c = n - 2;
    // cerr << c << endl;
    for(int i = 1; i < n; ++i){
        if(c >= 2){
            ans += a[i] * 2;
            c -= 2;
        }
        else if(c == 1){
            ans += a[i];
            --c;
        }
        if(c <= 0)  break;
    }
    cout << ans << endl;
}

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

int main(void) {
	int a, b, c, d, e, k, count = 0;
	cin >> a >> b >> c >> d >> e >> k;
	if (max({ e - d, d - e, e - c, c - e, e - b, b - e, e - a, a - e, d - c, c - d, d - b, b - d, d - a, a - d, c - b, b - c, c - a, a - c, b - a, a - b }) > k) {
		cout << ":(";
	}
	else cout << "Yay!";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

typedef pair<long long,long long> P;

int main(){
  int n;
  cin>>n;
  long long x[n],y[n];
  REP(i,n){
    cin>>x[i]>>y[i];
  }
  
  int e=0;//グラフの辺の数
  map<P,int> mp;
  REP(i,n){
    REP(j,n){
      if(i==j){
        continue;
      }
      mp[P(x[i]-x[j],y[i]-y[j])]++;
      e = max(e,mp[P(x[i]-x[j],y[i]-y[j])]);
    }
  }
  int ans = n-e;//グラフの連結成分の数
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
def main():
    import sys
    from fractions import gcd
    input = sys.stdin.readline

    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    A_ = [a//2 for a in A]
    lcm = A_[0]
    t_num = 0
    a = A_[0]
    while a % 2 == 0:
        t_num += 1
        a //= 2
    for a in A_:
        lcm = (lcm * a) // gcd(a, lcm)
        t_n = 0
        while a % 2 == 0:
            t_n += 1
            a //= 2
        if t_n != t_num:
            print(0)
            exit()
    ans = K // lcm
    print((ans+1)//2)


if __name__ == '__main__':
    main()


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

ll counter = 0;
ll limit = 0;

void dfs(ll val, int cond)
{
    if(val > limit)
    {
        return ;
    }
    if( cond == 0b111) counter++;
    if(int(log10(val))==int(log10(limit)))
    {
        return;
    }

    dfs(val*10+3,cond|0b001);
    dfs(val*10+5,cond|0b010); 
    dfs(val*10+7,cond|0b100);
}

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

    ll N;
    cin >> N;
    limit=N;

    dfs(0,0);

    cout << counter << endl;

    return 0;
}



Measured memory_bytes: 512
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int height[] = new int[10];
		int first = -1, second = -1, third = -1;
		
		for (int i = 0; i < 10; i++) {
			height[i] = scanner.nextInt();
		}
		for (int i = 0; i < 10; i++) {
			if (first == -1 || height[first] < height[i]) {
				third = second;
				second = first;
				first = i;
			}
		}
		for (int i = 0; i < 10; i++) {
			if ((i != first) && (second == -1 || height[second] < height[i])) {
				third = second;
				second = i;
			}
		}
		for (int i = 0; i < 10; i++) {
			if ((i != first) && (i != second) && (third == -1 || height[third] < height[i])) {
				third = i;
			}
		}
		System.out.println(height[first]);
		System.out.println(height[second]);
		System.out.println(height[third]);
	}
}

Measured memory_bytes: 12000
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long
const int M = 1000 * 1000 * 1000 + 7;

void solve() {
	int n;
	cin >> n;
	int a = 1, b = 1, c = 1, d = 1;
	for (int i = 0; i < n; i++) {
		a *= 10;
		b *= 9;
		c *= 8;
		a %= M;
		b %= M;
		c %= M;
	}
	cout << ((a - b - b + c) + M * 3) % M;
}

int32_t main() {
	int t = 1;
//	cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
int gcd(ll a,ll b){ return (b%a==0)?a:gcd(b-a*(b/a),a);}
int main()
{
   ll i,j,k,n,t,x;
   cin>>n>>x>>t;
   if(n%x==0){cout<<n*t/x<<endl;}
   else{cout<<((n/x)+1)*t<<endl;}
   return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace procon
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var inputs = new List<int>();
            for (int i = 0; i < n; i++)
            {
                inputs.Add(int.Parse(Console.ReadLine()));
            }
            
            Console.WriteLine(inputs.Count(num => isPrime(num) == true));
        }

        static bool isPrime(int n)
        {
            if (n == 2) return true;
            else if (n < 2 || n % 2 == 0) return false;

            var sq = Math.Sqrt(n);
            for (int i = 3; i <= sq; i+=2)
            {
                if (n % i == 0) return false;
            }

            return true;
        }
    }
}

Measured memory_bytes: 9696
#include<bits/stdc++.h>
using namespace std;
int n,m,q;
int qzh[501][501];
int l,r; 
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m>>q;
	for(int i=1;i<=m;i++){
		cin>>l>>r;
		qzh[l][r]++;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			qzh[i][j]+=qzh[i][j-1];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			qzh[i][j]+=qzh[i-1][j];
	for(int i=1;i<=q;i++){
		cin>>l>>r;
		cout<<qzh[r][r]+qzh[l-1][l-1]-qzh[r][l-1]-qzh[l-1][r]<<endl;
	}
	return 0;
}


Measured memory_bytes: 1920
import java.io.*;
import java.util.*;
  
public class Main{
  public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        String[] spl=s.split(" ");
        int a=Integer.parseInt(spl[0]);
        int b=Integer.parseInt(spl[1]);
        int c=Integer.parseInt(spl[2]);
  
        Arrays.sort(spl);
        System.out.println(spl[0]+" "+spl[1]+" "+spl[2]);
  
    }
}

Measured memory_bytes: 24132
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>	
#define inf INT_MAX
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(int *)a-*(int *)b;
}

int main(void){
	int n=in(),a,i,s,d,f,g,h,j,k,l,m,min;
	s=d=f=g=h=j=k=l=m=0;
	rep(i,n){
		a=in();
		if(a<400)s=1;
		else if(a<800)d=1;
		else if(a<1200)f=1;
		else if(a<1600)g=1;
		else if(a<2000)h=1;
		else if(a<2400)j=1;
		else if(a<2800)k=1;
		else if(a<3200)l=1;
		else m++;
	}
	min=s+d+f+g+h+j+k+l;
	if(min==0){
		print2(1,m);
	}
	else{
		print2(min,min+m);
	}
	return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
typedef long long ll;

int main()
{
    IOS

    int l;
    cin >> l;

    long double resp = (long double)l / 3;

    resp *= resp * resp;

    cout << fixed << setprecision(12) << resp;

    return 0;
}


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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

ll vatical[1010];
ll horizontal[1010];

int main(){
  int H,W,A,B;cin >> H >> W >> A >> B;
  for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){
      if(j < A && i < B) cout << 0;
      if(j >= A && i < B) cout << 1;
      if(j < A && i >= B) cout << 1;
      if(j >= A && i >= B) cout << 0;
    }
    cout << endl;
  }
}


Measured memory_bytes: 1280
import java.util.Scanner;

class Main{
    int i, x;
    public void aaaa(){
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        for(i = 1; x != 0; i++){
            System.out.println("Case " + i + ": " + x);
            x = sc.nextInt();
        }
    }
        public static void main(String[] args){
            new Main().aaaa();
        }
        
}

Measured memory_bytes: 33004
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
//original idea: stupid wanna check the node with many bfs search 
using namespace std;
#define N 105 // number of nodes
vector<int> neighbors[N]; //start from 1
queue<int> q;
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_C bfs
int dist[N];
int vis[N];
int res = 0;
void bfs(int d){
	if(q.empty()) return;
	//until q is empty
	while(!q.empty()){
		int temp = q.front();
		q.pop();
		if(dist[temp]!=-1){
			if(d<dist[temp]) dist[temp] = d;
			else {dist[temp] = dist[temp];}
		}else {
			dist[temp] = d;
		}
		for(int i = 0; i<neighbors[temp].size(); i++){
			d = dist[temp] +1;//next lever
		if(dist[neighbors[temp].at(i)] == -1){//not visited
			q.push(neighbors[temp].at(i));
			dist[neighbors[temp].at(i)] = d;
			}
		}
		
	}
	
}

int main()
{
    int n;
    scanf("%d",&n);
    memset(dist, -1, sizeof(dist));
    memset(vis, -1, sizeof(dist));
    for(int i = 0; i<n; i++){
        int node;
        scanf("%d",&node);
        int num;
        scanf("%d",&num);
        for(int j = 0; j<num; j++){
        	int temp;
        	scanf("%d",&temp);
        	neighbors[node].push_back(temp);
        	//neighbors[temp].push_back(node);
		}
    }
	q.push(1);//begin from 1
    bfs(0);
    for(int i = 1; i<=n; i++){
    	printf("%d %d\n",i, dist[i]);
	}
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;

typedef long long ll;

int main() {
  ll n, m;
  cin >> n >> m;
  priority_queue<ll> a;
  for (ll i = 0; i < n; i++) {
    ll x;
    cin >> x;
    a.push(-x);
  }
  vector<pair<ll, ll> > p(m);
  for (ll i = 0; i < m; i++) {
    ll b, c;
    cin >> b >> c;
    p[i].first = c;
    p[i].second = b;
  }
  sort(p.rbegin(), p.rend());
  for (ll i = 0; i < m; i++) {
    for (ll j = 0; j < p[i].second; j++) {
      ll tmp = a.top();
      if (tmp > -p[i].first) {
        a.pop();
        a.push(-p[i].first);
      }
      else {
        break;
      }
    }
  }
  ll ans = 0;
  while(!a.empty()) {
    ans += -a.top();
    a.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2676
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {

  int N;
  string S;
  cin>>N>>S;
  
  int x=0;
  
  if(N%2==1){
    cout<<"No"<<endl;
  }
  else if(N%2==0){
    for(int i=0;i<N/2;i++){
      if(S[i]==S[i+N/2]){
        x++;
      }
      else{
        x+=0;
      }
    }
  
  if(x==N/2){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  }
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    
    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            Dictionary<string, int> ret = new Dictionary<string, int>();
            ret["AC"] = 0;
            ret["WA"] = 0;
            ret["TLE"] = 0;
            ret["RE"] = 0;
            var N = int.Parse(Console.ReadLine());
            for (int i = 0; i < N; i++)
            {
                var r = Console.ReadLine();
                ret[r]++;
            }

            foreach (var item in ret)
            {
                Console.WriteLine(item.Key + " x " + item.Value);
            }
        }
    }
}

Measured memory_bytes: 30800
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
s=0
for i in range(n-1):
  for j in range(i+1,n):
    d=((l[i][0]-l[j][0])**2+(l[i][1]-l[j][1])**2)**0.5
    s+=d
print(s*2/n)

Measured memory_bytes: 3060