akhauriyash/Code-Regression huggingface dataset:
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *
import queue

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

H, W = In.ints()

grid = [["." for j in range(W)] for i in range(H)]

C = In.ints()
C = (C[0]-1, C[1]-1)
D = In.ints()
D = (D[0]-1, D[1]-1)

for i in range(H):
    s = In.str()

    for j in range(W):
        grid[i][j] = s[j]    

#print(grid)

moves = [[0,1], [0,-1], [1,0], [-1,0]]
setnext = set()
setnow = set([(C[0], C[1])])
quenow = deque([(C[0], C[1])])

ans = 0
found = False
hadOne = True

while hadOne:
    hadOne=False
    while len(quenow)>0:
        hadOne=True
        now = quenow.popleft()

        for i in range(-2,3):
            for j in range(-2, 3):
                nex = (now[0]+i, now[1]+j)

                if 0<=nex[0]<H and 0<=nex[1]<W and grid[nex[0]][nex[1]]==".":
                    if nex not in setnow and nex not in setnext:
                        setnext.add(nex)                    

        for m in moves:
            nex = (now[0]+m[0], now[1]+m[1])

            if nex == D:
                found = True
                break

            if 0<=nex[0]<H and 0<=nex[1]<W and grid[nex[0]][nex[1]] == "." and nex not in setnow:
                quenow.append(nex)
                setnow.add(nex)
        
        if found:
            break
    
    if found:
        break
    
    ans += 1

    for el in setnext:
        if el==D:
            found=True
            break
        if el not in setnow:            
            setnow.add(el)
            quenow.append(el)
    
    setnext.clear()
    
    if found:
        break


if found:
    Out.int(ans)
else:
    Out.int(-1)
######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 177844
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (mut a, mut b) = get!(i32, i32);
    let mut ans = 0;
    if a < b {
        ans += b;
        b -= 1;
    } else {
        ans += a;
        a -= 1;
    }
    if a < b {
        ans += b;
    } else {
        ans += a;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////
int main(){
    long long a, b, n;
    cin >> a >> b >> n;
    long long x;
    if (n >= b){
        x = b-1;
    }
    else {
        x = n;
    }

    long long ans = floor((a*x)/b) - a * floor(x/b);

    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;

struct E
{
	E(int dis, string to)
		: dis(dis), to(to){}
	int dis;
	string to;
};
struct P
{
	P(int calo, int visit, string pos)
		: calo(calo), visit(visit), pos(pos){}
	int calo, visit;
	string pos;
};
int main()
{
	int m, n, k, d;
	while (cin >> m >> n >> k >> d, m|n|k|d)
	{
		map<string, int> cake;
		for (int i = 1; i <= m; ++i)
			cin >> cake[string("C") + (char)('0' + i)];
		map<string, vector<E> > edge;
		for (int i = 0; i < d; ++i)
		{
			string a, b;
			int t;
			cin >> a >> b >> t;
			edge[a].push_back(E(t, b));
			edge[b].push_back(E(t, a));
		}
		map<string, map<int, int> > calo;
		queue<P> q;
		calo["H"][0] = 0;
		q.push(P(0, 0, "H"));
		while (!q.empty())
		{
			P p = q.front(); q.pop();
			if (calo.count(p.pos) && calo[p.pos].count(p.calo)
				&& p.calo > calo[p.pos][p.visit])
				continue;

			foreach (it, edge[p.pos])
			{
				int next_calo = p.calo + it->dis * k;
				int next_visit = p.visit;
				if (it->to[0] == 'C')
				{
					if (p.visit & 1 << (it->to[1] - '1'))
						continue;
					else
					{
						next_calo -= cake[it->to];
						next_visit |= 1 << (it->to[1] - '1');
					}
				}

				if (!calo.count(it->to) || !calo[it->to].count(next_visit)
					|| next_calo < calo[it->to][next_visit])
				{
					calo[it->to][next_visit] = next_calo;
					q.push(P(next_calo, next_visit, it->to));
				}
			}
		}

		int res = 100000000;
		foreach (it, calo["D"])
			res = min(res, it->second);
		printf("%d\n", res);
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
  
  int A[100];
  int i=0, j=0, N=0, minj=0;
  int a, n=0;
  
  scanf("%d", &N);
  for(i=0; i<N; i++){
    scanf("%d", &A[i]);
  }
  
  for(i=0; i<=N-1; i++){
    minj = i;
    for(j=i; j<=N-1; j++){
      if(A[j] < A[minj]){
	minj = j;
      }
    }
    a = A[i];
    A[i] = A[minj];
    A[minj] = a;
    if(minj != i){
      n++;
    }
  }
  for(i=0; i<N; i++){
    printf("%d", A[i]);
    if(i == N-1) printf("\n");
    else printf(" ");
  }
  printf("%d\n", n);
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  map<int,int> mac, mwa;
  rep(i,m){
    int p; string s;
    cin >> p >> s;
    if (mac[p]) {
      continue;
    }
    else if (s=="AC") {
      mac[p]++;
    }
    else {
      mwa[p]++;
    }
  }
  int ac = 0, wa = 0;
  for (auto m:mac) if(m.second) ac++;
  for (auto m:mwa) if(mac[m.first]) wa += mwa[m.first];
  printf("%d %d\n",ac,wa);
}


Measured memory_bytes: 6144
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin>>str;
  if(str=="SUN"){
    cout<<7<<endl;
  }
  if(str=="MON"){
    cout<<6<<endl;
  }
  if(str=="TUE"){
    cout<<5<<endl;
  }
  if(str=="WED"){
    cout<<4<<endl;
  }
  if(str=="THU"){
    cout<<3<<endl;
  }
  if(str=="FRI"){
    cout<<2<<endl;
  }
  if(str=="SAT"){
    cout<<1<<endl;
  }
}


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

int solve(){
    int n;
    cin>>n;
    vector<ll> v(100001,0);
    ll sum=0;
    for (int i = 1; i <= n; i++)
    {
        int ii;
        cin>>ii;
        v[ii]++;
        sum+=ii;
    }
    int q;
    cin>>q;
    for (int i = 0; i < q; i++)
    {
        int ll,mm;
        cin>>ll>>mm;
        sum-=v[ll]*ll;
        sum+=v[ll]*mm;
        v[mm]=v[mm]+v[ll];
        v[ll]=0;

        cout<<sum<<"\n";

    }
    

    
    return 0;
}

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


Measured memory_bytes: 3940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(4*i+j*7==n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

int n, w[112], v[112], W;
int dp[100 + 1][10000 + 1];

int main() {
	scanf("%d", &n);
	scanf("%d", &W);
	for (int i = 0; i < n; ++i) { scanf("%d%d", &v[i], &w[i]); }

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= W; ++j) {
			if (j < w[i]) {
				dp[i + 1][j] = dp[i][j];
			}
			else {
				dp[i + 1][j] = std::max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
			}
		}
	}

	printf("%d\n", dp[n][W]);
	return 0;
}

Measured memory_bytes: 6620
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    char b;
    map<char,char> H;
    cin >> b;
    H['A']='T';
    H['T']='A';
    H['C']='G';
    H['G']='C';
    cout << H[b] << endl;
    return 0;
}


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

