akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

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

	int n; cin >> n;
	cout << setprecision(10) << fixed;
	if (n % 2 == 0)
		cout << 0.5 << endl;
	else
		cout << (double((n + 1) / 2) / double(n)) << endl;

	return 0;
}

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

int main() {

	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	long long ans=0;
	for(int i=1;i<n;i++){
		if(arr[i]<arr[i-1]){
			ans+=(arr[i-1]-arr[i]);
			arr[i]=arr[i-1];
		}
	}	
	cout<<ans;

	return 0;
	
}

Measured memory_bytes: 4328
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            String s=scan.next();
            if(s.charAt(s.length()-1)=='s'){
                out.println(s+"es");
            }else{
                out.println(s+'s');
            }
        }
        out.flush();
        out.close();
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


Measured memory_bytes: 36280
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
string divide[4]={"dream","dreamer","erase","eraser"};
int main(){
  string s;
  cin>>s;
  reverse(s.begin(),s.end());
  for(int i=0;i<4;i++) reverse(divide[i].begin(),divide[i].end());
  
  bool can=true;
  for(int i=0;i<s.size();){
    bool can2=false;
    for(int j=0;j<4;j++){
      string d=divide[j];
      if(s.substr(i,d.size())==d){
         can2=true;
         i+=d.size();
      }
    }
    if(!can2){
      can=false;
      break;
    }
  }
  if(can) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
#define maxn 200005
using namespace std;
int read(){
	int x=0,c;while(!isdigit(c=getchar()));
	while(x=x*10+c-'0',isdigit(c=getchar()));
	return x;
}
int n,x,f[maxn],b[maxn],maxx;
int main(){
	n=read();
	for(int i=1;i<=n;i++)x=read(),b[x]=i;
	for(int i=1;i<=n;i++){
		if(b[i]>b[i-1])f[i]=f[i-1]+1;
		else f[i]=1;
	}
	for(int i=1;i<=n;i++)maxx=max(maxx,f[i]);
	printf("%d",n-maxx);
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>
#include <complex>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef complex<double> P;
int n;

double cross(P p1,P p2) {
    return (real(p1)*imag(p2) - imag(p1)*real(p2));
}
double calc_S(P p1,P p2,P p3) {
    double ret = 0.0;
    p1 -= p3;
    p2 -= p3;

    ret = cross(p1,p2)/2.0;
    
    return abs(ret);
}

int main() {
    cin>>n;
    while(n-->0) {
        double x1_,y1_;
        double x2_,y2_;
        double x3_,y3_;
        cin>>x1_>>y1_>>x2_>>y2_>>x3_>>y3_;
        P p1(x1_,y1_);
        P p2(x2_,y2_);
        P p3(x3_,y3_);
        P A = p1-p2;
        P B = p2-p3;
        P C = p1-p3;
        double S = calc_S(p1,p2,p3);
        double R = abs(A)*abs(B)*abs(C)/S;
        R /= 4.0;
        
        P A1 = 2.0*(p2-p1);
        P B1 = 2.0*(p3-p1);
        P C1 = P(norm(p1)-norm(p2),norm(p1)-norm(p3));
        double X = cross(P(imag(A1),imag(B1)),C1)/cross(A1,B1);
        double Y = cross(C1,P(real(A1),real(B1)))/cross(A1,B1);
        printf("%.3lf %.3lf %.3lf\n",X,Y,R);

    }
    return 0;
}

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

int main(){
int a[14][14];
for(int i=0;i<14;i++){
for(int j=0;j<14;j++){
a[i][j]=0;}}
int x,y,s;
int big=0,ans=0;
while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
if(s==1){
a[x+2][y+2]++;
a[x+1][y+2]++;
a[x+3][y+2]++;
a[x+2][y+1]++;
a[x+2][y+3]++;
}
if(s==2){
for(int i=1;i<4;i++){
for(int j=1;j<4;j++){
a[x+i][y+j]++;}}
}
if(s==3){
for(int i=1;i<4;i++){
for(int j=1;j<4;j++){
a[x+i][y+j]++;}}
a[x][y+2]++;
a[x+4][y+2]++;
a[x+2][y]++;
a[x+2][y+4]++;
}}
for(int i=2;i<12;i++){
for(int j=2;j<12;j++){
if(a[i][j]==0){ans++;}
if(big<a[i][j]){big=a[i][j];}}}
cout<<ans<<endl<<big<<endl;}

Measured memory_bytes: 1208
#include <iostream>
using namespace std;
int main()
{
	char a[3] = { 0 }, b[3] = { 0 };
	cin >> a >> b;
	int ans = 0;
	if (a[0] && a[0] == b[0])
		++ans;
	if (a[1] && a[1] == b[1])
		++ans;
	if (a[2] && a[2] == b[2])
		++ans;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
ls = [0]
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        ls.append(ls[i] + 1)
    else:
        ls.append(ls[i])
for i in range(Q):
    l, r = map(int, input().split())
    print(ls[r-1] - ls[l-1])

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

int main() {
    int N;
    cin >> N;
    vector<ll>A(N);
    int flagN = 0; // 0なら全部0以上
    int flagP = 0; // 0なら全部0以下
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if(A[i] < 0) flagN = 1;
        if(A[i] > 0) flagP = 1;
    }

    ll M = 0;
    if(flagN == 0){
        int x = 0; // A[x] は絶対値最小
        M = A[0];
        for (int i = 1; i < N; ++i) {
            if(A[x] > A[i]) x = i;
            M += A[i];
        }
        M = M - (2 * A[x]);
        cout << M << endl;
        if(x == 0){
            for (int i = 2; i < N; ++i) {
                cout << A[0] << " " << A[i] << endl;
                A[0] = A[0] - A[i];
            }
            cout << A[1] << " " << A[0] << endl;
        }else{
            for (int i = 1; i < N; ++i) {
                if(i != x){
                    cout << A[x] << " " << A[i] << endl;
                    A[x] = A[x] - A[i];
                }
            }
            cout << A[0] << " " << A[x] << endl;
        }
    }else if(flagP == 0){
        int x = 0; // A[x] は絶対値最小
        M = M - A[0];
        for (int i = 1; i < N; ++i) {
            if(A[x] < A[i]) x = i;
            M = M - A[i];
        }
        M = M + (2 * A[x]);
        cout << M << endl;

        for (int i = 0; i < N; ++i) {
            if(i != x){
                cout << A[x] << " " << A[i] << endl;
                A[x] = A[x] - A[i];
            }
        }
        /*
        if(x == 0){
            for (int i = 2; i < N; ++i) {
                cout << A[1] << " " << A[i] << endl;
                A[1] = A[1] + A[i];
            }
            cout << A[0] << " " << A[1] << endl;
        }else{
            for (int i = 1; i < N; ++i) {
                if(i != x){
                    cout << A[0] << " " << A[i] << endl;
                    A[0] = A[0] + A[i];
                }
            }
            cout << A[x] << " " << A[0] << endl;
        }
         */
    }else{
        int firstP = -1;
        int firstN = -1;
        for (int i = 0; i < N; ++i) {
            M = M + abs(A[i]);
            if(firstP == -1 && A[i] > 0) firstP = i;
            if(firstN == -1 && A[i] < 0) firstN = i;
        }
        cout << M << endl;
        for (int i = 0; i < N; ++i) {
            if(A[i] > 0 && i != firstP){
                cout << A[firstN] << " " << A[i] << endl;
                A[firstN] = A[firstN] - A[i];
            }
            if(A[i] <= 0 && i != firstN){
                cout << A[firstP] << " " << A[i] << endl;
                A[firstP] = A[firstP] - A[i];
            }
        }
        cout << A[firstP] << " " << A[firstN] << endl;
    }
    return 0;
}

Measured memory_bytes: 2688
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
import numpy as np

N,Q = map(int,input().split())
graph = [[] for _ in range(N+1)]
for _ in range(N-1):
    a,b,c,d = map(int,input().split())
    graph[a].append((b,c,d))
    graph[b].append((a,c,d))
query = [[int(x) for x in input().split()] for _ in range(Q)]

def euler_tour(x, tour_v, tour_d, depth = 0, parent=None):
    tour_v.append(x)
    tour_d.append(depth)
    for y, c, d in graph[x]:
        if y == parent:
            continue
        euler_tour(y, tour_v, tour_d, depth + 1, parent = x)
        tour_v.append(x)
        tour_d.append(depth)

tour_v = []
tour_d = []
euler_tour(1, tour_v, tour_d)
tour_d_arr = np.array(tour_d)
v_to_i = {v:i for i,v in enumerate(tour_v)}
v_to_d = dict(zip(tour_v, tour_d))

# sparse table
# 各インデックスから、2^i 項目分見て、一番depthの小さいインデックス
L = len(tour_v)
U = L.bit_length()
sp = [np.arange(L)]
for i in range(1,U):
    prev = sp[-1]
    width = 1 << (i-1)
    n1 = prev[:-width]
    n2 = prev[width:]
    sp.append(np.where(tour_d_arr[n1] < tour_d_arr[n2], n1, n2))

def LCA(x,y):
    ix = v_to_i[x]
    iy = v_to_i[y]
    if ix > iy:
        ix,iy = iy,ix
    items = iy - ix + 1
    L = items.bit_length() - 1
    n1 = sp[L][ix]
    n2 = sp[L][iy - (1 << L) + 1]
    n = n1 if tour_d[n1] < tour_d[n2] else n2
    return tour_v[n]

tasks = [[] for _ in range(N+1)]
for i,(x,y,u,v) in enumerate(query):
    tasks[u].append((i,x,y,1))
    tasks[v].append((i,x,y,1))
    tasks[LCA(u,v)].append((i,x,y,-2))

answer = [0] * Q

def dfs(x = 1, sums = [0] * (N+1), nums = [0] * (N+1), total = 0, parent = 0):
    for i,c,d,coef in tasks[x]:
        answer[i] += coef * (total - sums[c] + nums[c] * d)
    for y,c,d in graph[x]:
        if y == parent:
            continue
        sums[c] += d
        nums[c] += 1
        total += d
        dfs(y, sums, nums, total, x)
        sums[c] -= d
        nums[c] -= 1
        total -= d
    return

dfs()
print('\n'.join(map(str,answer)))

Measured memory_bytes: 251316
#include <iostream>
#include <algorithm>
#include <cmath>
#define ll long long
#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define FORQ(i, b, e) for (int i = (b); i <= (e); ++i)
#define REP(x, n) for (int x = 0; x < (n); ++x)

using namespace std;

int a, b, c;

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

    cin >> a >> b >> c;

    if ((b * 10 + c) % 4 == 0)
        cout << "YES"
             << "\n";
    else
        cout << "NO"
             << "\n";
}

