akhauriyash/Code-Regression huggingface dataset:
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
std::map<int, int> cou[2];


int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < N; i++)
	{
		int a;
		in >> a;
		cou[i & 1][a]++;
	}

	std::vector<std::pair<int32_t, int32_t> > max[2];
	for (size_t i = 0; i < 2; i++)
	{
		for (auto& v : cou[i]) {
			max[i].emplace_back(v.second, v.first);
		}
	}
	max[0].emplace_back(0, -1);
	max[1].emplace_back(0, -1);
	std::sort(max[0].begin(), max[0].end(), std::greater<>{});
	std::sort(max[1].begin(), max[1].end(), std::greater<>{});

	if (max[0][0].second == max[1][0].second) {
		out << std::min(N - max[0][0].first - max[1][1].first, N -  max[0][1].first - max[1][0].first) << endl;
	}
	else {
		out << N - max[0][0].first - max[1][0].first << endl;
	}

	return 0;
}
#endif


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

struct data {
	int num,nominal;
}peep[1000001];

bool cmp(data a,data b) {
	return a.num<b.num;
}

int main() {
	int a;
	cin>>a;
	for(int i=0;i<a;i++) {
		cin>>peep[i].num;
		peep[i].nominal=i+1;
	}
	sort(peep,peep+a,cmp);
	for(int i=0;i<a;i++) {
		cout<<peep[i].nominal<<" ";
	}
	cout<<endl;
}

Measured memory_bytes: 1536
n,m,s,t = map(int, input().split())
uvab=[list(map(int,input().split())) for i in range(m)]

from heapq import heappush, heappop,heappushpop,heapify
def dks(g,start,num_v):
    INF=float('inf')
    visited = set()
    hq = []
    heappush(hq, (0,start))
    cost = [INF] * num_v
    while hq:
        shortest, i = heappop(hq)
        if i in visited:
            continue
        visited.add(i)
        cost[i] = shortest
        for j, t in g[i]:
            if j in visited:
                continue
            heappush(hq, (shortest + t, j))
    return cost

link_yen = [[] for _ in range(n)]
link_snk = [[] for _ in range(n)]
for u,v,a,b in uvab:
    link_yen[u-1].append([v-1,a])
    link_yen[v-1].append([u-1,a])
    link_snk[u-1].append([v-1,b])
    link_snk[v-1].append([u-1,b])

cost_yen = dks(link_yen,s-1,n)
cost_snk = dks(link_snk,t-1,n)

ans=[]
mn=float("inf")
for i in reversed(range(n)):
    new_cost = cost_yen[i] + cost_snk[i]
    mn=min(mn,new_cost)
    ans.append(mn)

for a in reversed(ans):
    print(10**15 - a)

Measured memory_bytes: 183840
import math
import sys
n = int(sys.stdin.readline())
ans = 0
for i in range(3, n + 1, 2):
    # print(f'{i=}', end=' ')
    count = 0
    for j in range(1, int(math.sqrt(i)) + 1):
        if i % j == 0:
            # print(f'{i} % {j} is 0.')
            count += 2
    if count == 8:
        # print(f'{i} have just 8 divisors.')
        ans += 1
print(ans)

Measured memory_bytes: 3060
n,m = map( int,input().split() )
a = [ list(map(int,input().split())) for _ in range(m)]

#n,m = 5,3
#a = [[3,6],[5,7],[6,9]]

L = a[0][0]
R = a[0][1]

for i in range(1,m):
  L = max(L,a[i][0])
  R = min(R,a[i][1])

R = min(R,n)
if R >= L :
  print(R-L+1)
else:
  print(0)

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

int main() {
  int n;
  cin >> n;
  int a[n], b[n-1];
  for(int i=0;i<(n-1);++i) cin >> b[i];
  a[0]=b[0];
  a[1]=b[0];
  for(int i=1;i<(n-1);++i){
    if(b[i]>=a[i]) a[i+1] = b[i];
    else {a[i+1]=b[i]; a[i]=b[i];}
  }
  cout << accumulate(a, a+(sizeof(a)/sizeof(a[0])), 0) << endl;
  return 0;
}

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

int main ()
{
    int N;
    cin >> N;
    int W[N];
    int sum=0;
    for (int i=0;i<N;i++)
    {
        cin >> W[i];
        sum+=W[i];
    }
    int presum=0,minsum=sum;
    for(int i=0;i<N;i++)
    {
        presum+=W[i];
        minsum=min(minsum,abs(presum-(sum-presum)));
    }
    cout << minsum;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int n,i,j,num[100],cnt=0,tmp,min;
  int minj;

  scanf("%d",&n);

  for(i=0;i<n;i++)scanf("%d",&num[i]);

  for(i=0;i<n;i++){
      minj =i;
    for(j=i;j<n;j++){
       
      if(num[minj] > num[j]){
	minj = j;
      }
    }
    if(minj != i){
	tmp =num[i];
      num[i]=num[minj];
      num[minj]= tmp;
      cnt++;
    }
  }
  
    
  for(i=0;i<n;i++){
    printf("%d",num[i]);
    if(i != n-1)printf(" ");
      }
  printf("\n%d\n",cnt);
  
  return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	int x,k;
	cin>>k>>x;
	int l=max(-1000000,x-k+1);
	int r=min( 1000000,x+k-1);
	for(int i=l;i<r;i++)
		cout<<i<<" ";
	cout<<r;
	return 0;
}

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