int main()
{
    int N, M;
    cin >> N >> M;

    vector<string> A(N);
    vector<string> B(M);
    rep(i, N) cin >> A.at(i);
    rep(i, M) cin >> B.at(i);

    bool ans = false;
    for (int i = 0; i <= N - M; i++)
    {
        for (int j = 0; j <= N - M; j++)
        {
            ans = true;
            for (int k = 0; k < M; k++)
            {
                if (A.at(i + k).substr(j, M) != B.at(k))
                {
                    ans = false;
                    break;
                }
            }

            if (ans)
            {
                break;
            }
        }

        if (ans)
        {
            break;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3628
/*
g++ -std=c++11 -o2 -Wall ABC116C.cpp -o .\out\ABC116C.out
.\out\ABC116C.out
*/

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

typedef long long ll;

int x[100005];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> x[i];
  }
  if (n >= m) {
    cout << "0\n";
  } else {
    sort(begin(x), begin(x)+m);
    for (int i = 0; i < m-1; ++i) {
      x[i] = x[i+1] - x[i];
    }
    int ans = 0;
    sort(begin(x), begin(x)+(m-1));
    for (int i = 0; i < m - n; ++i) {
      ans += x[i];
    }
    cout << ans << "\n";
  }
}


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

int main() {
    using namespace std;
    unsigned long A, B;
    cin >> A >> B;
    A = __gcd(A, B);
    constexpr unsigned long maxN = 2000000;
    vector<unsigned long> sieve(maxN + 1, 1);
    unsigned long ans{1};
    for(unsigned long i = 2; i <= maxN; ++i){
        if(sieve[i]){
            ans += !(A % i);
            while(!(A % i))A /= i;
            if(A == 1)break;
            for(unsigned long j = i * i; j < maxN; j += i)sieve[j] = 0;
        }
    }
    cout << ans + (A != 1) << endl;
    return 0;
}

Measured memory_bytes: 15872
import java.util.*;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int x = sc.nextInt();

    int data[] = new int[n];
    int[] data2 = new int[n];
    int count = 0;

    for (int i  = 0;i<n ;i++ ) {
      data[i] = sc.nextInt();
    }

    data2[0] = data[0];

    for (int i = 1;i<n ;i++ ) {
      data2[i] = data2[i-1]+data[i];
    }

    for (int i = 0;i<n ;i++ ) {
    if (data2[i]<=x) {
      count++;
    }
    }
    System.out.println(count+1);


  }
}


