akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 100010
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    int n, x, t, tmp;
    cin >> n >> x >> t;
    tmp=ceil((double)n/(double)x);
    tmp*=t;
    cout << tmp << endl;
    return 0;
}


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

struct Card {
	char suit, value;
};

void Bubble(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		for (int j = N - 1; j >= i; j--) {
			if (A[j].value < A[j - 1].value) {
				Card t = A[j];
				A[j] = A[j - 1];
				A[j - 1] = t;
			}
		}
	}
}

void Selection(Card A[], int N) {
	for (int i = 0; i<N; ++i) {
		int minj = i;
		for (int j = i; j<N; ++j) {
			if (A[j].value<A[minj].value) minj = j;
		}
		swap(A[i], A[minj]);
	}
}
 

void Print(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		if (i > 0) {
			cout << " ";
		}
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[],int N){
	for (int i = 0; i < N; i++) {
		if (C1[i].suit != C2[i].suit) {
			return false;
		}
	}
	return true;
}

int main() {
	Card C1[100], C2[100];
	int N;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> C1[i].suit >> C1[i].value;
	}

	for (int i = 0; i < N; i++) {
		C2[i] = C1[i];
	}

	Bubble(C1, N);
	Selection(C2, N);

	Print(C1, N);
	cout << "Stable" << endl;
	Print(C2, N);
	
	if (isStable(C1, C2, N)) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}

	return 0;
}

Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if ((i + j) % 2 == 0) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
        sc.close();
    }
}


Measured memory_bytes: 34396
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

int W, H, N;
int x, y, a;
int xl, xr, yb, yt;

void paint(int x, int y, int a)
{
    switch (a) {
    case 1:
        xl = max(x, xl);
        break;
    case 2:
        xr = min(x, xr);
        break;
    case 3:
        yb = max(y, yb);
        break;
    case 4:
        yt = min(y, yt);
        break;
    }
    return;
}


int main()
{
    cin >> W >> H >> N;
    xl = 0;
    xr = W;
    yb = 0;
    yt = H;
    for (int i = 0; i < N; i++) {
        cin >> x >> y >> a;
        paint(x, y, a);
    }

    cout << max(xr - xl, 0) * max(yt - yb, 0) << endl;
    return 0;
}

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

int N, M;
string S;
const int MAX = 400000;
vector<int> edges[MAX];
int visited[MAX];

void dfs(int i){
    visited[i] = -1;
    for(auto j : edges[i]){
        if(visited[j] == -1){
            cout << "Yes" << endl;
            exit(0);
        }else if(!visited[j]){
            dfs(j);
        }
    }
    visited[i] = 1;
}

