akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
using namespace std;
int main()
{
    int n;
    vector<int> x, y;
    double l1_norm, l2_norm, l3_norm, linf_norm;
    l1_norm = 0.0;
    l2_norm = 0.0;
    l3_norm = 0.0;
    linf_norm = 0.0;
    
    cin >> n;
    x.resize(n);
    y.resize(n);
    for (int i=0; i<n; ++i){
        cin >> x[i];
    }
    for (int i=0; i<n; ++i){
        cin >> y[i];
    }
    
    // l1_norm
    for (int i=0; i<n; ++i){
        l1_norm += abs(x[i] - y[i]);
    }
    
    // l2_norm
    for (int i=0; i<n; ++i){
        l2_norm += pow(x[i] - y[i], 2);
        if (i == n-1){
            l2_norm = sqrt(l2_norm);
        }
    }
    
    // l3_norm
    for (int i=0; i<n; ++i){
        l3_norm += pow(abs(x[i] - y[i]), 3);
        if (i == n-1){
            l3_norm = pow(l3_norm, 1.0 / 3.0);
        }
    }
    
    // l_infty_norm
    for (int i=0; i<n; ++i){
        if(abs(x[i] - y[i]) >= linf_norm){
            linf_norm = abs(x[i] - y[i]);
        }
    }
    
    printf("%.8f\n", l1_norm);
    printf("%.8f\n", l2_norm);
    printf("%.8f\n", l3_norm);
    printf("%.8f\n", linf_norm);
    return 0;
}



Measured memory_bytes: 3344
#include<bits/stdc++.h>
#define FastIO1 ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define si(n) scanf("%d",&n)
#define sl(n) scanf_s("%lld",&n)
#define nsl(n) scanf_s("%lld\n",&n)
#define nsi(n) scanf("%d\n",&n)
#define repz(i,a,n) for(int i=a;i<n;i++)
#define repo(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for (int i=n;i>=a;i--)
#define stlfor(it,stl) for(auto &it:stl)
#define pb push_back
#define mp make_pair
namespace FastIO {
	const int SIZE = 1 << 16;
	char buf[SIZE], obuf[SIZE], str[60];
	int bi = SIZE, bn = SIZE, opt;
	int read(char* s) {
		while (bn) {
			for (; bi < bn && buf[bi] <= ' '; bi++);
			if (bi < bn) break;
			bn = fread(buf, 1, SIZE, stdin);
			bi = 0;
		}
		int sn = 0;
		while (bn) {
			for (; bi < bn && buf[bi] > ' '; bi++) s[sn++] = buf[bi];
			if (bi < bn) break;
			bn = fread(buf, 1, SIZE, stdin);
			bi = 0;
		}
		s[sn] = 0;
		return sn;
	}
	template<typename T>
	bool read(T& x) {
		int n = read(str), bf;
		if (!n) return 0;
		int i = 0; if (str[i] == '-') bf = -1, i++; else bf = 1;
		for (x = 0; i < n; i++) x = x * 10 + str[i] - '0';
		if (bf < 0) x = -x;
		return 1;
	}
};
using namespace FastIO;
using namespace std;
typedef long long ll;
typedef long double db;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll a, ll b,ll mod) { ll ans = 1; while (b) { if (b & 1) ans = (ans * a)%mod ; b >>= 1; a = (a * a)%mod; }return ans; }
ll qmul(ll a, ll b, ll mod) { ll ans = 0; while (b > 0) { if (b & 1)ans = (ans + a) % mod; b >>= 1; a = (a + a) % mod; }return ans; }
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}

