akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
from functools import reduce
from operator import mul

MOD = 998244353  # type: int

class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def solve(N: int, M: int, K: int):
    SUM = ModInt(0)
    n_1Ck = [ModInt(1) for k in range(K + 1)]
    for i in range(1, K + 1):
        n_1Ck[i] = n_1Ck[i-1] * (N-i) / i
    for k in range(0, K + 1):
        SUM += M * n_1Ck[k] * (pow(M - 1, N - 1 - k, MOD))
    print(SUM)
    return


# Generated by 1.1.6 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()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, M, K)

if __name__ == '__main__':
    main()


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

int main(){
 ll n,m,x[100001]={},y[100001]={}; 
 cin>>n>>m;

 for(int i=0;i<n;i++)cin>>x[i];
 for(int i=0;i<m;i++)cin>>y[i];

ll X=0,Y=0;
 for(int i=0;i<n-1;i++)
  X=(X+((x[i+1]-x[i])*((i+1)*(n-i-1))%D)%D)%D;

 for(int i=0;i<m-1;i++)
  Y=(Y+((y[i+1]-y[i])*((i+1)*(m-i-1))%D)%D)%D;

 cout<<(X*Y)%D<<endl;
 return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
	int n;
	int now=0;
	cin>>n;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		if(a == now+1){
			now++;
		}
	}
	if(now == 0){
		cout<<-1;
	} 
	else{
		cout<<n-now;
	}
	return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

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

    double x1, y1, x2, y2, ans;
    cin >> x1 >> y1 >> x2 >> y2;

    ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 3280
using System;
using System.Text;

class Program
{
    static void Main()
    {
        int i = 1;
        string x;
        StringBuilder sb = new StringBuilder();
        while ((x = Console.ReadLine()) != "0") 
        {
            sb.AppendLine($"Case {i++}: {x}");
        }
        Console.Write(sb);
    }
}


Measured memory_bytes: 13888
#include <stdio.h>
#include <string.h>

int main(){
  int i, count = 0;
  char w[10], t[1000], e[20] = "END_OF_TEXT";
  char *p, *q, *r;
  p = &e[0];
  q = &w[0];
  r = &t[0];
  scanf("%s", &w[0]);
  for(i = 0; i < 10; i++) {
    if('a' <= w[i] && w[i] <= 'z') {
      w[i] -= ' ';
    }
  }
  while(1) {
    scanf("%s", &t);
    if(strcmp(p, r) == 0) {
      break;
    }
    for(i = 0; i < 1000; i++) {
      if('a' <= t[i] && t[i] <= 'z') {
        t[i] -= ' ';
      }
    }
    if (strcmp(q, r) == 0) {
      count++;
    }
    for(i = 0; i < 1000; i++) {
      t[i] = '0';
    }
  }
  printf("%d\n", count);
  return 0;
}



Measured memory_bytes: 2100
#include <iostream>

int price;

bool dfs(int price, int num) {
    if (num > price) {
        return false;
    }
    if (num == price) {
        return true;
    }
    bool res = dfs(price, num+4);
    bool res2 = dfs(price, num+7);
    if (res || res2) {
        return true;
    }
    else {
        return false;
    }
}

int main() {
    std::cin >> price;
    bool b1, b2;
    b1 = dfs(price, 0);
    std::cout << ((b1) ? "Yes" : "No") << std::endl;

}


Measured memory_bytes: 256
#include <stdio.h>

long long saiki(long long n) {
  if(n == 1) {
    return 1;
  } else if(n <= 3) {
    return 3;
  } else {
    return 2 * saiki(n / 2) + 1;
  }
}

int main(void) {

  long h;
  scanf("%ld", &h);
  printf("%lld\n", saiki(h));
  
  return 0;
}


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

