akhauriyash/Code-Regression huggingface dataset:
using System;

namespace Stack
{
	class Stack
	{
		const int INIT_PTR = -1;

		private int _ptr;
		private string[] _stack;

		public Stack(int maxSize) {
			_ptr = INIT_PTR;
			_stack = new string[maxSize];
		}

		public string Pop() {
			if (_ptr == INIT_PTR)
				return null;
			string popped = _stack[_ptr];
			--_ptr;
			return popped;
		}

		public bool Push(string val) {
			if (_ptr == _stack.Length-1) {
				return false;
			}

			// ???????????????
			char[] op = val.ToCharArray();
			char c = op [0];
			if (c == '+' || c == '-' || c == '*' || c == '/') {

				// 2?????´??°???Pop?????????
				int b = int.Parse(_stack [_ptr]);
				--_ptr;
				if (_ptr < 0)
					return false;
				int a = int.Parse(_stack [_ptr]);
				--_ptr;

				// ?¨????????????????push
				int res = -1;
				switch (c) {
				case '+':
					res = a + b;
					break;
				case '-':
					res = a - b;
					break;
				case '*':
					res = a * b;
					break;
				case '/':
					res = a / b;
					break;
				}
				val = res.ToString ();
			}

			++_ptr;
			_stack [_ptr] = val;
			return true;
		}

		public bool isEmpty() {
			return _ptr == INIT_PTR;
		}

	}

	class MainClass
	{
		public static void Main (string[] args)
		{
			Stack stack = new Stack (1000);

			string readLine = Console.ReadLine ();
			string[] operands = readLine.Split (' ');
			foreach (string op in operands) {
				stack.Push (op);
			}

			while (!stack.isEmpty ()) {
				string op = stack.Pop ();
				Console.WriteLine (op);
			}

		}
	}
}

Measured memory_bytes: 9120
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int const MOD = 1e9 + 7;
int arr[100010];
int main(void)
{
    int N, M;
    cin >> N >> M;

    map<int, int> m1;
    map<int, int> m2;
    vector<pair<int, int>> vp;
    for (int i = 0; i < M; ++i)
    {
        int p, y;
        cin >> p >> y;
        vp.push_back({p, y});
        m1[y] = p;
    }
    for (int i = 0; i < 100010; ++i)
        arr[i] = 0;
    for (auto itr = m1.begin(); itr != m1.end(); ++itr)
    {
        m2[(*itr).first] = arr[(*itr).second] + 1;
        arr[(*itr).second]++;
    }

    for (int i = 0; i < M; ++i)
    {
        cout << setw(6) << setfill('0') << m1[vp[i].second];
        cout << setw(6) << setfill('0') << m2[vp[i].second];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 13684
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

/* 降順 */
int cmp(const void* x, const void* y) {
	uint64_t a = *(const uint64_t*)x, b = *(const uint64_t*)y;
	if (a > b) return -1;
	return a < b;
}

uint64_t memo[64][64];

uint64_t nCr(int n, int r) {
	if (r < 0 || n < r) return 0;
	if (r == 0 || n == r) return 1;
	if (memo[n][r]) return ~memo[n][r];
	return ~(memo[n][r] = ~(nCr(n - 1, r) + nCr(n - 1, r - 1)));
}

int main(void) {
	int N, A, B;
	uint64_t v[64];
	int i;
	int tigau;
	uint64_t sum = 0;
	uint64_t answer;
	if (scanf("%d%d%d", &N, &A, &B) != 3) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNu64, &v[i]) != 1) return 1;
	}
	qsort(v, N, sizeof(*v), cmp);
	for (i = 0; i < A; i++) sum += v[i];

	tigau = 0;
	for (i = 1; i < A; i++) {
		if (v[i] != v[0]) tigau = 1;
	}
	if (tigau) {
		/* 最後だけ候補が複数ある可能性がある (無駄に平均を下げないために、ちょうどA個選ぶ) */
		int lastDelta = 0, count = 1, snum;
		for (i = 1; i < A; i++) {
			if (v[i] != v[i - 1]) lastDelta = i;
		}
		while (lastDelta + count < N && v[lastDelta + count] == v[lastDelta]) count++;
		snum = A - lastDelta;
		/* count個からsnum個選ぶ */
		answer = nCr(count, snum);
	} else {
		int count = 1;
		while (count < N && v[count] == v[0]) count++;
		/* count個からA個以上B個以下選ぶ */
		answer = 0;
		for (i = A; i <= B && i <= count; i++) {
			answer += nCr(count, i);
		}
	}

	printf("%.15f\n%" PRIu64 "\n", (double)sum / A, answer);
	return 0;
}

/*
貪欲
平均より価値が低いものを選ぶ → 平均が下がる → 無駄
価値が違うものがあれば、追加したら平均が下がる
価値が違うものが無ければ、それと同じ価値のものを入れても平均が下がらない → 場合分け
*/


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int q;
	double x;

	while(1){
		scanf("%d", &q);
		if(q == -1)
			break;
		x = (double)q / 2;
		while(fabs(x*x*x - q) >= 0.00001 * q)
			x = x - (x*x*x - q)/(3*x*x);
		printf("%f\n", x);
	}
	return 0;
}

