akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <functional>
using namespace std;

int sum[1048576];
int sum_cnt = 0;
int a[20];

bool memo[20][2001];

void make_sum_array(int depth, int sum_now)
{
	if (sum_now > 2000)
	{
		return;
	}

	if (memo[depth][sum_now] == true)
	{
		return;
	}
	else
	{
		memo[depth][sum_now] = true;
	}

	if (depth == 19)
	{
		sum[sum_cnt++] = sum_now;
		sum[sum_cnt++] = sum_now + a[19];
	}
	else
	{
		make_sum_array(depth + 1, sum_now);
		make_sum_array(depth + 1, sum_now + a[depth]);
	}
}

int main()
{
	//Aの要素を任意に足しあわせてできる数字リストを作る
	//それをソートして、各mに対して二部探索する

	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	make_sum_array(0, 0);
	sort(sum, sum + sum_cnt);

	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		int m;
		cin >> m;

		int left = 0;
		int right = sum_cnt - 1;
		while (true)
		{
			if (m < sum[left] || m > sum[right])
			{
				cout << "no" << endl;
				break;
			}
			else if (right - left == 1)
			{
				if (m == sum[left] || m == sum[right])
				{
					cout << "yes" << endl;
					break;
				}
				else
				{
					cout << "no" << endl;
					break;
				}
			}
			else
			{
				if (m == sum[(left + right) / 2])
				{
					cout << "yes" << endl;
					break;
				}
				else if (m < sum[(left + right) / 2])
				{
					right = (left + right) / 2;
				}
				else if (m > sum[(left + right) / 2])
				{
					left = (left + right) / 2;
				}
			}
		}
	}
	return 0;
}

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

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

    vector<int> C(N), S(N), F(N);
    for(int i = 0; i < N; ++i){
        cin >> C[i] >> S[i] >> F[i];
    }

    for(int i = 0; i < N; ++i){
        int t = 0;
        for(int j = i; j < N; ++j){
            if(t < S[j]) t = S[j];
            else if(t % F[j] != 0){
                t = (t / F[j] + 1) * F[j];
            }
            t += C[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
N = gets.to_i

wk, i, t = N, 0, 0
while wk > t do
  wk -= t
  i += 1
  t = 26 ** i
end
t = (wk-1).to_s(26)

puts ('0' * (i-t.size) + t).tr('0123456789abcdefghijklmnop', 'abcdefghijklmnopqrstuvwxyz')


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

int main(){
    int L,R;
    cin >> L >> R;
    int m = 2019;
    int mi = 2019;
    for(long long i=L;i<=R;i++){
        for(long long j=i+1;j<=R;j++){
            int ans = ((i % m) * j) % m;
            mi = min(mi,ans);
            if(mi == 0)break;
        }
        if(mi == 0)break;
    }
    cout << mi << endl;

    return 0;
}

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

using namespace std;

int main() {
    string X;
    cin >> X;
    if(X[0] == X [1] && X[1] == X [2])
        cout << "Yes" << endl;
    else if(X[1] == X [2] && X[2] == X [3])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Object o = run();
        if (o != null)
            System.out.println(o);
    }

    static Object run() {
        try (Scanner sc = new Scanner(System.in)) {
            int n = sc.nextInt();
            double d = sc.nextInt();
            d *= d;
            int result = 0;
            for (int i = 0; i < n; i++) {
                double x = sc.nextInt();
                double y = sc.nextInt();
                if (d >= x*x+y*y) result++;
            }
            return result;
        }
    }
}

class ChenNumberUtil {
    static Collection<Integer> getDivisors(int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                al.add(i);
                if (n / i != i)
                    al.add(n / i);
            }
        }
        Collections.sort(al);
        return al;
    }
}

class ChenBitUtil {
    static int popCount(int bit) {
        return Integer.bitCount(bit);
    }

    static boolean isFlag(int bit, int i) {
        return 0 != (bit & (1 << i));
    }

    static int setTrue(int bit, int i) {
        return bit |= (1 << i);
    }