Measured memory_bytes: 23252
K, X = map(int, input().split())

if X+K-1 <= 1000000:
  right = X+K-1
else:
  right = 1000000
  
if X-K+1 >= -1000000:
  left = X-K+1
else:
  left = -1000000
  
ans = [i for i in range(left, right+1)]
print(' '.join(map(str, ans)))

Measured memory_bytes: 9072
// AOJ 2869 AA Graph
// 2018.3.29 bal4u

#include <stdio.h>
#include <ctype.h>

typedef struct { int a; int t; } Q;
Q q[500]; int top, end;
char map[53][53];
char mk[30];
int  hi[26], to[26][26];

int main()
{
	int H, W, s, t, r, c, rr, cc, a, b, d, i;
	char ss[5], tt[5];

	scanf("%d%d%s%s", &H, &W, ss, tt);
	s = ss[0] - 'A', t = tt[0] - 'A';

	for (r = 0; r < H; r++) scanf("%s", map[r]);
	for (r = 0; r < H; r++) for (c = 0; c < W; c++) {
		if (!isupper(map[r][c])) continue;
		a = map[r][c] - 'A';
		for (cc = c+1; cc < W; cc++) {
			if (isupper(map[r][cc])) {
				b = map[r][cc] - 'A';
				to[a][hi[a]++] = b;
				to[b][hi[b]++] = a;
				break;
			} else if (map[r][cc] != 'o' && map[r][cc] != '-') break;
		}
		for (rr = r+1; rr < H; rr++) {
			if (isupper(map[rr][c])) {
				b = map[rr][c] - 'A';
				to[a][hi[a]++] = b;
				to[b][hi[b]++] = a;
				break;
			} else if (map[rr][c] != 'o' && map[rr][c] != '|') break;
		}
	}

	q[0].a = s, q[0].t = 0, top = 0, end = 1;
	while (top < end) {
		a = q[top].a, d = q[top++].t;
		if (a == t) break;
		if (mk[a]) continue;
		mk[a] = 1;
		for (i = 0; i < hi[a]; i++) {
			b = to[a][i];
			if (mk[b]) continue;
			q[end].a = b, q[end++].t = d+1;
		}
	}
	printf("%d\n", d);
	return 0;
}


Measured memory_bytes: 2100
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>

using namespace std;

int N, A, X[51];
long long ans = 0, dp[51][51][3000];