Measured memory_bytes: 632
package main

import (
	"fmt"
	"sort"
)

// Pair .
type Pair struct {
	l int
	r int
}

// Pairs .
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}

func (p Pairs) Less(i, j int) bool {
	return p[i].r < p[j].r
}

func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func main() {
	var n int
	fmt.Scan(&n)

	pairs := make([]Pair, n)
	var x, l int
	for i := 0; i < n; i++ {
		fmt.Scan(&x, &l)
		pairs[i] = Pair{x - l, x + l}
	}
	sort.Sort(Pairs(pairs))

	ans := 0
	pr := int(-1e9 - 10)
	for i := 0; i < n; i++ {
		p := pairs[i]
		if pr <= p.l {
			ans++
			pr = p.r
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main(){
	int n; cin >> n;
	string s; cin >> s;
	vector<int> v(n);
	rep(i,n){
		if (i==0){
			if (s[i] == 'W'){
				v[i]+=1;
				continue;
			}
		}
		v[i] = v[i-1];
		if (s[i] == 'W'){
			v[i]+=1;
		}
	}
	int x = MOD;
	rep(i,n){
		int a=0,b=0;
		if (i>0){
			a = v[i-1];
		}
		b = n-1 - i - (v[n-1] - v[i]);
		x = min(x,a+b);
	}
	cout << x << endl;
}


Measured memory_bytes: 1796
#include <stdio.h>
#include <iostream>
#include <cassert>
#include <vector>
#include <string>
using namespace std;

int main()
{
  int i = 0, k = 0;
  cin >> k;
  string res = "";
  for(i; i < k; i++)
  {
    res += "ACL";
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3552
import math
l = []
ans = 0
for i in range(5):
    x = int(input())
    l.append(x)
for i in range(1,10):
    f = False
    for j in l:
        if j % 10 == i:
            ans += j
            l.remove(j)
            f = True
            break
    if f: break
for x in l:
    ans += math.ceil(x/10) * 10
print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
using namespace std;

int const MAX_N = 256 * 1024;

class Eratosthenes_Sieve {
public:
	int ES_MAX_GEN;                         // Should NOT be less than 150 for another methods using it here (!!!)
	int * minimal_prime_divisor;            // if value of [i]-index is 'i', then number is prime
	int * all_primes, all_primes_len;       // 0-based prime numbers list

public:
	Eratosthenes_Sieve(int GEN_TO_VALUE = 5000010) {
		ES_MAX_GEN = max(150, GEN_TO_VALUE);   // Should NOT be less than 150 for another methods using it here (!!!)
		minimal_prime_divisor = new int[ES_MAX_GEN + 1];
		all_primes = new int[ES_MAX_GEN + 1];
		all_primes_len = 0;

		minimal_prime_divisor[0] = minimal_prime_divisor[1] = -1;
		for (int i = 2; i <= ES_MAX_GEN; i++)
			minimal_prime_divisor[i] = 0;

		for (int i = 2; i <= ES_MAX_GEN; i++) {
			if (minimal_prime_divisor[i] == 0) {
				minimal_prime_divisor[i] = i;
				all_primes[all_primes_len++] = i;
			}
			for (int j = 0;
				j < all_primes_len &&
				all_primes[j] <= minimal_prime_divisor[i] &&
				i * all_primes[j] <= ES_MAX_GEN;
				j++)
				minimal_prime_divisor[i * all_primes[j]] = all_primes[j];
		}
	}

	~Eratosthenes_Sieve() {
		if (minimal_prime_divisor != NULL)
			delete[] minimal_prime_divisor;
		if (all_primes != NULL)
			delete[] all_primes;
	}
} QQ;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	long long n, p;
	cin >> n >> p;
	long long p_save = p;

	vector<pair<long long, long long> > ms;

	for (int i=2; i<QQ.ES_MAX_GEN && (i)*((long long)(i)) <= p; i++)
		if (QQ.minimal_prime_divisor[i] == i) {
			int cnt = 0;
			while (p % i == 0) {
				cnt++;
				p /= i;
			}
			ms.push_back(make_pair(i, cnt));
		}
	if (p > 1)
		ms.push_back(make_pair(p, 1));

	int sum = 0;
	for (int i = 0; i < (int)ms.size(); i++) sum += ms[i].second;

	if (n > sum) {
		cout << "1";
		return 0;
	}

	long long ans = 1;
	for (int i = 0; i < (int)ms.size(); i++) {
		long long tk = ms[i].second / n;
		for (int j = 0; j < tk; j++) ans *= ms[i].first;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 24056
double M[12][4096],r,t;D[12],n;
double dfs(p,f){if(M[p][f]<0){
int i=0;
for(M[p][f]=0;i<n;i++)if(!(f&1<<i)&&(t=dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]),M[p][f]<t))M[p][f]=t;
}return M[p][f];}
main(l,i,j,d){for(;~scanf("%d",&l);puts(d-r>l?"NA":"OK")){
for(d=n=0;getchar()-10;d+=D[n++]*2)scanf("%d",D+n);
for(i=0;i<n;i++)for(j=0;j<1<<n;j++)M[i][j]=-1;
for(r=i=0;i<n;i++)t=dfs(i++,1<<i),r=r>t?r:t;
}exit(0);}

Measured memory_bytes: 968
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll INF = 1e17;
ll n;
ll c[4];
map<ll,ll> mp; 

ll dfs(ll n) {
  if(n == 0) return 0;
  else if(n == 1) return c[3];
  else if(mp[n] != 0) return mp[n];
  ll res = INF;
  if(INF/c[3] >= n) res = c[3]*n;
  ll mod[3] = {n % 2, n % 3, n % 5};
  ll div[3] = {2, 3, 5};
  ll nex;
  rep(i,3) {
    nex = (n - mod[i])/div[i];
    res = min(res,dfs(nex)+c[i]+mod[i]*c[3]);
    nex++;
    if(mod[i] != 0) res = min(res,dfs(nex)+c[i]+(div[i]-mod[i])*c[3]);
  }
  return mp[n] = res;
}

int main(){
  int t;
  cin >> t;
  while(t--) {
    mp.clear();
    cin >> n;
    rep(i,4) cin >> c[i];
    cout << dfs(n) << endl;
  }
  return 0;
}


Measured memory_bytes: 4412
using System;
using System.Linq;

namespace Graph_II
{
    class Single_Source_Shortest_Path_I
    {
        struct Edge
        {
            public int to;
            public int cost;
        }

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var graph = new Edge[n][];

            for (int i = 0; i < n; i++)
                graph[i] = Console.ReadLine().Trim(' ').Split(' ')
                    .Skip(2)
                    .Select((s, index) => new { val = int.Parse(s), index})
                    .GroupBy(x => x.index / 2)
                    .Select(group => group.Select(g => g.val))
                    .Select(vc => new Edge { to = vc.First(), cost = vc.Last() })
                    .ToArray();

            var used = new bool[n];
            var mincost = Enumerable.Repeat(int.MaxValue, n).ToArray();
            mincost[0] = 0;

            while (true)
            {
                var v = -1;
                for (int i = 0; i < n; i++)
                    if (!used[i] && (v == -1 || mincost[i] < mincost[v])) v = i;

                if (v == -1) break;
                used[v] = true;

                for (int i = 0; i < graph[v].Length; i++)
                    mincost[graph[v][i].to] = Math.Min(mincost[graph[v][i].to], mincost[v] + graph[v][i].cost);
            }

            for (int i = 0; i < mincost.Length; i++)
                Console.WriteLine($"{i} {mincost[i]}");
        }
    }
}



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

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

int main() {

    int n, x;

    for ( ;; ) {

        std::cin >> n >> x;

        if ( n == 0 && x == 0 ) break;

        int sum = 0;

        REP(i, n) REP(j, i) REP(k, j) {
            if ( i + j + k == x - 3 ) sum++;
        }

        std::cout << sum << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3100
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
int main()
{
    FAST
    FO
    FI
    ll n,a,b;
    IN n>>a>>b;
    ll sum=a+b;
    ll ans=n/sum;
    ans*=a;
    ll temp=n%sum;
    ans+=min(temp,a);
    OUT ans<<endl
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
using namespace std;
ll n;
ll Dfs(ll x) {
  if (x>n) return 0;
  ll y=x,ko1=0,ko2=0,ko3=0;
  while (x) {
    if (x%10==3) ko1=1;
    if (x%10==5) ko2=1;
    if (x%10==7) ko3=1;
    x/=10;
  }
  x=y;
  ll res=1;
  if (!ko1 || !ko2 || !ko3) res=0;
  res+=Dfs(x*10+3);
  res+=Dfs(x*10+5);
  res+=Dfs(x*10+7);
  return res;
}

int main() {
  cin>>n;
  cout<<Dfs(0)<<endl;
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())

if a >= k:
  a = a-k
  print(a,b)
elif a < k <= a+b:
  x = k - a
  b -= x
  a = 0
  print(a,b)
elif k > a+b:
  a = 0
  b = 0
  print(a,b)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	if(c-a-b>0&&a*b*(long long)4<(c-a-b)*(c-a-b))printf("Yes\n");
	else printf("No\n");	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  ll N, K; cin >> N >> K;
  vector<ll> array(100010, 0);
  rep(i, N){
    int a, b; cin >> a >> b;
    array[a] += b;
  }
  ll tot = 0;
  rep(i, 100010){
    tot += array[i];
    if (tot >= K) {cout << i  << endl; return 0;}
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
int main(){
    int A,B;
    cin >> A >> B;
    int a=A+B;
    if(a<A-B) a=A-B;
    if(a<A*B) a=A*B;
    
    cout << a << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N=102;
int h[105];
int r=0;
int l=0;
bool flag=0;
int num=0;

int zero(int x){
  	for(int i=0;i<=N;i++){
    	if(i==N || x+i>N-1){
          x=-1;
          break;
        }
      	else if(h[x+i]==0){
          x+=i;
          break;
        }
    }
  
  	return x;
}

void func(int left, int right){
	for(int i=left;i<=right;i++){
    	h[i]--;
    }
  	num++;
}

void c(){
	for(int i=0;i<N;i++){
    	if(h[i]!=0){
        	flag =0;
          	break;
        }
    }


}


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

  while(!flag){
    flag=1;
    r=0;l=0;
   
    c();
    if(flag) break;
    // ここまでok(全部ゼロ)
    
    l=zero(l);
    
    if(l==-1){
    	func(0,N-1);
      	c();
    }
    
    
    else if(l>0){
      func(0,l-1);
      c();
    }
    else {
      for(int j=0;j<N;j++){
      	if(h[j]!=0){
        	l=j;
          break;
        }
      }
     // cout <<l <<" " <<h[l] <<endl;
      if(l==N-1) func(N-1,N-1);
      else{
      	r=zero(l);
      	if(r>0)	func(l,r-1);
      	else func(l,N-1);
      }
      c();
    }  

  }
    
  cout <<num;
  
  
}

Measured memory_bytes: 256
import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.groupingBy;

import java.util.Arrays;
import java.util.Map;
import java.util.Scanner;

public class Main {
    static final Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) {
        int N = nint();
        int T = nint();
        int[] A = nints(N);
        
        int min = Integer.MAX_VALUE;
        int[] profit = new int[N];
        
        for (int i = 0; i < N; i++) {
            min = Math.min(min, A[i]);
            profit[i] = A[i] - min;
        }
        
        Map<Integer, Long> map = Arrays.stream(profit).boxed().collect(groupingBy(i -> i, counting()));
        Long ans = map.entrySet().stream().max((e1, e2) -> e1.getKey() - e2.getKey()).get().getValue();
        System.out.println(ans);
    }
    
    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++) {
            a[i] = nstr();
        }
        return a;
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0);
    }

    private static char[][] nchars2(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}

Measured memory_bytes: 67672
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define writeln printf("\n")
using namespace std;
typedef long long LL;
typedef double DB;
const int MAXN = 20;
const DB eps = 1e-7;
int len;
LL n, m;
int a[1000][1000];
bool val[1000][2];
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i ++)
    {
        bool row = true;
        for (int j = 1; j <= m; j ++)
        {
            char ch;
            cin >> ch;
            if (ch == '#') a[i][j] = 1;
            else if (ch == '.') a[i][j] = 2;
            if (a[i][j] == 1) row = false;
        }
        val[i][0] = row;
//        printf("val[%d][0]=%d\n", i, val[i][0]);
    }
    for (int i = 1; i <= m; i ++)
    {
        bool col = true;
        for (int j = 1; j <= n; j ++) if (a[j][i] == 1) col = false;
        val[i][1] = col;
    }
    for (int i = 1; i <= n; i ++)
    {
        if (val[i][0]) continue;
        for (int j = 1; j <= m; j ++)
        {
            if (val[j][1]) continue;
            if (a[i][j] == 1) printf("#");
            else printf(".");
        }
        printf("\n");

    }
}
/*
*/

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

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

    int len = S.length();

    int count = 0;
    rep(i, len / 2) {
        if (S[i] != S[len - i - 1]) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int n, A[50];

int solve(int i,int m){
  if(m==0)return 1;
  if(i>=n) return 0;
  int res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}

int main(){
  int q,M,i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++){
  scanf("%d",&M);
  if(solve(0,M)) printf("yes\n");
  else printf("no\n");
}
return 0;
}

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

void solve() {
    int n, k; cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++)  cin >> a[i];
    vector<int> dp(n, 0);
    dp[1] = abs(a[1] - a[0]);

    for (int i = 2; i < n; i++) {
        int best_op = INT_MAX, op = 0;
        for (int j = i - 1; j >= i - k; j--) {
            if (j >= 0)
            {   op = abs(a[i] - a[j]) + dp[j];
                best_op = min(best_op, op);
            }
        }
        dp[i] = best_op;

    }

    cout << dp.back();



}

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

}