typedef vector<int> vi;

// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
class UnionFind {                                              // OOP style
private:
  vi p, rank, setSize;                       // remember: vi is vector<int>
  int numSets;
public:
  UnionFind(int N) {
    setSize.assign(N, 1); numSets = N; rank.assign(N, 0);
    p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
  int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
  bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  void unionSet(int i, int j) { 
    if (!isSameSet(i, j)) { numSets--; 
    int x = findSet(i), y = findSet(j);
    // rank is used to keep the tree short
    if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
    else                   { p[x] = y; setSize[y] += setSize[x];
                             if (rank[x] == rank[y]) rank[y]++; } } }
  int numDisjointSets() { return numSets; }
  int sizeOfSet(int i) { return setSize[findSet(i)]; }
};

int main() {
	int N,M; cin>>N>>M;
	UnionFind UF(N);
	for (int i=0; i<M; i++) {
		int X,Y,Z; cin>>X>>Y>>Z; X--; Y--;
		UF.unionSet(X,Y);
	}
	cout<<UF.numDisjointSets()<<"\n";
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <functional>
using namespace std;

template <typename T>
struct ReRooting
{
    using F = function<T(T, int)>;
    using F2 = function<T(T, T)>;
    static const int MAX_V = 200010;
    int V;
    vector<int> E[MAX_V];
    vector<T> dp[MAX_V];
    //f(v) = g(merge(f(dp_c1,c1), f(dp_c2,c2), ..., f(dp_ck,ck)) , v)
    F f, g;
    F2 merge;
    T mi; //identity of merge

    ReRooting(int V_, F f_, F2 merge_, T mi_, F g_ = [](T a, int b) { return a; })
        : V(V_), f(f_), merge(merge_), mi(mi_), g(g_) {}

    void add_E(int a, int b)
    {
        E[a].push_back(b);
        E[b].push_back(a);
    }

    T dfs1(int p, int v)
    {
        T res = mi;
        for (int i = 0; i < E[v].size(); ++i)
        {
            if (E[v][i] == p)
                continue;
            dp[v][i] = dfs1(v, E[v][i]);
            res = merge(res, f(dp[v][i], E[v][i]));
        }
        return g(res, v);
    }

    void dfs2(int p, int v, T add)
    {
        for (int i = 0; i < E[v].size(); ++i)
        {
            if (E[v][i] == p)
            {
                dp[v][i] = add;
                break;
            }
        }

        vector<T> pL(E[v].size() + 1), pR(E[v].size() + 1);
        pL[0] = mi;
        for (int i = 0; i < E[v].size(); ++i)
            pL[i + 1] = merge(pL[i], f(dp[v][i], E[v][i]));
        pR[E[v].size()] = mi;
        for (int i = E[v].size(); i > 0; --i)
            pR[i - 1] = merge(pR[i], f(dp[v][i - 1], E[v][i - 1]));

        for (int i = 0; i < E[v].size(); ++i)
        {
            if (E[v][i] == p)
                continue;
            T val = merge(pL[i], pR[i + 1]);
            dfs2(v, E[v][i], g(val, v));
        }
    }

    void calc(int root = 0)
    {
        for (int i = 0; i < V; ++i)
            dp[i].resize(E[i].size());
        dfs1(-1, root);
        dfs2(-1, root, mi);
    }

    T solve(int v)
    {
        T ans = mi;
        for (int i = 0; i < E[v].size(); ++i)
        {
            ans = merge(ans, f(dp[v][i], E[v][i]));
        }
        return g(ans, v);
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    auto f = [&](long long a, int v) {
        (void)v;
        return (a + 1) % m;
    };
    auto merge = [&](long long a, long long b) {
        return a * b % m;
    };
    ReRooting<long long> re(n, f, merge, 1);
    for (int i = 0; i < n - 1; ++i)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        re.add_E(x, y);
    }
    re.calc();
    for (int i = 0; i < n; ++i)
        cout << re.solve(i) << endl;
    return 0;
}


Measured memory_bytes: 38624
def LI():return list(map(int,input().split()))
def II():return int(input())
def yes():return print("Yes")
def no():return print("No")
INF=float("inf")
from collections import deque, defaultdict, Counter
from heapq import heappop, heappush
from itertools import product, combinations
from functools import reduce, lru_cache
from math import pi, gcd
from decimal import Decimal

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

class Unionfind:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])

        return self.p[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def count(self, x):
        return self.size[self.root(x)]


x=II()
if x==1:
    print(0)
else:
    print(1)



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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
  
  	bool flag = false;
  
  	while(!flag) {
    	if((a-1)*(ans-1) >= b-a) flag = true;
      	ans++;
    }
  
  	cout << ans-1 << endl;

    return 0;
}

