akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>

class uftree{
  std::vector<int> parent;
  std::vector<int> rank;
  std::vector<long long> ufsize;
  public:
  uftree(int n) : parent(n), rank(n), ufsize(n, 1) {
    for(int i = 0; i < n; i++){
      parent[i] = i;
    }
  }
  int root(int x){
    std::vector<int> update_node_arr;
    while(parent[x] != x){
      update_node_arr.push_back(x);
      x = parent[x];
    }
    for(const auto& it: update_node_arr) parent[it] = x;
    return x;
  }

  bool same(int x, int y){
    return root(x)==root(y);
  }

  long long size(int x){
    return ufsize[root(x)];
  }

  void unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x==y) return;
    long long xsize = size(x);
    long long ysize = size(y);
    if(rank[x]<rank[y]){
      parent[x] = y;
      ufsize[y] += xsize;
    }else{
      parent[y] = x;
      ufsize[x] += ysize;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }
};

int main(){
  int N;
  std::cin >> N;

  std::vector<int> index_arr(N);
  std::vector<std::tuple<int, int>> xy_arr(N);
  for(int i = 0; i < N; i++){
    int x,y;
    std::cin >> x >> y;
    x--; y--;
    xy_arr[i] = std::make_tuple(x,y);
    index_arr[i] = i;
  }

  std::vector<std::tuple<int, int, int>> edges;
  std::sort(index_arr.begin(), index_arr.end(), [&](int l, int r){return std::get<0>(xy_arr[l]) < std::get<0>(xy_arr[r]);});
  for(int i = 0; i < N-1; i++) edges.push_back(std::make_tuple(std::get<0>(xy_arr[index_arr[i+1]])-std::get<0>(xy_arr[index_arr[i]]), index_arr[i+1], index_arr[i]));
  std::sort(index_arr.begin(), index_arr.end(), [&](int l, int r){return std::get<1>(xy_arr[l]) < std::get<1>(xy_arr[r]);});
  for(int i = 0; i < N-1; i++) edges.push_back(std::make_tuple(std::get<1>(xy_arr[index_arr[i+1]])-std::get<1>(xy_arr[index_arr[i]]), index_arr[i+1], index_arr[i]));

  std::sort(edges.begin(), edges.end());
  uftree uf(N);

  long long ans = 0;
  for(auto&& it: edges){
    int length,n1,n2;
    std::tie(length,n1,n2) = it;
    if(uf.same(n1, n2)) continue;
    ans += length;
    uf.unite(n1, n2);
  }

  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 6132
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Contest.C
{
	static class Program
	{
		public static void Solve(Scanner cin)
		{
			int sx = cin.ReadInt();
			int sy = cin.ReadInt();
			int tx = cin.ReadInt();
			int ty = cin.ReadInt();

			int xdiff = tx - sx;
			int ydiff = ty - sy;

			var c = new List<char>();
			for (int i = 0; i < xdiff; i++)
			{
				c.Add('R');
			}
			for (int i = 0; i < ydiff; i++)
			{
				c.Add('U');
			}
			for (int i = 0; i < xdiff; i++)
			{
				c.Add('L');
			}
			for (int i = 0; i < ydiff + 1; i++)
			{
				c.Add('D');
			}
			for (int i = 0; i < xdiff + 1; i++)
			{
				c.Add('R');
			}
			for (int i = 0; i < ydiff + 1; i++)
			{
				c.Add('U');
			}
			c.Add('L');
			c.Add('U');
			for (int i = 0; i < xdiff + 1; i++)
			{
				c.Add('L');
			}
			for (int i = 0; i < ydiff + 1; i++)
			{
				c.Add('D');
			}
			c.Add('R');
			Console.WriteLine(string.Concat(c));
		}

		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);
			var cin = new Scanner();
			Solve(cin);
			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Read() => ReadString();

		public string ReadString()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return ReadString();
			i = 0;
			return s[i++];
		}

		public string[] ReadStringArray(int N)
		{
			string[] Array = new string[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadString();
			}
			return Array;
		}

		public int ReadInt()
		{
			return int.Parse(ReadString());
		}

		public int[] ReadIntArray(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadInt() + add;
			}
			return Array;
		}

		public long ReadLong()
		{
			return long.Parse(ReadString());
		}

		public long[] ReadLongArray(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadLong() + add;
			}
			return Array;
		}

		public double ReadDouble()
		{
			return double.Parse(ReadString());
		}

		public double[] ReadDoubleArray(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadDouble() + add;
			}
			return Array;
		}

		public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1));
	}
}