int main() {
    vector<int>x(3);
    for (int i = 0; i < 3; ++i) {
      cin >> x[i];
    }
    sort(x.begin(), x.end());
    int ans = x[0] + x[1];
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
typedef pair<int, int> P;

void solve()
{
	int w, n;
	cin >> w >> n;
	vector<P> vec(n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d,%d", &vec[i].first, &vec[i].second);
	}
	vector<int> pos(w);
	for(int i = 0; i < w; ++i)
	{
		int ans = i + 1;
		for(int j = 0; j < n; ++j)
		{
			if(vec[j].first == ans)
			{
				ans = vec[j].second;
			}
			else if(vec[j].second == ans)
			{
				ans = vec[j].first;
			}
		}
		pos[ans - 1] = i + 1;
	}
	for(int i = 0; i < w; ++i)
	{
		cout << pos[i] << endl;
	}
}

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

Measured memory_bytes: 1240
from copy import deepcopy

s = input()
ans = len(s)-1
for i in range(26):
    tc = chr(ord("a")+i)
    tv = 0
    ts = deepcopy(s)
    for j in range(len(s)):
        if ts.count(tc) == len(ts):
            ans = min(ans, tv)
            break
        nxt = ""
        for k in range(len(ts)-1):
            if ts[k] == tc or ts[k+1] == tc:
                nxt += tc
            else:
                nxt += ts[k]
        tv += 1
        ts = deepcopy(nxt)
print(ans)


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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  vector<int> A;
  if(S[0] == '0') A.push_back(0);
  int cnt = 1;
  S.push_back('2');
  rep(i, 1, N + 1) {
    if(S[i] == S[i-1]) cnt++;
    else {
      A.push_back(cnt);
      cnt = 1;
    }
  }
  rep(i, 0, 3) A.push_back(0);
  vector<int> sum(A.size() + 1);
  rep(i, 0, A.size()) sum[i+1] = sum[i] + A[i];
  int R = 2 * K + 1;
  int ans = 0;
  if(R >= A.size()) ans = N;
  else {
    rep(i, 0, sum.size() - R) {
      if(i%2) continue;
      ans = max(ans, sum[i+R] - sum[i]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1272
import math
import numpy as np
import sys
import os
from operator import mul
from operator import itemgetter

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N,M = LI()
H = LI()
AB = [LI() for _ in range(M)]

p = []
d = {}
for i in range(N):
    # p.append((i,H[i]))
    d[i]=H[i]
# p.sort(key=itemgetter(1),reverse=True)
# print(p)
# print(d)

# g = np.zeros(shape=(N,N),dtype='int')
g = [set()] * N
a = [True] * N

for i in range(M):
    f = AB[i][0]-1
    t = AB[i][1]-1
    if d[t]>d[f]:
        a[f]=False
    elif d[f]>d[t]:
        a[t]=False
    else:
        a[f]=False
        a[t]=False
# print(a)
print(sum(a))  
    # print(g[f])
    # g[f] = np.append(g[f],t)
    # g[t] = np.append(g[t],f)
   
    # g[f][t]=1
    # g[t][f]=1

# print(g)
# list.sort(key=itemgetter(0))

# for i in range(N):


# a = np.where(g[0]==1)
# print(a)

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    int w = 0, r = 0;
    rep(i,n){
        if(s[i] == 'W'){
            w++;
        }else if(s[i] == 'R'){
            r++;
        }
    }
    if(w == 0 || r == 0){
        cout << 0 << endl;
        return 0;
    }
    rep(i,r){
        if(s[i] == 'W'){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3752
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d",&A);
    scanf("%d",&B);
    if(A==1)
    {
        if(B==2)
        {
            printf("3\n");
        }
        else
        {
            printf("2\n");
        }
    }
    if(A==2)
    {
        if(B==1)
        {
            printf("3\n");
        }
        else
        {
            printf("1\n");
        }
    }
    if(A==3)
    {
        if(B==1)
        {
            printf("2\n");
        }
        else
        {
            printf("1\n");
        }
    }

    return 0;

}


Measured memory_bytes: 128
(function main() {
  let line = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('');
  let height_list = [0];
  let current_height = 0;

  // 初めの上昇と平坦を除去
  while (line.length > 0 && line[0] !== '\\') line.shift();
  // 終わりの下降と平坦を除去
  while (line.length > 0 && line[line.length - 1] !== '/') line.pop();

  line.forEach(function(e, i){
      if (e === '\\') current_height -= 1
      else if (e === '_') current_height += 0
      else current_height += 1
      height_list.push(current_height);
  });

  let sum = 0;
  let holes = [];
  for (;height_list.length > 1;) {
    let h = makeHole(height_list);
    if (h > 0) {
      sum += h;
      holes.push(h);
    }
  }

  console.log(sum);
  console.log(holes.length && holes.length + ' ' + holes.join(' '));
})();

function makeHole(list) {
    begin = list.shift();
    if (list[0] < begin && begin <= list.reduce((a, b) => Math.max(a, b), -100000)) {
    let area = 0;
      while (!(list.length === 0 || begin <= list[0])) {
        area += begin - list.shift();
      }
      return area;
    }
    return 0;
}



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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

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

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

struct Plain {
    ll arrival, leave;
};


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

    ll c, k;
    cin >> c >> k;
    vector<Plain> tmp;

    rep(i, n) {
        ll t;
        cin >> t;
        Plain plain{t, t + k};
        tmp.push_back(plain);
    }
    sort(tmp.begin(), tmp.end(), [](Plain p, Plain q) { return p.arrival < q.arrival; });

    queue<Plain> plains;
    for (Plain p : tmp) plains.push(p);

    ll ans = 0;
    while (!plains.empty()) {
        ll last = plains.front().leave;
        ll passengers = 0;
        while (!plains.empty() && plains.front().arrival <= last && passengers < c) {
            plains.pop();
            passengers++;
        }
        ans++;
    }
    cout << ans << endl;

}




Measured memory_bytes: 3440
#include <stdio.h>
#include <math.h>
#define swap(a,b) a^=b^=a^=b //二変数を入れ替え//

int main(void) {
	// your code goes here
	int a,b,c,d,i,j,k,x,y,z;
	scanf("%d %d %d",&a,&b,&c);
	scanf("%d",&k);
	if(a>b) swap(a,b);
	if(b>c) swap(b,c);
	d=a+b+c*pow(2,k);
	printf("%d\n",d);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define upb upper_bound
#define lwb lower_bound
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y){
    if(y<=0) return 1;
    ll ans = 1;
    x %= mod;
    while(y){
        if(y&1)
            ans = (x * ans) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = (a - b); if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = (a + b); if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

//const ll N = 2e5 + 1;
//vector<ll> adj[N];
//bool visited[N];


map<ll, ll> prm(ll n){
	map<ll, ll> op;
	if(n%2==0){
		op[2]++;
		while (n % 2 == 0)
		{
	        n = n/2;
	    }
	}

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
    	if(n%i==0){
    		op[i]++;
	        while (n % i == 0)
	        {
	            n = n/i;
	        }
	    }
    }

    if (n > 2)
        op[n]++;

	return op;
}

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

	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
//		a[i] = prm(a[i]);
	}
	ll g = a[0];
	for(int i=1;i<n;i++){
		g = __gcd(g, a[i]);
	}
	int flag=0;

	map<ll, ll> pref;
	map<ll, ll> op;
	for(int i=n-2;i>=0;i--){
		
		ll b = a[i+1];
		op = prm(b);
		for(auto it : op){
			if(pref[it.fi]) flag=1;
			pref[it.fi]++;
		}
		if(flag) break;
	}

	if(flag==0){
		cout<<"pairwise coprime";
	}
	else if(g==1){
		cout<<"setwise coprime";
	}
	else {
		cout<<"not coprime";
	}


    return 0;
}


Measured memory_bytes: 11508
N = int(input())
sum15 = 0
sum3 = 0
sum5 = 0
"""
a = []
for i in range(1,N+1):
    if i%15==0:
        pass
        #a.append("FizzBuzz")
    elif i%5==0:
        pass
        #a.append("Buzz")
    elif i%3==0:
        pass
        #a.append("Fizz")
    else:
        #a.append(i)
        sum += i
"""
sumA = int(N*(N+1)/2)

for i in range(3,N+1,3):
    #print(i)
    sum3 += i

for i in range(5,N+1,5):
    #print(i)
    sum5 += i

for i in range(15,N+1,15):
    #print(i)
    sum15 += i

suma = int(sumA - sum3 - sum5 + sum15)
print(suma)

Measured memory_bytes: 9200
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<list>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<limits>
#include<cctype>
#include<fstream>
#include<unordered_map>
#include<complex>
#pragma warning(disable:4996)
using namespace std;

#define debug(i) cout<<"<debug> "<<#i<<" "<<i<<" <\\debug>"<<endl
#define mfor(i,a,b) for(int i=(a);i<=(b);i++)
#define mrep(i,a,b) for(int i=(a);i>=(b);i--)
#define lll __int128
#define Re register
#define mem(a,b) memset(a,(b),sizeof(a))
#define Design ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
typedef pair<ll, ll> llpair;
typedef long double ld;
const double pi = acos(-1);
const double eps = 1e-5;
const int INF = 0x3f3f3f3f;
const long long int INFLL = 0x3f3f3f3f3f3f3f3f;

int main()
{
	Design;
	int n;
	cin >> n;
	mfor(i, 1, n) cout << "ACL";
}

Measured memory_bytes: 3128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Console;

namespace AtCoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var temp = CinTAr();
            var S = Cin();

            int N = temp[0];
            int A = temp[1] - 1;
            int B = temp[2] - 1;
            int C = temp[3] - 1;
            int D = temp[4] - 1;

            if (C < D)
            {
                if (Regex.IsMatch(S.Substring(A, D - A + 1), "##"))
                {
                    Cout("No");
                }
                else
                {
                    Cout("Yes");
                }
            }
            else
            {
                if (Regex.IsMatch(S.Substring(A, C - A + 1), "##"))
                {
                    Cout("No");
                    return;
                }
                if (Regex.IsMatch(S.Substring(B -1, D - B + 3), @"\.\.\."))
                {
                    Cout("Yes");
                }
                else
                {
                    Cout("No");
                }
            }


        }

        static readonly int MOD1E9 = (int)1e9 + 7;
        static string Cin() { return ReadLine(); }
        static string[] CinAr() { return ReadLine().Split(' '); }
        static int CinT() { return S2i(Cin()); }
        static int[] CinTAr() { return CinAr().Select((x, i) => { return S2i(x); }).ToArray(); }
        static long CinL() { return S2L(Cin()); }
        static long[] CinLAr() { return CinAr().Select((x, i) => { return S2L(x); }).ToArray(); }
        static double CinD() { return S2D(Cin()); }
        static double[] CinDAr() { return CinAr().Select((x, i) => { return S2D(x); }).ToArray(); }
        static int S2i(string s) { return int.Parse(s); }
        static long S2L(string s) { return long.Parse(s); }
        static double S2D(string s) { return double.Parse(s); }
        static void Cout(object s) { WriteLine(s); }
        /// <summary>
        /// Debug時のみの使用を推奨
        /// </summary>
        /// <typeparam name="Type"></typeparam>
        /// <param name="types"></param>
        static void CoutAr<Type>(IEnumerable<Type> types)
        {
            string text = "";
            foreach (var i in types)
            {
                text += " " + i;
            }
            WriteLine(text.Substring(1));
        }
    }
}