    static int setFalse(int bit, int i) {
        return bit &= ~(1 << i);
    }

    static int setReverse(int bit, int i) {
        return isFlag(bit, i) ? setFalse(bit, i) : setTrue(bit, i);
    }

    static int reverseAll(int bit) {
        return ~bit;
    }
}


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

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  int all;

  for (int i = 0; i <= N / R; i++) {
    for (int j = 0; j <= N / G; j++) {
      all = N;
      all -= i * R + j * G;
      if (all < 0) break;
      if (all % B == 0) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut dv = vec![0; n];
    for i in 0..n {
        dv[i] = read(&mut stdin_lock, &mut buf, b'\n');
    }

    dv.sort();
    let mut pd = dv[0];
    let mut ans = 1;
    for i in 1..n {
        let d = dv[i];
        if d > pd {
            pd = d;
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;
typedef long long int ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

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

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

	int h = n/100;

	if (n <= (111*h)) cout << 111*h <<"\n";
	else cout << 111*(h+1) << "\n";

	return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict

input = sys.stdin.readline


class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)


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

uf1 = UnionFind(N)
for _ in range(K):
    p, q = map(int, input().split())
    uf1.union(p - 1, q - 1)

uf2 = UnionFind(N)
for _ in range(L):
    s, t = map(int, input().split())
    uf2.union(s - 1, t - 1)

c = defaultdict(int)
for i in range(N):
    x = uf1.find(i)
    y = uf2.find(i)
    c[(x, y)] += 1

for i in range(N):
    x = uf1.find(i)
    y = uf2.find(i)
    print(c[(x, y)], end=' ')
print()


Measured memory_bytes: 56052
def solve(A,B,C,D, level):
    E = 3**level
    if level == -1:
        return int(abs(A-C) + abs(B-D))
    a,b,c,d = A//E, B//E, C//E, D//E
    if a != c and b != d:
        return int(abs(A-C) + abs(B-D))

    if a == c and b==d:
        return solve(A,B,C,D,level-1)

    if a != c and b==d:
        A,B,C,D = B,A,D,C
        a,b,c,d = b,a,d,c

    if b != d and a == c:
        if a%3 != 1:
            return solve(A,B,C,D,level-1)
        if abs(b-d) == 1:
            return solve(A,B,C,D,level-1)

        if B > D:
            A, B, C, D = C, D, A, B
            a, b, c, d = c, d, a, b

        x = E * a -1
        y1 = E * (b+1) -1
        y2 = E * d
        d = abs(x-A) + abs(y1-B) + abs(y1-y2) + abs(x-C) + abs(y2-D)
        x = E *(a+1)
        d2 = abs(x-A) + abs(y1-B) + abs(y1-y2) + abs(x-C) + abs(y2-D)
        return min(d,d2)

N = int(input())

for i in range(N):
    sg = [int(j.strip())  for j in input().split(' ')]
    s,g = [sg[0]-1,sg[1]-1],[sg[2]-1,sg[3]-1]
    A,B,C,D = s[0],s[1],g[0],g[1]
    print(solve(A,B,C,D,30))


Measured memory_bytes: 3316
// http://tenka1-2017.contest.atcoder.jp/submissions/1715227
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	int N,K;
	cin>>N>>K;
	vint A,B;
	for(int i=0;i<N;i++){
		int a,b;
		cin>>a>>b;
		A.pb(a);
		B.pb(b);
	}
	bool bit[32]={};
	for(int i=0;i<32;i++){
		bit[i]=(K>>i&1);
	}
	ll ans=0,sum=0;
	for(int i=0;i<N;i++){
		bool flag=0;
		for(int j=0;j<32;j++){
			if(!bit[j] && bit[j]!=(A[i]&(1<<j)))
				flag=1;
		}
		if(!flag)
			sum+=B[i];
	}
	ans=sum;
	for(int i=0;i<32;i++){
		if(bit[i]){
			sum=0;
			for(int j=0;j<N;j++){
				bool flag=0;
				for(int k=31;k>=0;k--){
					if(k<i){
					}
					else if(k==i){
						if(A[j]&(1<<k))
							flag=1;
					}
					else{
						if(!bit[k] && bit[k]!=(A[j]&(1<<k)))
							flag=1;
					}
				}
				if(!flag){
					sum+=B[j];
				}
			}
			ans=max(ans,sum);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1276
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>

int main() {
	int *D,n,i,j,max,flg=0;
	scanf("%d", &n);
	D = (int *)malloc(sizeof(int)*n);
	scanf("%d", &D[0]);
	max = D[0];
	for (i = 1; i < n; i++) {
		scanf("%d", D + i);
		if (max < D[i]) max = D[i];
	}
	for (i = 1;; i++) {
		for (j = 0; j < n; j++) {
			if ((max*i) % D[j] != 0) break;
			if (j == n - 1) flg = 1;
		}
		if (flg)break;
	}
	printf("%d\n", max*i);
	free(D);
	return 0;
}

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

#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    ll a,b,c;
    char x;
    cin >> a >> b >> x >> c;
    ll ans = a*b;
    ll ans2 = a*c;
    if(ans2) ans2 /= 100;
    cout << ans+ans2 << endl;
    return 0;
}



Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll =  long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;


constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
	template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
	template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
	template<typename T> void chadd(T& a, T b) { a = a + b; }

	void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }


	// 標準入出力
	struct inp {
		size_t sz;
		inp(size_t _sz = 1) : sz(_sz) {}
		template <typename T> operator T () const { T a; std::cin >> a; return a; }
		template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
		template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
	};

	inp inp1; // input one
}

int main() {

	ll h = inp1;
	ll w = inp1;

	ll ans = 0;

	if (h == 1 || w == 1) {
		Cout(1);
		return 0;
	}

	ll base_w_1 = (w + 1) / 2;
	ll base_w_2 = w - base_w_1;
	ll base_h_1 = (h + 1) / 2;
	ll base_h_2 = h - base_h_1;

	ans = base_w_1 * base_h_1 + base_w_2 * base_h_2;

	Cout(ans);

	return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var soliver = new Solver();

            soliver.Exe();
        }
    }

    public class Solver
    {
        public void Exe()
        {
            var ST = Console.ReadLine().Split();

            Console.WriteLine(ST[1] + ST[0]);
        }


    }
}