int main() {

	cin >> N >> A;

	for (int i = 1; i <= N; i++) {
		cin >> X[i];
	}
	
	dp[0][0][0] = 1;

	for (int j = 1; j <= N; j++) {
		for (int k = 0; k <= N; k++) {
			for (int s = 0; s <= 2500; s++) {
				//cout << "j: " << j << " k: " << k << " X[j]: " << X[j] << endl;
				if (s < X[j]) {
					dp[j][k][s] = dp[j - 1][k][s];
				}
				else if (X[j] <= s && 1 <= k) {	//k>=1でないと、選ぶ選ばないの話ができない
					dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k-1][s-X[j]];
				}else{
					dp[j][k][s] = 0;
				}
			}
		}
	}

	for (int k = 1; k <= N; k++) {
		ans += dp[N][k][k*A];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 60032
#include<stdio.h>
int main()
{
    int a,b,y;
    scanf("%d%d",&a,&b);
    if(a>b)
    {
        y=a+a;
    y--;
    printf("%d\n",y);
    }
    else if(b>a)
    {
        y=b+b;
        y--;
        printf("%d\n",y);
    }
    else if(a==b)
    {
        y=a+b;
        printf("%d\n",y);
    }

    return 0;
}

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

signed main() {
  ios::sync_with_stdio(false);

  const int M = 998244353;

  int K, N;
  cin >> K >> N;

  vector<int> ptwo(1 << 17);
  for (int i = ptwo[0] = 1; i < 1 << 17; ++i) ptwo[i] = 2LL * ptwo[i - 1] % M;

  vector<int> fac(1 << 17);
  for (int i = fac[0] = 1; i < 1 << 17; ++i) fac[i] = 1LL * fac[i - 1] * i % M;

  auto ipow = [](int v, int p, int m) {
    int r = 1;
    for (int i = p; i; i /= 2) {
      if (i & 1) r = 1LL * r * v % m;
      v = 1LL * v * v % m;
    }
    return r;
  };
  vector<int> ifac(1 << 17);
  ifac.back() = ipow(fac.back(), M - 2, M);
  for (int i = (1 << 17) - 1; i; --i) ifac[i - 1] = 1LL * ifac[i] * i % M;

  auto choose = [&](int n, int m) {
    return m < 0 || n < m ? 0 : 1LL * fac[n] * ifac[m] % M * ifac[n - m] % M;
  };

  auto hchoose = [&](int n, int m) -> int {
    if (n == 0) return m == 0;
    return choose(n + m - 1, m);
  };

  for (int s = 2; s < 2 * K + 1; ++s) {
    int q = 0;
    for (int i = 1; i < K + 1; ++i) q += i < s - i && 0 < s - i && s - i < K + 1;
    int ans = 0;
    if (s & 1) {
      for (int i = 0; i < min(N, q) + 1; ++i) {
        (ans += 1LL * ptwo[i] * choose(q, i) % M * hchoose(K - (2 * q - i), N - i) % M) %= M;
      }
    } else {
      for (int i = 0; i < min(N, q) + 1; ++i) {
        (ans += 1LL * ptwo[i] * choose(q, i) % M * (hchoose(K - (2 * q - i + 1), N - i) + hchoose(K - (2 * q - i + 1), N - (i + 1))) % M) %= M;
      }
    }
    if (ans < 0) ans += M;
    cout << ans << endl;
  }

  return 0;
}


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

int main() {
  long long H,W,ans;
  cin>>H>>W;
  string c="";
  char d;
  vector<string>a(H);
  for(int i=0;i<H;i++){
    cin>>a[i];
  }
  int b[H][W];
    for(int i = 0; i <H; i++){
    for(int j = 0; j < W; j++){
      b[i][j] = 0;
    }
  }
	for(int i=0;i<H;i++){
    	for(int j=0;j<W;j++){
      		ans=0;
      		if(a[i][j]=='#'){
              if(i>0){
                if(j>0){
                b[i-1][j-1]++;
                }
                if(j<W-1){
                  b[i-1][j+1]++;
                }
                b[i-1][j]++;
              }
                            if(i<H-1){
                if(j>0){
                b[i+1][j-1]++;
                }
                if(j<W-1){
                  b[i+1][j+1]++;
                }
                b[i+1][j]++;
              }
                              if(j>0){
                b[i][j-1]++;
                }
                if(j<W-1){
                  b[i][j+1]++;
                }
      		}
      		else{
              continue;
            }
        }
    }
for(int i=0;i<H;i++){
  for(int j=0;j<W;j++){
    if(a[i][j]=='#'){
      cout<<'#';
    }
    else{
  cout<<b[i][j];
}
  }
  cout<<endl;
}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int n = scn.nextInt();
            double[] x = new double[n];

            for(int i = 0; i < n; i++) {
                x[i] = scn.nextDouble();
            }

            double p0 = 0, p1 = 0, p2 = 0, p3 = 0;
            for(int i = 0; i < n; i++) {
                double y = scn.nextDouble();
                double z = Math.abs(x[i] - y);
                p0 = p0 > z ? p0 : z;
                p1 += z;
                p2 += Math.pow(z, 2);
                p3 += Math.pow(z, 3);
            }

            System.out.println(p1);
            System.out.println(Math.sqrt(p2));
            System.out.println(Math.cbrt(p3));
            System.out.println(p0);
        }
    }
}

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

string s;

int conv_stoi(string str){
  stringstream ss(str);
  int n;
  ss >> n;
  return n;
}

int parse(int l, int r){
  int n = 0;
  for(int i=r-1;i>=l;i--){
    if(s[i] == ')') n++;
    if(s[i] == '(') n--;
    if(!n){
      if(s[i] == '+') return parse(l,i) + parse(i+1,r);
      if(s[i] == '-') return parse(l,i) - parse(i+1,r);
    }
  }
  for(int i=r-1;i>=l;i--){
    if(s[i] == ')') n++;
    if(s[i] == '(') n--;
    if(!n){
      if(s[i] == '*') return parse(l,i) * parse(i+1,r);
      if(s[i] == '/') return parse(l,i) / parse(i+1,r);
    }
  }

  if(s[l] == '(' && s[r-1] == ')') return parse(l+1,r-1);
  return conv_stoi(s.substr(l,r-l));
}

int main(){
  int n;
  cin >> n;
  while(n--){
    cin >> s;
    cout << parse(0,(int)s.size()-1) << endl;
  }
}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	int cnt = 0;
	while (A >= B) B *= 2, cnt++;
	while (B >= C) C *= 2, cnt++;
	if (cnt > K) cout << "No\n";
	else cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define int long long
