akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


int main()
{
    int n , m ,c;
    cin>>n>>m>>c;
    int ans=0;
    int b[m];
    for(int i=0;i<m;i++ )
    {
        cin>>b[i];
    }
    for(int i=0;i<n;i++)
    {
        int a[m];
        int sum =0;
        for(int i=0;i<m;i++)
        {
            cin>>a[i];
            sum += a[i] * b[i];
        }
        sum += c;
        if( sum>0)
            ans++;
    }
    cout<<ans;
}

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

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        int c = 0;
        while (s.length() >= 2) {
            int vm = -1;
            for (int j = 1; j < s.length(); ++j) {
                int t1 = atoi(s.substr(0, j).c_str());
                int t2 = atoi(s.substr(j, s.length()-j).c_str());
                vm = max(vm, t1*t2);
            }
            ++c;
            s = to_string(vm);
        }
        cout << c << endl;
    }
}

Measured memory_bytes: 3264
#include <stdio.h>


int main(int argc, char const *argv[])
{
	int inputA;
	int inputB;
	
	scanf("%d %d", &inputA, &inputB);

	if(inputA > inputB) {
		printf("a > b\n");
	}
	else if (inputB > inputA)
	{
		printf("a < b\n");
	}
	else
	{
		printf("a == b\n");
	}
	
	return 0;
}


Measured memory_bytes: 2104
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

from heapq import heapify,heappop,heappush
def dijkstra(G,s = 0): #sを始点とした最短経を求める
    n = len(G)
    dist = [INF] * n
    dist[s] = 0
    q = [(0,s)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for e,cost in G[v]:
            if dist[e] > dist[v] + cost:
                dist[e] = dist[v] + cost
                heappush(q,(dist[e],e))
    return dist

def main():
    V,E,r = map(int,input().split())
    G = [[] for _ in range(V)]
    for _ in range(E):
        s,t,d = map(int,input().split())
        G[s].append((t,d))
    
    dist = dijkstra(G,s = r)
    print('\n'.join(map(lambda x:'INF' if x == INF else str(x),dist)))
if __name__ == '__main__':
    main()


Measured memory_bytes: 94688
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
typedef pair<int,pair<int, int>> P1;

using Graph = vector<vector<int>>;

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

  int H, A;
  cin >> H >> A;
  cout << (H+A-1)/A << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a[200005],b[200005],ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
	     cin>>a[i],b[a[i]]++;
	for(int i=1;i<=n;i++) 
	    if(b[i]>1) ans+=b[i]*(b[i]-1)/2;
	for(int i=1;i<=n;i++)
		cout<<ans-b[a[i]]+1<<endl;
	return 0;
}
//68871358
//76140264
//25446011
//200841159
//914174775

Measured memory_bytes: 4736
N = gets.to_i
A = gets.split.map &:to_i
min = A.min
sorted = Array.new(N, false)
sortedA = A.sort
cost=0

A.each_with_index {|e, i|
    index = sortedA.index(e)
    next if sorted[i] or index == i
    sorted[i] = true
    sum = e
    cycleMin = e
    num = 1
    value = e
    until index == i
        sorted[index] = true
        num+=1
        value = A[index]
        sum += value
        if value < cycleMin
            cycleMin = value
        end
        index = sortedA.index(A[index])
    end
    cost1 = cycleMin * (num - 3)
    cost2 = min * (num + 1)
    cost += sum + cycleMin + (cost1<=cost2 ? cost1 : cost2)
}
puts cost

Measured memory_bytes: 6124
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	M = int(input())
	C = 0
	D = 0
	for i in range(M):
		d, c = getlist()
		C += c
		D += d * c
	ans = C - 1
	while True:
		if D >= 10:
			ans += D // 10
			D = D // 10 + D % 10
			#print(D)
		else:
			break
	print(ans)

if __name__ == '__main__':
	main()

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

typedef long long ll;

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

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

    int A, B;
    cin >> A >> B;
    int x = A + B;

    if(x >= 10) cout << "error" << endl;
    else cout << x << endl;
}

