akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    int n;
    cin >> n;
    vll h(n);
    rep(i, 0, n) cin >> h[i];
    for (int i = n - 2; i >= 0; i--)
    {
        if (h[i + 1] - h[i] >= 0)
            continue;
        else if (h[i + 1] - h[i] == -1)
            h[i]--;
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1024
import bisect

n = int(input())
d = list(map(int, input().split()))
d.sort()
div = n // 2
count = 0
for i in range(10**5 + 1):
    insert_index = bisect.bisect_right(d, i)
    if insert_index == div:
        count += 1
print(count)


Measured memory_bytes: 14276
import java.util.Scanner;

class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num[][];
		int N = sc.nextInt();
		int D = sc.nextInt();
		num = new int[N][D];
		for(int i = 0;i < N;i++) {
			for(int j = 0;j < D;j++) {
				num[i][j] = sc.nextInt();
			}
		}
		int count = 0;
		for(int i = 0;i < N - 1;i++) {
			for(int j = i + 1;j < N;j++) {
				double distance = 0;
				for(int k = 0 ; k < D ;k++) {
					distance += (num[i][k] - num[j][k]) * (num[i][k] - num[j][k]);
				}
				distance = Math.sqrt(distance);
				if(distance == (double)((int)(distance))) count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
    int ans=INT_MAX;
for(int i=1;i<=100;i++)
{int cnt=0;
    for(int j=0;j<n;j++)
    {
        cnt+=(arr[j]-i)*(arr[j]-i);
    }
    ans=min(ans,cnt);
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N, K = gets.chomp.split(" ").map(&:to_i)
R, S, P = gets.chomp.split(" ").map(&:to_i)
T = gets.chomp

def choice(i, t, v, win, lose, even)
  ret = 0
  if i >= K && t[-K] == win then
    if i + K < N && T[i + K] == win.downcase then
      t.concat(even)
    else
      t.concat(lose)
    end
  else
    ret = v
    t.concat(win)
  end
  ret
end

ans = 0
t = ""
N.times{|i|
  case T[i]
  when 'r' then
    ans += choice(i, t, P, 'P', 'S', 'R')
  when 's' then
    ans += choice(i, t, R, 'R', 'P', 'S')
  when 'p' then
    ans += choice(i, t, S, 'S', 'R', 'P')
  end
}

puts ans


Measured memory_bytes: 4220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var inputLine = input.Split();

            int X = int.Parse(inputLine[0]);
            int Y = int.Parse(inputLine[1]);

            if((Y < X * 2) || (Y > X * 4) || !(Y % 2 == 0))
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }


        }
    }
}


Measured memory_bytes: 27432
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>


using namespace std;