int mian(){
	int x;
	cin>>x;
	map<int,int>a;
	for(int i=-128;i<=128;++i)
		a[i]=i*i*i*i*i;
	for(int i=-128;i<=128;++i)
		for(int j=-128;j<=128;++j)
			if(a[i]-a[j]==x){
				cout<<i<<' '<<j<<endl;
				return 0;
			}
	return 0;
}
signed main(){
	int t=1;
//	cin>>t;
	while(t--)
		mian();
	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int y1,m1,d1;
	int y2,m2,d2;
	int SA;
	cin>>y1>>m1>>d1;
	cin>>y2>>m2>>d2;
	SA=0;
	if(y1>y2){
		if(m1>m2) SA=y1-y2+1;
		else if(m1==m2){
			if(d1>d2) SA=y1-y2+1;
			else SA=y1-y2;
		}
		else SA=y1-y2;
	}
	else if(y1<y2){
		if(m1<m2) SA=y2-y1+1;
		else if(m1==m2){
			if(d1<d2) SA=y2-y1+1;
			else SA=y2-y1;
		}
		else SA=y2-y1;
	}
	else{
		if(m1!=m2||d1!=d2) SA=1;
	}
	
	cout<<SA<<endl;
	return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
using ll = long long;
using ld = long double;
using Pa = pair<int, int>;
ll mod = 1000000007;
ll MOD = 998244353;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2) % mod);
	else
		return (x * pow(x, n - 1)) % mod;
}
signed main() {
	int n; cin >> n;
	vector<pair<int, int>>a(n);
	rip(i, n) {
		cin >> a[i].second >> a[i].first;
	}
	sort(all(a));
	ll time = 0;
	rip(i, n) {
		time += a[i].second;
		if (time > a[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 4852
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int from,int to, T cost) {
        edges[from].emplace_back(to, cost);
        if(!directed){
            edges[to].emplace_back(from,cost);
        }
    }

    int size() {
        return n;
    }
};


int main() {

    int K,A,B;

    cin >> K >> A >> B;

    bool flag = false;

    FOR(i,A,B+1){
        if(i%K == 0){
            flag = true;
        }
    }

    cout << ((flag)?"OK":"NG") << endl;



    return 0;
}

Measured memory_bytes: 3620
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back
#define REP(i,a,b) for(int i=a; i<=b; i++)
#define MOD 1000000007

void solve(int test_case) {//209
	int n,m,x;
	cin>>n>>m>>x;
	vi c(n);
	vector<vi> a(n,vi(m));
	int ans = -1;
	REP(i,0,n-1) {
		cin>>c[i];
		for(int &j:a[i]) cin>>j;
	}
	for(int i=0;i<(1<<n);i++) {
		vi now(m,0);
		int cnt=0;
		for(int j=0;j<n;j++) {
			if(1&(i>>j)) {
				REP(k,0,m-1)now[k]+=a[j][k];
				cnt+=c[j];
			}
		}
		bool isSol = true;
		for(int j:now){if(j<x){isSol=0;break;}}
		if(isSol) {
			if(ans==-1)ans=cnt;
			else ans=min(ans,cnt);
		}
	}
	cout<<ans;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	//prefill();
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3652
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;

long long a , b , ans;

long long check(long long x){
	long long now = 1;
	for(int i = 1; i <= a ; i++){
		now *= x;
		if(now > b)return 0;
	}

	return (b % now) + 1;
}

int main(){
	cin >> a >> b;
	if(a == 1){
		cout << b;
		return 0;
	}
	long long now;
	long long i = 1;
	ans = 1;
	for(i = 2 ; i <= b ; i++){
		now = check(i);
		if(now == 0)break;
		if(now == 1){
			ans = max(ans,i);
		}
	}
	 cout << ans << endl ;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int a1, a2, a3, a4;
  while(cin >> a1 >> a2 >> a3 >> a4){
    int a[4];
    int b[4];
    int H = 0, B = 0; 
    a[0] = a1;
    a[1] = a2;
    a[2] = a3;
    a[3] = a4;
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    for(int i = 0; i < 4; i++){
      for(int j = 0; j < 4; j++){
	if(b[i] == a[j]){
	  B++;
	  if(i == j){
	    B--;
	    H++;
	  }
	}
      }
    }
    cout << H << ' ' << B << endl;
  }
}

Measured memory_bytes: 1160
#include  <bits/stdc++.h>
using namespace std;
int main(){
	long long a=0,b=0,c=0,n=1e18;
	scanf("%lld%lld%lld",&n,&a,&b);
	c=b-a;
	if(c%2==0){
		c/=2;	
		printf("%lld",c);
		return 0;
	}
	long long d=a-1,e=n-b,res=0;
	if(d<=e){
		res+=a;
		b-=a;
		a=1ll;
		c=(b-a)/2;
		res+=c;
	printf("%lld",res);		
	}else{
		res+=(e+1);
		b=n;
		a+=(e+1);
		c=(b-a)/2;
		res+=c;
		printf("%lld",res);
	}
}

Measured memory_bytes: 256
N,K=map(int,input().split())
P=list(map(lambda x: (int(x)+1)/2,input().split()))
s=sum(P[:K])
tmp=s
for i in range(K,N):
  tmp=tmp-P[i-K]+P[i]
  if tmp>s:
    s=tmp
print(s)

Measured memory_bytes: 32120
#include<stdio.h>
#define M 1000000007

 long long int Pow(long long int m,long long int n){
        long long int res;

        if(n==0)return 1;

        res=Pow((m*m)%M,n/2);

        if(n%2==1){
               res=(m*res)%M;
               }
        return res;
        }


 int main(){
        long long int m,n;
        scanf("%lld %lld",&m,&n);
        printf("%lld\n",Pow(m,n));
        return 0;
        }


Measured memory_bytes: 1964
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B;
    string ans;
    ans = "No";
    cin >> A >> B;
    for(int i = 1; i <= 3;i++){
        if((A * B * i) % 2 != 0 ){
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}


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

template <typename T> struct RMQ{
    
    const ll NMAX = 1 << 17; // 131072
    const ll LL_MAX = 1e18 + 20;
    ll n;
    vector<T> dat;

    RMQ(ll _n){
        n = 1;
        // 2^pまでpaddingする
        while(n < _n) n *= 2;
        // 初期化
        dat.resize((2 * NMAX - 1), LL_MAX);
    }

    RMQ(ll _n, T _ini_val){
        n = 1;
        // 2^pまでpaddingする
        while(n < _n) n *= 2;
        // 初期化
        dat.resize((2 * NMAX - 1), LL_MAX);
        for(ll i = 0; i < 2 * n - 1; i++) dat[i] = _ini_val;
    }

    void update(ll k, T a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k-1) / 2;
            dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }

    T query(ll a, ll b, ll k, ll l, ll r){
        // [a, b) の最小値を求める．
        // k := nodeの番号
        // kが[l, r)に対応している．
        // query(a, b, 0, 0, n)で外から呼ぶ
        
        // [a, b)と[l，r)が交差しないケース
        if(r <= a || b <= l){
            return LL_MAX;
        }

        if(a <= l && r <= b){
            // [a, b)を[l, r)含むケース
            return dat[k];
        }else{
            T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
    
    T query(ll a, ll b){
        return query(a, b, 0, 0, n);
    }

};

int main(){
    ll N, Q;
    cin >> N >> Q;
    RMQ<ll> sg(N, (1LL<<31) - 1);
    rep(q, 0, Q){
        ll comm, x, y;
        cin >> comm >> x >> y;
        if(comm == 0) sg.update(x, y);
        else cout << sg.query(x, y+1) << endl;
    }
    return 0;
}


Measured memory_bytes: 4972
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/


signed main() {
	int n; cin >> n;
	if (n % 2)cout << n / 2  << endl;
	else cout << n / 2 - 1 << endl;
}

Measured memory_bytes: 256
s = list(map(lambda x: ord(x) - ord('a'), list(input())))

ans = ["-1", "-1"]
# print(s)
if len(s) == 2:
    if len(set(s)) == 1:
        print(1, 2)
        exit()
    else:
        print(" ".join(ans))
        exit()

for i in range(len(s) - 2):
    # print(len(set(s[i:i+3])))
    if len(set(s[i:i+3])) <= 2:
        # print(s[i:i+3])
        ans = [str(i+1), str(i+3)]
        break

print(" ".join(ans))

Measured memory_bytes: 50184
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

while true
n=gets.to_i
break if n.zero?
s=get_f
v=s.inject(0){|res,x| res+x**2}/n-(s.inject(:+)/n)**2
puts (v**0.5).round(10)
end


Measured memory_bytes: 6988
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	var A, B, C int

	A = nextInt()
	B = nextInt()
	C = nextInt()
	if A == B {
		if B == C {
			fmt.Println("No")
		} else {
			fmt.Println("Yes")
		}
	} else {
		if B == C {
			fmt.Println("Yes")
		} else if A == C {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}

}

func nextInt() int {
	stdin.Scan()
	i, err := strconv.Atoi(stdin.Text())
	if err != nil {
		panic(err)
	}
	return i
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  string S;
  cin>>N>>S;
  string ans="No";
  if(N%2==0){
    ans="Yes";
  for(int i=0;i<N/2;i++){
   if(S.at(i)!=S.at(N/2+i)){
    ans="No"; break;
   }
  }
  
  } cout<<ans<<endl;
  return 0;
}

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

using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;
    int counter = 0;
    for (int i = 0 ; i < S.length() ; i++)
    {
        if (S[i] != T[i])
            counter++;
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 3692
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
 
    private static List<Long> divisor(long n) {
        List<Long> list = new ArrayList<>();
        for (long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                list.add(i);
                long j = n / i;
                if (j != i) {
                    list.add(j);
                }
            }
        }
        Collections.sort(list);
        return list;
    }
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long m = sc.nextLong();
        List<Long> div = divisor(m);
        long ans = 1;
        for (int i = 0; i < div.size(); i++) {
            long d = div.get(i);
            if (d * n <= m) {
                ans = Math.max(ans, d);
            }
        }
        System.out.println(ans);
    }
 
}

Measured memory_bytes: 27100
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



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

	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n)
	{
		cin >> a[i];
	}

	for (int i = 0; i < n - k; i++)
	{
		if (a[i] < a[k + i])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 4780
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C4N solver = new C4N();
        solver.solve(1, in, out);
        out.close();
    }

    static class C4N {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            long n = in.ints();
            for (int h = 1; h <= 3500; h++) {
                for (int w = h; w <= 3500; w++) {
                    long c = n * h * w;
                    long m = 4 * h * w - n * (w + h);
                    if (m > 0 && c % m == 0) {
                        out.print(h);
                        out.print(' ');
                        out.print(c / m);
                        out.print(' ');
                        out.println(w);
                        return;
                    }
                }
            }
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



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

vector<ll> X, Y;
 
signed main(){
	ll N, D;
	cin >> N >> D;
	X = Y = vector<ll>(N);
	for(int i = 0; i < N; i++){
		cin >> X.at(i) >> Y.at(i);
	}
	int sum = 0;
	for(int i = 0; i < N; i++){
		if(X.at(i)*X.at(i)+Y.at(i)*Y.at(i) <= D*D){
			++sum;
		}
	}
	cout << sum << endl;
 
	return 0;
}

Measured memory_bytes: 6372
a = [[0 for i in range(3)] for j in range(3)]
bingo = [[False for i in range(3)] for j in range(3)]
b = []
flag = False

# カードの数字を読み込み
for i in range(3):
    string = input()
    for j in range(3):
        a[i][j] = int(string.split()[j])

# N個の数を読み込み
n = int(input())
for i in range(n):
    b.append(int(input()))

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                bingo[i][j] = True

for i in range(3):
    if bingo[i][0] and bingo[i][1] and bingo[i][2]:
        flag = True
    if bingo[0][i] and bingo[1][i] and bingo[2][i]:
        flag = True
if bingo[0][0] and bingo[1][1] and bingo[2][2]:
    flag = True
if bingo[0][2] and bingo[1][1] and bingo[2][0]:
    flag = True

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n;
  rd(n);
  auto a = readln.split.to!(long[]);
  //   3 2 4  1  2
  // 0 3 5 9 10 12
  auto acc = new long[](n + 1);
  foreach (i; 0 .. n)
    acc[i + 1] = acc[i] + a[i];

  long inf = 1_000_000_000_000_000_000;
  auto mn = inf;
  for (int i = 0, j = 2, k = 2; j <= n - 2; j++) { // (0,i] (i,j] (j,k] (k,n]
    while (i < j && acc[i] <= acc[j] - acc[i]) {
      i++;
    }
    while (k < n && acc[k] - acc[j] <= acc[n] - acc[k]) {
      k++;
    }
    for (int x = 0; x <= 1; x++) {
      for (int y = 0; y <= 1; y++) {
        auto min_val = min(acc[i - x], acc[j] - acc[i - x], acc[k - y] - acc[j], acc[n] - acc[k - y]);
        auto max_val = max(acc[i - x], acc[j] - acc[i - x], acc[k - y] - acc[j], acc[n] - acc[k - y]);
        mn = min(mn, max_val - min_val);
      }
    }
  }
  writeln(mn);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

typedef vector<int> vi;
typedef vector<vi> vvi;


int main(){
    int W, H;
    while (cin >> H >> W){
        vvi point(H, vi(W));
        vvi color(H, vi(W));
        rep(i, H){
            rep(j, W){
                cin >> point[i][j];
            }
        }
        rep(i, H){
            rep(j, W){
                cin >> color[i][j];
            }
        }

        int h, w;
        cin >> h >> w;
        int ans = -(1 << 30);
        vvi color2(h, vi(w));
        rep(i, h)rep(j, w){
            cin >> color2[i][j];
        }

        rep(i, H - h + 1)rep(j, W - w + 1){
            bool ok = true;
            int t = 0;
            rep(ii, h)rep(jj, w){
                t += point[i + ii][j + jj];
                if (color[i + ii][j + jj] != color2[ii][jj]){
                    ok = false;
                }
            }
            if (ok){
                ans = max(ans, t);
            }
        }
        if (ans == -(1 << 30)){
            cout << "NA" << endl;
        }
        else{
            cout << ans << endl;
        }
    }
}


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

Measured memory_bytes: 256
import java.util.Scanner;
class Main
{

 public static void main(String[] args) 
 {
   int A;
   int B;

	Scanner scan = new Scanner(System.in);
	A = scan.nextInt();
	B = scan.nextInt();

	if(A>=2*B)
		System.out.println(A-2*B);
	else 
	  System.out.println(0);
 }
}

Measured memory_bytes: 23636
"""
Writer:SPD_9X2
https://atcoder.jp/contests/diverta2019/tasks/diverta2019_e


区分けされた部分1つ分のxorをAとすると、全体のxorは0かAかじゃないといけない
A→0→A→0となる部分に仕切りを入れられる
→DP

全体のxorが0以外の時は簡単→普通にDPすればいいだけ

全体のxorが0の時は、0を含め、出て来たすべてのxorに関して調べなきゃいけない
0が多いとき、計算量がO(N**2)になっちゃいそう…
Aをまとめて処理しなくてはいけない？

Aとしてありうるのは途中で出て来た0を含めたすべての数字
そこ1箇所で切ったのも採用可能＋今まで出て来たAのうち、それ以降で1度でも0が出たものに加えるのも可能
→0の選び方も自由だからなぁ…

愚直なdp遷移を考えてみる
dp[A] = 1 + Σdp[今まで出たA] * (その間にある0の数) →O(N**2)じゃ…(死)
どうやって高速化しよう…→上の推移式をO(1)で計算できないか？
→Σdp[今まで出たA]を記録して置けば、その間にあるAは全体で同数増加なのでO(1)で計算できる！！

"""
mod = 10**9+7
N = int(input())

a = list(map(int,input().split()))

allxor = 0
for i in range(N):
    allxor ^= a[i]

if allxor != 0: #0じゃない場合、簡単に解ける

    dp = [1,0] #0で終わってる場合数、allxorで終わってる場合数

    nxor = 0
    for i in range(N-1):
        ndp = [dp[0] % mod,dp[1] % mod]
        nxor ^= a[i]

        if nxor == 0:
            ndp[0] += dp[1]
        elif nxor == allxor:
            ndp[1] += dp[0]

        dp = ndp
        #print (dp)

    print (dp[0] % mod)

else:

    #必要なのは、各位置で今まで出た0の数
    #最後にAが出た位置
    #今までの各Aの通り数の和
    #0に関しては最後に計算する
    

    zsum = [1]
    lastA = {}
    sumdic = {}
    inddic = {}
    nxor = 0

    for i in range(N-1):

        nxor ^= a[i]

        if nxor == 0:
            zsum.append(zsum[-1] + 1)
            continue
        else:
            zsum.append(zsum[-1])

        if nxor not in inddic:
            inddic[nxor] = i
            sumdic[nxor] = 1
            lastA[nxor] = 1
        else:
            dpa = lastA[nxor] + sumdic[nxor] * (zsum[-1] - zsum[inddic[nxor]])
            lastA[nxor] = dpa % mod
            sumdic[nxor] += dpa % mod
            sumdic[nxor] %= mod
            inddic[nxor] = i

            #print (i,nxor,sumdic)

    ans = 0
    #print (sumdic)
    for i in sumdic:
        ans += sumdic[i]
        ans %= mod

    #print (ans,zsum)

    ans += pow(2,zsum[-1]-1,mod)

    print (ans % mod)
        


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


int main(void)
{
    int n;
    scanf("%d", &n);
    int a[n];
    for (int i=0; i < n; i++) scanf("%d", &a[i]);

    int cnt = 0;
    while(1){
        int flag = 0;
        for (int i=0; i < n; i++){
            if (a[i]%2 == 1){
                flag = 1;
            }
        }
        if (flag == 1) break;
        else cnt++;
        for (int j=0; j < n; j++) a[j] /= 2;
    }


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




    return 0;
} 



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

struct result{
  int step;
  int gcd;
};

void gcd(int a, int b, result* r);

int main(void){
  int a,b;
  result r;
  while(1){
    cin>>a>>b;
    if(a==0 and b==0)break;
    gcd(a,b,&r);
    cout<<r.gcd<<" "<<r.step<<endl;
  }
  return 0;
}

void gcd(int _a, int _b, result* r){
  int step=0;
  int a=min(_a,_b);
  int b=max(_a,_b);
  while(a!=0){
    int tmp=b%a;
    b=a;
    a=tmp;
    step+=1;
  }
  r->step=step;
  r->gcd=b;
}



Measured memory_bytes: 3060
n = int(input())
l = list(map(int, input().split()))

l = sorted(l)
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[k] < l[i] + l[j] and l[i] != l[j] != l[k]:
                ans += 1
print(ans)

Measured memory_bytes: 9132
const input = require('fs').readFileSync('/dev/stdin', 'UTF-8');

const minMaxSum = input => {
  const array = [
    ...input
      .split('\n')[1]
      .split(' ')
      .map(Number)
  ];
  const min = Math.min(...array);
  const max = Math.max(...array);
  const sum = array.reduce((acc, current) => acc + current);
  console.log([min, max, sum].join(' '));
};

minMaxSum(input);



Measured memory_bytes: 18944
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;


int main(){
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
def main():
    ans = s.count('R') * s.count('G') * s.count('B')

    if(n<4):
        return 0
    
    for i in range(n):
        for j in range(i+1,n):
            k= 2*j-i
            if k>=n:
                continue
            if(s[i]==s[j] or s[i]== s[k] or s[j]==s[k]):
                continue
            ans -= 1
    return ans
print(main())

Measured memory_bytes: 9232