Measured memory_bytes: 13268
N, A, B, C = gets.chomp.split(" ").map(&:to_i)
l = Array.new(N)
N.times do |i|
  l[i] = gets.chomp.to_i
end
l.sort!

# lをA,B,Cに分配する組み合わせを総当たり
min_cost = Float::INFINITY
1.upto(l.size-2) do |na|
  l.combination(na).each do |a|
    vala = a.inject(&:+)
    costa = 10 * (a.size - 1) + (A - vala).abs
    resta = l.dup
    a.each {|v| resta.delete_at(resta.index(v))}
    1.upto(resta.size-1) do |nb|
      resta.combination(nb).each do |b|
        valb = b.inject(&:+)
        costb = 10 * (b.size - 1) + (B - valb).abs
        restb = resta.dup
        b.each {|v| restb.delete_at(restb.index(v))}
        1.upto(restb.size) do |nc|
          restb.combination(nc).each do |c|
            valc = c.inject(&:+)
            costc = 10 * (c.size - 1) + (C - valc).abs
            cost = costa + costb + costc
            if cost < min_cost
              min_cost = cost
            end
          end
        end
      end
    end
  end
end
puts min_cost


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

int W, H;
int field[50][50][4];
int len[50][50];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};
int INF = 100000;
int main(){
	while(cin >> W >> H, W && H){
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				len[i][j] = INF;
				for(int k = 0; k < 4; k++){
					field[i][j][k] = 0;
				}
			}
		}
		int val;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W - 1; j++){
				cin >> val;
				if(!val){
					field[i][j][0]     = 1;
					field[i][j + 1][2] = 1;
				}
			}
			if(i == H - 1) break;
			for(int j = 0; j < W; j++){
				cin >> val;
				if(!val){
					field[i][j][3]     = 1;
					field[i + 1][j][1] = 1;
				}
			}
		}
		queue<pair<int, int> > qu;
		qu.push(make_pair(0, 0));
		len[0][0] = 1;
		while(!qu.empty()){
			pair<int, int> p = qu.front();
			qu.pop();
			for(int i = 0; i < 4; i++){
				if(field[p.first][p.second][i]){
					int nx = p.second + dx[i];
					int ny = p.first + dy[i];
					if(len[ny][nx] == INF){
						len[ny][nx] = len[p.first][p.second] + 1;
						qu.push(make_pair(ny, nx));
					}
				}
			}
		}
		cout << (len[H - 1][W - 1] == INF ? 0 : len[H - 1][W - 1]) << endl;
	}
}

Measured memory_bytes: 1252
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-7
#define MOD 999377ll
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pr;
typedef pair<pair<ll, ll>, pair<ll, ll>> tup;

inline void solve()
{
	ll h;
	cin >> h;
	ll cnt = 1;
	ll otv = 0;
	while (h != 0)
	{
		otv += cnt;
		h >>= 1;
		cnt <<= 1;
	}
	cout << otv;
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

int n,m;
vi in;
vvi dp;
int f(int a,int b){
	if(dp[a][b]+1)return dp[a][b];
	
	int t=0;
	rep(i,n)if(a-in[i]>=0&&!f(a-in[i],b^1))t=1;
	return dp[a][b]=t;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin>>n>>m;
	in=vi(n);
	rep(i,n)cin>>in[i];
	dp=vvi(m+1,vi(2,-1));
	if(f(m,0))cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}





Measured memory_bytes: 14080
j = 0
while 1:
    m,n_min,n_max = map(int,input().split())
    if m == 0 and n_max == 0 and n_min == 0:
        break
    lists = []
    ans_list = []
    max = -999999999999
    for i in range(m):
        point = int(input())
        lists.append(point)
    for i in range(n_min-1,n_max):
        num = lists[i] - lists[i+1]
        if max <= num:
            max = num
            ans = i+1
    print(ans)
    


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
double v[1005],k;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%lf",&v[i]);
	sort(v,v+n);
	k=v[0];
	for(int i=1;i<n;i++)
	{
		k=(k+v[i])/2;
		//cout<<k<<endl;
	}
	//cout<<k<<endl;
	printf("%.6f\n",k);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
lista = list(map(int, input().split()))
n = 1
cou = 0
while n<=N:
    if n%2==1:
        if lista[n-1]%2==1:
            cou = cou+1
            n = n+1
        else:
            n = n+1
    else:
        n = n+1
print(cou)

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

struct UnionFind
{
    vector<int> d; /* information about links */

    UnionFind(int n = 0) : d(n, -1) {}

    int find(int x)
    {
        if (d[x] < 0)
        {
            return x;
        }
        else
        {
            // return find(d[x]); /* naive */
            return d[x] = find(d[x]); /* path-shortened (memorized) */
        }
    }

    bool unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
        {
            return false;
        }
        else if (d[x] > d[y]) /* if the size associated with the node x is smaller than that of y */
        {
            swap(x, y);
        }
        d[x] += d[y]; /* refresh the size of the tree x */
        d[y] = x;     /* have y belong to the tree x */
        return true;
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }

    int size(int x)
    {
        return -d[find(x)];
    }
};