int main()
{
	string s;
	FastIO1
		cin >> s;
	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
		else if (i < s.size() - 2 && s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a[100008], lala[100008], rara[100008];

int main() {
	cin >> n;
	for(ll i = 1; i <= n; i++){cin >> a[i];}
	
	a[0] = 0; a[n+1] = 0;
	lala[0] = 0; rara[n+1] = 0;
	
	for(ll i = 1; i <= n; i++){lala[i] = lala[i-1]+abs(a[i]-a[i-1]);}
	for(ll i = n; i >= 1; i--){rara[i] = rara[i+1]+abs(a[i]-a[i+1]);}
	
	for(ll i = 1; i <= n; i++){
		cout << lala[i-1]+abs(a[i-1]-a[i+1])+rara[i+1] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>

int main() {
	int n, i, j, k, u, v, a[100][100];
	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) a[i][j] = 0;
	}

	for (i = 0; i < n; i++) {
		scanf("%d %d", &u, &k);
		for (j = 0; j < k; j++) {
			scanf("%d", &v);
			a[u - 1][v - 1] = 1;
		}
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < n-1; j++) {
			printf("%d ", a[i][j]);
		}
		printf("%d\n", a[i][j]);
	}
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int INF = 1e9;
double temp_start = 1000.0;
double temp_end = 0.0001; 
int climb_loop = 10000000;
double temp;

int main(){
  int seed = 12345;
  mt19937 eng(seed);
  uniform_real_distribution<> uniform_01;

  // input
  int D;
  cin >> D;
  int c[26];
  rep(i,26) cin >> c[i];
  int s[D+1][26];
  rep(i,D) rep(j,26) cin >> s[i+1][j];
  
  // define parameter
  int last[D+1][26];
  int t[D+1];
  rep(i,D+1) rep(j,26) last[i][j] = 0;
  
  // calculate initial content climbing
  int content = 0;
  for(int day = 1; day <= D; day++) {
    int content_after = -INF;
    int best_kind = 0;
    rep(kind,26) {
      int res = content + s[day][kind];
      rep(j,26) {
        if(j == kind) last[day][j] = day;
        else last[day][j] = last[day-1][j];
        res -= c[j] * (day - last[day][j]);
      }
      if(res > content_after) {
        best_kind = kind;
        content_after = res;
      }
    }
    t[day] = best_kind;
    content = content_after;
    rep(j,26) {
      if(j == t[day]) last[day][j] = day;
      else last[day][j] = last[day-1][j];
    }
  }
   
  // simulated annealing
  rep(x,climb_loop) {
    int d = (eng() % D) + 1;
    int q = eng() % 26;
    if(q != t[d]) {
      temp = temp_start + (temp_end - temp_start)*x/climb_loop;
      int diff = s[d][q] - s[d][t[d]];
      int cur = d;
      while(cur <= D && last[cur][t[d]] == d) {
        diff -= c[t[d]] * (d - last[cur-1][t[d]]);
        last[cur][t[d]] = last[cur-1][t[d]];
        cur++;
      }
      cur = d;
      while(cur <= D && last[cur][q] < d) {
        diff += c[q] * (d - last[cur][q]);
        last[cur][q] = d;
        cur++;
      }
      if(diff > 0 || uniform_01(eng) < exp((double)diff/temp)) {
        t[d] = q;
        content += diff;
      } else {
        int day = d;
        while(day <= D && last[day][t[d]] < d) {
          last[day][t[d]] = d;
          day++;
        }
        day = d;
        while(day <= D && last[day][q] == d) {
          last[day][q] = last[day-1][q];
          day++;
        }
      }
    }
  }
  // output
  for(int day = 1; day <= D; day++) cout << t[day]+1 << endl;
  return 0;
}


Measured memory_bytes: 4360
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header


vector<int> G[200010];
vector<i64> counter;
bool visited[200010];

void dfs(int v, i64 propagate)
{
    if (visited[v]) return;
    visited[v] = true;

    counter[v] += propagate;
    for (const int to : G[v]) {
        dfs(to, counter[v]);
    }
}

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

    var(int, N, Q);
    counter.resize(N);

    rep(i, N - 1) {
        var(int, a, b);
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    while(Q--) {
        var(int, v, x);
        --v;
        counter[v] += x;
    }

    dfs(0, 0);

    print(counter);

    return 0;
}


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

using namespace std;

int solve(int H, int W, int h, int w)
{
    int total = H * W;
    total -= h*W;
    total -= w*H;
    total += h*w;

    return total;
}

int main()
{
    ios::sync_with_stdio(false);

    int H, W, h, w;
    cin >> H >> W >> h >> w;

    auto ans = solve(H, W, h, w);

    cout << ans << '\n';

    return 0;
}


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

namespace B_Buffet
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine()
                            .Split(' ')
                            .Select(s => int.Parse(s))
                            .ToArray();
            int[] B = Console.ReadLine()
                            .Split(' ')
                            .Select(s => int.Parse(s))
                            .ToArray();
            int[] C = Console.ReadLine()
                            .Split(' ')
                            .Select(s => int.Parse(s))
                            .ToArray();
            
            int satisfy = 0;
            satisfy += B.Sum();
            for (int i = 0; i < N - 1; i++)
            {
                if (A[i] + 1 == A[i + 1])
                {
                    satisfy += C[A[i] - 1];
                }
            }
            Console.WriteLine(satisfy.ToString());
        }
    }
}