Measured memory_bytes: 256
import numpy as np

n = int(input())
a = [int(_) for _ in input().split()]

sub_num = []

for i in range(1, n+1):
#    print(abs(int(a[i-1]-i)))
    sub_num.append(int(a[i-1]-i))


b = np.median(sub_num)
#print(b)

result = 0
for i in range(n):
    result += abs(sub_num[i] - b)

print(int(result))

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

int main()
{
	ll int h,a=0,i,b=0;
	cin>>h;
	while(1)
	{
		if (h==0)
		break;
		h=h/2;
		
		a+=(ll int)(pow(2,b));
		b++;
	}
	cout<<a<<endl;
}
	




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

using namespace std;

int N,M;


int main(){
    cin >> N;

    vector<int> T(N,0);
    int total = 0;
    for(int d = 0; d < N; d++) {cin >> T[d];//解くのにかかる時間
        total += T[d];
    }
    
    cin >> M;
    vector<int> p(M,0),x(M,0);
    for(int d = 0; d < M; d++){ cin >> p[d] >> x[d];//問いp[d]がx[d]時間で解ける
        cout << total - (T[p[d]-1] - x[d]) << endl;
    }
    return 0;
}

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

int main()
{
	int n, tp = 0, hp = 0, i = 0;
	string taro, hanako;

	cin >> n;
	for (i = 0; i < n; i++){
		cin >> taro >> hanako;
		if (taro > hanako) 
			tp += 3;
		else if (taro < hanako) 
			hp += 3;
		else{ 
			tp++; 
			hp++; 
		}			
	}

	cout << tp << ' ' << hp << endl;

	return(0);
}