int deg[100005];
vector<int> to[100005];

void solve(int N, int M, int K, std::vector<int> A, std::vector<int> B, std::vector<int> C, std::vector<int> D)
{
    UnionFind uf(N);

    for (int i = 0; i < M; i++)
    {
        deg[A[i] - 1]++;
        deg[B[i] - 1]++;
        uf.unite(A[i] - 1, B[i] - 1);
    }

    for (int i = 0; i < K; i++)
    {
        to[C[i] - 1].push_back(D[i] - 1);
        to[D[i] - 1].push_back(C[i] - 1);
    }

    for (int i = 0; i < N; i++)
    {
        int ans = uf.size(i) - 1 - deg[i];
        for (int u : to[i])
        {
            if (uf.same(i, u))
            {
                --ans; /* delete if they were in a same cluster when they are blocking each other */
            }
        }
        printf("%d%c", ans, i == N - 1 ? '\n' : ' ');
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    int N;
    scanf("%d", &N);
    int M;
    scanf("%d", &M);
    int K;
    scanf("%d", &K);
    std::vector<int> A(M);
    std::vector<int> B(M);
    for (int i = 0; i < M; i++)
    {
        scanf("%d", &A[i]);
        scanf("%d", &B[i]);
    }
    std::vector<int> C(K);
    std::vector<int> D(K);
    for (int i = 0; i < K; i++)
    {
        scanf("%d", &C[i]);
        scanf("%d", &D[i]);
    }
    solve(N, M, K, std::move(A), std::move(B), std::move(C), std::move(D));
    return 0;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9 + 7;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n, k;
	scanf("%d%d", &n, &k);
	ll ans = 0;
	for (; k <= n+1; k++) {
		ll tmp = (ll)(n + 1 - k) * k + 1;
		ans = (ans + (tmp % MOD)) % MOD;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3812
def factorial(n, s):
    f = 1
    for i in range(s, n + 1):
        f *= i
    return f


def nCr(n, r):
    if n == r:
        return 1
    else:
        return factorial(n, r + 1) // factorial(n - r, 1)


T = 10 ** 9 + 7
N, B = list(map(int, input().split()))
R = N - B
for i in range(1, B + 1):
    if i > R + 1:
        print(0)
    else:
        print((nCr(R + 1, i) % T) * (nCr(B - 1, i - 1) % T) % T)

Measured memory_bytes: 43816
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
const int N=100005;
multiset<int> S[N];
int n,x,y;
map<pair<int,int>,int>Map;
queue<pair<int,int> > Q;
void add(int x,int y){
	S[x].insert(y);S[y].insert(x);
	if (x>y)swap(x,y);
	Map[mp(x,y)]++;
	if (Map[mp(x,y)]==2)Q.push(mp(x,y));
}
void del(int x,int y){
	S[x].erase(S[x].find(y));
	S[y].erase(S[y].find(x));
	if (x>y)swap(x,y);
	Map[mp(x,y)]--;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=2*n-2;i++){
		scanf("%d%d",&x,&y);
		add(x,y);
	}
	for (int i=1;i<n;i++){
		while (!Q.empty()&&Map[Q.front()]<2)Q.pop();
		if (Q.empty()){
			puts("NO");
			return 0;
		}
		int x=(Q.front()).fi,y=(Q.front()).se;Q.pop();
		del(x,y);
		del(x,y);
		if (S[x].size()<S[y].size())swap(x,y);
		vector<int> v;
		for (int j:S[y])v.push_back(j);
		for (int j:v){
			del(y,j);
			add(x,j);
		}
	}
	puts("YES");
}


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

int main() {
	int64_t a;
	int64_t b =0;

	cin >> a;
	for (int i = 1; i <= a; i++) {
		if (i % 3 == 0) {

		}
		else if (i % 5 == 0) {

		}
		else {
			b += i;
		}
	}

	cout << b << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F(i, a, b) for (int i = (a); i <= (b); i++)
#define D(i, a, b) for (int i = (a); i >= (b); i--)
#define R(i, a, b) for (int i = (a); i < (b); i++)
#define N 500000
#define ALL(vt) vt.begin(), vt.end()
#define ALLR(vt) vt.rbegin(), vt.rend()
int main(){
    ll n, k; cin >> n >> k;
    ll du = n % k;
    cout << min(du,abs(du - k));
}


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

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

using namespace std;
typedef long double ld;
const ld eps = 1e-8, INF = 1e+8;

int main() {
  int h,w;
  cin>>h>>w;
  vector<string> t(h+2,string(w+2,'.'));
  REP(i,h) {
    string str;
    cin>>str;
    t[i+1] = '.'+str+'.';
  }
  reverse(begin(t),end(t));
  map<ld,int> s;
  REP(i,h+1)REP(j,w+1) {
    if (t[i][j] == t[i+1][j+1] && t[i+1][j] != t[i][j+1]) {
      if (t[i][j] == t[i][j+1]) ++s[((ld)i)/j];
      else --s[((ld)i)/j];
    }
  }
  int sum = 0;
  int mxsum = 0;
  for (auto p : s) {
    sum += p.second;
    mxsum = max(mxsum, sum);
  }
  cout << mxsum+1 << endl;
  return 0;
}

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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

ll solve(int N, int L) {
    vi a(N);
    rep(i,N) a[i] = L+(1+i)-1;
    int total = accumulate(ALL(a), 0);
    int mindiff = INT_MAX, best = INT_MIN;
    rep(i,N){
        int aji = total - a[i];
        int diff = abs(total - aji);
        if (diff < mindiff) {
            mindiff = diff;
            best = aji;
        }
    }
    return best;
}

int main() {
    int N,L; cin>>N>>L;
    cout << solve(N,L) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair<int, int> P;
 
int h, w, ans;
int castle[1001][1001], times[1001][1001];
int dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
char beach[1001][1001];
 
inline int input(){
	int temp;
	scanf("%d", &temp);
	return temp;
}

int main(){
    h = input();
    w = input();
    for(int i = 0; i < h; i++){
        scanf("%s", beach[i]);
    }
 
    queue<P> Q;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(beach[i][j] == '.'){
                Q.push(P(i, j));
            } else{
                castle[i][j] = beach[i][j] - '0';
            }
        }
    }
 
    while(Q.size()){
        P p = Q.front();
        Q.pop();
        ans = max(ans, times[p.first][p.second]);
 
        for(int i = 0; i < 8; i++){
            int y = p.first + dy[i], x = p.second + dx[i];
            if(y < 0 || y >= h || x < 0 || x >= w){
                continue;
            }
 
            castle[y][x]--;
            if(castle[y][x] == 0){
                Q.push(P(y, x));
                times[y][x] = times[p.first][p.second] + 1;
            }
        }
    }
 
    printf("%d\n", ans);
 
    return 0;
}

Measured memory_bytes: 11548
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

int N,M;
map<string,int>mp;

int main() {
	cin>>N;
	for(int i=0;i<N;i++){
		string s;
		cin>>s;
		mp[s]++;
	}
	cin>>M;
	for(int i=0;i<M;i++){
		string t;
		cin>>t;
		mp[t]--;
	}
	int ans=0;
	for(auto i:mp)ans=max(ans,i.second);
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
//  RAKSHIT KADAM
 #include <bits/stdc++.h>
 
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
 #warning !!!check the size of arrayss!!!
 
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define newMOD  998244353
 #define MAX 300006
            
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define endl "\n"
 #define x first
 #define y second
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define INF 1000000000000000005
 #define vi vector<ll>
#define pi 3.1415926535897932384626433832795
#define Endl endl
#define lb lower_bound
#define ub upper_bound
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
 
//ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}

void solve()
{
    queue<ll>q;
    for(ll i=1;i<=9;i++) q.push(i);
    ll k;
    cin>>k;
    for(ll i=1;i<k;i++)
    {
        ll p=q.front();
        q.pop();
        if(p%10)
            q.push(p*10+(p%10)-1);
        q.push(p*10+p%10);
        if(p%10!=9)
        q.push(p*10+p%10+1);
    }
    cout<<q.front()<<endl;
    
}
signed main()
{
    
   
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }

  solve();
    return 0;
    
}
 


Measured memory_bytes: 1792
from collections import deque, defaultdict, Counter
import sys
def input():
    return sys.stdin.readline().strip()

L = [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())
print(L[K - 1])

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

using namespace std;

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

    int change_to_0_first = 0;
    for(int i = 0; i < S.size(); i++)
    {
        change_to_0_first += (S[i] != '0' + i%2);
    }

    int change_to_1_first = 0;
    for(int i = 0; i < S.size(); i++)
    {
        change_to_1_first += (S[i] != '1' - i%2);
    }

    int minimum_changes = min(change_to_0_first, change_to_1_first);

    cout << minimum_changes;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;
int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a*b>c*d) cout<<a*b;
	else cout<<c*d<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine().Split();
        var a = int.Parse(str[0]);
        var b = int.Parse(str[1]);
        var c = int.Parse(str[2]);

        var min = a + b;
        if (min > b + c) min = b + c;
        if (min > a + c) min = a + c;
        WriteLine(min);
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main(void) {
	int n, i;
	int a[100];
	
	//数列の長さを入力する
	scanf("%d", &n);
	//数列の長さぶん数値を入力する
	for(i = 0; i < n; i++) {
	    scanf("%d", &a[i]);
	}
	//逆順にして出力する
	for(i = n - 1; i > 0; i--) {
	    printf("%d ", a[i]);
	}
	printf("%d\n", a[i]);
	return 0;
}



Measured memory_bytes: 2080
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,M = I()
links = [[] for _ in range(N)]
for i in range(M):
    a,b = I()
    links[a-1].append(b-1)
    links[b-1].append(a-1)
for l1 in links[0]:
    for l2 in links[l1]:
        if l2 == N-1:
            print('POSSIBLE')
            exit()
print('IMPOSSIBLE')

Measured memory_bytes: 113976
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();

            for (int i = 0; i < s.length() - 1; i++) {
                if (s.substring(i, i + 2).equals("AC")) {
                    out.println("Yes");
                    return;
                }
            }

            out.println("No");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>

using namespace std;

int main() {
  int A, B, C, X, Y;
  scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);

  printf("%d\n", min(A * X + B * Y, min(2 * C * max(X, Y), 2 * C * min(X, Y) + (X > Y ? A * (X - Y) : B * (Y - X)))));
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int main(){
    int n,k,a[200000];
    int kind=0;
    int cnt[200000]={};

    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(cnt[a[i]-1]==0)kind++;
        cnt[a[i]-1]++;
    }
    qsort(cnt,n,sizeof(int),asc);
    if(kind<=k){
        printf("%d\n",0);
        return 0;
    }

    int ans=0;
    for(int i=0;i<n;i++){
        if(cnt[i]==0)continue;
        ans+=cnt[i];
        kind--;
        if(kind<=k)break;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2556
#include <iostream>
#include <algorithm>
#include <map>
#include <string.h>
using namespace std;
int a[100005],num[100005];
map<int,int>m;
int gcd(int a,int b)
{
    int temp;
    while(b)
    {
        temp=a%b;
        a=b;
        b=temp;
    }
    return a;
}
int main()
{
  int n,x,w,maxc;
  scanf("%d%d",&n,&x);
  a[0]=x;
  for(int i=1;i<=n;i++)
  {
      scanf("%d",&w);
      a[i]=w;
  }
  sort(a,a+n+1);
  int j=0;
  for(int i=0;i<n;i++)
  {
      if(m[a[i+1]-a[i]]==0)
        m[a[i+1]-a[i]]=1,num[j++]=a[i+1]-a[i];
  }
  sort(num,num+j);
    maxc=num[0];
  for(int i=1;i<j;i++)
  {
    maxc=gcd(maxc,num[i]);
    if(maxc==1)
        break;
  }
  printf("%d\n",maxc);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/range/algorithm.hpp>
#define rep(i,n) for (int i=0; i< (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> l(m), r(m);
  rep(i,m){
    cin >> l[i] >> r[i];
  }
  decltype(l)::iterator lmax = max_element(l.begin(),l.end());
  decltype(r)::iterator rmin = min_element(r.begin(),r.end());
  size_t lindex = distance(l.begin(), lmax);
  size_t rindex = distance(r.begin(), rmin);
  int ans;
  if(r[rindex]>=l[lindex]) ans = r[rindex]-l[lindex]+1;
  else ans = 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
/*
 * 16-11-20_chu2_D.cpp
 *
 *  Created on: 2016/11/29
 *      Author: ryoma
 */
#include<iostream>
#include<algorithm>

using namespace std;

int field[210][210];
int H, W;

int dp[210][210][410];

int rs[4] = { 0, 0, 1, 1 }, re[4] = { 0, 1, 0, 1 };

int dfs(int sj, int ej, int d) {
	if (sj > W || ej > W || d - sj > H || d - ej > H || d > H + W)
		return 0;
	if (dp[sj][ej][d] > 0) {
		return dp[sj][ej][d] - 1;
	}
	int res = 0;
	for (int i = 0; i < 4; i++) {
		res = max(res, dfs(sj + rs[i], ej + re[i], d + 1));
	}
	res += field[d - sj][sj] + field[d - ej][ej];
	if (sj == ej)
		res -= field[d - sj][sj];
	dp[sj][ej][d] = res + 1;
	return res;
}

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> field[i][j];
		}
	}
	cout << dfs(0, 0, 0) << endl;

	return 0;
}