Measured memory_bytes: 4000
#include <iostream>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c ;

    if (a == b && b == c){
        cout << 1;
    }
    else if(a == b || b == c || c == a){
        cout << 2;
    }
    else {
        cout << 3;
    }

    return 0;
}

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


using ll = long long;
using ull = unsigned long long;

int mod = 1000000007;

using namespace std;

int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;
	string str,str2;
	std::cin >> str >> str2;

	// 1つ前の状態を表す
	// 0 -> 横
	// 1 -> 縦
	int pre;
	ll ans;
	int i;
	if (str[0] == str[1]) {
		ans = 6;
		pre = 0;
		i = 2;
	}
	else {
		ans = 3;
		pre = 1;
		i = 1;
	}
	while (i < str.size()) {
		if (i == str.size() - 1) {
			if (pre == 0) {
				ans = ((ans%mod) * 1) % mod;
			}
			else if (pre == 1){
				ans = ((ans%mod) * 2) % mod;
			}
			pre = 1;
			i++;
		}
		else if(str[i] != str[i+1]){
			if (pre == 0) {
				ans = ((ans%mod) * 1) % mod;
			}
			else if (pre == 1){
				ans = ((ans%mod) * 2) % mod;
			}
			pre = 1;
			i++;
		}
		else if (str[i] == str[i+1]) {
			if (pre == 0) {
				ans = ((ans%mod) * 3) % mod;
			}
			else if (pre == 1) {
				ans = ((ans%mod) * 2) % mod;
			}
			pre = 0;
			i += 2;
		}
	}

	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    string s,t;
    cin>>s>>t;
    sort(all(s));
    
    sort(all(t));
    reverse(all(t));

    if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}