Measured memory_bytes: 11092
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    double sum = 0;
    rep(i, n){
        double a; cin >> a;
        sum += 1 / a;
    }
    cout << setprecision(10) << 1 / sum;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
if S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()
if len(S) < 26:
    for i in range(26):
        c = chr(ord('a') + i)
        if c in S: continue
        print(S + c)
        exit()

cset = set()
for i,(a,b) in enumerate(reversed(list(zip(S,S[1:])))):
    cset.add(b)
    if a < b:
        last = 'z'
        for c in cset:
            if c < a: continue
            last = min(last, c)
        print(S[:-i-2] + last)
        exit()

Measured memory_bytes: 3064
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);
	std::vector<int> a(n);
	REP(i, 0, n){
	    scanf("%d", &a[i]);
	    a[i] -= i+1;
	}
	std::vector<int> b(a);
	std::sort(ALL(b));
	int mid = b[n/2];
	ll ans = 0;
	REP(i, 0, n) ans += labs(a[i]-mid);
	printf("%ld\n", ans);
	return 0;
}



Measured memory_bytes: 4820
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{

	class Program
	{

		static void Main(string[] args)
		{
			var inputNum = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

			if(inputNum[0] > inputNum[1])
			{
				Console.WriteLine("safe");
			}
			else
			{
				Console.WriteLine("unsafe");
			}

		}
	}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> vec(H);
  for (int i = 0; i < H; i++)
  {
    cin >> vec.at(i);
  }
  
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (vec.at(i).at(j) == '.')
      {
        int num = 0;
        for (int k = -1; k < 2; k++)
        {
          for (int l = -1; l < 2; l++)
          {
            if (i + k < 0 || i + k >= H || j + l < 0 || j + l >= W)
            {
              continue;
            }
            if (vec.at(i + k).at(j + l) == '#')
            {
              num++;
            }
          }
        }
        cout << num;
      }
      else
      {
        cout << '#';
      }
    }
    cout << endl;
  }
}


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