Measured memory_bytes: 13396
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
	x := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i])
	}

	ans := 0
	for i := 0; i < n-1; i++ {
		ans += min(a*(x[i+1]-x[i]), b)
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 5504
use text_io::*;
use std::collections::*;
use std::process::exit;

fn main() {
    let mut n:usize = read!();
    let mut v:Vec<usize> = Vec::new();
    for i in 0..n {
        let mut a:usize = read!();
        v.push(a);
    }
    v.sort();
    let mut ans:f64 = v[0]as f64;
    for i in 0..n {
        ans=(ans+v[i]as f64)/2.0;
    }
    println!("{}",ans);
}

Measured memory_bytes: 2176
// c++ cpp.cpp -o cpp.exe -std=c++14

#include <iostream>
#include <vector>
using namespace std;

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

int main()
{
    lint n, m, l;
    cin >> n >> m >> l;
    vector<vector<lint>> a(n), b(m), c(n);

    rep(i, n)
    {
        a[i].resize(m);
        rep(j, m) { cin >> a[i][j]; }
    }

    rep(i, m)
    {
        b[i].resize(l);
        rep(j, l) { cin >> b[i][j]; }
    }

    rep(i, n)
    {
        c[i].resize(l);
    }

    rep(i, n)
    {
        rep(k, l)
        {
            rep(j, m)
            {
                c[i][k] += a[i][j] * b[j][k];
            }
        }
    }

    rep(i, n)
    {
        rep(k, l)
        {
            if (k != 0)
            {
                cout << " ";
            }
            cout << c[i][k];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3220
n,q=map(int,input().split())
s=input()
ac=[0]
buf=0
for i in range(1,n):
    if s[i-1:i+1]=="AC":
        buf+=1
    ac.append(buf)
for i in range(q):
    l,r=map(int,input().split())
    ans=ac[r-1]-ac[l-1]
    print(ans)

Measured memory_bytes: 6180
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define dbV(arr) cout << #arr << "=[ "; \
for(auto i:arr) cout << i << " "; cout << "]\n";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repF(i,a,n) for(int i = (a); i <= (n); ++i)
#define repB(i,a,n) for(int i = (a); i >= (n); --i)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define umii unordered_map<int,int>
#define umll unordered_map<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define seti set<int>
#define setl set<ll>
#define pb push_back
#define F first
#define S second
#define MOD 1000000007
#define all(z) z.begin(),z.end()
using namespace std;
using ll = long long;
ll dp[102][100002];
/*ll solve(vector<pair<int, ll>> &item, int n, int w) {
	if (n < 0) return 0LL;
	if (dp[n][w] != -1) return dp[n][w];
	if (item[n].F <= w)
		return dp[n][w] = max(item[n].S + solve(item, n - 1, w - item[n].F), solve(item, n - 1, w));
	else
		return dp[n][w] = solve(item, n - 1, w);
};*/
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, w; cin >> n >> w;
	vector<pair<int, ll>> item(n);
	rep(i, n) cin >> item[i].F >> item[i].S;
	memset(dp, -1, sizeof(dp));
	function<ll(int, int)> solve = [&](int n, int w) {
		if (n < 0) return 0LL;
		if (dp[n][w] != -1) return dp[n][w];
		if (item[n].F <= w) return dp[n][w] = max(item[n].S + solve(n - 1, w - item[n].F), solve(n - 1, w));
		else return dp[n][w] = solve(n - 1, w);
	};
	cout << solve(n - 1, w) << '\n';
	return 0;
}

Measured memory_bytes: 83328
C=[0]*(10**5+2)
C[0]=1
C[1]=1
s=[0]*(10**5+2)
S=[0]*(10**5+2)
t=1
while(t<=(10**5)):
    t+=1
    if(C[t]==1):
        continue
    k=1
    while(True):
        k+=1
        if(t*k>(10**5)):
            break 
        C[t*k]=1

for i in range(1,(10**5),2):
    if(C[i]==0):
        if(C[(i+1)//2]==0):
            s[i]=1

for i in range(1,len(S)):
    S[i]+=s[i]+S[i-1]

N=int(input())
for i in range(N):
    l,r=map(int,input().split())
    print(S[r]-S[l-1])


Measured memory_bytes: 7924
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 1e5 + 5;
typedef int arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n;
int main()
{
	rg int cnt = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)
		if (read() == cnt + 1)
			cnt++;
	if (!cnt)
		puts("-1");
	else
		cout << n - cnt << '\n';
	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x = int(readline())

for a in range(-140, 140):
    for b in range(-140, 140):
        if a ** 5 - b ** 5 == x:
            print(a, b)
            exit()


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

#define ll long long
#define d long double

#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%Lf",&n)
#define pri(n) printf("%d ",(int)n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%Lf ",n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define dprin(n) printf("%Lf\n",n)

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define bitcount(n) __builtin_popcount(n)
#define tc   int tt; scf(tt); while(tt--)
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264

const ll M =1e9+7;
const int N = 1e6+7;



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

   vector<int>s,s1;
    while(n--)
    {
        int a,b;
        cin>>a>>b;

        s.pb(a+b);
        s1.pb(a-b);
    }

    sort(all(s));
    sort(all(s1));
    
    cout<<max(s[s.size()-1]-s[0],abs(s1[s1.size()-1]-s1[0]));
    
    
return 0;
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll a,b;cin>>a>>b;
  ans(a<=9&&b<=9,a*b,-1);
  return 0;
}

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

int main(){
    int n,m;
    int c=0;
    int s=0;
    cin>>n>>m;

    vector<int> a(n);

    rep(i,n){
        cin>>a.at(i);
        s=s+a.at(i);
    }

   

rep(i,n){
    if(4*m*a.at(i)>=s){
        c++;
    }
}

  
if(c>=m){
    cout<<"Yes"<<endl;}
    if(c<m){cout<<"No"<<endl;}
  
  
}

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

int main(){
    int n, i, j;
    string s, t;
    cin >> n >> s >> t;
    for(i=0; i<n; i++){
        for(j=i; j<n; j++){
            if(s[j] != t[j-i]){
                break;
            }
            if(j == n-1){
                cout << n+i;
                return 0;
            }
        }
    }
    cout << 2*n;
    return 0;
}

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

using namespace std;

string s;

int main()
{
    cin >> s;

    int n = s.size();

    int rez = n;
    int cr = 0;
    for(int i = 0, j = n - 1; i < j; i ++, j --)
        cr += s[i] != s[j];

    cout << min(rez, cr) << "\n";

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)

int main(void) {
	ll n;
	cin >> n;
	vector<ll>a(n);
	for (ll i = 0;i < n;i++)cin >> a[i];
	sort(a.begin(), a.end());
	ll left = a[0];
	ll right = a[n - 1];
	ll ans = abs(left - right);
	ll l = 1, r = n - 2;
	bool which1 = true;//左
	bool which2 = true;//hidari
	while (l<=r) {
		//cout << ans << " " << left << " " << right << endl;
		ll num1 = 0, num2 = 0;
		if (abs(left - a[l]) > abs(right - a[l])) {
			which1 = true;
			num1 = abs(left - a[l]);
		}
		else {
			which1 = false;
			num1 = abs(right - a[l]);
		}
		if (abs(left - a[r]) > abs(right - a[r])) {
			which2 = true;
			num2 = abs(left - a[r]);
		}
		else {
			which2 = false;
			num2 = abs(right - a[r]);
		}
		//cout << a[l] << " " << a[r] << " " << num1 << " " << num2 << endl;
		if (num1 > num2) {
			if (which1) {
				ans += num1;
				left = a[l];
				l++;
			}
			else {
				ans += num1;
				right = a[l];
				l++;
			}
		}
		else {
			if (which2) {
				ans += num2;
				left = a[r];
				r--;
			}
			else {
				ans += num2;
				right = a[r];
				r--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

struct P
{
    long long x,y,z;

    bool operator<(const P &a)const{
              return x<a.x;
    }

};

vector<int> v[1];
//bitset<4001000> b;
int a,c,i,b,n,m,k,d;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
long long o[522122];
long long l[552221];
int j[1];
int e;
int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long x,y,mod=1000000007,mod2=1000000009,mod3=2017;
long long z;
double pi=3.14159265;
P u[1];
//stack<int> s;

//set<long long> s;
queue<int> q,q1;

//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//list<int> l;

//string r,r1;
//char r[1333336];
//deque<int> de;
//srand((int)time(NULL));
bool as(P a,P b)
{
    if(a.x*b.y!=b.x*a.y)
    return a.x*b.y<b.x*a.y;
    return a.y>b.y;
}

long long f(int n,int m)
{
    return l[m]-l[n-1];

}

int main()
{
    x=mod*mod*4;
    scanf("%d %d",&a,&b);
    for(int t=1;t<=a;t++)
    {
        scanf("%lld",&o[t]);
        //o[t]+=o[t-1];
    }
    for(int t=1;t<=a;t++)
    {
        l[t]=o[a-t+1],l[t]+=l[t-1];
        //printf("%lld ",l[t]);
    }
    for(int t=1;t<=a;t++)
    {
        y=l[t]+(long long)t*b;
        long long i=2;
        for(int h=1;h<=a;i++,h+=t)
        {
            z=0;
            if(h+t-1<=a)
            {
                if(i>2)
                z+=(l[h+t-1]-l[h-1])*(i*i-(i-1)*(i-1));
                else

                z+=(l[h+t-1]-l[h-1])*(i*i);
            }
            else
            {
                if(i>2)
                z+=(l[a]-l[h-1])*(i*i-(i-1)*(i-1));
                else
                    z+=(l[a]-l[h-1])*(i*i);
            }
            z=min(z,mod*mod);
            y+=z;
            y=min(y,mod*mod);
        }
        //printf("##%lld\n",(long long)a*b+z);
        x=min(x,y);
    }
    printf("%lld",x+(long long)a*b);
}
//1 4 3 2 1


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

int powmod(int x, int y, int m){
	int a = 1;
	while(y){
		if(y & 1) a = a * x % m;
		y >>= 1;
		x = x * x % m;
	}
	return a;
}

const char *ptr;
int p;

int expr();
int term();
int factor();

int expr(){
	int a = term();
	while(1){
		if(*ptr == '+'){
			++ptr;
			a = (a + term()) % p;
		}
		else if(*ptr == '-'){
			++ptr;
			a = (a - term() + p) % p;
		}
		else{
			break;
		}
	}
	return a;
}

int term(){
	int a = factor();
	while(1){
		if(*ptr == '*'){
			++ptr;
			a = a * factor() % p;
		}
		else if(*ptr == '/'){
			++ptr;
			int b = factor();
			if(b == 0) throw 0;
			a = a * powmod(b, p - 2, p) % p;
		}
		else{
			break;
		}
	}
	return a;
}

int factor(){
	if(*ptr == '('){
		++ptr;
		int a = expr();
		++ptr;
		return a;
	}

	char *endp;
	int a = strtol(ptr, &endp, 10);
	ptr = endp;
	return a % p;
}

int main(){
	string s;
	while(cin >> p, p != 0){
		cin.ignore();
		getline(cin, s);
		s.erase(remove(s.begin(), s.end(), ' '), s.end());
		ptr = s.c_str();

		try{
			int a = expr();
			cout << s << " = " << a << " (mod " << p << ")\n";
		}catch(...){
			cout << "NG\n";
		}
	}
}

Measured memory_bytes: 1408
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

void chmax(ll& x, ll y) {
    if (x < y) x = y;
}

struct UnionFind {
    vector<int> par;

    UnionFind(int n): par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);

        if (x == y) return false;

        // merge by size
        // force size of x to be bigger than that of y
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;

        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

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

    int n, m; cin >> n >> m;

    vector<int> a(m), b(m);
    REP(i, m) cin >> a[i] >> b[i];

    int ans = 0;
    REP(ng, m) {
        UnionFind uf(n + 1);

        REP(j, m) {
            if (j == ng) continue;
            uf.merge(a[j], b[j]);
        }

        ll s = 0;
        REP(i, n) chmax(s, uf.size(i));
        if (s != n) ans++;
    }

    print(ans);


}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int n,m,K,ans;
long long a[200004],b[200004];
int main() {
	cin>>n>>m>>K;
	for (int i=1; i<=n; i++) cin>>a[i],a[i]=a[i-1]+a[i];
	for (int i=1; i<=m; i++) cin>>b[i],b[i]=b[i-1]+b[i];
	for (int i=0; i<=n; i++) {
        if(K>=a[i]) {
		    int res = upper_bound(b+1, b+1+m, K-a[i]) - b - 1;
		    ans = max(ans, res+i);
	    }
    }
	cout<<ans;
    return 0;
}

Measured memory_bytes: 6684
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
int dp[100010]; //ぴったりとると面倒なこと起きがちらしい
int main() {
    for (int n = 1; n <= 100000; ++n) {
        dp[n] = inf;
        int power = 1;
        while (power <= n) {
            dp[n] = min(dp[n], dp[n - power] + 1);
            power *= 6;
        }
        power = 1;
        while (power <= n) {
            dp[n] = min(dp[n], dp[n - power] + 1);
            power *= 9;
        }
    }
    int n; cin >> n;
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	ll W, H, x, y;
	cin >> W >> H >> x >> y;
	int ans = 0;
	if (x*2 == W && y*2 == H)
		ans = 1;
	printf("%lf %d\n", (double)(W*H)/2, ans);
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int n,k;cin>>n>>k;
	ll ans=0;
	for(int i=k+1;i<=n;i++){
		ans+=n/i*(i-k);
		if(k>0&&n%i>k-1) ans+=n%i-(k-1);
		if(k==0) ans+=n%i;
	}
	cout<<ans<<endl;
}


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

int main(void){

  char s[11];
  scanf("%s", s);
  if (s[0] != 'A' || s[1] < 'a' || s[1] > 'z') {
    printf("WA\n");
    return 0;
  }
  int length = strlen(s);
  int C_count = 0;
  int C_place;
  for (int i = 2; i <= length-2; i++) {
    if (s[i] == 'C') {
      C_count++;
      C_place = i;
    }
  }
  if (C_count != 1) {
    printf("WA\n");
    return 0;
  }
  for (int i = 2; i < length; i++) {
    if (i == C_place) {
      continue;
    }
    if (s[i] < 'a' || s[i] > 'z') {
      printf("WA\n");
      return 0;
    }
  }
  printf("AC\n");

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){

  for(;;){

  int n,m,p;
  cin>>n>>m>>p;

  if(!n) break;

  int x[100],sum=0;
  for(int i=0;i<n;i++) cin>>x[i],sum+=x[i];

  if(!x[m-1]){
    cout<<0<<endl;
    continue;
  }
  sum*=100;
  sum-=sum*p/100;
  cout<<sum/x[m-1]<<endl;

  }

  return 0;

}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  ll X, Y;
  I(X);
  I(Y);

  bool ok = true;
  if (Y%2 == 1) ok = false;
  if (Y/2 - X < 0) ok = false;
  if (2*X - Y/2 < 0) ok = false;

  P(ok?"Yes":"No");

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  ll ra,rb,rc,rd,re;
  ra = ((a+9)/10)*10-a;
  rb = ((b+9)/10)*10-b;
  rc = ((c+9)/10)*10-c;
  rd = ((d+9)/10)*10-d;
  re = ((e+9)/10)*10-e;
  ll num;
  num = max(ra,(max(rb,max(rc,max(rd,re)))));
  cout << ((a+9)/10)*10+((b+9)/10)*10+((c+9)/10)*10+((d+9)/10)*10+((e+9)/10)*10-num;

  
  
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

string S,T;

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

    int ans=0;
    rep(i,S.size()-T.size()+1){
        int cnt=0;
        rep(j,T.size()){
            if(S[i+j]==T[j]) cnt++;
        }
        ans=max(ans,cnt);
    }
    ans=T.size()-ans;

    cout<<ans<<endl;
}

Measured memory_bytes: 3624
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {k: i32, a: i32, b: i32};

    let x = b / k * k;

    if a <= x {
        println!("OK")
    } else {
        println!("NG")
    }
}


Measured memory_bytes: 2068
#include<bits/stdc++.h>
#define mp make_pair
#define x first
#define y second
using namespace std;
typedef int lli;
#define P pair<lli, lli>
const lli N=1009, inf=1e9, M=400009;
lli n, m, s, t, c[M], f[M], Time[N], T=1, minn[N], reach[N], dd[M], cnt;
P trace[N];
struct Ed
{
	lli v, id;
};
vector<Ed> D[N];
void Addedge(lli u, lli v, lli w)
{
	D[u].push_back({v, cnt});
	D[v].push_back({u, cnt+1});
	D[v].push_back({u, cnt+2});
	D[u].push_back({v, cnt+3});
	c[cnt]=w;
	c[cnt+2]=w;
	cnt+=4;
}
void Inp()
{
	char ch;
	cin>>m>>n;
	s=m+n+1;
	t=m+n+2;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>ch;
			if(ch=='S')
			{
				Addedge(s, i, inf);
				Addedge(s, m+j, inf);
			}
			if(ch=='T')
			{
				Addedge(i, t, inf);
				Addedge(m+j, t, inf);
			}
			if(ch=='o')
			{
				Addedge(i, m+j, 1);
			}
		}
	}
}
bool findpath()
{
	deque<lli> p;
	p.push_back(s);
	minn[s]=inf;
	Time[s]=T;
	while(!p.empty())
	{
		lli u=p.front();
		p.pop_front();
		for(auto i: D[u])
		{
			lli v=i.v, id=i.id;
			if(Time[v]!=T&&c[id]>f[id]) 
			{
				Time[v]=T;
				minn[v]=min(minn[u], c[id]-f[id]);
				trace[v]=mp(u, id);
				if(v==t)
				{
					return 1;
				}
				p.push_back(v);
			}
		}
	}
	return 0;
}
void Solve()
{
	lli kq=0;
	while(findpath())
	{
		lli del=minn[t];
		kq+=del;
		lli u=t;
		while(u!=s)
		{
			f[trace[u].y]+=del;
			f[(trace[u].y^1)]-=del;
			u=trace[u].x;
		}
		T++;
	}
	if(kq>=inf)
	{
		cout<<-1;
		return ;
	}
	cout<<kq;
}
int main()
{
	//freopen("test.inp","r",stdin);
	Inp();
	Solve();
}  

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[100005][2];
int main()
{
	ll n,i,j;
	cin >> n;
	ll a[n];
	for(i=0;i<n;i++)
		cin >> a[i];
		
	dp[1][0]=abs(a[1]-a[0]);
	dp[1][1]=LLONG_MAX;
	for(i=2;i<n;i++)
	{
		dp[i][0]=min(dp[i-1][0],dp[i-1][1])+abs(a[i]-a[i-1]);
		dp[i][1]=min(dp[i-2][0],dp[i-2][1])+abs(a[i]-a[i-2]);
	}
	cout<<min(dp[n-1][0],dp[n-1][1])<<"\n";
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int h,w,m,x[300010],y[300010];
int num_a[300010],num_b[300010];
int maxx=0,wherex,maxb,wherey,ans1,ans2;
int main(){
    cin>>h>>w>>m;
    for(int i=1;i<=m;i++) cin>>x[i]>>y[i];
	for(int i=1;i<=m;i++) num_a[x[i]]++;
	for(int i=1;i<=h;i++) 
	    if(num_a[i]>maxx) {
	    	maxx=num_a[i];
	    	wherex=i;
		}
    for(int i=1;i<=m;i++) 
        if(x[i]!=wherex)
        	num_b[y[i]]++;
    for(int i=1;i<=m;i++)
        if(num_b[y[i]]>maxb) {
        	maxb=num_b[y[i]];
        	wherey=y[i];
		}
//	cout<<wherex<<" "<<wherey<<endl;
	for(int i=1;i<=m;i++) 
	    if(x[i]==wherex || y[i]==wherey)
	        ans1++;
	        
	memset(num_a,0,sizeof(num_a));
	memset(num_b,0,sizeof(num_b));
	maxx=0,maxb=0;        
	        
	for(int i=1;i<=m;i++) num_b[y[i]]++;
	for(int i=1;i<=w;i++) 
	    if(num_b[i]>maxb) {
	    	maxb=num_b[i];
	    	wherey=i;
		}
    for(int i=1;i<=m;i++) 
        if(y[i]!=wherey)
        	num_a[x[i]]++;
    for(int i=1;i<=m;i++)
        if(num_a[x[i]]>maxx) {
        	maxx=num_a[x[i]];
        	wherex=x[i];
		}
//	cout<<wherex<<" "<<wherey<<endl;
	for(int i=1;i<=m;i++) 
	    if(x[i]==wherex || y[i]==wherey)
	        ans2++;
	cout<<max(ans1,ans2);
	return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int N,K,X,Y;
    cin >> N >> K >> X >> Y;
    int ans = 0;
    if (N <= K){
        ans += X*N;
    } else {
        ans += X*K+(N-K)*Y;
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
using namespace std;
#define ll long long
#define INF 1000000007
signed main(){
    int n,y;
    cin>>n>>y;
    int ans1=-1,ans5=-1,ans10=-1;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            if(10000*i+5000*j+1000*(n-i-j)==y){
                ans1=n-i-j;
                ans5=j;
                ans10=i;
            }
        }
    }
    cout<<ans10<<" "<<ans5<<" "<<ans1<<endl;
    return 0;
}





Measured memory_bytes: 256
local s=io.read()
local n=#s
local k=io.read("n")
local t1={}
for i=1,k do
    for j=1,n-i+1 do
        local sub=s:sub(j,j+i-1)
        table.insert(t1,sub)  
    end
end
table.sort(t1)

local t2={t1[1]}
for i=1,#t1-1 do
    if t1[i]~=t1[i+1] then
        table.insert(t2,t1[i+1])
    end
end
print(t2[k])

Measured memory_bytes: 3524
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

const (
	maxBufSize = 1024 * 1024
)


var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

func gcd(a, b int64) int64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func lcm(a, b int64) int64 {
	result := a * b / gcd(a, b)

	return result
}

func subSolve(a int64, c int64, d int64) int64 {
	ret := a - a / c - a / d + a / lcm(c, d)
	return ret
}

func solve(a int64, b int64, c int64, d int64) int64 {
	return  subSolve(b, c, d) - subSolve(a - 1, c, d)
}

func main() {
	defer out.Flush()

	a := nextInt()
	b := nextInt()
	c := nextInt()
	d := nextInt()
	res := solve(a, b, c, d)
	fmt.Fprintln(out, res)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	b -= a;
	b = abs(b);
	n--;
	bool ans = false;
	REP(x, n + 1)
	{
		ll y = n - x;
		ll mn = c * x - d * y;
		if (mn <= b && mn + (d - c) * n >= b) ans = true;
	}
	cout << (ans ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,x,y = gets.chomp.split.map(&:to_i)
x -= 1
y -= 1

ans = Array.new(n, 0)

n.times do |start_i|
  q = [start_i]
  d = 0
  ds = Array.new(n, -1)
  ds[start_i] = 0
  until q.empty?
    nq = []
    d+=1
    q.each do |index|
      if index == x && ds[y] == -1
        ds[y] = d
        nq.push y
      elsif index == y && ds[x] == -1
        ds[x] = d
        nq.push x
      end
      if index > 0 && ds[index-1] == -1
        ds[index-1] = d
        nq.push(index - 1)
      end
      if index < n - 1 && ds[index+1] == -1
        ds[index+1] = d
        nq.push(index + 1)
      end
    end
    q = nq
  end
  # p ds
  (start_i + 1).upto(n-1) do |i|
    ans[ds[i]] += 1
  end
end

ans.shift

ans.each do |e|
  puts e
end


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

class B
{
	class Restaurant
	{
		public int Id { get; set; }
		public string City { get; set; }
		public int Point { get; set; }
	}

	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var restaurants = Enumerable.Range(0, n)
			.Select(i => Console.ReadLine().Split())
			.Select((x, i) => new Restaurant { Id = i + 1, City = x[0], Point = int.Parse(x[1]) })
			.ToArray();

		var query = restaurants
			.OrderBy(r => r.City)
			.ThenByDescending(r => r.Point)
			.Select(r => r.Id);
		Console.WriteLine(string.Join("\n", query));
	}
}


Measured memory_bytes: 13908
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;

signed main() {
	double a, b, c;
	cin >> a >> b >> c;
	double sum = a + b + c;
	if (sum / 2 == a || sum / 2 == b || sum / 2 == c)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <stdio.h>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
  ll x;
  IN(x);
  ll ans;
  REP(i,x) ans += i;
  OUT(ans);
}

Measured memory_bytes: 256