Measured memory_bytes: 3620
n = int(input())
a = list(map(int, input().split()))

x = 0
y = sum(a)
ans = float("inf")
for i in range(n):
    x += a[i]
    y -= a[i]
    if not i == n - 1:
        ans = min(ans, abs(x - y))
print(ans)


Measured memory_bytes: 24832
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 303000;
int n,k,c;
string s;
int fw[MAXN],rw[MAXN];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n >> k >> c;
  cin >> s;
  int days1 = 0, days2 = 0;
  int cur = 0;
  for(int i=0;i<n;i++){
    if(s[i]=='o' && !cur){
      cur = c;
      days1++;
      fw[i]=1;
    }
    else {
      cur--;
    }
    cur = max(cur,0LL);
  }
  reverse(all(s));
  cur = 0;
  for(int i=0;i<n;i++){
    if(s[i]=='o' && !cur){
      cur = c;
      rw[n-i-1]=1;
      days2++;
    }
    else {
      cur--;
    }
    cur = max(cur,0LL);
  }
  // cerr << days << endl;
  if(days1>k){
    return 0;
  }
  int ans = 0;
  for(int i=0;i<n;i++){
    if(fw[i] && rw[i]){
      cout << i+1 << endl;
    }
  }


return 0;
}
///....


Measured memory_bytes: 5396
def main14():
    strbuf = input('');
    num = int(strbuf);
    kari = num;
    peku = 0;
    while(True):
        iti = int(kari % 10);
        peku = peku + iti;
        if(kari<10):
            break;
        kari = (kari - iti) / 10;
    if((int(num % peku) == 0)):
        print("Yes");
    else:
        print("No");