Measured memory_bytes: 17100
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define M 1000000007
typedef long long ll;
int main() { 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t,n,i,x;
    char a[110],c;
    string s;
    cin>>n;
    cin>>s;
    c='A';
    for(i=1;i<=26;i++){
        a[i]=++c;
    }
    for(i=0;s[i];i++){
        x=s[i]-'A';
        if((x+n)%26)
        s[i]=a[(x+n)%26];
        else
        s[i]='A';
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;
 

typedef long long ll;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll a, b, c, k, sum = 0, tot = 0;
  cin >> a >> b >> c >> k;
  if(a >= k){
    sum = k;
  }
 // cout << sum << k << " ";
  else{
    sum = a;
    tot = k - a;
    if(b < tot){
      tot -= b;
      if(c < tot){
        sum -= c;
      }
      else {
        sum -= tot;
      }
    }
  }
  cout << sum << endl;
  return 0;
}

/*
         ,--"""",--.__,---[],-------._         
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________
 
*/

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

int n, m;
const int N = 100010;
vector<int> G[N];
vector<bool> seen(N);

void dfs(int now){
    seen[now] = true;
    for(int i = 0; i < G[now].size(); i++){
        int to = G[now][i];
        if(seen[to]) continue;
        dfs(to);
    }
}

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

    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(!seen[i]){
            dfs(i);
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8832
H, W = gets.split.map(&:to_i)

if H % 3 == 0
  area_min = 0
else
  area_min = W
end

if W % 3 == 0
  area_min = 0
else
  area_min = H if H < area_min
end

(1...H).each do |h|
  a = h * W
  rest_h = H - h
  b = W / 2 * rest_h
  c = (W.even? ? W / 2 : W / 2 + 1) * rest_h
  max = [a, b, c].max
  min = [a, b, c].min
  diff = max - min
  area_min = diff if diff < area_min
end

(1...W).each do |w|
  a = H * w
  rest_w = W - w
  b = H / 2 * rest_w
  c = (H.even? ? H / 2 : H / 2 + 1) * rest_w
  max = [a, b, c].max
  min = [a, b, c].min
  diff = max - min
  area_min = diff if diff < area_min
end

puts area_min


Measured memory_bytes: 1916
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define do long double
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; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
int a;
  cin>>a;
  cout<<a*a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    ll dp[n][k+1];
    rep(i,n) rep(j,k+1) dp[i][j]=0;
    rep(i,a.at(0)+1) dp[0][i]=1;
    for (int i=1;i<n;i++){
        ll u=0;
        rep(j,k+1){
            (u+=dp[i-1][j])%=MOD;
            if (j-a.at(i)>0) u=(MOD+u-dp[i-1][j-a.at(i)-1])%MOD;
            dp[i][j]=u;
        }
    }
    cout << dp[n-1][k] << endl;
}


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

#ifdef LOCAL_PC
	#define debug(args...) cout.flush(); fflush(stdout); fprintf(stderr, args)
#else
	#define debug(args...) ; /*  */
#endif
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class num> inline void rd(num &x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar()))
	x = (x << 3) + (x << 1) + c - '0';
	if (neg) x = -x;
}