Measured memory_bytes: 65792
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int x = in.nextInt();
            int y = in.nextInt();
            out.println(Math.min(k, n) * x + (n - k < 0 ? 0 : n - k) * y);
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 31572
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int N;
	cin >> N;
	cout << divcel(N, 2) << endl;

	return 0;
}


Measured memory_bytes: 3504
s = input()[::-1]
v = 0
mods = [ 0 for i in range(2019) ]
mods[0] = 1
d = 1

for c in s:
    v += int(c) * d
    v %= 2019
    d *= 10
    d %= 2019
    mods[v] += 1

ans = 0
for n in mods:
    ans += (n * (n - 1)) // 2

print(ans)

Measured memory_bytes: 9352
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

template<typename T>
vector<T> getVector(int N) {
    vector<T> v(N);
    REP(i, N) cin >> v[i];
    return v;
}

char s[1000020];

bool check(vector<pair<int, int> > &v) {
    int l = 0;
    for (auto &p : v) {
        if (l + p.first < 0) {
            return false;
        }
        l += p.second;
    }
    return true;
}

int main(void)
{
    int N;
    cin >> N;
    vector<pair<int, int> > lv;
    vector<pair<int, int> > rv;
    int totL = 0;
    REP(i, N) {
        scanf("%s", s);
        int l = 0;
        int m = 0;
        for (int j = 0; s[j]; j++) {
            if (s[j] == '(')
                l++;
            else
                l--;
            m = min(m, l);
        }
        totL += l;
        if (l >= 0) {
            lv.push_back({m, l});
        }
        else {
            l = 0;
            m = 0;
            for (int j = strlen(s)-1; j>=0; j--) {
                if (s[j] == ')')
                    l++;
                else
                    l--;
                m = min(m, l);
            }
            assert(l > 0);
            rv.push_back({m, l});
        }
    }
    if (totL != 0) {
        cout << "No" << endl;
        return 0;
    }

    sort(lv.rbegin(), lv.rend());
    sort(rv.rbegin(), rv.rend());
    if (check(lv) && check(rv)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 11328
#include<iostream>
#include<math.h>
using namespace std;

int main() {
  int x, n,n1;
  cin >> x;
  n = ceil(x/1.08);
  n1 = n*1.08;
  if (n1==x) {
    cout << n << endl;
  }
  else {
    cout << ":(" << endl;
  }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            string[] val = Console.ReadLine().Split(' ');

            int[] intArray = val.Select(int.Parse).ToArray();
            Array.Sort(intArray);

            int a = intArray[num/2-1];
            int b = intArray[num/2];
            int count = 0;

            count = (b - a - 1);

            int[] c = Array.FindAll(intArray, delegate (int f) { return f < a; });
            int[] d = Array.FindAll(intArray, delegate (int f) { return f < b; });

            if (c.Length == num / 2)
                count++;
            if (d.Length == num / 2)
                count++;
            if (count < 0)
                count = 0;

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 20576
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B):
    def f(n):
        ans = 0
        n += 1
        for i in range(41):
            c = 1 << (i+1)
            d = (n // c) * (c // 2)
            d += max(0, n % c - c // 2)
            if d % 2 == 1:
                ans += 1 << i

        return ans

    return f(A-1) ^ f(B)


def main():
    A, B = read_int_n()
    # A = [read_int_n() for _ in range(N)]
    print(slv(A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6376
#include<bits/stdc++.h>
#define int long long
const int mod=998244353;
using namespace std;
const int maxn=1e5+10;
char s[3*maxn];
main(){
    int n;
    scanf("%lld%s",&n,s);
    int r,g,b,rg,rb,gb;
    r=g=b=rg=rb=gb=0;
    int ans=1;
    for(int i=0;s[i];++i){
        if(s[i]=='R'){
            if(gb){
                ans=ans*gb%mod;
                gb--;
            }
            else if(g){
                ans=ans*g%mod;
                rg++;
                g--;
            }
            else if(b){
                ans=ans*b%mod;
                rb++;
                b--;
            }
            else r++;
        }
        else if(s[i]=='G'){
            if(rb){
                ans=ans*rb%mod;
                rb--;
            }
            else if(r){
                ans=ans*r%mod;
                rg++;
                r--;
            }
            else if(b){
                ans=ans*b%mod;
                gb++;
                b--;
            }
            else g++;
        }
        else {
            if(rg){
                ans=rg*ans%mod;
                rg--;
            }
            else if(r){
                ans=ans*r%mod;
                rb++;
                r--;
            }
            else if(g){
                ans=ans*g%mod;
                gb++;
                g--;
            }
            else b++;
        }
    }
    for(int i=1;i<=n;++i)ans=ans*i%mod;
    printf("%lld\n",ans);
}


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

#define mod 1000000007
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c;
    cin >> a >> b >> c;
    for(ll i = b; i <= c; i++){
        if(i%a==0){
            cout << "OK";
            return 0;
        }
    }
   
    cout << "NG";
    return 0;
}

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

long gcd(long a, long b) {
    int r = a % b;
    if(r == 0){
        return b;
    } else {
        gcd(b,r);
    }
}

long lcm(long a, long b) {
    return (a * b) / gcd(a, b);
}
int main(void) {
    int A , B;
    cin >> A >> B;

    unsigned long lc = lcm(max(A,B), min(A,B));
    cout << lc << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#define int long long
using namespace std;
typedef pair<int, int> P;

int h, w, n;
int a, b;
set<P> blackCells;
set<P> leftCorns;
int cntTable[10];

signed main() {
	int i;
	
	cin >> h >> w >> n;
	for (i = 0; i < n; i++) {
		cin >> a >> b;
		a--; b--;
		blackCells.insert(P(a, b));
		for (int dy = -2; dy <= 0; dy++) {
			for (int dx = -2; dx <= 0; dx++) {
				int ny = a + dy;
				int nx = b + dx;
				if (0 <= ny && ny < h - 2 && 0 <= nx && nx < w - 2) {
					leftCorns.insert(P(ny, nx));
				}
			}
		}
	}
	
	for (set<P>::iterator it = leftCorns.begin(); it != leftCorns.end(); it++) {
		int ty = it->first;
		int tx = it->second;
		int cnt = 0;
		for (int dy = 0; dy < 3; dy++) {
			for (int dx = 0; dx < 3; dx++) {
				int y = ty + dy;
				int x = tx + dx;
				if (blackCells.find(P(y, x)) != blackCells.end()) {
					cnt++;
				}
			}
		}
		cntTable[cnt]++;
	}
	
	int ssum = 0;
	for (i = 1; i < 10; i++) ssum += cntTable[i];
	cntTable[0] = (h - 2) * (w - 2) - ssum;
	
	for (i = 0; i < 10; i++) {
		cout << cntTable[i] << endl;
	}
	return 0;
}

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

typedef long long int ll;

int main(void) {
	int n, a, b;
	ll ans, x0, x1;

	cin >> n >> a >> b;
	cin >> x0;
	ans = 0;
	for (int i = 1; i < n; ++i) {
		cin >> x1;
		ans += min((x1 - x0) * (ll)a, (ll)b);
		x0 = x1;
	}

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


Measured memory_bytes: 256
Module Module1

    Sub main()
        Dim user2 = Split(Console.ReadLine(), " ")
        Dim sumAnimals As Integer = user2(0)
        Dim legs As Integer = user2(1)
        Const TSURU = 2, KAME = 4

        Dim result = "No"
        ' 亀の数

        For i = sumAnimals To 0 Step -1
            If i * KAME + (sumAnimals - i) * TSURU = legs Then
                result = "Yes"
                Exit For
            End If
        Next

        Console.WriteLine(result)
    End Sub
end module

Measured memory_bytes: 28284
while true
    n = gets.to_i
    break if n == 0

    table = [0]
    n.times{|i|
        table[i + 1] = table[i] + gets.to_i
    }

    answers = []
    1.upto(n){|interval|
        interval.upto(n){|right|
            answers << table[right] - table[right - interval]
        }
    }
    puts answers.max
end

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

string N;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  cin >> N;

  if(N.find('7') != -1) cout << "Yes\n";
  else cout << "No\n";

  return 0;
}

Measured memory_bytes: 3616
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin >> a>>b>>c;
    if (( a==5 && b ==5&& c==7)||(a==7 && b==5 && c== 5 )||(a==5 && b == 7 && c == 5) )
    {
        cout<<"YES";

    } else
    cout << "NO";
    return 0;
}



Measured memory_bytes: 256
/*
Voronoi Diagram in Metric Space
Time complexity: (N + M) log (N + M)

Other problems that can be solved using this method:
https://atcoder.jp/contests/keyence2019/tasks/keyence2019_e
https://codeforces.com/problemset/problem/1095/F
*/

//Credits to http://tokoharuland.hateblo.jp/entry/2018/04/01/155743
//Good explanation at http://koba-e964.hatenablog.com/entry/2019/01/14/200541
//Try to use google translate (in case you don't understand japanese)
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define endl '\n'
using namespace std;

typedef long long LL;

const int N = 5e5;
const LL INF = 1e18;
LL arr[N + 5];
vector<pair<int,LL> > vec[N + 5];
vector<pair<LL, pair<int,int> > > edges;

int par[N + 5];
int col[N + 5];
LL dist[N + 5];

int find(int x) {
	if(x == par[x]) return x;
	return par[x] = find(par[x]);
}

LL voronoiGraphMST(int n) {
	for(int i = 1;i <= 2 * n;i++) par[i] = i, col[i] = -1;
	priority_queue<pair<LL, pair<int,int> > > pq; //cost, idx, color
	for(int i = 1;i <= n;i++) pq.push({0, {i, i}});
	while(!pq.empty()) {
		LL cost = -pq.top().FI;
		int idx = pq.top().SE.FI;
		int color = pq.top().SE.SE;
		pq.pop();
		if(col[idx] == -1) { //If this vertex hasn't been visited
			dist[idx] = cost; 
			col[idx] = color; //mark this vertex with current color
			for(int i = 0;i < vec[idx].size();i++) {
				int nx = vec[idx][i].FI;
				LL ncost = vec[idx][i].SE;
				pq.push({-cost - ncost, {nx, color}});
			}
		} else {
			if(color != col[idx]) { 
				//if the color is different, then it must be intersection ofboth vertices
				edges.PB({cost + dist[idx],{col[idx], color}}); //potential edges
			}
		}
	}
	//Do the usual MST
	LL res = 0;
	sort(edges.begin(), edges.end());
	for(int i = 0;i < edges.size();i++) {
		LL ct = edges[i].FI;
		int u = edges[i].SE.FI;
		int v = edges[i].SE.SE;
		if(find(u) != find(v)) {
			res += ct;
			par[find(u)] = find(v);
		}
	}
	return res;
}

void solve() {
	int n;
	cin>>n;
	for(int i = 1;i <= n;i++) {
		cin>>arr[i];
		vec[i].PB({i + n, arr[i]});
		vec[i + n].PB({i, arr[i]});
	}
	for(int i = 1;i < n;i++) {
		int u,v,w;
		cin>>u>>v>>w;
		vec[u + n].PB({v + n, w});
		vec[v + n].PB({u + n, w});
	}
	cout<<voronoiGraphMST(n)<<endl;
}

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	solve();
	return 0;
}




Measured memory_bytes: 77028
#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 D[9];
int K;
bool check(int num) {
    while(num > 0){
        int tmp = num % 10;
        rep(i, K) {
            if (tmp == D[i]) return false;
        }
        num /= 10;
    }
    return true;
}


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N >> K;

    rep(i, K) cin >> D[i];
    while(true) {
        if (check(N)) {
            cout << N << endl;
            return 0;
        }
        N++;
    }



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int n, m;
int main() {
  while (cin >> n >> m) {
	for (int i = 0; i < n; ++i) {
	  string str;
	  cin >> str;
	  for (int j = 0; j < 2; ++j) cout << str << endl;
	}
  }
}


Measured memory_bytes: 256