def main15():
    strbuf1 = input('');
    strbuf2 = input('');
    buf1 = [];
    buf2 = [];
    for i in range(2):
        buf1.append(int(strbuf1[i]));
    for i in range(buf1[0]):
        buf2.append(int(strbuf2[i]));


if __name__ == '__main__':
    main14()

Measured memory_bytes: 3064
elements = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
th = K-1
print(elements[th])

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

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

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read();
    let ans = (0..n)
        .map(|_| read::<u32>().trailing_zeros())
        .min()
        .unwrap();
    println!("{}", ans)
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
int INF = 1e9+7;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    vector<ll> dp(n);
    vector<int> recon(n);
    for(int i = 0; i < n; i++)
    {
        recon[i] = -1;
    }

    ll ans = -1e10;
    int pos = 0;
    for(int i = 0; i < n; i++)
    {
        dp[i] = a[i];
        for(int j = 0; j < i; j++)
        {
            if((i-j)%2 == 0 && dp[j] + a[i] > dp[i])
            {
                dp[i] = dp[j] + a[i];
                recon[i] = j;
            }
        }
        if(ans < dp[i])
        {
            ans = dp[i];
            pos = i;
        }
    }
    vector<int> v;
    for(int i = n; i > pos+1; i--)
    {
        v.push_back(i);
    }
    while(recon[pos] != -1)
    {
        int left = recon[pos];
        while(left != pos)
        {
            v.push_back((left+1 + pos+1) / 2);
            pos -= 2;
        }
    }
    for(int i = 0; i < pos; i++)
    {
        v.push_back(1);
    }
    cout << ans << endl;
    cout << v.size() << endl;
    for(int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
}


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

#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
#define pb push_back
#define ar array

typedef long long ll;
typedef long double ld;
//using ll = long long;

typedef vector<int> vi;

const ld EPS = 1e-9, PI = acos(-1.);
const int INF = 0x3f3f3f3f, MOD = 1e9+7;

// global to problem

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

	int s,w;
	cin >> s >> w;
	(w >= s) ? cout<<"unsafe\n" : cout<<"safe\n";
}


Measured memory_bytes: 3640
//IOI 2021

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

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 100 * 1000 + 17;