int main(){

	long N, K;

	cin >> N >> K;

	long x = N/K;
	long y = (N+K/2)/K;

	long count = x * x * x;

	if(K % 2 == 0){
		if(y > 2){
			count += y * (y-2) * (y-1);
		}
		if(y > 1){
			count += y * (y-1) * 3;
		}
			count += y;
	}


	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;

@SuppressWarnings("unused")
public class Main {
	String fileName = "input.txt";
	final boolean isDebug = false;
	//final boolean isDebug = true;
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	final int MOD = (int)1e9+7;
	final long INF = Long.MAX_VALUE / 2;
	//final int INF = Integer.MAX_VALUE / 2;
	
	//System.out.println();はつかわない！！
	void solve() throws Exception{
		int N = in.nextInt();
		int[] W = new int[N];
		long sum1 = 0;
		for(int i = 0; i < N; i++){
			W[i] = in.nextInt();
			sum1 += W[i];
		}
		
		long min = sum1;
		long sum2 = 0;
		for(int i = 0; i < N; i++){
			sum2 += W[i];
			sum1 -= W[i];
			min = Math.min(min, Math.abs(sum1 - sum2));
		}
		out.println(min);
	}
	
	/* end solve */
	
	/* main */
	public static void main(String[] args) throws Exception {
		new Main().m();
	}
	
	void m() throws Exception {
		if(isDebug) in = new FastScanner(new FileInputStream(fileName));
		solve();
		out.flush();
	}
	/* end main */
}
/* end Main */

class FastScanner {
	Reader input;

	FastScanner() {this(System.in);}
	FastScanner(InputStream stream) {this.input = new BufferedReader(new InputStreamReader(stream));}
	
	int nextInt() {return (int) nextLong();}

	long nextLong() {
		try {
			int sign = 1;
			int b = input.read();
			while ((b < '0' || '9' < b) && b != '-' && b != '+') {
				b = input.read();
			}
			if (b == '-') {
				sign = -1;
				b = input.read();
			} else if (b == '+') {
				b = input.read();
			}
			long ret = b - '0';
			while (true) {
				b = input.read();
				if (b < '0' || '9' < b) return ret * sign;
				ret *= 10;
				ret += b - '0';
			}
		} catch (IOException e) {
			e.printStackTrace();
			return -1;
		}
	}

	double nextDouble() {
		try {
			double sign = 1;
			int b = input.read();
			while ((b < '0' || '9' < b) && b != '-' && b != '+') {
				b = input.read();
			}
			if (b == '-') {
				sign = -1;
				b = input.read();
			} else if (b == '+') {
				b = input.read();
			}
			double ret = b - '0';
			while (true) {
				b = input.read();
				if (b < '0' || '9' < b) break;
				ret *= 10;
				ret += b - '0';
			}
			if (b != '.') return sign * ret;
			double div = 1;
			b = input.read();
			while ('0' <= b && b <= '9') {
				ret *= 10;
				ret += b - '0';
				div *= 10;
				b = input.read();
			}
			return sign * ret / div;
		} catch (IOException e) {
			e.printStackTrace();
			return Double.NaN;
		}
	}

	char nextChar() {
		try {
			int b = input.read();
			while (Character.isWhitespace(b)) {
				b = input.read();
			}
			return (char) b;
		} catch (IOException e) {
			e.printStackTrace();
			return 0;
		}
	}

	String nextStr() {
		try {
			StringBuilder sb = new StringBuilder();
			int b = input.read();
			while (Character.isWhitespace(b)) {
				b = input.read();
			}
			while (b != -1 && !Character.isWhitespace(b)) {
				sb.append((char) b);
				b = input.read();
			}
			return sb.toString();
		} catch (IOException e) {
			e.printStackTrace();
			return "";
		}
	}
}

Measured memory_bytes: 23124
N, M = map(int, input().split())
s, l = min(N, M), max(N, M)
if s == 1 and l == 1:
  print(1)
elif s == 1:
  print(l - 2)
elif s == 2:
  print(0)
else:
  print(s * l - (s * 2 + l * 2 - 4))

Measured memory_bytes: 3060
#include<iostream>
#include<climits>
#include<algorithm>
using namespace std;
int main(){
    int n,m,x;
    int ans,tmp1=0, tmp2=0;
    cin >> n >> m >> x;
    int a[m];
    for(int i=0; i<m; i++){
        cin >> a[i];
        if(a[i]<x){
            tmp1++;
        }else tmp2++;
    }
    ans = min(tmp1, tmp2);
    cout << ans << endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    pair<int, int> P[100010];
    rep(i, N) {
        int X, L;
        cin >> X >> L;
        P[i].first = X + L;
        P[i].second = X - L;
    }
    sort(P, P + N);
    int ans = 0, t = -INF;
    rep(i, N) {
        if (t <= P[i].second) {
            ans++;
            t = P[i].first;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define max(p,q)((p)>(q)?(p):(q))
#define INF 1000000000

int a[100010];
int n,m;
int f(int L){
	if(a[0]>L)return INF;
	int pos=0;//右にいる相手
	int lv=1;
	int cnt=0;
	while(a[n-1]>=lv+L){
		int left,right;
		if(pos)left=L-(lv-a[pos-1]);
		else left=0;
		right=L-(a[pos]-lv);
		int up=max(left,right);
		if(up<=0){
			cnt+=-right+1;
			lv+=-right+1;
		}else{
			lv+=up;
			while(pos<n&&a[pos]<lv)pos++;
			cnt++;
		}
	}
	return cnt+1;
}

int main(){
	while(scanf("%d%d",&n,&m),n){
		for(int i=0;i<n;i++)scanf("%d",a+i);
		if(f(1)<m){
			puts("-1");
			continue;
		}
		int l=1,r=1000010;
		while(r-l>1){
			int mid=(l+r)/2;
			if(f(mid)<m)r=mid;
			else l=mid;
		}
		printf("%d\n",f(l)==INF?-1:l);
	}
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const v(T)&a){ll res(0);for(auto&&x:a)res+=x;return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  --n;
  ll ans = 0;
  rrep(i,n) {
    ans += n/i;
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 3800
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const ll inf=1e18;
int main(){
	int n;
	cin>>n;
	vi a(n),b(n);
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	ll out=1;
	bool h=true;
	if(n==1){
		if(a[0]==b[0])cout<<1<<endl;
		else cout<<0<<endl;
		return 0;
	}
	if(b[0]!=b[1]&&b[0]!=a[0])h=false;
	if(a[n-1]!=a[n-2]&&a[n-1]!=b[n-1])h=false;
	loop(i,1,n-1){
		if(a[i-1]!=a[i]&&b[i]!=b[i+1]){
			if(a[i]!=b[i])h=false;
		}
		if(a[i-1]!=a[i]&&b[i]==b[i+1]&&a[i]>b[i])h=false;
		if(a[i-1]==a[i]&&b[i]!=b[i+1]&&a[i]<b[i])h=false;
		if(a[i-1]==a[i]&&b[i]==b[i+1])
			out=out*min<ll>(a[i],b[i])%1000000007LL;
	}
	if(!h)out=0;
	cout<<out<<endl;
}









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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;

const long double PI  = 3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve()
{
	ll k ,x;
  cin>>k>>x;
  repn(i, max(x-k+1, -1000000LL), min(x+k-1, 1000000LL))
    cout<<i<<" ";
  cout<<endl;
}


int main()
{
	ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, X = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))

A = np.array(A)

# 解説AC
# 何回色変えるかを固定
ans = A.sum()
for k in range(1, N):
    # k 個前までの最小値
    A = np.minimum(A, np.roll(A, 1))
    ans = min(ans, A.sum() + k * X)
print(ans)


Measured memory_bytes: 23236
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
const int MAXN = 2e5+7;
int n,A[MAXN];
bool f[MAXN];
int main(){
    ____();
    cin >> n;
    memset(f,0,sizeof(f));
    f[0] = true;
    for(int i = 1; i <= n; i++){
        cin >> A[i];
        f[A[i]] = f[A[i]-1]||f[A[i]];
    }
    int maxx = -1;
    for(int i = 1; i <= n; i++){
        if(f[i]==true) maxx = i;
        else break;
    }
    cout << (maxx==-1?-1:n-maxx) << endl;
    return 0;
}

Measured memory_bytes: 1280
# coding: utf-8
# Your code here!

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


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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    vector<int> A;
    rep(i,N) {
        int a;
        cin >> a;
        if (A.size()==0) {
            A.push_back(a);
        }
        else {
            auto idx = lower_bound(A.rbegin(),A.rend(), a) - A.rbegin();
            //cout << "input:" << a << " idx:" << idx << endl;
            if (idx==0) {
                A.push_back(a);
            }
            else {
                //cout << "input:" << a << " idx:" << A.size()-idx << endl;
                A[A.size()-idx] = a;
            }
        }
        //sort(A.begin(),A.end());
    }
    int ans = A.size();
    cout << ans << endl;

    //rep(i,A.size()) {
    //    cout << A[i] << " ";
    //}
    //cout << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  string s;
  ll w;
  cin >> s >> w;
  // for (int i = 0; i < int(s.size()) / w + 1; i++)
  // {
  //   cout << s[i * w];
  // }
  int i = 0;
  while(i * w <= int(s.size())-1) {
    cout << s[i * w];
    i++;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

ll vs[100000+10];

int main(void) {
  int n;
  ll walk, warp;
  scanf("%d%lld%lld", &n, &walk, &warp);
  REP(i, n) {
    scanf("%lld", &vs[i]);
  }
  ll res = 0;
  ll cur = vs[0];
  REP(i, n) {
    res += min((vs[i]-cur)*walk, warp);
    cur = vs[i];
  }
  cout << res << endl;
  
  return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

void dfs(vvll& to, vector<bool>& rblFrom1, ll v) {
  if (rblFrom1[v]) return;
  rblFrom1[v] = true;
  for (auto u : to[v]) {
    dfs(to, rblFrom1, u);
  }
}

void rdfs(vvll& ot, vector<bool>& rblToN, ll v) {
  if (rblToN[v]) return;
  rblToN[v] = true;
  for (auto u : ot[v]) {
    rdfs(ot, rblToN, u);
  }
}

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

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

  vector<bool> rblFrom1(n, false);
  vector<bool> rblToN(n, false);
  vvll to(n);
  vvll ot(n);

  vT eds;
  rep(i,m){
    ll a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    eds.emplace_back(a, b, p - c);
    to[a].emplace_back(b);
    ot[b].emplace_back(a);
  }

  dfs(to, rblFrom1, 0);
  rdfs(ot, rblToN, n - 1);

  vector<bool> ok(n);
  rep(i, n) ok[i] = rblFrom1[i] && rblToN[i];

  vll d(n, INF);
  d[0] = 0;
  bool upd = true;
  ll step = 0;
  while (upd) {
    upd = false;
    for (auto e : eds) {
      ll a, b, c;
      tie(a, b, c) = e;
      if (!ok[a]) continue;
      if (!ok[b]) continue;
      ll newD = d[a] + c;
      if (newD < d[b]) {
        d[b] = newD;
        upd = true;
      }
    }
    step++;
    if (step > n) {
      puts("-1");
      return 0;
    }
  }

  ll ans = -d[n - 1];
  if(ans < 0) ans = 0;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4076
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)

ll R,G,B,N;

int main() {
    cin >> R >> G >> B >> N;
    ll ans = 0;
    rep(i,3010){
        rep(j,3010){
            if ((N-R*i-G*j) >= 0 && (N-R*i-G*j)%B == 0) ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

int N,W,v[110],w[110],dp[110][10010];

int main(){
    cin>>N>>W;

    for(int i=0;i<N;i++){
        cin>>v[i]>>w[i];
    }

    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            if(j-w[i]>=0){
                dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }else{
                dp[i+1][j]=dp[i][j];
            }
        }
    }
    cout<<dp[N][W]<<endl;
}



Measured memory_bytes: 7000
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

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

al = [[] for i in range(N+1)]
for i in range(M):
    a, b = map(int, input().split())
    al[a].append(b)
    al[b].append(a)

block = [[] for i in range(N+1)]
for i in range(K):
    c, d = map(int, input().split())
    block[c].append(d)
    block[d].append(c)

seen = [0 for i in range(N+1)]
num_connect = [0 for i in range(N+1)]
cluster = [0 for i in range(N+1)]

def bfs(u, c):
    visited = []
    stack = deque([u])
    seen[u] = 1
    count = 1

    while len(stack) > 0:
        v = stack.popleft()
        visited.append(v)
        cluster[v] = c
        for w in al[v]:
            if seen[w] == 0:
                stack.append(w)
                count += 1
                seen[w] = 1

    for v in visited:
        num_connect[v] = count

c = 1
for i in range(1,N+1):
    if seen[i] == 0:
        bfs(i, c)
        c += 1

for i in range(1,N+1):
    bl = 0
    for d in block[i]:
        if cluster[i] == cluster[d]:
            bl += 1
    print(num_connect[i] - 1 - len(al[i]) - bl, end=" ")

Measured memory_bytes: 128108
n = int(input())
a = list(map(int, input().split()))
a.sort()
m = 0
i = 0
while True:
    if a[i] == a[i + 1]:
        m = 1
        break
    elif i == n - 2:
        break
    i += 1
if m == 0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 26808
#include "bits/stdc++.h"
using namespace std;

#define MOD 98244353
long long int ppow(long long int i, long long int j) {
	long long int res = 1LL;
	while (j) {
		if ((j & 1LL)) {
			res *= i;
			if (res >= MOD) {
				res %= MOD;
			}
		}
		j >>= 1;
		i *= i;
		if (i >= MOD) {
			i %= MOD;
		}
	}
	return res;
}

int n;

int main() {
	int ans = 0;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (n - i <= i)break;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

int main(void){
    ll x;
    cin >> x;
    for(ll a=-199; a<200; a++){
        for(ll b=-199; b<200; b++){
            if( (a*a*a*a*a)-(b*b*b*b*b) ==x ){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3628
require 'set'
n = gets.to_i
left_nodes = Set[0]
right_nodes = Set.new
g = {?s => Set[0], 0 => Set.new}

def augument_path(g)
    queue = [?s]
    reached = Set[?s]
    prev = {}
    until queue.empty?
        u = queue.shift
        g[u].each do |v|
            next if reached.include?(v)
            prev[v] = u
            reached << v
            queue << v
        end
        break if prev[?t]
    end
    if prev[?t]
        path = [?t]
        v = path[0]
        while u = prev[v]
            path.unshift(u)
            v = u
        end
        return path
    end
    return nil
end

k = 0
(1..n).each do |j|
    i = gets.to_i
    if left_nodes.include?(i)
        right_nodes << j
        g[j] = Set[?t]
        g[i] << j
    else
        left_nodes << j
        g[?s] << j
        g[j] = Set[i]
    end
    path = augument_path(g)
    if path
        k += 1
        path.each_cons(2) do |u, v|
            g[u].delete(v)
            (g[v] ||= Set.new) << u
        end
    end
    p k
end



Measured memory_bytes: 9972
#https://atcoder.jp/contests/abc127/tasks/abc127_a

AB = [int(i) for i in input().split()]

if AB[0] >= 6 and AB[0] <= 12:
    print(int(AB[1] / 2))
elif AB[0] <= 5:
    print(0)
else:
    print(AB[1])

Measured memory_bytes: 3060
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    
    
    int a,b,c;
 
    Scanner sc = new Scanner(System.in);
    a = sc.nextInt();
    b = sc.nextInt();
    
	double doubleA;
    double doubleB;
    double doubleC;
      
    doubleA = (double) a;
    doubleB = (double) b;
    doubleC = Math.ceil( (doubleB - 1.0 ) / (doubleA - 1.0 ) );
    c = (int) doubleC;
    System.out.println(c);
    
    return;
  }
}

    
    
    

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int n;
const int limit = 20010;
int a[limit], b[limit], c[limit];
vector<int> graph[limit];

int amax = 0;
int ans[limit];
int pos = 0;

void dfs(int v, int p){
	ans[v] = c[pos++];
	if(p != -1) amax += min(ans[v], ans[p]);
	
	for(auto &v2:graph[v]){
		if(v2 == p) continue;
		dfs(v2, v);
	}
}

int main(void){
	cin >> n;

	rep(i, n - 1){
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		graph[a[i]].push_back(b[i]);
		graph[b[i]].push_back(a[i]);
	}

	rep(i, n) cin >> c[i];
	sort(c, c + n);
	reverse(c, c + n);

	dfs(0, -1);

	cout << amax << endl;
	rep(i, n) cout << (i?" ":"") << ans[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n,m;
	cin>>n>>m;
	vector<ll> p(m);
	vector<ll> sp(n-1,0),si(n-1,0);
	vector<ll> cnt(n,0);
	for(ll i=0;i<m;i++){
		cin>>p[i],p[i]--;
	}
	for(ll i=0;i<m-1;i++){
		ll now = min(p[i],p[i+1]);
		ll next = max(p[i],p[i+1]);
		cnt[now]++;
		cnt[next]--;
	}
	for(ll i=1;i<n;i++)cnt[i]+=cnt[i-1];
       	ll sum = 0;	
	for(ll i=0;i<n-1;i++){
		ll a,b,c;
		cin>>a>>b>>c;
		si[i] = c;
		sum += min(cnt[i]*a,cnt[i]*b+c);
	}
	cout<<sum<<endl;
	

	return 0;
}



Measured memory_bytes: 5964
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	ll a, b, c;
	cin >> a >> b >> c;
	ll ans = INF;
	if( a%2 == 0 || b%2 == 0 || c%2 == 0 ){
		ans = 0;
	} else {
		ans = min({a*b, b*c, c*a});
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

vector<int> graph[100001];
bool reached[100001];
int ans[100001];

void bfs(){
	reached[1] = true;
	queue<int> que;
	que.push(1);

	while(!que.empty()){
		int now = que.front();
		que.pop();
		for (auto next : graph[now]){
			if (reached[next] == false){
				que.push(next);
				ans[next] = now;
				reached[next] = true;
			}
		}
	}
	return;
}

int main(){
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	bfs();
	for (int i = 1; i <= n; i++){
		if (reached[i] == false){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	for (int i = 2; i <= n; i++){
		cout << ans[i] << endl;
	}
	return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int k,t;cin>>k>>t && k|t;){
		vi a(t);
		rep(i,t) cin>>a[i];

		int mx=*max_element(all(a));
		cout<<max(2*mx-k-1,0)<<endl;
	}
}


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

int main(){
  string S, T;
  cin >> S;
  cin >> T;
  int l = S.size();
  bool can = false;
  for(int i = 0; i < l; i++){
    char s = S[l-1];
    S.erase(l-1);
    S = s + S;
    if(S == T) can = true;
  }
  cout << (can? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
S=input()
lens=len(S)

mod=10**9+7


Asum=[0]*lens
#Bsum=[0]*lens
Csum=[0]*lens
qsum=[0]*lens

for i in range(lens):
    if S[i]=="A":
        Asum[i]=Asum[i-1]+1
        Csum[i]=Csum[i-1]
        qsum[i]=qsum[i-1]
    elif S[i]=="C":
        Asum[i]=Asum[i-1]
        Csum[i]=Csum[i-1]+1
        qsum[i]=qsum[i-1]
    elif S[i]=="?":
        Asum[i]=Asum[i-1]
        Csum[i]=Csum[i-1]
        qsum[i]=qsum[i-1]+1
    else:
        Asum[i]=Asum[i-1]
        Csum[i]=Csum[i-1]
        qsum[i]=qsum[i-1]        

CSUM=Csum[lens-1]
QSUM=qsum[lens-1]


count=0
for i in range(1,lens-1):
    if S[i]=="B":
        count+=Asum[i-1]*(CSUM-Csum[i])*pow(3,max(0,QSUM),mod)%mod
        count+=Asum[i-1]*(QSUM-qsum[i])*pow(3,max(0,QSUM-1),mod)%mod
        count+=qsum[i-1]*(CSUM-Csum[i])*pow(3,max(0,QSUM-1),mod)%mod
        count+=qsum[i-1]*(QSUM-qsum[i])*pow(3,max(0,QSUM-2),mod)%mod


    elif S[i]=="?":
        count+=Asum[i-1]*(CSUM-Csum[i])*pow(3,max(0,QSUM-1),mod)%mod
        count+=Asum[i-1]*(QSUM-qsum[i])*pow(3,max(0,QSUM-2),mod)%mod
        count+=qsum[i-1]*(CSUM-Csum[i])*pow(3,max(0,QSUM-2),mod)%mod
        count+=qsum[i-1]*(QSUM-qsum[i])*pow(3,max(0,QSUM-3),mod)%mod
        
    



#count=0
#for a in range(lens-2):
#    if S[a]=="A" or S[a]=="?":
#        for b in range(a+1,lens-1):
#            if S[b]=="B" or S[b]=="?":
#                for c in range(b+1,lens):
#                    if S[c]=="C" or S[c]=="?":
#                        count+=1
print(count%mod)


            


Measured memory_bytes: 10296
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;
 
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    rep(i,b){
        if((b*i+c)%a==0){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> subset1,subset2;
vector<vector<int> >v1,v2;
int r,c,kk;
void search1(int k){// start with 1
	if(k==r+1){
		v1.push_back(subset1);

	}
	else{
		subset1.push_back(k);//include k
		search1(k+1);
		subset1.pop_back();// don't include k
		search1(k+1);
	}
}
void search2(int k){// start with 1
	if(k==c+1){
		v2.push_back(subset2);
	}
	else{
		subset2.push_back(k);//include k
		search2(k+1);
		subset2.pop_back();// don't include k
		search2(k+1);
	}
}

int main(){
	cin>>r>>c>>kk;
    string sr[r],ar[r];
    for(int i=0;i<r;i++){
        cin>>sr[i];
    }
	search1(1);
	search2(1);
	int ans=0;
	for(auto i:v1){
        for(auto a:v2){
            for(int ii=0; ii<r; ii++){
            ar[ii]=sr[ii];
        }
        for(auto j:i){
            for(int ii=0;ii<c;ii++){
                ar[j-1][ii]='.';
            }
        }
            for(auto b:a){
                for(int ii=0;ii<r;ii++){
                    ar[ii][b-1]='.';
                }
            }
            int cc=0;
            for(int aa=0;aa<r;aa++){
                for(int bb=0;bb<c;bb++){
                    if(ar[aa][bb]=='#'){
                        cc++;
                    }
                }
            }
            //cout<<cc<<endl;
            if(cc==kk){
                ans++;
            }
        }

	}
	cout<<ans;

	return 0;
}


Measured memory_bytes: 3636
A, B, C = map(int, input().split())
A, B, C = sorted([A, B, C])

if (A + B + C) % 2 == (C * 3) % 2:
    ans = (C - A + C - B) // 2
else:
    ans = (C + 1 - A + C - B) // 2 + 1
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
using Graph = vector<vector<int>>;

int digsum(int n) {
      int res = 0;
      while(n > 0) {
          res += n%10;
          n /= 10;
      }
      return res;
  }



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


int n,a,b,sum = 0;
cin >> n >> a >> b;
for(int i = 1;i <= n;i++){
  if(digsum(i) >= a && digsum(i) <= b) sum += i;
}
cout << sum << endl;



//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 256
#![allow(unused_imports)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{min, max};
use std::collections::{HashMap, HashSet, VecDeque, BinaryHeap};

fn main() {
    input!{
        n: usize,
        mut v: [(usize, usize); n]
    }
    if n % 2 == 1 {
        v.sort_by_key(|x| x.0);
        let l = v[n / 2].0;
        v.sort_by(|x, y| y.1.cmp(&x.1));
        let r = v[n / 2].1;
        println!("{}", r - l + 1);
    } else {
        v.sort_by_key(|x| x.0);
        let l = v[n / 2 - 1].0 + v[n / 2].0;
        v.sort_by(|x, y| y.1.cmp(&x.1));
        let r = v[n / 2 - 1].1 + v[n / 2].1;
        println!("{}", r - l + 1);
    }
}


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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
int gcd(int a, int b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint comb(int n, int m) {
    return perm(n) / (perm(n - m) * perm(m));
}

// 定数 //
#define pi acos(-1)
// End of Template //

vi color;

bool isBipartite(vvi& graph, int n, int cl = 0) {
    color[n] = cl;
    for (auto x : graph[n]) {
        if (color[x] != -1) {
            if (color[x] == cl) return false;
            continue;
        }
        if (!isBipartite(graph, x, 1 - cl)) return false;
    }
    return true;
}

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
        
    lint N, M;   
    cin >> N >> M;

    color.assign(N, -1);
    vvi graph(N);
    int a, b;
    rep(i, M) {
        cin >> a >> b;
        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
    }

    bool f = false;
    rep(i, N) {
        if (color[i] != -1) continue;
        if (!isBipartite(graph, i)) {
            f = true;
        }
    }

    sort(color);
    lint cnt = 0;
    while (color[cnt] == 0) cnt++;

    cou((f ? N * (N - 1) / 2 - M : cnt * (N - cnt) - M));
}

Measured memory_bytes: 6528