int main(){
    int i, j, k;
    cin >> N >> M >> S;
    for(i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(S[a] == S[b]){
            edges[a].push_back(b+N);
            edges[b].push_back(a+N);
        }else{
            edges[a+N].push_back(b);
            edges[b+N].push_back(a);
        }
    }

    for(i=0; i<N; i++){
        if(!visited[i]) dfs(i);
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 24452
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if (S == "RRR") {
    cout << 3 << endl;
  }
  else if (S == "RRS" || S == "SRR"){
    cout << 2 << endl;
  }
  else if (S == "RSS" || S == "SRS" || S == "SSR" || S == "RSR") {
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
    
    
}

Measured memory_bytes: 3624
import sys
from collections import Counter, defaultdict


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  

N = int(input())
MOD = 10**9 + 7

if N == 1:
  print(1)
  sys.exit()
  
d = defaultdict(int)

for n in range(2, N+1):
  prime_factor = prime_factorize(n)
  for key, value in Counter(prime_factor).items():
    d[key] += value
    
ret = 1
for i in d.values():
  ret *= i + 1
  ret %= MOD
  
print(ret)

Measured memory_bytes: 3444
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

vector<vector<int>> GridBFS(int sh, int sw, vector<string>& vs) {
	int dh[] = { 1,-1,0,0 };
	int dw[] = { 0,0,1,-1 };
	int H = vs.size();
	int W = vs[0].size();
	queue<pair<int, int>> q;
	vector<vector<int>> d(H, vector<int>(W, inf));
	q.emplace(sh, sw);
	d[sh][sw] = 0;
	while (!q.empty()) {
		int h, w; tie(h, w) = q.front();
		q.pop();
		for (int i = 0; i < 4; i++) {
			int nh = h + dh[i];
			int nw = w + dw[i];
			if (nh < 0 or nh >= H or nw < 0 or nw >= W) continue;
			if (vs[nh][nw] == '#') continue;
			if (chmin(d[nh][nw], d[h][w] + 1)) q.emplace(nh, nw);
		}
	}
	return d;
}

vector<vector<int>> MultiGridBFS(vector<int> &sh, vector<int> &sw, vector<string>& vs) {
	int dh[] = { 1,-1,0,0 };
	int dw[] = { 0,0,1,-1 };
	int H = vs.size();
	int W = vs[0].size();
	queue<pair<int, int>> q;
	vector<vector<int>> d(H, vector<int>(W, inf));
	for (int i = 0; i < sh.size(); i++) {
		d[sh[i]][sw[i]] = 0;
		q.emplace(sh[i], sw[i]);
	}
	while (!q.empty()) {
		int h, w; tie(h, w) = q.front();
		q.pop();
		for (int i = 0; i < 4; i++) {
			int nh = h + dh[i];
			int nw = w + dw[i];
			if (nh < 0 or nh >= H or nw < 0 or nw >= W) continue;
			if (vs[nh][nw] == '#') continue;
			if (chmin(d[nh][nw], d[h][w] + 1)) q.emplace(nh, nw);
		}
	}
	return d;
}


int main()
{
	
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	
	int H, W; cin >> H >> W;
	vector<string> vs(H); for (int i = 0; i < H; i++) cin >> vs[i];
	int ph = -1, pw = -1, eh = -1, ew = -1;;
	vector<int> sh, sw;
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
		if (vs[i][j] == '$') sh.emplace_back(i), sw.emplace_back(j);
		if (vs[i][j] == '@') ph = i, pw = j;
		if (vs[i][j] == '%') eh = i, ew = j;
	}
	auto d1 = GridBFS(ph, pw, vs);
	auto d2 = MultiGridBFS(sh, sw, vs);
	if (d1[eh][ew] < d2[eh][ew]) cout << "Yes" << "\n";
	else cout << "No" << "\n";
	return 0;
}



Measured memory_bytes: 3904
from collections import deque

h, w = map(int, input().split())
s = [list(input()) for i in range(h)]

w_cnt = 0
for i in range(h):
    w_cnt += s[i].count('.')

def bfs():
    d = [[float("inf")] * w for i in range(h)]

    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    que = deque([])
    que.append((0, 0))
    d[0][0] = 0

    while que:
        p = que.popleft()
        if p[0] == h-1 and p[1] == w-1:
            break
        for i in range(4):
            n_row = p[0] + dx[i]
            n_col = p[1] + dy[i]

            if 0 <= n_row < h and 0 <= n_col < w and s[n_row][n_col] != "#" and d[n_row][n_col] == float("inf"):
                que.append((n_row, n_col))
                d[n_row][n_col] = d[p[0]][p[1]] + 1

    return d[h-1][w-1]

if bfs() == float("inf"):
    print(-1)
else:
    print(w_cnt-bfs()-1)

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

struct P {
    bool operator<(const P& p) const {
        return b < p.b;
    }
    int a, b;
};

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

    int n;
    cin >> n;

    ll x = 0;

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].a >> p[i].b;

        int t = p[i].a - p[i].b;
        if (t > 0) x += t;
    }

    if (x == 0) {
        cout << 0 << endl;
        return 0;
    }

    sort(p.begin(), p.end());

    ll r = 0, s = 0;
    for (int i = 0; i < n; i++) {
        int t = p[i].a - p[i].b;
        int u = p[i].a; // aが小さい場合これだけ取れる 大きくてもこれだけ取れることがある
        int v = p[i].a - p[i].b; // aのが大きくてもこれだけは取れる
        if (t <= 0) {
            r += u;
        } else {
            if (s == 0) {
                r += v;
                s = 1;
            } else {
                r += u;
            }
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
int main(void){
  long int i,sum=0,num_int=0;
  char num[20000000];
  scanf("%s",num);
  for(i=0;i<strlen(num);i++){
    sum+=(num[i]-'0');
    num_int+=(num[i]-'0');
    num_int*=10;
  }
  if((num_int/10)%sum==0){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

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


def solve(D: int):
    if(D == 25):
        print("Christmas")
    elif(D == 24):
        print("Christmas Eve")
    elif(D == 23):
        print("Christmas Eve Eve")
    elif(D == 22):
        print("Christmas Eve Eve Eve")
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    solve(D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;
#define int LL

const int inf = 1e9;

signed main(){
	int te;scanf("%lld",&te);
	while(te--){
		int a,b;scanf("%lld%lld",&a,&b);
		if(a>b)swap(a,b);
		if(a==b){printf("%lld\n",2*a-2);continue;}
//		if(a+1==b){printf("%lld\n",2*a-2);continue;}
		int c=sqrt(1ll*a*b);
		if(c*c==a*b)--c;
		if(c*(c+1)>=a*b)printf("%lld\n",2*c-2);
		else printf("%lld\n",2*c-1);
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 6010;
int n,mod,f[N][2*N];

inline void upd(int &x,int y){
	x+=y;
	if (x>=mod) x-=mod;
}

int main(){
	n=read()*3,mod=read();
	f[0][N]=1;
	FOR(i,0,n) For(j,N-i,N+i) if (f[i][j]){
		upd(f[i+1][j+1],f[i][j]);
		f[i+2][j-1]=(f[i+2][j-1]+1ll*f[i][j]*(i+1))%mod;
		f[i+3][j]=(f[i+3][j]+1ll*f[i][j]*(i+1)%mod*(i+2))%mod;
	}
	int ans=0;
	For(i,N,N+n) upd(ans,f[n][i]);
	printf("%d\n",ans);
}

Measured memory_bytes: 133196
from itertools import accumulate

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


for _ in range(K):
    lamp = [0] * (N + 1)                    # imos法: 区間[l,r)　に要素を加算する操作を、lamp[l] += 1 と　lamp[r+1] -= 1　にすることで、
                                            # 情報の更新をO(1)で終わらせることができる。（愚直にやるとO(l-r) <= O(N)でアウト）
                                            # 右端を開にしているため、N+1 個の要素が必要。
    for i, a in enumerate(A):
        lamp[max(i-a,0)] += 1
        lamp[min(i+a+1,N)] -=1
    B = tuple(accumulate(lamp))[:-1]
    if B == A:
        break
    A = B


print(*A)

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

int main(){
	int n;
	cin >> n;
	vector<int> v(n);
	for(int& x:v){
		cin >> x;
	}
	int current = 1;
	for (int i=0; i<n; i++){
		if (v[i] == current){
			current+=1;
		}
	}
	if (current == 1) cout << -1;
	else cout << n-current+1;
	

 }


Measured memory_bytes: 1152
fn main(){
	let v = read_vec::<i32>();
	let n = (v[0]..v[1] + 1).filter(|x| v[2] % x == 0).count();
	println!("{}", n)

}
 
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 5032
def main():
  N = int(input())
  work_list = []
  for n in range(N):
    work_list.append(list(map(int, input().split())))
  work_list = sorted(work_list, key=lambda x:x[1])
  time = 0
  for work in work_list:
    time += work[0]
    if time > work[1]:
      print('No')
      break
  else:
    print('Yes')

main()

Measured memory_bytes: 55188
x = int(input())
def make_divisors(n):
  divisors = []
  for i in range(int(n**0.5)+1,0,-1):
    if n % i == 0:
      divisors.append(i)
      divisors.append(n//i)
      break
  return divisors
div = make_divisors(x)
print(sum(div)-2)

Measured memory_bytes: 2940
N , M  = map(int,input().split())
bridge = []
cut = []

for i in range(M):
    a,b = map(int,input().split())
    bridge.append((a,b))

bridge = sorted(bridge, key=lambda x: x[1])

for a,b in bridge:
    if len(cut)==0:
        cut.append(b-1)
    else:
        c = cut[-1]
        if a > c:
            cut.append(b-1)

print(len(cut))


Measured memory_bytes: 18972
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    int n,m,a[60],b[60],c[60],d[60] ;
    scanf("%d%d",&n,&m) ;
    for (int i=0; i<n; i++){
        scanf("%d%d",&a[i],&b[i]);
    }
    for (int i=0; i<m; i++){
        scanf ("%d%d",&c[i],&d[i]);
    }
    for (int i=0; i<n; i++){
        int anslong=500000000;
        int ans=-1;
        for (int j=0; j<m; j++){
            int tmp;
            tmp=abs(a[i]-c[j])+abs(b[i]-d[j]) ;
            if (tmp<anslong){
                anslong=tmp;
                ans=j+1;
            }
        }
        printf ("%d\n",ans) ;
    }
    return 0 ;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var s = int.Parse(ReadLine());

        int f(int n) => (n % 2 == 0) ? n / 2 : 3 * n + 1;

        var a = new int[1000001];
        a[1] = s;
        for (int i = 2; i < a.Length; i++)
            a[i] = f(a[i - 1]);

        var used = new HashSet<int>();
        var ans = 0;
        for (int i = 1; i < a.Length; i++)
        {
            if(used.Contains(a[i]))
            {
                ans = i;
                break;
            }

            used.Add(a[i]);
        }

        WriteLine(ans);
    }
}


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

int main() {
  long long res1;
  long long res2;
  long double a;
  long double b;
  cin >> a >> b ;
  
  long double bb = b;
  long double bc = b -bb;
  res1 = a*bb;
  res2 = a * bc;
  //res = a*b;
 
  cout << res1+ res2 << endl;
 }


Measured memory_bytes: 3668
#include <iostream>
#include <utility>
#include <cmath>
#include <iomanip>
#include <vector>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

pair<double, double> div(pair<double, double> p1, pair<double, double> p2, int m, int n)
{
    double x = n * p1.first + m * p2.first;
    x /= double(n + m);
    double y = n * p1.second + m * p2.second;
    y /= double(n + m);
    return make_pair(x, y);
}

pair<double, double> rotate(pair<double, double> p1, pair<double, double> p2, double theta)
{
    double x = (p2.first - p1.first) * cos(theta) - (p2.second - p1.second) * sin(theta);
    double y = (p2.first - p1.first) * sin(theta) + (p2.second - p1.second) * cos(theta);
    return make_pair(p1.first + x, p1.second + y);
}

void kochCurve(pair<double, double> p1, pair<double, double> p2, int n, vector<pair<double, double>> &stock)
{
    if (n == 0)
    {
        return;
    }
    pair<double, double> s, u, t;
    s = div(p1, p2, 1, 2);
    t = div(p1, p2, 2, 1);
    u = rotate(s, t, M_PI / 3.);
    kochCurve(p1, s, n - 1, stock);
    stock.push_back(s);
    kochCurve(s, u, n - 1, stock);
    stock.push_back(u);
    kochCurve(u, t, n - 1, stock);
    stock.push_back(t);
    kochCurve(t, p2, n - 1, stock);
}

int main()
{
    vector<pair<double, double>> koch(0);
    int n;
    cin >> n;
    koch.push_back(make_pair(0., 0.));
    kochCurve(make_pair(0., 0.), make_pair(100., 0.), n, koch);
    koch.push_back(make_pair(100., 0.));

    for (auto e : koch)
    {
        cout << fixed << setprecision(10) << e.first
             << " " << fixed << setprecision(10) << e.second << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
import sys 
from functools import reduce
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def gcd(*numbers):
    return reduce(math.gcd, numbers)
K = int(readline())
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += gcd(i,j,k)
print(ans)

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

using namespace std;

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

  string S;
  cin >> S;

  int result = 0;
  for (int i = 0; i < 4; ++i) {
    if (S[i] == '+') ++result;
    else --result;
  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define N 1000005
#define BB(V) V[V.size()-2]
#define ex(V) return printf(V),0
using namespace std;
int a[100005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(a[i]==i){
			if(i<n)swap(a[i],a[i+1]);
			else swap(a[i],a[i-1]);
			cnt++;
		}
	}
	printf("%d",cnt);
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

unsigned char D[252004];
bool E[252004];
int Q[252004];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	int n = N + 2;
	rep1(i, N) {
		int ij = n * i + 1;
		unsigned char kari = min(i - 1, N - i);
		unsigned char kari2 = 3;

		rep(j, kari) {
			D[ij++] = kari2++;
		}
		rep(j, N - kari - kari) {
			D[ij++] = kari + 3;
		}
		rep(j, kari) {
			D[ij++] = --kari2;
		}
	}

	int kotae = 0;
	rep(k, N * N) {
		int ij = getint();
		ij += (ij - 1) / N * 2 + N + 2;

		kotae += D[ij];
		E[ij] = 1;

		int p = 0, q = 0;
		Q[p++] = ij;

		while (p > q) {
			int ij = Q[q++];
			int d =	D[ij] - E[ij] + 1;

			if (D[ij - n] > d) {
				D[ij - n] = d;
				Q[p++] = ij - n;
			}
			if (D[ij + n] > d) {
				D[ij + n] = d;
				Q[p++] = ij + n;
			}
			if (D[ij - 1] > d) {
				D[ij - 1] = d;
				Q[p++] = ij - 1;
			}
			if (D[ij + 1] > d) {
				D[ij + 1] = d;
				Q[p++] = ij + 1;
			}
		}
	}

	printf("%d\n", kotae - 3 * N * N);



	Would you please return 0;
}

Measured memory_bytes: 4512
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	string s;
	cin >> n >> s;
	int r = 0, w = 0;
	for (int i = 0;i < n;i++) {
		if (s[i] == 'R')r++;
	}
	for (int i = 0;i < r;i++) {
		if (s[i] == 'W')w++;
	}
	cout << w << endl;
	return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}


int main(){
    double a,b;cin>>a>>b;
    cout<<fixed<<setprecision(10)<<(a*b)/(a+b)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

int main() {
    int n, _q, op, t, x;
    scanf("%d %d", &n, &_q);
    queue<int> q[n];
    while (_q--) {
        scanf("%d %d", &op, &t);
        if (op == 0) {
            scanf("%d", &x);
            q[t].push(x);
        } else if (op == 1) {
            if (!q[t].empty()) printf("%d\n", q[t].front());
        } else {
            if (!q[t].empty()) q[t].pop();
        }
    }
    return 0;
}


Measured memory_bytes: 3944
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int A[200010];
ll cnt[200010]={};

int main() {
	int N;
	cin >> N;
	for(int i=0; i<N; ++i){
		cin >> A[i];
		++cnt[A[i]];
	}
	ll ans=0;
	for(int i=1; i<=N; ++i){
		ans += cnt[i]*(cnt[i]-1)/2;
	}
	for(int i=0; i<N; ++i){
		cout << ans-cnt[A[i]]+1 << endl;
	}
	return 0;
}

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

#define PI 4*atan(1)
#define INF 1e8

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int main(){
  int K, S;
  cin >> K >> S;
  int cnt = 0;
  for(int i = 0; i <= K; i++){
    for(int j = 0; j <= K; j++){
      if(0 <= S - (i + j) && S - (i + j) <= K){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}


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

string s;
int k;
int main() {
  cin >> s >> k;
  set<string> st;
  for (int i = 0; i < s.size(); ++i) {
    for (int k = 1; k <= 5; ++k) {
      st.insert(s.substr(i, k));
    }
  }
  
  auto it = st.begin();
  for (int i = 0; i < k - 1; ++i) ++it;
  cout << *it << endl;
}


Measured memory_bytes: 1664
//In The Name Of God
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 3e3 + 5, Mod = 1e9 + 7, P = 727, Lg = 22, TOF = 1900, Inf = 3e18 + 10;

int Dp[N][N], Par[N][N];
int main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      string s, t; cin >> s >> t;
      int n = s.size(), m = t.size();
      for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                  if(s[i - 1] == t[j - 1])
                        Dp[i][j] = Dp[i - 1][j - 1] + 1, Par[i][j] = 1;
                  else{
                        Dp[i][j] = max(Dp[i][j - 1], Dp[i - 1][j]);
                        if(Dp[i][j - 1] > Dp[i - 1][j])
                              Par[i][j] = 2;
                        else
                              Par[i][j] = 3;
                  }
            }
      }
      string ret = "";
      int p1 = n, p2 = m;
      while(p1 && p2){
            if(Par[p1][p2] == 1){
                  ret += s[p1 - 1];
                  p1--, p2--;
                  continue;
            }
            if(Par[p1][p2] == 2){
                  p2--;
                  continue;
            }
            p1--;
      }
      reverse(ret.begin(), ret.end());
      cout << ret;
      return 0;
}



Measured memory_bytes: 70784
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int dh[4]={0,1,0,-1};
int dw[4]={1,0,-1,0};

string s;
int main (){
      cin>>s;
      int n=s.size();
      string t={};
      rep0(i,n){
            if(s[i]!='x') t+=s[i];
      }
      int m=t.size();
      bool ok=true;
      rep0(i,m){
            if(t[i]!=t[m-1-i])ok=false;
      }
      if(!ok){
            cout<<-1<<endl;
            return 0;
      }
      int hoge=0;
      int mochi=n-1;
      int ans=0;
      while(hoge<mochi){
            if(s[hoge]!=s[mochi]){
                  if(s[hoge]=='x'){
                        ans++;
                        hoge++;
                  }
                  else if(s[mochi]=='x'){
                        ans++;
                        mochi--;
                  }
                  else{
                        cout<<"unko"<<endl;
                        return 0;
                  }
            }
            else if(s[hoge]==s[mochi]){
                  hoge++;
                  mochi--;
            }
      }
      cout<<ans<<endl;
      
      return 0;
}


Measured memory_bytes: 640
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

template<class T> inline bool chmin(T& a, T b){ if(a>b){a=b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b){ if(a<b){a=b; return 1;} return 0;}

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__


void solve(void){
  
  int N, M;
  
  cin >> N >> M;
  
  int a, b;
  
  if(N<2){
    a=0;
  }
  else
  {
    a=N*(N-1)/2;
  }
  
  if(M<2){
    b=0;
  }
  else
  {
    b=M*(M-1)/2;
  }
  
  cout << a+b << endl;

  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}


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

int main(){
    int n ;
    cin >> n ;
    vector<int> a(n) ;
    char c ;
    bool one = false ;
    int ans = 0;
    for (size_t i = 0; i < n; i++)
    {
        cin >> c ;
        a.at(i) = c - '1' ;
        if (a.at(i) == 1)
        {
            one = true ;
        }        
    }
    if (one == true )
    {
        for (size_t i = 0; i < n; i++)
        {
            a.at(i) %= 2 ;
        }
        
    }else
    {
        for (size_t i = 0; i < n; i++)
        {
            a.at(i) /= 2 ;
        }
        
    }
    int two = 0 ;
    ans += a.at(0) ; 
    for (size_t i = 1; i < n; i++)
    {
        int copy = i ;
        int copy2 = n-i  ;
        while (copy % 2 == 0 && copy > 1)
        {
            two -- ;
            copy /= 2 ;
        }
        while (copy2 %2 == 0 && copy2 > 1)
        {
            two ++ ;
            copy2 /= 2 ;
        }
        if (two == 0)
        {
            ans += a.at(i) ;
        }
        
    }
    ans %= 2 ;
    if (one == false)
    {
        ans *= 2 ;
    }
    cout << ans << endl ;
    
}

Measured memory_bytes: 4096
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

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;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.pb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  int n;
  cin>>n;
  vi a=calc(n);
  int ans=0;
  rep(i,4) if(a[i]==2) ans++;
  out(ans);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10, MOD = 1e9 + 7;
int n, i, a[N];
LL ans, q[N];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (i = 1; i <= n; i++) cin >> a[i];
	for (i = n; i >= 1; i--) q[i] = (q[i + 1] + a[i]) % MOD;
	for (i = 1; i < n; i++) ans = (ans + (a[i] * q[i + 1]) % MOD) % MOD;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 5880
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define READ(i, j) FOR(i, 0, j, 1)
#define RREAD(i, j) RFOR(i, j, 0, 1)



void solve() 
{
    string s,t;
    cin>>s>>t;
    int maxcount = 0;
    int count = 0;
    for(int i = 0; i<=s.size()-t.size(); i++)
    {
        count = 0;
        for(int j = i, k=0 ; j < t.size(), k<t.size();j++,k++)
        {
            {
                if(s[j]==t[k])
                    count++;
                //cout<<count<<" coun\n"<<j<<"i "<<k<<" j\n";
            }
        }
        maxcount = max(count,maxcount);
    }
    cout<<t.size()-maxcount;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int tc = 1; 
    //cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}


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

int main() {
  long long a;
  cin >> a;
  long long t=a%50;
  long long u=a/50;
  vector<long long> b(50);
for (int i=0;i<50;i++){
    b.at(i)=49+u-t;
}
for (int i=0;i<t;i++){
    b.at(i)+=51;
}
cout << 50 << endl;
rep(i,49){
    cout << b.at(i) << " ";
}
cout << b.at(49) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;
  vector<long> vecA(A),vecB(B),vecC(C),vecABC(X+Y+C);
  for(long i=0;i<A;i++){
    cin >> vecA[i];
  }
  for(long i=0;i<B;i++){
    cin >> vecB[i];
  }
  for(long i=0;i<C;i++){
    cin >> vecC[i];
  }
  sort(vecA.begin(),vecA.end());
  sort(vecB.begin(),vecB.end());
  reverse(vecA.begin(),vecA.end());
  reverse(vecB.begin(),vecB.end());
  for(long i=0;i<X;i++){
    vecABC[i]=vecA[i];
  }
  for(long i=X;i<X+Y;i++){
    vecABC[i]=vecB[i-X];
  }
  for(long i=X+Y;i<X+Y+C;i++){
    vecABC[i]=vecC[i-X-Y];
  }
  sort(vecABC.begin(),vecABC.end());
  reverse(vecABC.begin(),vecABC.end());
  long ans=0;
  for(long i=0;i<X+Y;i++){
    ans+=vecABC[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4736
#include <iostream>

using namespace std;

void solve()
{
	int n, m;
	cin >> n >> m;
	int max_car = m;
	for(int i = 0; i < n; ++i)
	{
		int  in, out;
		cin >> in >> out;
		m = m + in - out;
		if(m > max_car)
		{
			max_car = m;
		}
		else if(m < 0)
		{
			cout << 0 << endl;
			return;
		}
	}
	cout << max_car << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
pair<int,int> a[200005];
int ans[200005];
int main() {
	int n,x;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		a[i].first=x;
		a[i].second=i;
	}
	sort(a,a+n);
	for(int i=0;i<n/2;i++){
		ans[a[i].second]=a[n/2].first;
	}
	for(int i=n/2;i<n;i++){
		ans[a[i].second]=a[n/2-1].first;
	}
	for(int i=0;i<n;i++)cout<<ans[i]<<'\n';
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define L long long
#define R(n) for(L i=0;++i<n;)
L n,m,p,q,s[100002],S,t;
int main(){cin>>n>>m>>p;R(m)cin>>q,s[p<q?p:q]++,s[p>q?p:q]--,p=q;S=t=0;R(n)cin>>p>>q>>m,t+=s[i],S+=min(t*p,t*q+m);cout<<S<<endl;return 0;}

Measured memory_bytes: 3844
from collections import deque
N,M = map(int,input().split())
edge = [[] for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

#print(edge)

print('Yes')

ans = [None]*N
#print(edge)
q = deque([0])

tmp = [-1]*N#部屋１からの距離
tmp[0] = 0

while q:
    now = q.popleft()
    #print(edge[now])
    for v in edge[now]:
        if ans[v] == None:
            ans[v] = now
        if tmp[v] != -1:
            if tmp[now]+1 < tmp[v]:
                tmp[v] = tmp[now]+1
                ans[v] = now
            continue
        tmp[v] = tmp[now] + 1
        q.append(v)
    #print("ans",ans)
for c in ans[1:]:
    print(c+1)
    

Measured memory_bytes: 35548
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp
ll a, b, c; 
ll k;
string s = "No";
ll cnt = 0;
void calc(ll a, ll b, ll c, ll count){
    if(count == k){
        if(a < b && b < c){
            s = "Yes";
        }
        cnt++;
    }else{
        calc(a*2, b, c, count+1);
        calc(a, b*2, c, count+1);
        calc(a, b, c*2, count+1);
    }
    
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    cin >> a >> b >> c;
    cin >> k;

    calc(a, b, c, 0);

    cout << s << endl;

}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
  int n;
  cin >> n;
  int t, st, kyori, x, y, nt = 0, nx = 0, ny = 0;
  for (int i = 0; i < n; i++) {
    cin >> t >> x >> y;
    st = t - nt;
    kyori = abs(x - nx + y - ny);
    if (kyori > t || t % 2 != kyori % 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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


int main(){
  int i,n;
  int *A,*B,C[10001]={};
  scanf("%d",&n);
  A=malloc(n*sizeof(int));
  B=malloc((n+1)*sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    C[A[i]]++;
  }
  for(i=1;i<=10000;i++) C[i]+=C[i-1];
  for(i=0;i<n;i++){
    B[C[A[i]]]=A[i];
    C[A[i]]--;
  }
  for(i=1;i<n;i++) printf("%d ",B[i]);
  printf("%d\n",B[n]);
  return 0;
}

Measured memory_bytes: 16280
import java.util.*;

public class Main {
    public static void main (String[] args) {
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                System.out.println(Integer.toString(i) + "x" + Integer.toString(j) + "=" + Integer.toString(i*j));
            }
        }
    }
}

Measured memory_bytes: 17060
#include <bits/stdc++.h>
using namespace std;
 
long long mINF=-9999999999999999LL;
 
int main(){
	int N;
	cin >> N;
	vector<long long> A(N);
	for(auto &i:A)cin >> i;
	
	long long dp[N+1][3];
	for(int i=0;i<N+1;i++)for(int j=0;j<3;j++)dp[i][j]=mINF;
	dp[0][0]=dp[0][1]=dp[0][2]=dp[0][1]=dp[0][2]=dp[1][2]=0;
	dp[1][0]=A[0];
	dp[2][1]=A[1];
	if(N%2==1)dp[3][2]=A[2];
	
	for(int i=2;i<N;i++){
		dp[i+1][0]=max(dp[i+1][0],dp[i-1][0]+A[i]);
		dp[i+1][1]=max(dp[i+1][1],dp[i-1][1]+A[i]);
		dp[i+1][1]=max(dp[i+1][1],dp[i-2][0]+A[i]);
		if(N%2==1 && i>2){
			dp[i+1][2]=max(dp[i+1][2],dp[i-1][2]+A[i]);
			dp[i+1][2]=max(dp[i+1][2],dp[i-2][1]+A[i]);
			dp[i+1][2]=max(dp[i+1][2],dp[i-3][0]+A[i]);
		}
	}
	long long ans;
	if(N%2==0)ans=max(dp[N-1][0],dp[N][1]);
	if(N%2==1)ans=max(max(dp[N-2][0],dp[N-1][1]),dp[N][2]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9592
#include <bits/stdc++.h>
using namespace std;
#define data_type long long
#define endl "\n"
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    data_type n,a,b,c,k,sum=0;

    cin>>a>>b>>c>>k;

    sum+=min(a,k);
    k-=min(a,k);
   // sum+=min(b,k);
    k-=min(b,k);
    sum-=min(c,k);
    k-=min(c,k);
    cout<<sum<<endl;



    return 0;
}


Measured memory_bytes: 3652
# coding: utf-8

N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return len(divisors)

cnt = 0
for i in range(N):
  if((i+1)%2==1 and make_divisors(i+1)==8):
    cnt+=1
print(cnt)

Measured memory_bytes: 38384
#!/usr/bin/ruby 
#encoding: utf-8

s = gets.chomp
t = gets.chomp

ans = false

(0..s.size-1).each do |i|
  if s == t then
    ans = true
  end
  
  # 文字列操作
  s = s[s.size-1].to_s << s[0,s.size-1]
  #puts s
end

if ans == true
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
var
	N,M,i,u,v:Longint;
	ok:Array[1..200000]of Boolean;
begin
	read(N,M);
	for i:=1 to M do begin
		read(u,v);
		if u=1 then begin
			if ok[v]then begin
				writeln('POSSIBLE');
				exit;
			end;
			ok[v]:=True;
		end;
		if v=N then begin
			if ok[u]then begin
				writeln('POSSIBLE');
				exit;
			end;
			ok[u]:=True;
		end;
	end;
	writeln('IMPOSSIBLE');
end.


Measured memory_bytes: 256
// author-Shivam gupta

#include <bits/stdc++.h>


using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))

#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define IN(A, B, C) assert( B <= A && A <= C)

#define MP make_pair
#define FOR(i,a) for(int i=0;i<a;i++)

#define FOR1(i,j,a) for(int i=j;i<a;i++)

#define EB emplace_back

#define INF (int)1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007

#define read(type) readInt<type>()
#define max1 100001
#define out(x) cout<<x<<'\n'
#define out1(x) cout<<x<<" "
#define END cout<<'\n'
#define int long long
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}


signed main(){

int n;
cin>>n;
if(n<30){out("No");}
else{out("Yes");}
}


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

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

int main(void) {
    int n, ans = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n) {
        if (to_string(i + 1).length() % 2 != 0) {
            ans++;
        }
    }

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

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
int main(){
  int x;
  cin >> x;

  int t = sqrt(x);
  int max=1;
  if( x==1 ){ printf("1\n"); return 0; }
  for(int i=2; i<t+1; i++){
    int j=i;
    for(; j<x; j*=i){
      if( j > max ) max = j;
    }
    if( j==x ) max = j;
  }
  printf("%d\n", max);
  return 0;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int N, ans = 1;
    cin >> N;
    priority_queue<string> S;
    string s;
    for(int i = 0; i < N; ++i) {
        cin >> s;
        S.push(s);
    }
    string A = S.top();
    S.pop();
    while(!S.empty()){
        string B = S.top();
        if(A != B) ans++;
        A = B;
        S.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11564
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll a, b, c, d, k;
	cin >> a >> b >> c >> d >> k;
	ll e = a * 60 + b, f = c * 60 + d;

	co(f - e - k);

	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cctype>
//#include <stdio.h>
using namespace std;

string toUpper(string s){
	string t = s;
	for (int i = 0;i < t.size(); i++){
		t[i] = toupper(s[i]);
	}
	return t;
	
}

int main(){
	string W, T[20001];
	string s = "END_OF_TEXT";
	int num = 0;
	cin >> W;
	W = toUpper(W);
	
	for (int i = 0; i < 20000; i++){
		cin >> T[i];
		if (T[i] == s) break;
		T[i] = toUpper(T[i]);
		if (T[i] == W) num++;
		
	}

	cout << num << endl;
	return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

string s;

int main(){
	cin >> s;
	int ans = INF;
	for(int i=0;i<s.size()-2;i++){
		ans = min(ans, abs(753-s[i]*100-s[i+1]*10-s[i+2]+'0'*111));
	} 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256