int n, m, a[MAXN], cnt, ans;
vector<int> adj[MAXN], cmp[MAXN];
bool mark[MAXN];

void dfs(int v) {
	cmp[cnt].pb(v);
	mark[v] = true;
	for (auto i : adj[v])
		if (!mark[i])
			dfs(i);
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= m; i++) {
		int v, u;
		cin >> v >> u;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	for (int i = 1; i <= n; i++)
		if (!mark[i])
			cnt++, dfs(i);
	for (int i = 1; i <= n; i++)
		mark[i] = false;
	for (int i = 1; i <= cnt; i++) {
		for (auto j : cmp[i])
			mark[j] = true;
		for (auto j : cmp[i])
			if (mark[a[j]])
				ans++;
		for (auto j : cmp[i])
			mark[j] = false;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12284
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int main() {
  bool old=false;
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int mn=-100;
    tuple<int,int,int,int> tp;
    REP(i,a+1)REP(j,b+1)REP(k,c+1)REP(l,d+1){
      int sum = i*10+j*50+k*100+l*500-n;
      if(sum<0)continue;
      int e=0,f=0,g=0,h=0;
      while(sum>=500){
        sum-=500;
        ++h;
      }
      while(sum>=100){
        sum-=100;
        ++g;
      }
      while(sum>=50){
        sum-=50;
        ++f;
      }
      while(sum>=10){
        sum-=10;
        ++e;
      }
      if((i&&e)||(j&&f)||(k&&g)||(l&&h))continue;
      int num=i+j+k+l-e-f-g-h;
      if(num > mn) {
        tp=make_tuple(i,j,k,l);
      }
    }
    int i,j,k,l;
    tie(i,j,k,l)=tp;
    if(old)
      cout<<endl;
    if(i)cout<<"10 "<<i<<endl;
    if(j)cout<<"50 "<<j<<endl;
    if(k)cout<<"100 "<<k<<endl;
    if(l)cout<<"500 "<<l<<endl;
    old=true;
  }
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()

int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
//	freopen("out1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n; cin >> n;
	int m = 1 << n;
	vector<int> a(m);
	vector<pii> c(m);
	for(int i = 0; i < m; i++) {
		cin >> a[i];
		c[i] = make_pair(a[i], 0);
	}
	auto add = [&](pii &a, const pii &b) {
		if(a.se < b.fi) {
			a.se = b.fi;
			if(a.fi < a.se) swap(a.fi, a.se);
			if(a.se < b.se) a.se = b.se;
		}
	};
	for(int i = 1; i < m; i <<= 1)
		for(int j = 0; j < m; j += i * 2)
			for(int k = 0; k < i; k++)
				add(c[i + j + k], c[j + k]);
	vector<int> ans(m);
	for(int i = 1; i < m; i++) {
		ans[i] = c[i].fi + c[i].se;
		ans[i] = max(ans[i], ans[i - 1]);
		cout << ans[i] << '\n';
	}
	return 0;
}


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

#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)

using namespace __gnu_pbds;
using namespace std;

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif


std::mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int a, int b) {
    return uniform_int_distribution<int>(a, b)(rng);
}

ll power(ll x, ll y, ll p){
   ll res = 1;
   x = x % p;
   while (y > 0) {
      if (y & 1)
         res = (res * x) % p;
      y = y >> 1;
      x = (x * x) % p;
   }
   return res;
}

const ll INF = (ll)(8e18);
const ll MOD = (ll)(1e9 + 7);
const ll HMOD = (ll)4222234727;
const ll Hashprime = (ll)31;

const int maxn = 100100;

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    while(t--){
      string s; cin >> s;
      int a = stoi(s.substr(0, 2));
      int b = stoi(s.substr(2, 2));
      cerr << a << ' ' << b << '\n';
      if(b <= 12 && b > 0 && a <= 12 && a > 0){
         cout << "AMBIGUOUS" << '\n';
         return 0;
      }
      if(b <= 12 && b > 0){
         cout << "YYMM" << '\n';
         return 0;
      }
      if(a <= 12 && a > 0){
         cout << "MMYY" << '\n';
         return 0;
      }
      cout << "NA" << '\n';
    }
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "c" "comp.cpp" -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g


Measured memory_bytes: 3640
h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
cnt = 0
for i in range(h):
    cnt += c[i].count("#")
ans = 0
for bit_i in range(2 ** h):
    h_check = []
    h_cnt = 0
    for i in range(h):
        if bit_i >> i & 1:
            h_cnt += c[i].count("#")
            h_check.append(i)
    for bit_j in range(2 ** w):
        w_cnt = 0
        for j in range(w):
            if bit_j >> j & 1:
                for y in range(h):
                    if c[y][j] == "#" and  y not in h_check:
                        w_cnt += 1
        if h_cnt + w_cnt == cnt - k:
            ans += 1
print(ans)


Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007

ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) { return m / gcd(n, m) * n; }