int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    ll sum = 0;

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    for (int i = 0; i < N; i++) {
        if (i == 0) continue;
        else if (i == 1) sum += a[0];
        //else if (i == 2 || i == 3) sum += a[1];
        else {
            sum += a[i/2]; 
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3996
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/
#define MAX_V 10010
struct edge{
    int to;
    int cap;
    int cost;
    int rev;
    edge(){}
    edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
};

int V;
vector<edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void add_edge(int from,int to,int cap,int cost){
    G[from].push_back(edge(to,cap,cost,(int)G[to].size()));
    G[to].push_back(edge(from,0,-cost,(int)G[from].size()-1));
}

int min_cost_flow(int s,int t,int f){
    int res=0;
    while(f>0){
        fill(dist,dist+V,INF);
        dist[s]=0;
        bool update = true;
        while(update){
            update = false;
            for(int v=0; v<V ;v++){
                if(dist[v]==INF) continue;
                for(int i=0; i<G[v].size(); i++){
                    edge &e = G[v][i];
                    if(e.cap > 0 && dist[e.to] > dist[v]+e.cost) {
                        dist[e.to] = dist[v] + e.cost;
                        prevv[e.to] = v;
                        preve[e.to] = i;
                        update = true;
                    }
                }
            }
        }
        if(dist[t]==INF) return -1;
        
        int d = f;
        for(int v=t; v!=s; v=prevv[v])d=min(d,G[prevv[v]][preve[v]].cap);
        f -= d;
        res += d*dist[t];
        for(int v=t; v!=s; v=prevv[v]){
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return res;
}


int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int M,N,K; cin >> M >> N >> K;
    
    V = K;
    
    int res = 0;
    vector<int> A(N);
    vector<vector<int> > B(N);
    for(int i = 0; i < N;i++) cin >> A[i];
    for(int i = 0; i < K;i++){
        int a; cin >> a; a--;
        B[a].push_back(i);
        res += A[a];
    }
    
    for(int i = 0; i < N;i++){
        if((int)B[i].size() <= 1) continue;
        for(int j = 0; j < (int)B[i].size()-1;j++){
            int s = B[i][j], t = B[i][j+1];
            if(s+1 != t){
                add_edge(s+1, t, 1, -A[i]);
            }else{
                res -= A[i];
            }
        }
    }
    for(int i = 0; i < K-1;i++){
        add_edge(i, i+1, M, 0);
    }
    cout << res + min_cost_flow(0, K-1, M-1) << endl;
    return 0;
}



Measured memory_bytes: 4496
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = LI()
    graph[a - 1] += [b - 1]
    graph[b - 1] += [a - 1]




f_que = deque([0])
s_que = deque([n - 1])
visited = [0] * n
visited[0] = 1
visited[n - 1] = 1
f_cnt = s_cnt = 0
while f_que or s_que:
    f_tmp = deque()
    for cur in f_que:
        for nxt in graph[cur]:
            if visited[nxt]:
                continue
            f_tmp += [nxt]
            visited[nxt] = 1
            f_cnt += 1
    f_que = f_tmp
    s_tmp = deque()
    for cur in s_que:
        for nxt in graph[cur]:
            if visited[nxt]:
                continue
            s_tmp += [nxt]
            visited[nxt] = 1
            s_cnt += 1
    s_que = s_tmp


if s_cnt >= f_cnt:
    print('Snuke')
else:
    print('Fennec')

Measured memory_bytes: 57120
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ar[3],c1,c2;
    c1=0;
    c2=0;
    for(int i=0;i<3;i++)
    {
        cin>>ar[i];
        if(ar[i]==5)
            c1++;
        else if(ar[i]==7)
            c2++;
    }
    if(c1==2 && c2==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> c(m);
  rep(i, m) cin >> c[i];

  sort(c.begin(), c.end());
  vector<int> dp(n+1, INF);
  dp[0] = 0;
  rep(i, m) {
    rep(j, n+1) {
      if (j < c[i]) continue;
      dp[j] = min(dp[j], dp[j - c[i]] + 1);
    }
  }

  cout << dp[n] << endl;
  


  
  return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int K,S; cin >> K >> S;
    int ans = 0;
    rep(i,K+1)rep(j,K+1){
        int d = S-i-j;
        if(d >= 0 && d <= K) ans++;
    }
    cout << ans << endl;
}

    



Measured memory_bytes: 256
n = []
s = input()
def culc(cur, op_c,ans):
    if op_c == 3:
        if cur == 7:
            print(ans + "=7")
            exit()
    else:
        culc(cur+int(s[op_c+1]), op_c+1, ans + "+" + s[op_c+1])
        culc(cur-int(s[op_c+1]), op_c+1, ans + "-" + s[op_c+1])
culc(int(s[0]), 0, s[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int a, b;
    cin >> a >> b;
    cout << (b - a) * (1 + b - a) / 2 - b << endl;
}

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;
	cin >>N;
	vector<int> vec(N);
	rep(i,N){
		cin >>vec.at(i);
	}

	set<int> st(vec.begin(),vec.end());
	
	cout <<((vec.size()==st.size())?"YES":"NO") <<endl;
}

Measured memory_bytes: 11008
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int n,k;
    cin >> n >> k;
    string d[k];
    inrep(k,d);

    while(1){
	string s = to_string(n);
	bool f = 0;

	rep(i,0,k){
	    if((int)s.find(d[i]) != -1){
		f = 1;
		break;
	    }
	}
	if(f == 0){
	    P(s);
	    break;
	}
	n++;
    }
    return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

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

    vector<vector<int>> c(3, vector<int>(3));
    cin >> c;

    bool valid = false;
    //a1をループして調べる
    REP(i, 101) {
        if (c[0][0] < i)break;

        int b1 = c[0][0] - i;
        int a2 = c[1][0] - b1;
        int a3 = c[2][0] - b1;
        int b2 = c[0][1] - i;
        int b3 = c[0][2] - i;
        if (a2 + b2 != c[1][1])continue;
        if (a2 + b3 != c[1][2])continue;
        if (a3 + b2 != c[2][1])continue;
        if (a3 + b3 != c[2][2])continue;
        valid = true;
        break;
    }

    YESNO(valid, "Yes", "No");
    return 0;
}

Measured memory_bytes: 256
n = int( input())
a = list( map( int, input().split()))
cnt = 0

for i in range ( 1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i+1]<a[i]<a[i-1]):
    cnt += 1
    
print (cnt)    


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

using namespace std;

int main()
{
    vector <char> v;
    int n;
    cin >> n;
    cin.ignore();
    string a;
    string b;
    cin >> a;
    cin >> b;
    string c;
    for(int i = 0; i < n; i++)
    {
        v.push_back(a[i]);
        v.push_back(b[i]);
    }
    int len =  v.size();
    for(int j = 0; j <len; j++)
        cout << v[j];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,a,n) for(int i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
ll dp[100001];
int main()
{
    fio;
    ll n;
    cin>>n;
    ll a[n];
    rep(i,n)
    {
        cin>>a[i];
    }
    dp[1]=abs(a[0]-a[1]);
    dp[2]=min(abs(a[0]-a[1])+abs(a[1]-a[2]),abs(a[0]-a[2]));
    //cout<<dp[1]<<" "<<dp[2]<<" ";
    for(int i=3;i<n;i++)
    {
        ll x=0;
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-2]+abs(a[i-2]-a[i-1])+abs(a[i-1]+a[i])));
        //cout<<dp[i]<<" ";
    }
    cout<<dp[n-1]<<endl;
}

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    vector<ll> v(n), w(n);
    for(ll i=0; i<n; i++)
        cin >> v[i] >> w[i];

    ll q;
    cin >> q;
    map<ll,vector<tuple<ll,ll,ll>>> qs;
    set<ll> sss;
    for(ll i=0; i<q; i++) {
        ll x, l;
        cin >> x >> l;
        x--;
        qs[x].push_back({x, l, i});
        while(1) {
            sss.insert(x);
            if(!x) break;
            x = (x-1)/2;
        }
    }

    vector<ll> res(q);

    vector<vector<int>> u(1<<11, vector<int>(1e5+1));
    for(ll i=0; i<min((ll)1<<11, n); i++) {
        for(ll j=1e5; j>=0; j--)
            u[i][j] = max({(ll)u[i][j], (j-w[i] >= 0 ? u[(i-1)/2][j-w[i]] + v[i] : -1), (ll)u[(i-1)/2][j]});
        for(ll j=1; j<=1e5; j++)
            u[i][j] = max(u[i][j], u[i][j-1]);
    }

    auto dfs = [&](auto dfs, ll j, const map<ll,ll> &pre) -> void {

        if(j < 1<<11) {
            if(qs.count(j) > 0)
                for(auto [x, l, i]: qs[j])
                    res[i] = u[j][l];
            if(sss.count(2*j+1)) dfs(dfs, 2*j+1, pre);
            if(sss.count(2*j+2)) dfs(dfs, 2*j+2, pre);
        } else { 
            map<ll,ll> t = pre;
            for(auto [ww, vv]: pre)
                if(ww+w[j] <= 1e5)
                    t[ww + w[j]] = max(t[ww + w[j]], vv + v[j]);

            if(qs.count(j) > 0) {
                for(auto [x, l, i]: qs[j]) {
                    while(x >= 1<<11) x = (x-1)/2;

                    ll r = 0;
                    for(auto &[ww,vv]: t) {
                        if(l - ww < 0) break;

                        r = max(r, vv + u[x][l-ww]);
                    }
                    res[i] = r;
                }
            }
            if(sss.count(2*j+1)) dfs(dfs, 2*j+1, t);
            if(sss.count(2*j+2)) dfs(dfs, 2*j+2, t);
        }
    };
    map<ll,ll> t;
    t[0] = 0;
    dfs(dfs, 0, t);
    for(auto &e: res) cout << e << "\n";
}