const int MAXN = 1e5 + 5, INF = 0x3f3f3f3f;

int main() {
	ll w, h, x, y;
	rd(w); rd(h); rd(x); rd(y);

	ll ans = w * h;
	if (ans%2 == 0) printf("%lld.000000 ", ans/2);
	else printf("%lld.500000 ", ans/2);

	bool can = 2*x == w && 2*y == h;
	printf("%d\n", can);
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr first
#define sc second
#define ll long long

using namespace std;
const int MN = 1e5+7;
const int MD = 1e9+7;
const ll BIG_INF = 1e18+7;
const int INF = 2147483645;

int n, mark1[MN], mark2[MN];

vector<int> g[MN];

void dfs1(int now, int dis){
    mark1[now] = dis;
    for(int i = 0; i < g[now].size(); i++){
        if(mark1[g[now][i]] == -1){
            dfs1(g[now][i], dis+1);
        }
    }
}

void dfs2(int now, int dis){
    mark2[now] = dis;
    for(int i = 0; i < g[now].size(); i++){
        if(mark1[g[now][i]] <= dis+1)continue;
        if(mark2[g[now][i]] == -1){
            dfs2(g[now][i], dis+1);
        }
    }
}

int main()
{
    memset(mark1, -1, sizeof mark1);
    memset(mark2, -1, sizeof mark2);
    cin >> n;
    int s, e;
    cin >> s >> e;
    for(int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    s--; e--;
    dfs1(e, 0);
    dfs2(s, 0);
    int mx = 0;
    for(int i = 0; i < n; i++){
        //cout << mark1[i] << ' ' << mark2[i] << endl;
        if(mark2[i] == -1)continue;
        int w = mark1[i];
        mx = max(mx, w);
    }
    cout << mx-1;
}


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

using namespace std;

int main(){
	int N, time[101], drink, que[101], x[101];
	int i, j, ans[101] = {0}, cnt = 0, tmp;
	cin >> N;
	for(i = 1; i <= N; ++i) cin >> time[i];
	cin >> drink;
	for(i = 1; i <= drink; ++i) cin >> que[i] >> x[i];
	for(i = 1; i <= drink; ++i){
		tmp = time[que[i]];
		time[que[i]] = x[i];
		for(j = 1; j <= N; ++j) ans[cnt] += time[j];
		time[que[i]] = tmp;
		++cnt;
	}
	for(i = 0; i < drink; ++i) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>

using namespace std;

#define MOD 1000000007

// long long comb(const long long a, const long long b){
//     long long mod = 1000000007;
//
//     long long fact[a + 1];
//     long long inv[a + 1];
//     fact[0] = 1;
//     inv[0] = 1;
//
//     for(long long i = 1; i <= a; i++){
//         fact[i] = (fact[i-1] * i) % mod;
//
//         long long ans = 1;
//         long long n = mod-2;
//         long long x = fact[i];
//         while(n){
//             if(n & 1){
//                 ans = (ans * x) % mod;
//             }
//             x = (x * x) % mod;
//             n>>=1;
//         }
//         inv[i] = ans % mod;
//     }
//     return ( fact[a] * (inv[b] * inv[a-b] % mod)) % mod;
// }

long long qpow(long long a, long long b){
  long long s = 1;
  while (b > 0) {
    if (b & 1)s = s * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return s;
}

const int maxn = 2000 + 10;
int fac[maxn], invfac[maxn];
void init() {
	int n = maxn - 1;
	fac[0] = 1;
	for (int i = 1; i <= n; ++i)
		fac[i] = 1ll * fac[i - 1] * i % MOD;
	invfac[n] = qpow(fac[n], MOD - 2);
	for (int i = n - 1; i >= 0; --i) {
		invfac[i] = 1ll * invfac[i + 1] * (i + 1) % MOD;
	}
}
long long comb(int n, int m) {
	if (n < m) return 0;
	return 1ll * fac[n] * invfac[m] % MOD * invfac[n - m] % MOD;
}

int main(){
  long long n,k;
  cin >> n >> k;
  n -= k;
  init();
  for(int i = 0; i < k; i++){
    long long num = i+1;
    long long s = comb(n+1, num);
    long long t = comb(k-1, num-1);
    cout << (s*t) % MOD << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n, d = gets.split.map(&:to_i)
range = d*2

if n > range
  cnt = 1
  while 1
    n = n - (range + 1)
    if n < 0 || n == 0
      puts cnt
      exit
    else
      cnt = cnt + 1
    end
  end
else
  puts 1
end

Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template<class T>using vv = vector<vector<T>>;

#define in(v) v; cin >> v;
// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif

int main() {
  int in(N); int in(M);

  vi A(N);
  int sum = 0;
  rep(i, N) {
    cin >> A[i];
    sum += A[i];
  }
  int count = 0;
  rep(i, N) {
    if (A[i] * 4 * M >= sum)
      ++count;
  }
  if (count >= M) {
    cout << "Yes\n";
  } else
    cout << "No\n";

  return 0;
}


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

using namespace std;

int main(void) {
    int64_t H, W;
    cin >> H >> W;

    int64_t ans = numeric_limits<int64_t>::max();
    for(int64_t i=1; i<H; i++) {
        int64_t S1 = i * W;
        int64_t S2 = (H-i) * (W/2);
        int64_t S3 = H*W - S1 - S2;
        ans = min(ans, max({S1, S2, S3}) - min({S1, S2, S3}));
    }
    for(int64_t i=1; i<W; i++) {
        int64_t S1 = i * H;
        int64_t S2 = (W-i) * (H/2);
        int64_t S3 = H*W - S1 - S2;
        ans = min(ans, max({S1, S2, S3}) - min({S1, S2, S3}));
    }
    if(H%3) {
        ans = min(ans, W);
    } else {
        ans = min(ans, 0L);
    }
    if(W%3) {
        ans = min(ans, H);
    } else {
        ans = min(ans, 0L);
    }

    cout << ans << endl;
    return 0;
}


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

int str_comp(const void *a, const void *b){
    return (strcmp( *(char **)a , *(char **)b  ));
}


int main(void){
    int N;
    scanf("%d", &N);
    char **words = (char * *)malloc(N * sizeof(char *));
    for (int i = 0; i < N; i++) {
        words[i] = (char *)malloc(10 * sizeof(char));
        scanf("%s", words[i]);
    }
    qsort(words,N,sizeof (words), str_comp);
    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        if (strcmp(words[i],words[i + 1]) != 0){
            ans++;
        }
    }
    printf("%d\n",ans + 1);

}


Measured memory_bytes: 10712
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();
    let k: i64 = input();

    let mut v: Vec<i64> = (a..a + k)
        .chain(b - k + 1..b + 1)
        .filter(|&i| a <= i && i <= b)
        .collect();
    v.sort();
    v.dedup();

    for i in v {
        println!("{}", i);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define FIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

using namespace std;

const int N = int(10e5 + 5);

int main() {

	FIO
	int n; cin >> n;
	double d; cin >> d;
	double dis = 0;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
        ll x, y; cin >> x >> y;
        ll p = abs(x), q = abs(y);
        dis = sqrt(x*x + y*y);
        if (dis <= d) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int a,b,c,d,i;
    cin>>a>>b>>c;
    d=c;
    for(i=0;i<10;i++)
    {
        d=a*d-b;
        cout<<d<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, char const *argv[]){
	int o,a[4],n[]={0,0,0},i,tmp;
	scanf("%d",&o);
	a[3]=o%10;
	a[2]=(o%100-a[3])/10;
	a[1]=(o%1000-a[3]-a[2]*10)/100;
	a[0]=o/1000;
	while(1){
		tmp=a[0];
		for(i=0;i<3;i++)
			tmp=(n[i]==0)? tmp+a[i+1]:tmp-a[i+1];
		if(tmp==7)
			break;
		if(n[0]==0)
			n[0]=1;
		else{
			n[0]=0;
			if(n[1]==0)
				n[1]=1;
			else{
				n[1]=0;
				if(n[2]==0)
					n[2]=1;
				else
					break;
			}
		}
	}
	for(i=0;i<4;i++){
		if(i!=0){
			if(n[i-1]==0)
				printf("+");
			else
				printf("-");
		}
		printf("%d",a[i]);
	}
	printf("=7");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<bool> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll d; cin >> d;
    vector<ll> c(26);
    rep(i,26) cin >> c.at(i);
    vector<vector<ll>> s(d,vector<ll>(26));
    rep(i,d) rep(j,26) cin >> s.at(i).at(j);
    vector<ll> last(26,0);

    ll sat = 0;

    rep(i,365){
        cout << 1 << endl;
    }

    /*
    for(int i=1;i<=d;i++){
        ll t; cin >> t;
        t--;
        last.at(t) = i;
        sat += s.at(i-1).at(t);
        for(int j=0;j<26;j++){
            sat -= c.at(j) * (i - last.at(j));
        }
        cout << sat << endl;
    }
    */
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    string s;
    cin >> s;
    li res = INF;
    rep(i, sz(s) - 2) {
        res = min(res, abs(753ll - atoi(s.substr(i, 3).c_str())));
    }
    cout << res << endl;

    return 0;
}

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

int main(){
  set<int> x;
  set<int> y={1,4,7,9};
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  x.insert(a);
  x.insert(b);
  x.insert(c);
  x.insert(d);
  if(x==y) cout << "YES" << endl;
  else cout << "NO" << endl;
}
  

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
ll n, a[100005], dp[100005];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for (ll i = 1; i <= n; i++)cin >> a[i];
	dp[1] = 0;
	dp[2] = abs(a[2]-a[1]);
	for (ll i = 3; i <= n; i++){
		ll c = abs(a[i]-a[i-2]) + dp[i-2];
		ll b = abs(a[i]-a[i-1]) + dp[i-1];
		dp[i] = min(c, b);
	}
	cout << dp[n];
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,q;
    cin>>a>>b>>q;
    vector<ll> s(a+2),t(b+2);
    s[0]=-1e18,t[0]=-1e18,s[a+1]=1e18,t[b+1]=1e18;
    FOR(i,1,a+1) cin>>s[i];
    FOR(i,1,b+1) cin>>t[i];
    sort(begin(s),end(s));
    sort(begin(t),end(t));
    rep(i,q){
      ll x;
      cin>>x;
      ll ans=1e18;
      ll ind=lower_bound(begin(s),end(s),x)-begin(s);
      rep(i,2){
        ll ind2=lower_bound(begin(t),end(t),s[ind-i])-begin(t);
        rep(j,2){
          if(ans>abs(x-s[ind-i])+abs(s[ind-i]-t[ind2-j])){
            ans=abs(x-s[ind-i])+abs(s[ind-i]-t[ind2-j]);
          }
        }
      }
      ind=lower_bound(begin(t),end(t),x)-begin(t);
      rep(i,2){
        ll ind2=lower_bound(begin(s),end(s),t[ind-i])-begin(s);
        rep(j,2){
          if(ans>abs(x-t[ind-i])+abs(t[ind-i]-s[ind2-j])){
            ans=abs(x-t[ind-i])+abs(t[ind-i]-s[ind2-j]);
          }
        }
      }
      cout<<ans<<endl;
    }
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define each(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizoef(a))
#define sz(s) (int)((s).size())
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define pb push_back
#define MP(x,y) make_pair((x),(y))

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	ll a, b; cin >> a >> b;
	if ((a > 0LL && b > 0LL) || ((a < 0LL && b < 0LL) && (b-a) % 2LL != 0LL)){
		cout << "Positive" << endl;
	}else if (a * b < 0LL){
		cout << "Zero" << endl;
	}else{
		cout << "Negative" << endl;
	} // end if

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


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


  return 0 ;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;
void printb(unsigned int v) {
    unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
    do putchar(mask & v ? '1' : '0');
    while (mask >>= 1);
}
int main() {
    int n, m;
    cin >> n >> m;

    vector<vector<int>> s(m);
    vector<int> p(m);

    for (int i = 0; i < m; ++i) {
        int k; cin >> k;
        for (int j = 0; j < k; ++j) {
            int sw; cin >> sw;
            s[i].push_back(sw);
        }
    }
    for (int i = 0; i < m; ++i) {
        int pw; cin >> pw;
        p[i] = pw;
    }

    auto onCount = [](int state, vector<int>s) {
        int cnt = 0;
        for (const auto& e : s) {
            if (state & (1 << (e - 1))) cnt++;
        }
        return cnt;
    };

    int cnt = 0;
    for (int i = 0; i <= (1 << n) - 1; ++i) {
        // 全探索
        int j = 0;
        for (; j < m; ++j) {
            int count = onCount(i, s[j]);
            if (count % 2 != p[j]) break;
        }
        if (j == m) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


 
void solve(){
    string s;
    cin>>s;
    rep(i,19)if(s[i]==',') s[i]=' ';
    cout<<s<<endl;
}
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    ll Q=1;
    // cin>>Q;
    rep(_,Q){
 
        solve();
 
    }
   
 
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    for(int i = 1;i <= 3;i++)
    {
        if(i != a && i != b)
        {
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<map>
using namespace std;
#define fr first
#define sc second
int main(){
  int h,w,n,mas[1002][1002],dp[1002][1002],x,y;
  while(cin >> h >> w >> n , h){
    for(int i = 0 ; i < h ; i++ ){
      for(int j = 0 ; j < w ; j++ ){
        cin >> mas[i][j];
        dp[i][j] = 0;
      }
    }
    dp[0][0] = n - 1;
    for(int i = 0 ; i < h ; i++ ){
      for(int j = 0 ; j < w ; j++ ){
        if(i<h-1)dp[i + 1][j] += (dp[i][j] + (mas[i][j] == 1 ? 0:1)) / 2;
        if(j<w-1)dp[i][j + 1] += (dp[i][j] + (mas[i][j] == 0 ? 0:1)) / 2;
      }
    }
    x = 0 , y = 0;
    while(x != h && y != w) (dp[x][y]+mas[x][y]) % 2 == 0 ? x++ : y++ ;
    cout << x + 1 << " " << y + 1 << endl;
  }
}

Measured memory_bytes: 9000