Measured memory_bytes: 256
//InTheNameOfGod
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
ll n;
ll s(ll u)
{
    ll o=0;
    while(u)
    {
        o+=u%10;
        u/=10;
    }
    return o;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    if(n%s(n))cout<<"No";
    else cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 10;
int a[N] , n;

int main(){
    cin >> n;
    int ans=1,del=1;
    rep(i,0,n) cin >> a[i] , ans *= 3 , del *= a[i] & 1 ? 1 : 2;
    cout << ans - del << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define   LF      '\n'
#define   ALL(x)  x.begin(), x.end()
#define   iostreamBooster()  do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f'3f3f3f3fLL;


signed main()
{
  int cnt[4] { };
  int a, b;
  for (int i= 0; i < 3; ++i) {
    cin >> a >> b;
    --a, --b;
    ++cnt[a];
    ++cnt[b];
  }

  sort(cnt, cnt+4);
  if (cnt[0] == 1 && cnt[1] == 1 && cnt[2] == 2 && cnt[3] == 2) {
    puts("YES");
  } else {
    puts("NO");
  }

  return 0;
}



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

using namespace std;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;





int main()
{
	int N, K;
	cin >> N >> K;

	vec V(N);

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

	int ans = 0;
	
	for (int p = 0; p <= N && p <= K; ++p)
	{
		for (int q = 0; (p + q) <= N && (p + q) <= K; ++q)
		{
			lst M;
			int total = 0;

			for (int i = 0; i < p; ++i)
			{
				total += V[i];
				if (V[i] < 0) { M.push_back(V[i]); }
			}

			for (int i = N-q; i < N; ++i)
			{
				total += V[i];
				if (V[i] < 0) { M.push_back(V[i]); }
			}

			M.sort();

			for (int i = 0; i < K - p - q && !M.empty(); ++i)
			{
				total -= M.front();
				M.pop_front();
			}

			ans = max(ans, total);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  string s;
  cin >> s;
  deque<char> d;
  rep(i,s.size()) d.push_back(s[i]);
  int q;
  cin >> q;
  bool reversed = 0;
  rep(i,q){
    int que;
    cin >> que;
    if(que == 1) reversed = !reversed;
    if(que == 2){
      int f;
      char c;
      cin >> f >> c;
      if(f == 1){
        if(!reversed) d.push_front(c);
        else d.push_back(c);
      }
      if(f == 2){
        if(!reversed) d.push_back(c);
        else d.push_front(c);
      }
    }
  }
  if(reversed){
    while(!d.empty()){
      char tmp = d.back();
      d.pop_back();
      cout << tmp;
    }
  }else{
    while(!d.empty()){
      char tmp = d.front();
      d.pop_front();
      cout << tmp;
    }
  }
  cout << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int w, h, n;

	cin >> w >> h >> n;

	int left = 0;
	int right = w;
	int top = h;
	int bottom = 0;
  	int x, y, a;

	int i;

	rep(i, n) {
		cin >> x >> y >> a;

		if (a == 1) Max(left, x);
		else if (a == 2) Min(right, x);
		else if (a == 3) Max(bottom, y);
		else if (a == 4) Min(top, y);
	}

	Out(max(0, right - left) * max(0, top - bottom));
	
	return 0;
}


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

int main(void){
    int n,m,x;
    cin >> n >> m >> x;

    int ans1=0, ans2=0;
    int a;
    for(int i=0; i<m; i++){
        cin >> a;
        if(a < x){
            ans1++;
        }else if(a > x){
            ans2++;
        }
    }

    cout << min(ans1, ans2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
const int mod=1e9+7;
int main (){
    ll m1 , d1 , m2 ,d2 ;
    cin >> m1 >> d1 >> m2 >> d2 ;

    if(d2 - d1 != 1){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
   
   return 0 ;
}

 


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>; using vvi = vector<vector<int>>;
using vl = vector<ll>; using vvl = vector<vector<ll>>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
//#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n;
  cin >> n;
  vi a(n);
  REP(i,n) cin >> a[i];
  sort(ALL(a));
  int b = a.back();
  a.pop_back();
  int s = accumulate(ALL(a),0);
  cout << (b<s?"Yes":"No") << endl;
}

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

int N, M, a[100010], b[100010];
using namespace std;

int dp[100010];
typedef pair<int,int> p;

int main() {
   cin >> N >> M;
   vector<p> vec(M+1);
   for (int i=1;i<=M;i++) {
      int a_1, b_1;
      cin >> a_1 >> b_1;
      vec[i] = make_pair(a_1,b_1);
   }
   std::sort(vec.begin(), vec.end(), [](p x, p y) -> int {
	 return (x.second < y.second );
	 });

   int c = 0;
   int counter = 0;
   for (int i=1;i<=M;i++) {
      //cout << vec[i].first << " : " << vec[i].second << ":" << c << endl;
      if (vec[i].first < c) {
	 continue;
      } else {
	 c = vec[i].second;
	 counter++;
	 //cout << c << " " << counter << endl;
      }
   }
   cout << counter << endl;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int a,b,c,x,y,d,ans,z;
int main(void){
    cin>>a>>b>>c>>x>>y;
    d=min(x,y);
    z=max(x,y);
    if(a+b>2*c){
        ans=d*2*c+(x-d)*a+(y-d)*b;
    }
    else ans=a*x+b*y;
    cout<<min(ans,2*z*c)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n; cin >> n;
    ll MOD = 1e9+7;
    string s; cin >> s;

    ll dp[n+1][n+1];
    rep(i,n+1)rep(j,n+1)dp[i][j] = 0;
    srep(j,1,n+1) dp[1][j] = 1; 

    srep(i,2,n+1){
        char c = s[i-2];
        if(c == '>'){
            ll sum = dp[i-1][n+2-i];
            drep(j,n+2-i){
                if(j == 0)break;
                dp[i][j] = sum;
                sum = (sum + dp[i-1][j]) % MOD;
            }
        }else{
            ll sum = 0;
            srep(j,1,n+2-i){
                sum = (sum + dp[i-1][j]) % MOD;
                dp[i][j] = sum;
            }
        }
    }

    cout << dp[n][1] << endl;
    return 0;
}




Measured memory_bytes: 70656
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

const int nax = 1e5 + 5;
vector<vector<int>> adj(nax);
vector<int> in_degree(nax);
vector<int> dist(nax, 0);
vector<int> visited(nax);
int n, e;

void dfs(int a){
	visited[a] = true;
	for(auto b: adj[a]){
		dist[b] = max(dist[b], dist[a] + 1);
		--in_degree[b];
		if(in_degree[b] == 0)
			dfs(b);
	}
}

signed main() {
 
	crap;

	cin >> n >> e;
	int t = e;
	while(t--){
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		++in_degree[b];
	}


	for (int i = 1; i <= n; ++i){
		if(!visited[i] and in_degree[i] == 0)
			dfs(i);
	}

	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans = max(ans, dist[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11264
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int h, w; cin >> h >> w;
		if (h == 0) break;
		int x = h * h + w * w;
		i_i mini(150 * 150, 150);
		for (int H = 1; H <= 150; H++)
			for (int W = H + 1; W <= 150; W++) {
				int X = H * H + W * W;
				if (i_i(X, H) > i_i(x, h))
					mini = min(mini, i_i(X, H));
			}
		int X = mini.first, H = mini.second;
		int W = sqrt((double)X - H * H);
		cout << H << ' ' << W << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)

#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define lei(v) int(v.length())
#define lel(v) ll(v.length())
#define rev(v) reverse(v.begin(),v.end())
#define so(v) sort(v.begin(),v.end())
#define pb(n) push_back(n)

#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl

#define fi first
#define se second
#define ve vector
#define pa pair

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;
typedef vector<vector<pair<int,int>>> vvp;


int N;
vi A;
vvp B;

int ans = 0;

bool check(string S){
    vi C(N,0);
    rep(i,N) if(S[i] == '1') C[i] = 1;
    
    rep(i,N){
        if(S[i] == '1'){
            rep(j,A[i]){
                pa<int,int> P = B[i][j];
                if(C[P.fi] != B[i][j].se) return false;
            }
        }
    }
    return true;
}


void dfs(int n, string S,int v){
    
    if(n==N){
        if(check(S)) ans = max(ans,v);
        //out(S);
    }else{
        dfs(n+1,S+'1',v+1);
        dfs(n+1,S+'0',v);
    }
}


int main()
{
    cin >> N;
    A.res(N);
    B.res(N);
    
    rep(i,N){
        cin >> A[i];
        rep(j,A[i]){
            int x,y;
            cin >> x >> y;
            x--;
            B[i].push_back({x,y});
        }
    }
    
    string aa = "";
    dfs(0,aa,0);
    out(ans);
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#include <queue>
#define int long long
using namespace std;
int32_t main(){
    int x, y;
    cin >> x >> y;
    int ans = 0;
    while (x <= y){
        ans++;
        x*=2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,int> P;
typedef pair<LL,P> PP;
const LL INF=1LL<<60;
vector<P> G[100000];
vector<PP> E;
LL dist[100000];
map<LL,LL> m;
int main() {
    int N,M;
    LL C;
    scanf("%d %d %lld",&N,&M,&C);
    for(int i=0;i<M;i++) {
        int A,B;
        LL D;
        scanf("%d %d %lld",&A,&B,&D); A--;B--;
        G[A].push_back(P(B,D));
        G[B].push_back(P(A,D));
        E.push_back(PP(D,P(A,B)));
    }
    priority_queue<P,vector<P>,greater<P> > Q;
    fill((LL*)dist,(LL*)(dist+100000),INF);
    Q.push(P(0,0));
    dist[0]=0;
    while(!Q.empty()) {
        P p=Q.top();Q.pop();
        int x=p.second;
        LL d=p.first;
        if(dist[x]<d) continue;
        for(int i=0;i<G[x].size();i++) {
            int to=G[x][i].first;
            LL cost=G[x][i].second;
            if(dist[x]+cost<dist[to]) {
                dist[to]=dist[x]+cost;
                Q.push(P(dist[to],to));
            }
        }
    }
    LL sum=0;
    for(int i=0;i<E.size();i++) {
        LL d=E[i].first;
        int a=E[i].second.first;
        int b=E[i].second.second;
        if(dist[a]>dist[b]) swap(a,b);
        m[dist[b]]+=d;
        sum+=d;
    }
    vector<LL> V;
    for(int i=0;i<N;i++) {
        V.push_back(dist[i]);
    }
    sort(V.begin(),V.end());
    V.erase(unique(V.begin(),V.end()),V.end());
    LL ans=sum;
    for(int i=0;i<V.size();i++) {
        sum-=m[V[i]];
        ans=min(ans,sum+C*V[i]);
    } 
    printf("%lld\n",ans);  
}

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

#pragma region Macros
using ll = long long;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define int ll
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#pragma endregion

const int MAX_N = 100010;

signed main() {
    IOS;

    V<> X(5, 0);
    int ans = 0;
    REP(i, 5) {
         cin >> X[i];
         if(X[i] == 0) {
             print(i+1);
             return 0;
         }
    }

    return 0;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    char table[n][n];
    char tmp[m][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>table[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            cin>>tmp[i][j];
        }
    }
    for(int i=0;i<=n-m;i++){
        for(int j=0;j<=n-m;j++){
            if(table[i][j]==tmp[0][0]){
                for(int k=0;k<m;k++){
                    for(int l=0;l<m;l++){
                        if(table[i+k][j+l]==tmp[k][l]){
                            continue;
                        }else{
                            goto Exit;
                        }
                    }
                }
                cout<<"Yes\n";
                return 0;
            }
            Exit:;
        }
    }
    cout<<"No\n";
}


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

#define MAX 100000
typedef long long ll;

int n, k;
ll T[MAX];


int check(int p){
  int i = 0;
  for(int j = 0; j < k; j++){
    ll s = 0;
    while(s + T[i] <= p){
      s += T[i];
      i++;
      if(i == n) return n;
    }
  }
  return i;
}

int solve(){
  ll left = 0;
  ll right = 1000000000;
  ll mid;
  while( right > left){
    mid = (left + right) / 2;
    int v = check(mid);
    if (v>=n) right = mid;
    else left = mid + 1;
  }
  return right;
}

int main(){
  cin >> n >> k;
  for(int i = 0; i < n; i++) cin >> T[i];
  ll ans = solve();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3856
/*Author : Sambhu show(jgec)*/
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itc ll t;cin>>t;while(t--)
#define PI 3.141592653589793238
#define Max(a,b,c) max(a,max(b,c));
#define Min(a,b,c) min(a,min(b,c));
#define all(v) v.begin(),v.end()
#define ll long long int
#define ld long double
#define pb push_back
#define eb emplace_back
#define gcd(a,b) __gcd(a,b)
#define fi first
#define se second
#define endl "\n"
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int XX[8] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
int tc = 0;
void solve()
{
	int n, k;
	cin >> n >> k;
	int ar[n + 1];
	for (int i = 1; i <= n; i++)cin >> ar[i];

	for (int i = k + 1; i <= n; i++)
	{
		if (ar[i] > ar[i - k])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}
int main()
{
	fio
	//itc
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 4352
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}
void printvi(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
void printvil(vector<int> v){rep(i,0,v.size()){cout<<v[i]<<endl;}}
void printvvi(vector<vector<int>> v){
    rep(i,0,v.size()){
        rep(j,0,v[i].size())cout<<v[i][j];
        cout<<endl;
    }
}
void printvstr(vector<string> v){
    rep(i,0,v.size()){
        cout<<v[i]<<endl;
    }
}

signed main (){
    string s[3];
    rep(i,0,3)cin>>s[i];
    if(s[0][s[0].size()-1]==s[1][0]&&s[1][s[1].size()-1]==s[2][0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    
}
/*

*/


Measured memory_bytes: 256
S = list(input())
K = int(input())

n = len(S)
start = 0
i = 0
while i < n and S[0] == S[i]:
    start += 1
    i += 1

if i == n:
    print ((n * K) // 2)
    exit()

lst = [start]
count = 1
tmp = i
i += 1
while i < n:
    if S[tmp] == S[i]:
        count += 1
        i += 1
    else:
        lst.append(count)
        count = 1
        tmp = i
        i += 1

lst.append(count)
# print (lst)
if S[0] != S[-1]:
    ans = 0
    for i in lst:
        ans += i // 2
    print (ans * K)
else:
    ans = (lst[0] + lst[-1]) // 2
    for i in lst[1:-1]:
        ans += i //2
    ans *= (K - 1)
    # print (ans)
    for i in lst:
        ans += i //2
    print (ans)
    
    



Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
// #include <atcoder/all>
// using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

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

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    vector<int> b(128);
    rep (i, s.size()) {
        if (b[s[i]]) {
            cout << "no\n"; return 0;
        }
        b[s[i]] = true;
    }
    cout << "yes\n";
    /***************************************************/
    /* Use "submit code (with ACL v1)" when using ACL! */
    /***************************************************/
    return 0;
}

Measured memory_bytes: 3620
import sys


if __name__ == '__main__':
    N = int(input())
    S = str(input())

    S_list = list(S)

    answer = - sys.maxsize
    for i in range(1,len(S)):
        left_S = S_list[:i:]
        right_S = S_list[i::]
        cnt_both_S = len(set(left_S) & set(right_S))
        answer = max(answer, cnt_both_S)

    print(answer)

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

using namespace std;
using ll = long long;

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

int main() {
  int s, w;
  cin >> s >> w;
  if (s <= w)
    puts("unsafe");
  else
    puts("safe");
  return 0;
}


Measured memory_bytes: 3556
#include <stdio.h>

int main(){
  int N,A[100];
    int i,j,flag,temp;

  scanf("%d",&N);
  if(1 <= N && N <= 100 ){
    for (j=0;j<N;j++){
      scanf("%d",&A[j]);
	}
  flag = 1;
  
  while (flag != 0){
    flag = 0;
   for (j =N-1;j>=1;j--){

    if(A[j] < A[j-1]){
      temp = A[j];
      A[j] = A[j-1];
      A[j-1] = temp;
      flag = 1;
      i++;
    }
   }
  }

  for(j=0;j<N-1;j++){
    printf("%d ",A[j]);
  }
  printf("%d",A[N-1]);
  printf("\n");
  printf("%d",i);
  printf("\n");
    }
return 0;
}


Measured memory_bytes: 2104
# https://atcoder.jp/contests/abc110/tasks/abc110_d
# 誤読をしないように気をつけよう
# 発想は惜しいところまで行っていたしもう一回解いてみよう

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


def factorization(n: int):
    if n == 1:
        return []  # 1は素数ではない
    # 素因数分解
    arr = []
    temp = n
    for i in range(2, int(n**0.5) + 1):  # ここにバグがないか心配
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append((i, cnt))

    if temp != 1:
        arr.append((temp, 1))

    if arr == []:
        arr.append((n, 1))

    return arr


def combination_mod(n, r, mod):
    if r > n:
        return 0  # このような通りの数は無いため便宜上こう定義する
    r = min(r, n - r)
    nf = rf = 1
    for i in range(r):
        nf = nf * (n - i) % mod
        rf = rf * (i + 1) % mod
    return nf * pow(rf, mod - 2, mod) % mod


MOD = 10**9 + 7
facts = factorization(M)
ans = 1
for i, n in facts:
    ans *= combination_mod(n + N - 1, n, MOD)  # 取り出したところがたまたま壁になるっていう発想でもいいかも
    ans %= MOD
print(ans)


Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  rep(i, M){
    cin >> a.at(i) >> b.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  vector<int> cnt(N);
  rep(i, M){
    cnt.at(a.at(i))++;
    cnt.at(b.at(i))++;
  }
  rep(i, N){
    cout << cnt.at(i) << endl;
  }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A>> B;
  C = A + B;
  D = B - A;
  if(B % A == 0)
    cout << C;
  else
    cout << D;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> > 
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

ll add(ll x, ll y) {ll res=x+y; return(res>=MOD?res-MOD:res);}
ll mul(ll x, ll y) {ll res=x*y; return(res>=MOD?res%MOD:res);}
ll sub(ll x, ll y) {ll res=x-y; return(res<0?res+MOD:res);}
ll lcm(ll x, ll y) {ll res=(x*y)/__gcd(x,y); return res;}
ll power(ll x, ll y) {ll res=1; x%=MOD; while(y){if(y&1)res=mul(res,x); y>>=1; x=mul(x,x);} return res;}

const int MAX = 1e6 + 5;
vector <int> primes;
map <int, int> mp, cnt;
bool prime[MAX];
void sieve()
{
	memset(prime, true, sizeof(prime));
	for(int i = 2; i < MAX; i++){
		if(prime[i]){
			for(int j = 2 * i; j < MAX; j += i)
			prime[j] = false;
		}
	}
	for(int i = 0; i < MAX; i++){
		if(prime[i])
		primes.pb(i);
	}
}
void work(int val)
{
	int x = val;
	vi w;
	for(int i = 2; i <= sqrt(x); i++){
		if(x % i == 0) w.pb(i);
		while(x % i == 0){
			cnt[i]++;
			x /= i;
		}
	}
	if(x > 1){
		w.pb(x);
		cnt[x]++;
	}
	for(int i = 0; i < w.size(); i++){
		mp[w[i]] = max(mp[w[i]], cnt[w[i]]);
		cnt[w[i]] = 0;
	}
}
int main()
{
	boost;
	sieve();
	int n, i, j;
	cin >> n;
	int arr[n];
	fo(i, 0, n)
	cin >> arr[i];
	fo(i, 0, n)
	work(arr[i]);
	ll lcm = 1;
	fo(i, 0, primes.size())
	lcm = mul(lcm, power(primes[i], mp[primes[i]]));

	ll ans = 0;
	fo(i, 0, n)
	ans = add(ans, mul(lcm, power(arr[i], MOD - 2)));
	cout << ans;
}

Measured memory_bytes: 5752
import Control.Monad
import Data.Maybe (fromJust)
import Data.List

data LastPattern = First | Vertical | Horizontal deriving (Show, Eq)

modNum :: Int
modNum = 1000000007

solve :: String -> String -> LastPattern -> Int -> Int
solve [] [] _ curr = curr
solve (c11:[]) (c21:[]) last curr = solveVertical [c11] [c21] last curr

solve s1 s2 last curr
    | c1 == c2 = solveVertical s1 s2 last curr
    | otherwise = solveHorizontal s1 s2 last curr
    where
        c1 = s1!!0
        c2 = s2!!0

solveVertical :: String -> String -> LastPattern -> Int -> Int
solveVertical (c11:ss1) (c21:ss2) last curr = solve ss1 ss2 Vertical next
    where
        next = case last of
            First -> 3
            Vertical -> ((curr * 2) `mod` modNum)
            Horizontal -> (curr `mod` modNum)

solveHorizontal :: String -> String -> LastPattern -> Int -> Int
solveHorizontal (c11:c12:ss1) (c21:c22:ss2) last curr = solve ss1 ss2 Horizontal next
    where
        next = case last of
            First -> 6
            Vertical -> ((curr * 2) `mod` modNum)
            Horizontal -> ((curr * 3) `mod` modNum)

main :: IO ()
main = do
    n <- read <$> getLine :: IO Int
    s1 <- getLine
    s2 <- getLine
    let s = solve s1 s2 First 1
    print s


Measured memory_bytes: 380
#include <iostream>
    
using namespace std;
    
int main(){
 int a,b,c,n=0;
 cin >> a;
 cin >> b;
 cin >> c;
 while (1) {
  if (c/a*a==c) {
   n++;
  }
  if (a==b) break;
  a++;
 }
 cout <<n<<endl;
 return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int d,t,s; cin >> d >> t >> s;
  if (s*t>=d) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3672
#include "bits/stdc++.h"
using namespace std;
const int N = 55;
const int S = N * N;
int n , a;
int arr[N];
long long dp[2][S * 2];
int main(){
    cin >> n >> a;
    for(int i = 1 ; i <= n ; ++i){
        cin >> arr[i];
        arr[i] -= a;
    }
    memset(dp , 0 , sizeof(dp));
    dp[0][S] = 1;
    for(int i = 1 ; i <= n ; ++i){
        for(int j = 0 ; j < S + S ; ++j){
            dp[i & 1][j] = dp[!(i & 1)][j] + ((j - arr[i] >= 0) ? (j - arr[i] < S + S) ? dp[!(i & 1)][j - arr[i]] : 0 : 0);
        }
    }
    printf("%lld\n" , dp[n & 1][S] - 1);
}

Measured memory_bytes: 384
A, B, C, D = map(int, input().split())

while A > 0 and C > 0:
  C = C - B
  if A <= 0 or C <= 0:
    break;
  A = A - D
  if A <= 0 or C <= 0:
    break;
if A <= 0:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 9192
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VP ps(n);
    REP(i,0,n) {
        cin >> ps[i].first >> ps[i].second;
    }
    int ans = 0;

    sort(all(ps), [](auto &l, auto &r) {
        return l.first + l.second < r.first + r.second;
    });
    chmax(ans, abs(ps[n-1].first - ps[0].first) + abs(ps[n-1].second - ps[0].second));

    sort(all(ps), [](auto &l, auto &r) {
        return l.first - l.second < r.first - r.second;
    });
    chmax(ans, abs(ps[n-1].first - ps[0].first) + abs(ps[n-1].second - ps[0].second));

    cout << ans << endl;
}

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

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> T(N);
  long long int sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> T[i];
    sum += T[i];
  }
  int M;
  cin >> M;
  vector<int> P(M), X(M);
  for(int i = 0; i < M; i++) {
    cin >> P[i] >> X[i];
    int p = P[i] - 1;
    cout << sum - T[p] + X[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3588
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n),sum(n+1);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        sum[i+1]=sum[i]+a[i];
    }
    ll ans=INF;
    for(ll i=3;i<=n-1;i++){ //後ろのグループの最初の要素のindex
        ll v=sum[i-1];
        auto it1=lower_bound(sum.begin(),sum.end(),(v+1)/2)-sum.begin();
        ll diff1=abs(v-2*sum[it1]);
        ll p=min(v-sum[it1],sum[it1]);
        ll q=max(v-sum[it1],sum[it1]);
        if(it1!=1 && abs(v-2*sum[it1-1])<diff1){
            p=min(v-sum[it1-1],sum[it1-1]);
            q=max(v-sum[it1-1],sum[it1-1]);
        }
        ll w=sum[n]-sum[i-1];
        auto it2=lower_bound(sum.begin(),sum.end(),(w+1)/2+sum[i-1])-sum.begin();
        ll diff2=abs(w-2*(sum[it2]-sum[i-1]));
        ll r=min(w-(sum[it2]-sum[i-1]),sum[it2]-sum[i-1]);
        ll s=max(w-(sum[it2]-sum[i-1]),sum[it2]-sum[i-1]);
        if(it2!=i && abs(w-2*(sum[it2-1]-sum[i-1]))<diff2){
            r=min(w-(sum[it2-1]-sum[i-1]),sum[it2-1]-sum[i-1]);
            s=max(w-(sum[it2-1]-sum[i-1]),sum[it2-1]-sum[i-1]);
        }
        ll top=max({p,q,r,s});
        ll bot=min({p,q,r,s});
        //cout << p << " "  << q << " " << r  << " " << s << endl;
        ans=min(ans,top-bot);
    }
    cout << ans << endl;
} 

Measured memory_bytes: 3328
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int[] NK = ria();
        int N = NK[0];
        int K = NK[1];
        int[] AArray = ria();

        // string ans;
        // int score_bef = 1;
        // for (int i = 0; i < N; i++)
        // {
        //     if(i < K) {
        //         score_bef *= AArray[i];
        //     }else {
        //         int score_now = score_bef / AArray[i - K] * AArray[i];

        //         if(score_now > score_bef) ans = "Yes";
        //         else ans = "No";
        //         Console.WriteLine(ans);

        //         score_bef = score_now;
        //     }
        // }

        for (int i = K; i < N; i++)
        {
            string ans = "No";
            if(AArray[i] > AArray[i - K]) ans = "Yes";
            Console.WriteLine(ans);
        }

		Console.ReadLine();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


Measured memory_bytes: 45756
#include<iostream>
#include<string>
using namespace std;
# define MAXN 100 

int main(){
  int h,w;
  char c[100][100],result[200][100];
  cin >> h >> w;
  for (int j(0);j < h; j++){
    for (int i(0);i < w; i++){
      cin >> c[j][i];
    }
  }

  for (int j(0);j < h; j++){
    for (int i(0);i < w; i++){
      if (c[j][i] == '*'){
        result[2*j][i] = '*';
        result[2*j+1][i] = '*';
      }else{
        result[2*j][i] = '.';
        result[2*j+1][i] = '.';
      }
    }
  }

  for (int j(0);j < h * 2; j++){
    for (int i(0);i < w; i++){
      cout << result[j][i];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import itertools
A,B,C=map(int,input().split())
K=int(input())
for seq in itertools.product(range(3),repeat=K):
    a,b,c=A,B,C
    for i in range(K):
        if seq[i]==0:
            a=a*2
        elif seq[i]==1:
            b=b*2
        else:
            c=c*2
    if b>a and c>b:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 65364
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


def lcm(x, y):
    return x * y // gcd(x, y)


a, b, c, d = map(int, input().split())
a = a - 1
e = b - b // c - b // d + b // lcm(c, d)
f = a - a // c - a // d + a // lcm(c, d)
print(e - f)


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

int main(){
  
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  
  if(r<=x && x<=W-r && r<=y && y<= H-r)
    cout << "Yes"<<endl;
  else
    cout << "No"<<endl;
  
  return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    string S;
    cin >> S;
    ll ans1=0;ll ans2=0;
    for(ll i=0;i<S.size();i++){
        if(i%2&&S[i]=='0')ans1++;
        else if(i%2==0&&S[i]=='1')ans1++;
    }
    for(ll i=0;i<S.size();i++){
        if(i%2==0&&S[i]=='0')ans2++;
        else if(i%2&&S[i]=='1')ans2++;
    }
    print(min(ans1,ans2))
    return 0;
}


Measured memory_bytes: 512