Measured memory_bytes: 3152
from operator import itemgetter

N = int(input())
SP = []
d = {}
for i in range(1, N+1):
    s, p = input().split()
    SP.append([s, -int(p), i])
    d[int(p)] = i
# SP.sort(key= lambda x:x[0])
# SP.sort(key=lambda x:x[1])
SP.sort()
[print(i[2]) for i in SP]


Measured memory_bytes: 38384
import java.util.*;
class Engine implements Comparable<Engine>
{
  int X,Y;
  double atan2;
  Engine(int X,int Y)
  {
    this.X =X;
    this.Y=Y;
    atan2 = Math.atan2(Y,X);
  }
  public int compareTo(Engine x)
  {
    return Double.compare(this.atan2,x.atan2);
  }
}
class Main
{
  public static void main(String Args[])
  {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    List <Engine> engines = new ArrayList<>(n);
    for(int i = 0;i< n;i++)
    {
      int x = in.nextInt();
      int y = in.nextInt();
      if(x==0&&y==0)
        continue;
      engines.add(new Engine(x,y));
    }
    Collections.sort(engines);
    int m = engines.size();
    double max = 0.0;
    for(int i = 0;i< m;i++)
    {
      double y = 0.0;
      double x = 0.0;
      for(int j = 0;j<m;j++)
      {
        int index = (i+j)%m;
        Engine engine  = engines.get(index);
        y += engine.Y;
        x += engine.X;
        max = Math.max(max , Math.hypot(x,y));
      }
    }
    System.out.printf("%.20f",max);
  }
}


Measured memory_bytes: 24916
def fact(n: int)->int:
    if n == 1:
        return 1
    return n * fact(n-1)