int main(void) {
	VI a(3);
	REP(i, 3) cin >> a[i];
	sort(all(a));
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
	return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <vector>

int main(int argc, char const *argv[])
{
	std::vector<int> x, y;
	int a = 1, b = 1;
	while (!((a == 0) && (b == 0)))
	{
		std::cin >> a >> b;
		x.push_back(a);
		y.push_back(b);
	}
	for (int i = 0; i < x.size()-1; ++i)
	{
		if (x[i] > y[i])
		{
			std::swap(x[i], y[i]);
		}
		std::cout << x[i] << " " << y[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
const int INF = 1000000;
using namespace std;
int map[101][101][2];//a, b, cost, time;
int d[101];//始点からの最短距離
bool used[101];//使われたかのフラグ
int V;//頂点数

int dijkstra(int start, int end, bool flag){
	fill(d, d + V + 1, INF);
	fill(used, used + V + 1, false);
	d[start] = 0;

	while(1){
		int v = -1;
		for(int u=1;u<=V;u++){
			if(!used[u] && (v == -1 || d[u] < d[v]))v = u;
		}

		if(v == -1)break;

		used[v] = true;

		for(int u=1;u<=V;u++){
			d[u] = min(d[u], d[v] + map[v][u][flag]);
		}
	}

	return d[end];
}

int main(){
	int n, m;
	while(cin >> n >> m, n){
		V = m;

		for(int i=0;i<101;i++){
			for(int j=0;j<101;j++){
				map[i][j][0] = (map[i][j][1] = INF);
			}
		}

		for(int i=n;i;i--){
			int a, b, cost, time;
			cin >> a >> b >> cost >> time;
			map[a][b][0] = cost;
			map[a][b][1] = time;
			map[b][a][0] = cost;
			map[b][a][1] = time;
		}

		int k;
		cin >> k;
		while(k--){
			int p, q, r;
			cin >> p >> q >> r;
			cout << dijkstra(p, q, r) << '\n';
		}
	}
}

Measured memory_bytes: 1240
#include <stdio.h>

struct cards {

  char suit;
  int  value;

};

void int_swap(int *, int *);
void char_swap(char *, char *);

int main(void) 
{
  int i, j, N, min;
  int stable = 1;

  scanf("%d", &N);

  struct cards card[N], bubble[N], selection[N];

  for (i = 0; i < N; i++) {
    scanf(" %c%d", &card[i].suit, &card[i].value);

    bubble[i].suit     = card[i].suit;
    bubble[i].value    = card[i].value;
    selection[i].suit  = card[i].suit;
    selection[i].value = card[i].value;
  }

  for (i = 0; i < N; i++) 
    for (j = N - 1; j > i; j--) 
      if (bubble[j].value < bubble[j - 1].value) {
	char_swap(&bubble[j].suit, &bubble[j - 1].suit);
	int_swap(&bubble[j].value, &bubble[j - 1].value);
      }

  for (i = 0; i < N; i++) {

    min = i;

    for (j = i; j < N; j++) 
      if (selection[j].value < selection[min].value) 
	min = j;

    if (min != i) {
      char_swap(&selection[i].suit, &selection[min].suit);
      int_swap(&selection[i].value, &selection[min].value);
    }
  }

  for (i = 0; i < N; i++) {
    if (bubble[i].suit != selection[i].suit) {
      stable = 0;
      break;
    }
  }

  for (i = 0; i < N - 1; i++) 
    printf("%c%d ", bubble[i].suit, bubble[i].value);

  printf("%c%d\n", bubble[N - 1].suit, bubble[N - 1].value);
  printf("Stable\n");

  for (i = 0; i < N - 1; i++) 
    printf("%c%d ", selection[i].suit, selection[i].value);

  printf("%c%d\n", selection[N - 1].suit, selection[N - 1].value);

  if (stable == 1) 
    printf("Stable\n");
  else 
    printf("Not stable\n");

  return 0;
}

void 
int_swap(int *x, int *y) {

  int tmp;

  tmp = *x;
  *x  = *y;
  *y  = tmp;
}

void 
char_swap(char *x, char *y) {

  char tmp;

  tmp = *x;
  *x  = *y;
  *y  = tmp;
}

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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
  int N;
  ll A, B;
  cin >> N >> A >> B;
  vector<ll> X(N, 0);
  rep(i, N) cin >> X[i];

  ll ans = 0;
  rep(i, N - 1) { ans += min(A * (X[i + 1] - X[i]), B); }

  cout << ans << endl;

  return 0;
}

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    char g[H][W], h[H][W];
    rep(i, H){
        rep(j, W){
            cin >> g[i][j];
        }
    }
    //条件を満たす場合の数の個数
    int ptn = 0;
    //各状態について見る
    for(int bith = 0; bith < (1<<H); bith++){
        for(int bitw = 0; bitw < (1<<W); bitw++){
            rep(i, H) rep(j, W) h[i][j] = g[i][j];

            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                    if(((bith >> i) & 1) || ((bitw >> j) & 1)) h[i][j] = 'r';
                }
            }
            int cnt = 0;
            rep(i, H) rep(j, W) if(h[i][j] == '#') cnt++;
            if(cnt == K) ptn++;
        }
    }
    cout << ptn << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		HashSet<Long> list = new HashSet<Long>();
		boolean check = true;
		long in = 0;

		for(int i = 0;i < n;i++) {
			in = scan.nextLong();
			if(list.contains(in)) {
				check = false;
			}
			list.add(in);
		}

		if(!check) {
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}
	}
}