Measured memory_bytes: 256
while True:
  H, W = map(int, input().split())
  if H == 0 and W == 0:
    break
  for j in range(H):
    for i in range(W):
      if (i+j)%2 == 0:
        print('#', end="")
      else:
        print('.', end="")
    print()
  print()


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

#define GOAL 2019

int main(void){
  int x[200]={0};
  int n,m;
  
  cin >> n;
  for (int i=0; i<n; i++){
    int t;
    cin >> t;
    x[i]=t;
  }
  cin >> m;
  for (int i=0; i<m; i++){
    int a;
    cin >> a; a--;
    if (x[a]!=GOAL && x[a+1]-x[a]!=1){
      x[a]++;
    }
  }
  for (int i=0; i<n; i++){
    cout << x[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
n, m, c = map(int, input().split())
bL = list(map(int, input().split()))
ans = 0
for i in range(n):
    aL = list(map(int, input().split()))
    sum_ab = 0
    for j in range(m):
        sum_ab += aL[j]*bL[j]
    if sum_ab > (-1)*c:
        ans += 1
print(ans)

Measured memory_bytes: 3064
N = int(input())
S = input()
ans=0

r=0
g=0
b=0

for i in range(N):
    if S[i]=="R":
        r+=1
    elif S[i]=="G":
        g+=1
    else:
        b+=1

ans=r*g*b

for j in range(1,N-1):
    for d in range(1,min(j,N-j-1)+1):
        if S[j-d]!= S[j] and S[j]!= S[j+d] and S[j-d]!= S[j+d]:
            ans-=1
print(ans)


Measured memory_bytes: 73620
N = int(input())
S = [input() for _ in range(N)]

alphabet = [chr(i) for i in range(97, 97 + 26)]
ans = ""

for a in alphabet:
    c_min = 50
    for i in range(N):
        c = S[i].count(a)
        c_min = min(c, c_min)
    ans += a * c_min

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset>
#include<unordered_map> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
#define fio ios_base::sync_with_stdio(false)
#define mod 1000000007
#define mod1 mod
#define mod2 1000000007
#define li long long int
#define ll li
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%lld",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 1000000000000000005
#define MINN -1000000000000000000
#define INTMAX 1000001000
#define pii pair<ll,ll> 
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 300005
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 3.1415926535
#define lgn 20 
using namespace std;
map<li,vector<li>>M;li n,m;li v[100005];
li DFS(li i){v[i]=0;li ans=1;
for(auto x:M[i]){if(v[x]==-1){ans=(ans*(DFS(x)+1))%m;}}
v[i]=ans;return(ans);}
void DFS2(li i,li j,li pans){
v[i]=(v[i]*(pans+1))%m;
vector<li>pre;li xx=1,c=0,cc=0,y;
for(auto x:M[i]){if(x!=j){pre.pb((v[x]+1)%m);c++;}}
vector<li>suf(c);
for(li i1=c-1;i1>=0;i1--){xx=(xx*pre[i1])%m;suf[i1]=xx;}
for(auto x:M[i]){if(x!=j){y=1;
if((cc-1)>=0){y=(y*pre[cc-1])%m;pre[cc]=(pre[cc]*pre[cc-1])%m;}
if((cc+1)<c) y=(y*suf[cc+1])%m;
DFS2(x,i,(y*(pans+1))%m);cc++;
}}
}
int main(){readl(n);li i,j,a,b;readl(m);
for(i=1;i<n;i++){readl(a);readl(b);M[a].pb(b);M[b].pb(a);v[i]=-1;}v[n]=-1;
DFS(1);DFS2(1,1,0);
for(i=1;i<=n;i++) printf("%lld\n",v[i]);
}

Measured memory_bytes: 28800
package main

import (
	"fmt"
)

func main() {
	var a,b,c int
	fmt.Scan(&a,&b,&c)
	
	if a + b == c || a + c == b || b + c == a {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

using namespace std;
int main() {
  ll N;
  cin>>N;
  ll count=0;
  while(N>1) {
    N/=2;
    count+=1;
  }
  ll S=0;
  repr(i,0,count) {
    S+=pow(2,i);
  }
  cout<<S<<endl;
}
  
  


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

int main(){
  string s;
  cin >> s;

  int z=0,o=0;
  for(int i=0;i<s.length();i++){
    if(s[i]=='0')z++;
    else if(s[i]=='1')o++;
  }
  cout << min(z,o)*2 << endl;
}

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

int main() {
int numberA = 0, numberB = 0;
int roundedUpAverage = 0;
double average = 0;

  
  cin >> numberA;
  cin >> numberB;
  average = (numberA + numberB) / 2.0;
  roundedUpAverage = average + 0.5;
  
  cout << roundedUpAverage << endl;
}

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

int cnt[256];
int main(void){
  char c;
  int f;
  while (scanf("%c",&c),c>='a'&&c<='z'){
    cnt[c-'a']++;
  }
  
  f = false;
  for (int i=0; i<26; i++){
    if (cnt[i]==0 && !f){
      printf("%c\n",i+'a');
      f = true;
    }
  }
  if (!f) puts("None");
  return 0;
}

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

#define N 100000*2
#define INF 1LL << 60

long long n, X;
long long sum[N+1];

int main()
{
	cin >> n >> X;
	for( long long i = 0; i < n; i++ ) {
		long long x;
		cin >> x;
		sum[i + 1] = sum[i] + x;
	}

	long long ans = INF;
	for( long long k = 1; k <= n; k++ ) {
		long long i = n;
		long long res = (n + k) * X + sum[i] * 5;
		i -= k * 2;
		while( i > 0 ) {
			res += sum[i] * 2;
			i -= k;
			if( res < 0 ) {	// avoid overflow
				res = INF;
				break;
			}
		}
		ans = min( ans, res );
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
    int n, i, x;
    cin >> n;
    i = 3;
    while (i <= n) {
        if (i % 3 == 0) {
            cout << " " << i;
        } else {
            x = i;
            while (x) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
        i++;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define ll  unsigned long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 1000030;
bool isPrime[MAXN];
vector<ll> ans;
void sieve()
{
    memset(isPrime, 1, sizeof isPrime);
    isPrime[0] = isPrime[1] = 0;

    for (int i = 2; i * i <= MAXN; i += 1 + (i & 1))
    {
        if (isPrime[i])
        {

            for (int j = i * i; j < MAXN; j += i)
                isPrime[j] = 0;
        }
    }
    for(int i=0; i<MAXN; i++)
    {
        if(isPrime[i])
        {

            ans.push_back(i);
        }
    }
}

int main()
{
    FAST
    ll n;
    cin>>n;
    ll temp=n;
    ll cnt=0;

    for(ll j=2; j*j<=temp; j++)
    {
        if(temp%j==0)
        {
            ll c=0;
            while(temp % j == 0)
            {
                c++;
                temp /= j;
            }
            ll sum=0;
            for(int i=1;; i++)
            {
                sum+=i;
                if(sum>c)
                {
                    cnt+=(i-1);
                    break;
                }
            }

        }
    }
    if(temp>1)
        cnt++;

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

int abs(int A){return A>0?A:-A;}

int main(){
  int N;
  int x,y,h,tmp;
  int H[101][101]; // -2:no-answer -1:no-processed 0:earth(no-answer) >0:candidate
  
  scanf("%d",&N);

  for(int X=0;X<=100;X++)
    for(int Y=0;Y<=100;Y++)
      H[X][Y]=-1;
  
  for(int i=0;i<N;i++){
    scanf("%d %d %d",&x,&y,&h);
    if(h==0)
      H[x][y]=0;
    else
      for(int X=0;X<=100;X++)
	for(int Y=0;Y<=100;Y++){
	  tmp = h+abs(X-x)+abs(Y-y);
	  if(H[X][Y]==-1)
	    H[X][Y]=tmp;
	  else if(H[X][Y]>0)
	    if(H[X][Y]!=tmp)
	      H[X][Y]=-2;
	}
  }

  for(int X=0;X<=100;X++)
    for(int Y=0;Y<=100;Y++)
      if(H[X][Y]==0)
	for(int Xx=0;Xx<=100;Xx++)
	  for(int Yy=0;Yy<=100;Yy++)
	    if(H[Xx][Yy]>0)
	      if(H[Xx][Yy]-abs(Xx-X)-abs(Yy-Y)>0)
		H[Xx][Yy]=-2;

  for(int X=0;X<=100;X++)
    for(int Y=0;Y<=100;Y++)
      if(H[X][Y]>0)
	printf("%d %d %d\n",X,Y,H[X][Y]);

  
  return 0;
}


Measured memory_bytes: 256
import sys
lines = sys.stdin.readlines()
N,X = map(int, lines.pop(0).split())
doughnuts = sorted(list(map(int, lines)))
count = N
X -= sum(doughnuts)
for doughnut in doughnuts:
    q,mod = divmod(X,doughnut)
    if q == 0:
        break
    else:
        count += q
        X = mod
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

    vector<pll> ans;
    if(N % 2 == 1) {
        for(ll i = 1; i <= N; i++) {
            for(ll j = i+1; j <= N; j++) {
                if(i + j == N) continue;
                ans.emplace_back(i, j);
            }
        }
    }
    else {
        for(ll i = 1; i <= N; i++) {
            for(ll j = i+1; j <= N; j++) {
                if(i + j == N+1) continue;
                ans.emplace_back(i, j);
            }
        }
    }

    cout << ans.size() << endl;
    for(auto p : ans) cout << p.first << " " << p.second << endl;
}


Measured memory_bytes: 512
import sys

def main():
  input = sys.stdin.readline
  A, B, C, X, Y = map(int, input().split())
  n = max(X, Y)
  ans = float('INF')
  for i in range(max(X, Y)+1):
    cur = C * 2 * i + max(0, X - i) * A + max(0, Y - i) * B
    ans = min(ans, cur)
  print(ans)


if __name__ == '__main__':
  main()

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

int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans;
    if (a >= k){
        ans = k;
    }else if(a+b>=k){
        ans = a;
    }else{
        ans = 2*a + b - k;
    }
    cout << ans << endl;
}

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

int main(int argc, char** argv) {
    int size;
    scanf("%d\n", &size);
    if(size < 1 || size > 100)
        return (EXIT_FAILURE);
    int array[size];
    
    for(int i = 0; i < size; i++){
        scanf("%d", &array[i]);
    }
    
    int count = 0;
    int temp;
    for(int i = 0; i < size; i++){
        for(int j = size - 1; j > i; j--){
            if(array[j] < array[j - 1]){
                temp = array[j];
                array[j] = array[j-1];
                array[j-1] = temp;
                count++;
            }
        }
    }
    for(int i = 0; i < size; i++){
        if(i == size - 1)
            printf("%d\n",array[i]);
        else
            printf("%d ", array[i]);
    }
    printf("%d\n",count);
    return (EXIT_SUCCESS);
}




Measured memory_bytes: 2124
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

#define MAXN 1000005

int a[MAXN];

void judgePrime()
{
    int m=sqrt(MAXN);
    memset(a,0,sizeof(a));
    for(int i=2; i<=m; i++)
    {
        if(!a[i])
        {
            for(int j=i*i; j<MAXN; j+=i)
                a[j]=1;
        }
    }
}

int main()
{
    judgePrime();
    int n;
    while(~scanf("%d",&n))
    {
        int cnt=0;
        for(int i=2; i<=n; i++)
        {
            if(!a[i])
                cnt++;
        }
        printf("%d\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 6992
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>


using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}

int main()
{
  ios::sync_with_stdio(false);
  string s;
  int x,y;
  cin>>s>>x>>y;
  vector<int> a,b;
  bool f=1;
  int tmp=0;
  int suma=0,sumb=0;
  for(auto itr=s.begin();itr !=s.end();itr++)
  {
    if(*itr=='F'){tmp++;}
    else {
      if(f){a.push_back(tmp);suma+=tmp;}
      else{b.push_back(tmp);sumb+=tmp;}
      f=!f;
    tmp=0;
  }

  }
  if(f){a.push_back(tmp);suma+=tmp;}
  else{b.push_back(tmp);sumb+=tmp;}
  x-=a[0];
  suma-=a[0];
  x=abs(x);
  y=abs(y);
  a.erase(a.begin());
  int flag=0;
  if((suma-x)%2 or (sumb-y)%2 or suma<x or sumb<y){flag=0;}
  else
  {
    x=(suma-x)/2;
    y=(sumb-y)/2;
    vector<int> dpx(x+1),dpy(y+1);
    dpx[0]=1;
    dpy[0]=1;
    for(auto itr1=a.begin();itr1 !=a.end();itr1++)
    {
      for(int i=x-*itr1;i>-1;i--)
      {
        if(dpx[i]==1){dpx[i+*itr1]=1;}
      }
      if(dpx[x]!=0){flag+=1;break;}

    }
    if(a.size()==0 and x==0){flag+=1;}
    for(auto itr2=b.begin();itr2 !=b.end();itr2++)
    {
      for(int i=y-*itr2;i>-1;i--)
      {
        if(dpy[i]==1){dpy[i+*itr2]=1;}
      }
      if(dpy[y]!=0){flag+=1;break;}
    }
    if(b.size()==0 and y==0){flag+=1;}
  }
  cout<<yn(flag>=2)<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
char col[10][10];
int main(){
    ll h,w,k;   
    boost;
    cin>>h>>w>>k;
    
  	for(ll i=0;i<h;i++){
  		for(ll j=0;j<w;j++){
  			cin>>col[i][j];
		  }
	}
	ll ans=0;
	for(ll i=0;i<(1ll<<h);i++){
		for(ll j=0;j<(1ll<<w);j++){
			ll s=0;
			for(ll r=0;r<h;r++){
				for(ll c=0;c<w;c++){
					if((i&(1ll<<r))==0 && (j&(1ll<<c))==0 &&  col[r][c]=='#')s++;
				}
			}
			if(s==k)ans++;
			
		}
	}
	cout<<ans;
    	
		
		
    
			
}

Measured memory_bytes: 3648
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

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

    ll c = m;
    ll ans = 1;
    while (n > 0) {
        if (n & 1) ans *= c, ans %= MOD;
        n >>= 1;
        c *= c, c %= MOD;
    }

    print(ans);
}


Measured memory_bytes: 3224
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define RANGE(i, x, n) for(int i = x; i < n; ++i)

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
}

Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from heapq import heappop, heappush

def build():
    for i in range(N - 1, 0, -1):
        cl, cr = i << 1, i << 1 | 1
        E[i].append((cl, 0))
        E[i].append((cr, 0))
        E[ref(cl + N2)].append((ref(i + N2), 0))
        E[ref(cr + N2)].append((ref(i + N2), 0))

def add_range_edge(l0, r0, l1, r1, w):
    E.append([])
    v = len(E) - 1
    _add_range_edge(l0 + N, r0 + N, v, w, to = True)
    _add_range_edge(l1 + N, r1 + N, v, 0, to = False)

def _add_range_edge(l, r, v, w, to):
    while l < r:
        if l & 1:
            E[ref(l + N2)].append((v, w)) if to else E[v].append((l, w))
            l += 1
        if r & 1:
            r -= 1
            E[ref(r + N2)].append((v, w)) if to else E[v].append((r, w))
        l >>= 1
        r >>= 1

def resolve():
    global N, N2, E, ref
    n, m = map(int, input().split())
    N = 1 << (n - 1).bit_length()
    N2, N3 = N * 2, N * 3
    E = [[] for _ in range(N3)]
    ref = lambda v : v if v < 3 * N else v - N2

    build()
    for _ in range(m):
        u, v, w = map(int, input().split())
        u -= 1
        add_range_edge(u, v, u, v, w)

    # Dijkstra (start : N, terminal : N + n - 1)
    dist = [INF] * (N3 + m)
    dist[N] = 0
    heap = [(0, N)]
    while heap:
        d, v = heappop(heap)
        if dist[v] != d:
            continue
        for nv, w in E[v]:
            if dist[nv] > d + w:
                dist[nv] = d + w
                heappush(heap, (d + w, nv))

    ans = dist[N + n - 1]
    if ans == INF:
        ans = -1
    print(ans)
resolve()

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

#define MOD 1000000007
#define INF 1000000000000

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


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}

vector<vector<int>> G;
vector<int> dp;

int rec(int v) {
    if (dp[v] >= 0) return dp[v];
    int ret = 0;
    for (int u : G[v]) {
        ret = max(ret, rec(u) + 1);
    }
    return dp[v] = ret;
}

int main(int argc, char const *argv[]) {
    int N, M;
    cin >> N >> M;

    G.resize(N);
    for (int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        x -= 1; y -= 1;
        G[x].push_back(y);
    }
    // print(G);

    dp.resize(N, -1);
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        ans = max(ans, rec(i));
    }
    // print(dp);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8192
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		int N = keyboard.nextInt();
		long[] A = new long[N];
		long sum = 0;
		
		for(int i=0; i<N; i++) {
			A[i] = keyboard.nextLong();
			sum = sum+A[i]-1;
		}
		
		System.out.println(sum);
		keyboard.close();
	}
}

Measured memory_bytes: 40592
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
vector<pair<int,int> >A;
long dp[5050];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int h,p;cin>>h>>p;
		A.push_back(make_pair(h,p));
		dp[i+1]=9e18;
	}
	sort(A.begin(),A.end(),[](pair<int,int>x,pair<int,int>y){return x.first+x.second<y.first+y.second;});
	for(int i=0;i<N;i++)
	{
		for(int j=N;j>=0;j--)
		{
			if(dp[j]<=A[i].first)
			{
				dp[j+1]=min(dp[j+1],dp[j]+A[i].second);
			}
		}
	}
	int ans=0;
	while(ans+1<=N&&dp[ans+1]<9e18)ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let t: f64 = read();
    let a: f64 = read();
    let mut cnt = std::f64::MAX;
    let mut ans = 0;
    for i in 1..=n {
        let tmp = (a - (t - read::<f64>() * 0.006)).abs();
        if tmp < cnt {
            cnt = tmp;
            ans = i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2144
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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


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

	double ans = l/3.0;
	cout << fixed << setprecision(12) << pow(ans, 3) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
    char input[200];
    int i,num;
    
    for(i=1; true ;i++){
    scanf("%c",&input[i]);
    if(input[i]=='\0'){
        num=i;
      break;
    }
    }    
    
    for(i=1;i<num - 1;i=i+2){
        if(input[i]=='L'){
            printf("No");
            return 0;
        }
    }
    for(i=2;i<num - 1;i=i+2){
        
     if(input[i]=='R'){
            printf("No");
            return 0;
    
        }
    } 
        printf("Yes");
 
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(true){
        c = c -b;
    
        if(c<=0){
            cout<<"Yes"<<endl;
            break;
        }
        a = a -d;
    
        if(a<=0){
            cout<<"No"<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
#define min(a, b) ((a) < (b) ? (a) : (b))

int
main(int argc, char *argv[])
{
  int n, k, x[100]; int ans = 0;
  scanf("%d%d", &n, &k);
  for(int i = 0; i < n; i++){
    scanf("%d", &x[i]);
    ans += 2 * min(x[i], k - x[i]);
  }
  
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
int main(){
    int a, b, c, k, ans = 0;
    scanf("%d%d%d%d", &a, &b, &c, &k);
    if(k >= a) ans += a, k -= a;
    else ans += k, k = 0;
    if(k >= b) k -= b;
    else k = 0;
    if(k >= c) ans -= c, k -= c;
    else ans -= k, k = 0;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define INF 0x3f3f3f3f
using namespace std;
typedef pair<double, int>P;

int x[200], y[200];
int pre[200];
double d[200];

int main() {
	int n;
	while (scanf("%d", &n), n) {
		rep(i, n) {
			int b, xi, yi; scanf("%d%d%d", &b, &xi, &yi); b--;
			x[b] = xi; y[b] = yi;
		}
		vector<P>E[200];
		rep(i, n)for (int j = i + 1; j < n; j++) {
			double f = sqrt((double)(abs(x[i] - x[j])*abs(x[i] - x[j]) + abs(y[i] - y[j])*abs(y[i] - y[j])));
			if (f <= 50.) {
				E[i].push_back(P(f, j));
				E[j].push_back(P(f, i));
			}
		}
		int m; scanf("%d", &m);
		rep(k, m) {
			int s, g; scanf("%d%d", &s, &g); s--; g--;
			fill(d, d + n, INF);
			memset(pre, -1, sizeof(pre));
			priority_queue<P, vector<P>, greater<P>>que;
			d[s] = 0;
			que.push(P(0, s));
			while (!que.empty()) {
				P p = que.top(); que.pop();
				if (d[p.second] != p.first)continue;
				if (p.second == g)break;
				for (P u : E[p.second]) {
					if (d[u.second] > p.first + u.first) {
						d[u.second] = p.first + u.first;
						pre[u.second] = p.second;
						que.push(P(d[u.second], u.second));
					}
				}
			}
			if (d[g] == INF)puts("NA");
			else {
				vector<int>v;
				for (int u = g; ~u; v.push_back(u), u = pre[u]);
				for (int i = v.size() - 1; i >= 0; i--) {
					printf("%d", v[i] + 1);
					if (i)printf(" ");
					else printf("\n");
				}
			}
		}
	}
}

Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
//set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<ll> deq;
//vector<ll> vll;
ll num[ten52];
//priority_queue<ll> pq;          //decreasing

int main(void)
{
    ll m,n,i,j,k=0,d,pre=0,now;
    string s,s1,s2;
    cin>>k>>n;
    for(i=0;i<=k;i++)
    {
        for(j=0;j<=k;j++)
        {
            d=n-i-j;
            if(d>=0 && d<=k)
                pre++;
        }
    }
    cout<<pre;
}


Measured memory_bytes: 3596
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		List<Integer> flight = new ArrayList<>();
		for(int i=0;i<3;i++) {
			flight.add(sc.nextInt());
		}
		Collections.sort(flight);
		System.out.println(flight.get(0) + flight.get(1));
	}
}


Measured memory_bytes: 22100
#include <stdio.h>
#include <iostream>
#include <string>
#include <cmath>
#include <string.h>
using namespace std;
int a[100005];
int main(){
	int n,sum;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sum+=abs(a[1]);
	sum+=abs(a[n]);
	for(int i=1;i<n;i++){
		sum+=abs(a[i+1]-a[i]);
	}
	for(int i=1;i<=n;i++){
		if(i==1) {
			cout<<sum-abs(a[1])-abs(a[2]-a[1])+abs(a[2]) << endl;
		}
		else if(i==n){
			cout << sum-abs(a[n])-abs(a[n]-a[n-1])+abs(a[n-1]) << endl;
		}
		else cout<<sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1])<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
signed main() {
  string s,t;
  long long cun = 0;
  cin >> s >> t;
  for (int i = 0; i < s.size(); i++){
    if (s[i] != t[i]) {
      cun++;
    }
  }
  cout << cun <<"\n";
  return 0;
}

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


int tran(int num){
	char s[15];
	int id = 0;
	while(num >= 10){
		s[id++] = num % 10;
		num /= 10;
	}
	s[id++] = num;
	for(int i = 0;i < id / 2;i++){
		if(s[i] != s[id - 1 - i])  return 0;
	}
	return 1;
}
int main(){
	int a,b,c;
	cin >> a >> b;
	int ans = 0;
	for(int i = a;i <= b;i++){
		ans += tran(i);
	}
	cout << ans;
	return 0;
} 

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

using namespace std;
const int MOD=2019;
#define ll long long

int main()
{
   int n;
   cin>>n;
   ll ans=0;
   for (int i=1;i<=n;i++)
    if (i%3!=0 && i%5!=0)
    ans+=i;
   cout<<ans;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n;
  cin >> n;
  vector<int> buka(n);
  REP(i, n-1) {
    int a;
    cin >> a;
    buka.at(a - 1)++;
  }
  REP(i, n) { cout << buka.at(i) << "\n"; }
  return 0;
}


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

using namespace std;

int main()
{
    int n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sum+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<sum<<endl;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF LONG_MAX/3

struct edge {ll u, c;};

vector<edge> v[100000];
ll d[100000];
bool visited[100000];

int main(){
    cin.sync_with_stdio(false);
    ll n, m, mini;
    cin >> n >> m;

    mini = n;
    rep(i, m) {
        ll l, r, c;
        cin >> l >> r >> c;
        l--, r--;
        edge e1{r, c}, e2{l, -c};
        v[l].pb(e1);
        v[r].pb(e2);
        minch(mini, l);
    }

    rep(i, n) d[i] = INF;
    d[mini] = 0;

    bool ok = true;
    while (true) {
        queue<ll> q;
        q.push(mini);
        while(q.size()) {
            int p = q.front(); q.pop();
            if (visited[p]) continue;
            visited[p] = true;
            rep(i, v[p].size()) {
                int u = v[p][i].u, c = v[p][i].c;
                if (!visited[u] && d[u] == INF) {
                    d[u] = d[p] + c;
                    q.push(u);
                } else if (visited[u] && d[u] != d[p] + c) {
                    ok = false;
                }
            }
        }

        mini = -1;
        rep(i, n) if (!visited[i] && v[i].size() > 0) mini = i;
        if (mini == -1) break;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 14208
// skyrim belongs to the nords
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back 
#define sz(a) ((int)(a).size())
#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define dec(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end() 
#define LOGN 18
#define EPS 1e-8
#define fcin ios_base::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;


int main(){
	fcin;
	cin.tie(0);

	int N, ans;
	cin >> N;

	for (int i = 0; (1 << i) <= N; i++ ) {
		ans = 1 << i;
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#define LL long long
#define eps 1e-6
int main(){
	LL a,b,c;
	double d;
	scanf("%lld%lf",&a,&d);
	d+=eps;
	b=d*100;
	c=a*b/100;
	printf("%lld\n",c);
}

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

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

int main() {
    lli l, r;
    cin >> l >>r;
    if ((r / 2019) != (l / 2019)) {
        cout << 0 << endl;
    }
    else {
        lli l1 = l % 2019;
        lli r1 = r % 2019;
        lli ans = LLONG_MAX;
        REP(i, l1, r1) {
            REPE(j, i+1, r1) {
                ans = min(ans, (i * j) % 2019);
                //cout << ans << endl;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
 
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
const int SIZE = 31;
const int INF = 1<<27;
 
int G[SIZE][SIZE], C[4];
int H, W;
 
struct State {
public:
  int x, y, d, cost;
  State() {}
  State(int x, int y, int d, int cost) : x(x), y(y), d(d), cost(cost) {}
  bool operator<(const State &s) const {
    return cost>s.cost;
  }
};
 
int solve() {
  int cost[4][SIZE][SIZE];
  priority_queue<State> pq;
  pq.push(State(0,0,0,0));
  fill(cost[0][0], cost[4][0], INF);
  cost[0][0][0] = 0;
  while(!pq.empty()) {
    const State s = pq.top(); pq.pop();
    if(cost[s.d][s.y][s.x] < s.cost) continue;
    if(s.x == W-1 && s.y == H-1) return s.cost;
    for(int i=0; i<4; i++) {
      State t = s;
      t.cost += ( G[s.y][s.x] == i ? 0 : C[i] );
      t.d = (s.d + i) % 4;
      t.x += dx[t.d], t.y += dy[t.d];
      if(0 <= t.x && t.x < W 
     && 0 <= t.y && t.y < H 
     && cost[t.d][t.y][t.x] > t.cost) {
    pq.push(t);
    cost[t.d][t.y][t.x] = t.cost;
      }
    }
  }
   
  return INF;
}
 
int main() {
  while(cin >> W >> H, W+H) {
    for(int i=0; i<H; i++)
      for(int j=0; j<W; j++)
    cin >> G[i][j];
     
    for(int i=0; i<4; i++) cin >> C[i];
     
    cout << solve() << endl;
  }
   
  return 0;
}

Measured memory_bytes: 1328