def triangular_relationship(N: int, K: int)->int:
    res = 0
    if K % 2 == 1:
        odd, even = 0, 0
        for k in range(K, N+1, K):
            if k % 2 == 0:
                even += 1
            else:
                odd += 1

        res = sum(d*d*d for d in [odd, even])

        res += odd*odd*even
        res += odd*even*odd
        res += even*odd*odd

        res += even*even*odd
        res += even*odd*even
        res += odd*even*even
    else:
        leftK, leftK2 = 0, 0
        for k in range(K//2, N+1, K//2):
            if k % K == 0:
                leftK += 1
            else:
                leftK2 += 1

        res = sum(d*d*d for d in [leftK, leftK2])

    return res


if __name__ == "__main__":
    N, K = map(int, input().split())
    ans = triangular_relationship(N, K)
    print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=1000010,Mo=1000000007;
int f[N];
int main() {
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
	if(i==1) f[i]=1;
	else if(i==2) f[i]=1;
	else f[i]=((f[i-1]-f[i-2]+f[i-3])%Mo+Mo)%Mo;
	if(i==n) ans=(ans+1LL*n*f[i])%Mo;
	else if(i==n-1) ans=(ans+1LL*f[i]*(n-1)%Mo*n)%Mo;
	else ans=(ans+f[i]*(1LL*(n-1)*(n-1)%Mo+i+1))%Mo;
	f[i]=(f[i-1]+f[i])%Mo;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4096
def solve(n, a):
    x = a[0]
    for i in range(1, n):
        x = x ^ a[i]
    ans = [x ^ a[i] for i in range(n)]
    return " ".join(map(str, ans))

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for (int mi = 1; mi <= m; mi++) {
        for (int di = 1; di <= d; di++) {
            int d1 = di % 10;
            int d2 = di / 10;
            if (d1 <= 1) continue;
            if (d2 <= 1) continue;

            if (d1 * d2 == mi) ans++;
        }
    }
    cout << ans << endl;
}


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

int main() {
  string N;
  cin >> N;
  bool check = false;
  for (int i = 0; i < 3; i++) {
    if (N[i] == '7') {
      check = true;
    }
  }
  if (check) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/04/03  Problem: ABC 049 C / Link: http://abc049.contest.atcoder.jp/tasks/abc049_c  ----- */


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

	string s; cin >> s;
	VL dp(SZ(s) + 1, 0);
	dp[0] = 1;
	VS vs = { "dream","dreamer","erase","eraser" };
	FOR(i, 0, SZ(s)) {
		if (!dp[i])continue;
		for (auto it : vs) {
			bool ok = 1;
			if (SZ(it) + i > SZ(s))continue;
			FOR(k, 0, SZ(it)) {
				ok &= s[i + k] == it[k];
			}
			if (ok) {
				dp[i + SZ(it)] = 1;
			}
		}
	}
	LL ans = dp[SZ(s)];
	auto print_yesno = [](LL yes, int mode = 0) {
		if (mode == 0) {
			cout << (yes ? "yes" : "no") << endl;
		}
		else if (mode == 1) {
			cout << (yes ? "Yes" : "No") << endl;
		}
		else if (mode == 2) {
			cout << (yes ? "YES" : "NO") << endl;
		}
		else assert(0);
	};
	print_yesno(ans, 2);

	return 0;
}


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

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

	long long int i, o, t, j, l, s, z, k[2], r = 0;
	cin >> i >> o >> t >> j >> l >> s >> z;
	k[0] = (i/2)*2 + (j/2)*2 + (l/2)*2;
	r = max(r, k[0]);
	if (i >= 1 && j >= 1 && l >= 1){
		k[1] = 3 + ((i-1)/2)*2 + ((j-1)/2)*2 + ((l-1)/2)*2;
		r = max(r, k[1]);
	}
	cout << r + o<< "\n";
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   string s;
   int ans = 0;
   cin >> s;
   int l = s.length();
   FOR(i, 0, l / 2)
   if (s[i] != s[l - i - 1])
      ans++;
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
s = (str(input())).count
if ((s('a')>1)or(s('b')>1)or(s('c')>1)or(s('d')>1)or(s('e')>1)or(s('f')>1)
    or(s('g')>1)or(s('h')>1)or(s('i')>1)or(s('j')>1)or(s('k')>1)or(s('l')>1)
    or(s('m')>1)or(s('n')>1)or(s('o')>1)or(s('p')>1)or(s('q')>1)or(s('r')>1)
    or(s('s')>1)or(s('t')>1)or(s('u')>1)or(s('v')>1)or(s('w')>1)or(s('x')>1)
    or(s('y')>1)or(s('z')>1)):
    print('no')
else:
    print('yes')


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

int main(void) {
  int n, a, b;
  cin >> n >> a >> b;

  cout << min((a*n),b) << endl;
  return 0;
}

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


int main() {
	ll n, d;
	cin >> n >> d;
	ll dis = d*d, ans = 0;
	for(int i=0; i<n; i++) {
		ll a, b;
		cin >> a >> b;
		if((a*a+b*b) <= dis) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> num(55556);
    for(int i = 0; i < 55556; i++) num[i] = i;
    num[0] = -1;
    num[1] = -1;
    for(int i = 2; i < 55556; i++){
        if(num[i] == -1) continue;
        int t = 2;
        while(i * t <= 55555){
            num[i * t] = -1;
            t++;
        }
    }
    vector<int> sosuu;
    for(int i = 0; i < 55556; i++){
        if(num[i] != -1) sosuu.push_back(num[i]);
    }
    vector<int> cnt(5, 0);
    for(int i = 0; i < sosuu.size(); i++){
        cnt[sosuu[i] % 5]++;
    }
    int t = 0;
    for(int i = 0; i < sosuu.size(); i++){
        if(t == N) break;
        if(sosuu[i] % 5 == 1) {
            cout << sosuu[i] << ' ';
            t++;
        }
    }
    cout << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
int a[1000000],b[1000000];
int main() {
	int x,i;
	cin>>x;
	for(i=1;i<=x;i++)
	cin>>a[i];
	b[1]=0;
	b[2]=b[1]+abs(a[2]-a[1]);
	for(i=3;i<=x;i++)
	{
		b[i]=min((b[i-1]+abs(a[i]-a[i-1])),(b[i-2]+abs(a[i]-a[i-2])));
	}
	//for(i=1;i<=x;i++)
	//cout<<b[i]<<" ";
	cout<<b[x];
	return 0;
}

Measured memory_bytes: 4276
#include<cstdio>
#include<iostream>
using namespace std;
int N;
int main()
{
	cin>>N;
	if(N>17)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(N%4==0)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(((N-7)%4==0)&&(N>=7))
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(((N-14)%7==0)&&(N>=14))
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <functional>
#include <limits>
#include <vector>
#include <list>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <complex>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const LL modn = 1e9+7;


int main()
{
    // ios::sync_with_stdio(false); cin.tie(0);
    int n, m;
    while(scanf("%d %d", &n, &m)!=EOF) {
        printf("%d\n", ((n-m)*100+m*1900)*(1<<m));
    }
    return 0;
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
       
        static void SolveA()
        {
            var tmp = ReadAndParseIntArr();
            int n = tmp[0];
            int y = tmp[1];

            for(long i=0;i<=n;++i)
            {
                long maxj = n - i;
                for(long j =0;j<=maxj;++j)
                {
                    long k = n - i - j;
                    long total = i * 10000 + j * 5000 + k * 1000;
                    if( total != y) { continue; }

                    Console.WriteLine($"{i} {j} {k}");
                    return;
                }
            }
            Console.WriteLine("-1 -1 -1");
        }


        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13140
#include<stdio.h>

int main(void)

{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);

	if (c >= a && c <= b)
	{
		printf("Yes\n");
	}
	else {
		printf("No\n");

	}

	return 0;


}

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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> r(n,0);
    int min, dif, max_dif;
    rep(i, n) {
        scanf("%d", &r[i]);
        if (i == 1) {
            min = ::min(r[0], r[1]);
            dif = r[1] - r[0];
            max_dif = dif;
        } else if (i > 1) {
            dif = r[i] - min;
            if (dif > max_dif) max_dif = dif;
            if (r[i] < min) min = r[i];
        }
    }
    printf("%d\n", max_dif);
}


Measured memory_bytes: 3588
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	readln.replace("peach", "~").replace("apple", "peach").replace("~", "apple").write;
}

Measured memory_bytes: 1048
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int dp[2005];
int solve(int i,int sum){
  if(sum==0)return 1;
  if(dp[sum]!=-1)return dp[sum];
  int ans=0;
  rep(j,3,sum+1){
      ans+=solve(i+1,sum-j);
      ans%=mod;
  }
  dp[sum]=ans;
  return ans;
}
int32_t main(){
    clr(dp,-1);
    int n; cin>>n;
    cout<<solve(0,n);
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


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

using namespace std;
int n , a[100000] , b[100000] , c[100000] , dp[100000] , ap[100000] , bp[100000] , cp[100000] ;
int main()
{
cin >> n ;
for(int i = 0 ; i < n ; i++){
    cin >> a[i] >> b[i] >>c[i];
}
ap[0] = max(b[0] , c[0]);
bp[0] = max(a[0] , c[0]);
cp[0] = max(b[0] , a[0]);
for(int i = 1 ; i < n ; i++){
ap[i] = max(b[i]+bp[i-1] , c[i]+cp[i-1]) ;
bp[i] = max(a[i]+ap[i-1] , c[i]+cp[i-1]) ;
cp[i] = max(b[i]+bp[i-1] , a[i]+ap[i-1]) ;
}
dp[0] = max(a[0], b[0]) ;
dp[0] = max(dp[0] , c[0]) ;
for(int i = 1 ; i< n; i++){
    dp[i] = max(a[i]+ap[i-1] , b[i]+bp[i-1]) ;
    dp[i] = max(dp[i] , c[i]+cp[i-1]) ;
}
cout << dp[n-1] ;
    return 0;
}


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

using ll= long long;
const ll INF=1LL<<60;
const ll MOD=1000000007;

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

int N;
vector<int> a;
vector<vector<ll>> dp;

ll rec(int l=0, int r=N){
    if(r-l == 1) return 0;
    if(r-l == 2) return a[l]+a[l+1];
    ll &ret = dp[l][r];
    if(ret != INF) return ret;
    for(int i=l+1; i<=r-1; i++){
        ll x=0, y=0;
        for(int j=l; j<i; j++) x+=a[j];
        for(int j=i; j<r; j++) y+=a[j];
        chmin(ret, rec(l, i)+rec(i,r)+x+y);
    }
    return ret;
}

int main(){
    cin >> N;
    a.resize(N);
    dp.assign(N+1, vector<ll>(N+1, INF));
    for(auto &x : a) cin >> x;
    cout << rec() << endl; 
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std ; 
# define pb push_back
# define ll long long
# define mp make_pair 
# define endl "\n"
# define vi vector<int>
# define vc vector<char>
# define vll vector<ll> 
# define pi pair<int,int> 
const int MOD = 1e9 + 7 ; 
const ll inf = 1e18 ; 

void solve() {
	int n ; 
	cin >> n ; 
	vi a(n) ; 
	for(int i=0; i < n ; ++i)
		cin >> a[i] ; 
	vector<bool> vis(n) ; 
	int i=0 ; 
	int cnt= 0 ; 
	bool ok = false ; 
	while(true) {
		//cout << i ; 
		if(vis[i]) {
			ok = false ;
			break ; 
		}
		if(i == 1) {
			ok = true ; 
			break ; 
		}
		vis[i] = true ; 
		i = a[i]-1 ;
		cnt++;  
	}
	if(ok) {
		cout << cnt ; 
	} else {
		cout << -1 ; 
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	int t ; 
	//cin >> t ; 
	t = 1 ;
	while(t--)
		solve() ; 
	return 0; 
}


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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)

struct Edge {
    int src, dst, capacity;
    Edge(int src, int dst, int capacity): src(src), dst(dst), capacity(capacity) {}
};
using Graph = vector<vector<Edge>>;

void add_edge(Graph& graph, int src, int dst, int capacity) {
    graph[src].emplace_back(src, dst, capacity);
    graph[dst].emplace_back(dst, src, 0);
}

struct Augment {
    const Graph graph;
    const vector<int>& level;
    vector<vector<int>>& flow;
    vector<int>& progress;
    int sink;
    Augment(const Graph& graph, const vector<int>& level, vector<vector<int>>& flow, vector<int>& progress, int sink):
        graph(graph), level(level), flow(flow), progress(progress), sink(sink) {}
    int operator()(int u, int f) const {
        if (u == sink) return f;
        int total = 0, i = progress[u];
        for (; i < (int)graph[u].size(); ++i) {
            auto& e = graph[u][i];
            int residue = e.capacity - flow[e.src][e.dst];
            if (residue > 0 && level[e.src] < level[e.dst]) {
                int aug = (*this)(e.dst, min(f - total, residue));
                flow[e.src][e.dst] += aug;
                flow[e.dst][e.src] -= aug;
                total += aug;
                if (total == f) break;
            }
        }
        progress[u] = i;
        return total;
    }
};

int dinic(const Graph& graph, int source, int sink) {
    vector<vector<int>> flow(graph.size(), vector<int>(graph.size()));
    int total = 0;
    for (;;) {
        // construct level graph
        vector<int> level(graph.size(), -1); level[source] = 0;
        queue<int> Q; Q.push(source);
        while (!Q.empty()) {
            int u = Q.front(); Q.pop();
            if (level[sink] != -1 && level[u] > level[sink]) break;
            for (auto& e : graph[u]) {
                if (level[e.dst] == -1 && e.capacity - flow[e.src][e.dst] > 0) {
                    level[e.dst] = level[e.src] + 1;
                    Q.push(e.dst);
                }
            }
        }
        if (level[sink] == -1) return total;

        // push blocking flow
        vector<int> progress(graph.size());
        total += Augment(graph, level, flow, progress, sink)(source, INT_MAX);
    }
}

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

    int V, E;
    while (cin >> V >> E) {
        Graph graph(V);
        REP(i, E) {
            int u, v, c; cin >> u >> v >> c;
            add_edge(graph, u, v, c);
        }
        cout << dinic(graph, 0, V-1) << '\n';
    }
}

Measured memory_bytes: 3292
//q096.cpp
//Tue Sep 15 20:23:46 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

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

	ll ans = 0;
	rep(i,n){
		ans += i;
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

int x;
bool po[250000];
vector<int> v;

int main() {
    scanf("%d", &x);
    for (int i = 2; i * i < 250000; i++) {
        if (po[i]) continue;
        for (int j = i * 2; j < 200000; j += i) po[j] = true;
        v.push_back(i);
    }

    for (int i = 500; i < 250000; i++) {
        if (!po[i]) v.push_back(i);
    }

    printf("%d\n", *lower_bound(v.begin(), v.end(), x));
    return 0;
}


Measured memory_bytes: 1020
N, K = map(int, input().split())
S = list(input())
# print(N)
# print(K)
# print(S)
if S[K-1] == "A":
    S[K-1] = "a"
if S[K-1] == "B":
    S[K-1] = "b"
if S[K-1] == "C":
    S[K-1] = "c"

print(''.join(S))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  
  string ans = s.substr(0, n - 8);
  
  cout << ans << endl;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

ll len[51];
ll p[51];

ll dfs(ll N, ll X) {
    if (N == 0) {
        return 1;
    }
    if (X == 0) return 0;
    if (X == len[N] - 1) return 1 + 2 * p[N - 1];
    if (X == len[N] / 2) return 1 + dfs(N - 1, X - 1);
    if (X < len[N] / 2) return dfs(N - 1, X - 1);
    return 1LL + p[N - 1] + dfs(N - 1, X - len[N - 1] - 2);
}

void solve() {
    int N;
    ll X;
    cin >> N >> X;
    X--;
    len[0] = 1;
    p[0] = 1;
    for (int i = 1; i < 51; i++) {
        len[i] = len[i - 1] * 2 + 3;
        p[i] = p[i - 1] * 2 + 1;
    }
    ll ans = dfs(N, X);
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  vector<int> p(n), q(n);
  rep(i, n){
    cin >> p[i];
    q[i] = p[i];
  }

  sort(q.begin(), q.end());
  int cnt = 0;
  rep(i, n) if(p[i] != q[i]) cnt++;
  
  cout << (cnt <=  2 ? "YES" : "NO") << endl;

}


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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v ) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

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

    int diff = (a[n-1] - b[n-1]) / 2;
    for (int i = 0; i < n; ++i) {
        b[i] += (i%2 ? -1 : 1) * diff;
    }

    for (int i = 0; i < n; ++i) {
        cout << b[i]*2 << (i == n-1 ? "\n" : " ");
    }

    return 0;
}


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

using ll = long long;

int main(){
  int n;
  cin >> n;
  vector<ll> book(n), mid_sum(n);
  ll sum = 0;
  for(int i = 0; i < n; i++){
    cin >> book.at(i);
    sum += book.at(i);
    mid_sum.at(i) = sum;
  }
  ll ans = 10000000000;
  for(int i = 0; i < n-1; i++){
    ans = min(ans,abs(mid_sum.at(i)-(sum-mid_sum.at(i))));
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
int main(){
  while(1){
    int d,e;
    cin>>d>>e;
    if(d==0&& e==0) break;
    double x=d,y=0,che=1;
    double ans=100000;
    while(y<=x){
      if(sqrt(x*x+y*y)-e<0) che=-1;
      else che=1;
      if((sqrt(x*x+y*y)-e)*che<ans)
	ans=(sqrt(x*x+y*y)-e)*che;
      y++;
      x--;
    }
    cout<<ans<<endl;
  }
  return 0;
}
  



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a[5];
    for (int i = 0; i < 5; i++){
        cin >> a[i];
        if(a[i]==0){
            cout << (i+1) << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
b = [0]*26
while True:
    try: 
        a = raw_input()
        for i in a:
            c = ord(i.lower())
            if c>= ord("a") and c <= ord("z"):
                b[c-ord("a")] +=1
    except EOFError,e:
        break
for i,v in enumerate(b):
    print "{0} : {1}".format(chr(i+ord("a")),v)

Measured memory_bytes: 4216
#include<bits/stdc++.h>
using namespace std;
#define int long long
using P=pair<int,int>;
using PP=pair<int,P>;
signed main(){
  int n,m,s,t;
  cin>>n>>m>>s>>t;
  s--,t--;
  vector<vector<PP>> A(n);
  for(int i=0;i<m;i++){
    int u,v,a,b;
    cin>>u>>v>>a>>b;
    A[u-1].push_back({v-1,{a,b}});
    A[v-1].push_back({u-1,{a,b}});
  }
  vector<int> B(n,1000000000000000000),C(n,1000000000000000000);
  B[s]=0,C[t]=0;
  priority_queue<P,vector<P>,greater<P>> Q;
  Q.push({s,0});
  while(!Q.empty()){
    P R=Q.top();
    Q.pop();
    if(R.second>B[R.first])
      continue;
    for(PP p:A[R.first])
      if(B[p.first]>R.second+p.second.first){
        B[p.first]=R.second+p.second.first;
        Q.push({p.first,R.second+p.second.first});
      }
  }
  Q.push({t,0});
  while(!Q.empty()){
    P R=Q.top();
    Q.pop();
    if(R.second>C[R.first])
      continue;
    for(PP p:A[R.first])
      if(C[p.first]>R.second+p.second.second){
        C[p.first]=R.second+p.second.second;
        Q.push({p.first,R.second+p.second.second});
      }
  }
  vector<int> D(n+1,0);
  for(int i=n-1;i>=0;i--)
    D[i]=max(D[i+1],1000000000000000-(B[i]+C[i]));
  for(int i=0;i<n;i++)
    cout<<D[i]<<endl;
}

Measured memory_bytes: 17588
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, a=0, b=0, c=0;
  long long ans=1;
  cin >> N;
  vector<int> n(N);
  for(int i=0; i<N; i++){
    cin >> n.at(i);
  }
  for(int i=0; i<N; i++){
    int num=0;
    if(n.at(i)==a) num++;
    if(n.at(i)==b) num++;
    if(n.at(i)==c) num++;
    ans*=num;
    ans%=1000000007;    
    
    if(n.at(i)==a) a++;
    else if(n.at(i)==b) b++;
    else if(n.at(i)==c) c++;    
  }
  cout << ans << endl;
}


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

int main() {
    int n, m; std::cin >> n >> m;
    std::vector<int> l(n, -1);
    for (int i = 0; i < m; i++) {
        int a, b; std::cin >> a >> b;
        if (l[a-1] != -1 && l[a-1] != b) {
            std::cout << -1 << std::endl;
            return 0;
        }

        if (n > 1 && a == 1 && b == 0) {
            std::cout << -1 << std::endl;
            return 0;
        }
        l[a-1] = b;
    }

    for (int i = 0 ; i < n; i++) {
        int d = std::max(l[i], (n > 1 && i == 0)?1:0);
        std::cout << d;
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 256
S = input()

T = "AKIHABARA"
cand = [
  "KIHBR",
  "KIHBAR",
  "KIHABAR",
  "KIHABR",
  "AKIHABAR",
  "AKIHBAR",
  "AKIHABR",
  "AKIHBR",
  "KIHBRA",
  "KIHBARA",
  "KIHABARA",
  "KIHABRA",
  "AKIHABARA",
  "AKIHBARA",
  "AKIHABRA",
  "AKIHBRA",
]
print("YES" if S in cand else "NO")

Measured memory_bytes: 2940
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	r := nextInt()
	fmt.Fprint(out, r*r*3, "\n")
}

func solve(N int, a []int, used []int, s2, x1, x2, depth int) bool {
	// fmt.Fprint(out, used, depth, x1, x2, "\n")
	if depth == N {
		// fmt.Fprint(out, "atta\n")
		return x1^x2^a[0] == 0 && x2^a[0]^s2 == 0
	}
	for i := 0; i < N; i++ {
		if used[i] > 0 {
			continue
		}
		if depth >= 2 && x1^x2^a[i] != 0 {
			continue
		}
		used[i] = 1
		if depth == 1 {
			s2 = a[i]
		}
		if solve(N, a, used, s2, x2, a[i], depth+1) {
			return true
		}
		used[i] = 0
	}
	return false
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// Genericsがないので筋肉で...
// interfaceでの取扱がようわからんし
func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// mapからkeysとvaluesを返す感じのやつ
// なんかしらんけどmap[interface{}]interface{}しか受け付けない。なんのためのinterface{}やねん
// なので呼ぶときのmapはmap[int]stringとかじゃダメ
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
	return
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
  
int main(){
  int n;
  ll a, b = 0, ans = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a;
    if(a == 0) ans += b / 2, b = 0;
    b += a;
  }
  cout << ans + b / 2 << endl;
  return 0;
}

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

#define ll long long
#define vi vector<int>
#define vll vector<long long> 
#define str string 
#define ch char
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair

int dp[200005][3];
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin>>n;
    int act[n][3];
    for(int i=0; i<n; i++){
        cin>>act[i][0]>>act[i][1]>>act[i][2];
    }
    for(int i=0; i<n; i++){
        if(i==0){
            for(int j=0; j<3; j++) dp[0][j] = act[i][j];
        }
        else{
            for(int j=0; j<3; j++){
                dp[i][j] = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) + act[i][j];
            }
        }
    }
    cout<<max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]);
}



Measured memory_bytes: 5900