Measured memory_bytes: 831620
#include <stdio.h>

int bezero(int n)
{
	if(n%10==0)return 0;
	return n;
}

int max(int N,int s[N])
{
	int sum=0;
	int max=-114514;
	for(int i=0;i<N;i++)
		sum+=s[i];
	if(bezero(sum)!=0)return sum;
	for(int i=0;i<N;i++)
	{
		int x=bezero(sum-s[i]);
		if(max<x)
			max=x;
	}
	return max;
}

int main(void)
{
	int N;
	scanf("%d",&N);
	int s[N];
	for(int i=0;i<N;i++)
		scanf("%d",&s[i]);
	int a=max(N,s);
	printf("%d\n",a);
	return 0;
}


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

int main()
{
    int H, A;
    cin >> H >> A;
    int n;
    if (H % A == 0)
    {
        n = H / A;
    }
    else
    {
        n = H / A + 1;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    ll x;
    cin >> x;
    while (1) {
        bool flag = true;
        ll y = x;
        for (int i = 2; i * i <= y; i++) 
            if (y%i == 0)
                flag = false;

        if (flag) {
            cout << x << endl;
            return 0;
        }
        x++;
    }
}

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int N = 200005;

char word[N];

int main() {
    scanf("%s", &word[1]);
    int n = strlen(word + 1);
    int pot = 1;
    map<int, int> cnt;
    cnt[0] = 1;
    long long ans = 0;
    int rem = 0;
    for (int i = n; i >= 1; i--) {
        rem += (word[i] - '0') * pot;
        rem %= 2019;
        ans += cnt[rem];
        cnt[rem]++;
        pot *= 10;
        pot %= 2019;
    }
    
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#define ALL(a) (a).begin(),(a).end()

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

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};




long long fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  // 前処理
  //COMinit();

  ll A,B,C;
  cin>>A>>B>>C;
	string S;

  if(A<C&&B>C){
      cout<<"Yes"<<endl;
  }else if(A>C&&B<C){
      cout<<"Yes"<<endl;
  }else{
          cout<<"No"<<endl;
  }




  return 0;
 
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var a = new List<int>();
		for (var i = 0; i < 5; i++) a.Add(F);
		var k = F;
		var f = false;
		foreach (var p in a) foreach (var q in a) f |= Abs(p - q) > k;
		WriteLine(f ? ":(" : "Yay!");
	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <stack>
#include <cmath>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <math.h>
#include <cstdlib>
#include <stdlib.h>
#include <set>
#include <unordered_set>
#include <cassert>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forn1(i, n) for (int i = 1; i <= n; ++i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll p = 997;
const ll base = 1e9 + 7;
const ll MAXN = 5e5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double PII = 3.14159265358979323846264338327950288419716939937510;
const double Epsilon = 1.19209e-9;
const ld fi = 1.6180339887498948482;
const ll one = 2147483647;
const ll two = 1e9 + 7;
void print_vectorll(vector<ll> & a) {
    forn(i, (int)a.size()) {
        cout << a[i] << " ";
    }
    cout << "\n";
}
void print_vectorint(vector<int> & a) {
    forn(i, (int)a.size()) {
        cout << a[i] << " ";
    }
    cout << "\n";
}
void read_vector(vector<ll> & a, ll n) {
    ll h;
    forn(i, n) {
        cin >> h;
        a.pb(h);
    }
}
bool check_four(int a){
  int sum = 0;
  while(a){
    sum += a % 10;
    a /= 10;
  }
  return sum % 4 == 0;
}
void upd_max(int & a, int b){
  a = max(a, b);
}
void upd_min(int & a, int b){
  a = min(a, b);
}
ll n, a, b;
bool check_sum(ll ss){
    while(ss){
        if(ss % 10 != a && ss % 10 != b){
            return false;
        }
        ss /= 10;
    }
    return true;
}
ll upd_mod(ll a, ll MOD){
    if (a > MOD){
        a %= MOD;
    }
    return a;
}
ll bin_pow(ll a, ll pow){
    if (pow == 0){
        return 1;
    }
    if (pow == 1){
        return a;
    }
    ll h = bin_pow(a, pow / 2);
    if (pow % 2 == 0){
        return upd_mod(h * h, MOD);
    }
    return upd_mod(upd_mod(h * h, MOD) * a, MOD);
}
//#define DEBUG
int main(){
    FastIO;
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
    #endif // DEBUG
    int n;
    cin >> n;
    int k;
    cin >> k;
    int cnt = 0;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 1; i < n; ++i){
        if (s[i] == s[i - 1]){
            ++ans;
        }
        else{
            ++cnt;
        }
    }
    cout << ans + min(cnt, k * 2) << endl;
    return 0;
}


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

int main() {
	int n; cin >> n;
	vector<int>L(n); for (auto&& x : L)cin >> x;

	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			if (L[i] == L[j])continue;
			for (int k = j + 1; k < n; k++) {
				if (L[i] == L[k] || L[j] == L[k])continue;
				vector<int>tmp(3);
				tmp[0] = L[i]; tmp[1] = L[j]; tmp[2] = L[k];
				sort(tmp.begin(), tmp.end());
				if (tmp[0] + tmp[1] > tmp[2])ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <iomanip>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
 
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=1e3 + 5;
const int M=1e5 + 5;
 
char s[N][N];
char s1[N],s2[N]; 
 
int main()
{
    ios_base::sync_with_stdio(false);
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    int i,j;
    for(i=0;i<w;i++){
        if(i<a){
            s1[i]='0';
            s2[i]='1';
        }
        else{
            s1[i]='1';
            s2[i]='0';
        }
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(i<2*b){
                if(i%2==0) s[i][j]=s1[j];
                else s[i][j]=s2[j];
            }
            else{
                s[i][j]=s1[j];
            }
            cout << s[i][j];
        }
        cout << endl;
    }


 
    return 0;
}

Measured memory_bytes: 2176