Measured memory_bytes: 72020
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main()
{
    string x;
    cin >> x;
    int n, cc = 1 << 30;

    for (int i = 0; i < x.size()-2; ++i) {
        string s = x.substr(i, 3);
        n = atoi(s.c_str());
        n = abs(n - 753);
        if (cc > n) cc = n;
    }
    cout << cc << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
const ll MAX = 3234566667;

vl v;

void dfs(ll depth, ll x) {
    if(MAX < x) {
        return;
    }
    v.pb(x);
    ll y = x%10;
    if(y == 0) {
        dfs(depth+1, 10*x);
        dfs(depth+1, 10*x + 1);
    }
    else if(y == 9) {
        dfs(depth+1, 10*x + 8);
        dfs(depth+1, 10*x + 9);
    }
    else {
        dfs(depth+1, 10*x + y - 1);
        dfs(depth+1, 10*x + y);
        dfs(depth+1, 10*x + y + 1);
    }
}

int main() {
    ll k;
    cin >> k;
    k--;

    exrep(i, 1, 9) {
        dfs(0, i);
    }

    sort(all(v));

    out(v[k]);
    re0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<string>
#include<vector>

using namespace std;

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

    for(int i=0 ; i<s.size() ; i++){
        n=(int)('{'-s[i])%26;
        if(n<=K){
            K=K-n;
            s[i]='a';
        }
        if(i==s.size()-1){
            s[i]=s[i]+(K%26);    
        }
        if(K==0)break;
    }
    cout<<s<<"\n";
	return 0;
}


Measured memory_bytes: 512
N = int(input())
U = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 0
rU, rB = [0]*(N+1), [0]*(N+1)

for i in range(N):
    rU[i+1] = rU[i] + U[i]
    rB[N-i-1] = rB[N-i] + B[N-i-1]

for j in range(1,N+1):
    ans = max(ans, rU[j]+rB[j-1])

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

int main() {
    int n; cin >> n;
    vector<int> a(n); rep(i, n) cin >> a.at(i);
    sort(all(a), greater<int>());

    int result = 0;
    rep(i, n) result += pow(-1, i) * a.at(i);

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

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int a, b;
  cin >> a >> b;
  int ans = (b - 1) / (a - 1);
  if ((b - 1) % (a - 1) != 0)
    ans += 1;
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int n; cin>>n;
    int m=0;
    while (m*(m+1)/2<n) ++m;
    while (n>0) {
        cout<<m<<'\n';
        n-=m;
        m=min(n, m-1);
    }
}

Measured memory_bytes: 256
n = int(input())

if n == 3:
    print(2, 5, 63)
elif n == 4:
    print(2, 5, 20, 63)
elif n == 5:
    print(2, 5, 20, 30, 63)
else:
    a = []
    count = 0
    for i in range(2, 30001):
        if i % 2 == 0 or i % 3 == 0:
            a.append(i)
            count += 1
        if count == n:
            break
    sum_a = sum(a)
    if sum_a % 6 == 0:
        print(*a)
    elif sum_a % 6 == 2:
        a[4] = 30000
        print(*a)
    elif sum_a % 6 == 3:
        a[5] = 30000
        print(*a)
    else:
        a[5] = 29998
        print(*a)



Measured memory_bytes: 4556
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];
	int x = 0;
	REP(i, N)x ^= A[i];

	int ans = 0;

	for (int i = 35; i >= 0; i--) {
		if (x&(1 << i)) {
			REP(j, N) {
				int t = A[j] ^ (A[j] - 1);
				if (t + 1 == (1 << (i + 1))) {
					x ^= t;
					ans++;
					break;
				}
			}
		}
	}


	
	
	if (x == 0)cout << ans << endl;
	else cout << -1 << endl;

	return 0;
}



Measured memory_bytes: 1024
#include <iostream>

int main(int argc, char const* argv[])
{
    const int index_max = 2000000;
    const int data_max  = 10000;
    int       n;
    std::cin >> n;
    int data[index_max];
    int backet[data_max];
    for (int i = 0; i < n; i++) {
        std::cin >> data[i];
        backet[data[i]]++;
    }

    int cnt = 0;
    for (int i = 0; i < data_max; i++) {
        for (int j = 0; j < backet[i]; j++) {
            if (cnt) {
                std::cout << " ";
            }
            std::cout << i;
            cnt++;
        }
    }
    std::cout << std::endl;

    return 0;
}



Measured memory_bytes: 10964