akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(){
  int h, w, n, sr, sc;
  scanf("%d%d%d%d%d", &h, &w, &n, &sr, &sc);
  char s[n+1], t[n+1];
  scanf("%s%s", s, t);
  int i;
  int c_l = sc, c_r = sc, r_u = sr, r_d = sr;
  for(i=0;i<n;i++){
    if(s[i] == 'L'){
      c_l--;
      if(c_l < 1){
        puts("NO");
        return 0;
      }
    }else if(s[i] == 'R'){
      c_r++;
      if(c_r > w){
        puts("NO");
        return 0;
      }
    }else if(s[i] == 'U'){
      r_u--;
      if(r_u < 1){
        puts("NO");
        return 0;
      }
    }else if(s[i] == 'D'){
      r_d++;
      if(r_d > h){
        puts("NO");
        return 0;
      }
    }
    if(t[i] == 'L' && c_r > 1){
      c_r--;
    }else if(t[i] == 'R' && c_l < w){
      c_l++;
    }else if(t[i] == 'U' && r_d > 1){
      r_d--;
    }else if(t[i] == 'D' && r_u < h){
      r_u++;
    }
  }
  puts("YES");
  return 0;
}


Measured memory_bytes: 512
x,y,z,K = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

abc = []

for i in range (x):
      for j in range(y):
            for(k) in range(z):
                  if (i+1)*(j+1)*(k+1) <= K:
                        abc.append(a[i]+b[j]+c[k])
                  else:
                        break

abc.sort(reverse=True)
for i in abc[:K]:
      print(i)

Measured memory_bytes: 8708
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	string s; cin >> s;
	REP(i, s.length()) {
		if (i % 2 == 0)cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 512
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

N = int(input())

d = [0]*(10**6 + 1)

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            res = x**2 + y**2 + z**2 + x*y + y*z + z*x
            d[res] += 1

for i in range(1,N+1):
    print(d[i])


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

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

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

const int INF = 1 << 30;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int a, b; cin >> a >> b;
	if (a%3==0 || b%3==0 || (a+b)%3==0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
import itertools
import collections

S = input().split()[0]
T = input().split()[0]
st_set_list = []

for s, t in zip(S, T):
    st_set_list.append(''.join([s, t]))

# 重複する組み合わせを排除
st_set_list = list(set(st_set_list))

s_list = [s for s, t in st_set_list]
t_list = [t for s, t in st_set_list]
s_c = collections.Counter(s_list)
t_c = collections.Counter(t_list)
ans = 'Yes' if s_c.most_common()[0][1] == 1 and t_c.most_common()[0][1] == 1 else 'No'
print(ans)


Measured memory_bytes: 17072
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int P[] = new int[N];
		int A[] = new int[N + 1];
		for(int i = 0 ; i < N ; ++i) {
			P[i] = sc.nextInt();
			A[P[i]] = i + 1;
		}
		TreeSet<Integer> phigh = new TreeSet<>();
		phigh.add(0);
		phigh.add(N + 1);
		phigh.add(A[N]);
		long S = 0;
		//X [i,j]  = P => [i,j] P未満かつP以上が一つ
		for(int n = N - 1; n >= 1 ; --n) {
			int Xi = A[n];
			long y = phigh.higher(Xi);
			long z = N + 1;
			if(y < N + 1) {
				z = phigh.higher((int)y);				
			}
			long x = phigh.lower(Xi);
			long w = 0;
			if(x != 0) {
				w = phigh.lower((int)x);				
			}
			long C = (x - w) * (y - Xi) + (Xi - x) * (z - y);
			S += C * n;
			phigh.add(Xi);
		}
		System.out.println(S);
	}
}


Measured memory_bytes: 58000
#include <stdio.h>

int main(){
	int N; int even = 0;
	int M; int odd = 0;
	scanf ("%d %d", &N, &M);
	
	for (int i=2; i <= N; i++){
		even = even +i-1; 
	}
	for(int i=2; i <= M; i++){
		odd = odd +i-1;
	}
	printf ("%d", odd+even);
	
	
	return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;

const string YES = "Yes";
const string NO = "No";

int main(){
    int d, t, s;
    cin >> d >> t >> s;

    int reachDist = t * s;
    string ans = YES;
    if(reachDist < d) ans = NO;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#define MIN(a,b) ((a<b)?(a):(b))
 
int main() {
    int zero_odd = 0, zero_even = 0, one_odd = 0, one_even = 0, i;
    char str[100001];
 
    scanf("%s", str);
 
    for (i = 0; str[i] != '\0'; i++) {
        if (str[i] == '1') {
            if (i%2 == 0) {one_odd++;}
            else {one_even++;}
        } else {
            if (i%2 == 0) {zero_odd++;}
            else {zero_even++;}
        }
    }
 
    printf("%d", MIN(zero_odd, zero_even) + MIN(one_odd, one_even));
 
}

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

#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1)
#define MAXS 100000
#define MOD 998244353
#define all(v) v.begin(),v.end()
#define pb push_back

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


int tc;


void sol()
{

    int n,c,g=0,s=0,a[105];
    cin>>n;
    for(int i=1; i<=n; i++)cin>>a[i];
    for(int j=1; j<=n; j++){
        cin>>c;
        if(c<a[j]){
            g+=a[j];
            s+=c;
        }
    }
    cout<<g-s<<endl;


}

int main()
{

    _fastIO;

    //cin>>tc;while(tc--)
    sol();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    vec<plint> dishes(N);
    range(i, 0, N) {
        lint A, B; cin >> A >> B;
        dishes.at(i) = {A, B};
    }
    sort(dishes.begin(), dishes.end(), [](const plint& a, const plint& b) {
        return a.first + a.second > b.first + b.second;
    });
    lint ans = 0;
    bool takahashi_eats = true;
    range(i, 0, N) {
        ans += (takahashi_eats ? dishes.at(i).first : -dishes.at(i).second);
        takahashi_eats ^= true;
    }
    cout << ans << "\n";
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

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


int main() {
    ll a,b;  cin >>a>>b;
    ll d = b-a;
    ll b_be = d*(d+1)/2;
    cout << b_be - b << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int c = a + b;
        int d = a-b;
        int e=  a*b;
        int f = Math.max(c, Math.max(d, e));
        out.println(f);
        out.close(); System.exit(0);
    }
}


Measured memory_bytes: 22484
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split();
		string[] str2 = Console.ReadLine().Split();
		int[]A = new int[N];
		int[]B = new int[N];
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str[i]);
			B[i] = int.Parse(str2[i]);
		}
		int a1 = 0;
		int ac = 1;
		for(var i=N-2;i>=0;i--){
			int ct = A[i];
			for(var j=i-1;j>=0;j--){
				if(A[j]<A[i]){
					ct--;
				}
			}
			a1 += ct * ac;
			ac *= N-i;
		}
		int b1 = 0;
		ac = 1;
		for(var i=N-2;i>=0;i--){
			int ct = B[i];
			for(var j=i-1;j>=0;j--){
				if(B[j]<B[i]){
					ct--;
				}
			}
			b1 += ct * ac;
			ac *= N-i;
		}
		Console.WriteLine(Math.Abs(a1-b1));
	}
}

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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, p;
	getline(cin, s);
	getline(cin, p);
	s+=s;
	if(s.find(p)!=string::npos) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}



Measured memory_bytes: 3236
#include <cstring>
#include <iostream>
using namespace std;
int main() {
    int N, S; cin >> N >> S;
    int a[N]; for (int i = 0; i < N; i++) cin >> a[i];
    long long dp[S+1];
    memset(dp, 0, sizeof dp);
    long long ans = 0;
    const int M = 998244353;
    for (int r = 0; r < N; r++) {
        for (int t = S-a[r]; t >= 0; t--)
            (dp[t+a[r]] += dp[t]) %= M;
        if (a[r] <= S) dp[a[r]] += r+1;
        ans += dp[S];
        ans %= M;
    }

    cout << ans % M << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var dic = new Dictionary<int, int>();
        var prime = new List<int>();
        var bo = new bool[num+1];
        for (var i = 2; i <= num; i++)
            if (!bo[i])
            {
                prime.Add(i);
                for (var j = 2 * i; j <= num; j += i)
                    bo[j] = true;
            }
        for (var i = 2; i <= num; i++)
            foreach (var prim in prime)
            {
                if (i < prim) break;
                if (i % prim == 0)
                {
                    var al = i;
                    while (al%prim==0)
                    {
                        if (dic.ContainsKey(prim)) dic[prim]++;
                        else dic[prim] = 1;
                        al /= prim;
                    }
                }
            }
        var ar = new[] { 74, 24, 14, 4, 2 };
        var uu = new int[ar.Length];
        for (var i = 0; i < ar.Length; i++)
            uu[i] = dic.Values.Count(v => v >= ar[i]);
        var res = 0;
        res += uu[0];
        res += uu[1] * (uu[4] - 1);
        res += uu[2] * (uu[3] - 1);
        res += uu[3] * (uu[3] - 1) * (uu[4] - 2)/2;
        WriteLine(res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


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

int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;

  int ans;
  bool sum = true;
  if (s.size() <= t.size()) {
    for (int i = 0; i < s.size(); i++) {
      string st = s.substr(0, i) + t;
      if (st.substr(0, s.size()) == s && st.substr(st.size() - t.size()) == t) {
        ans = st.size();
        sum = false;
        break;
      }
    }
    if (sum) {
      ans = s.size() + t.size();
    }
  } else {
    for (int i = 0; i < t.size(); i++) {
      string st = s + t.substr(t.size() - i);
      if (st.substr(0, s.size()) == s && st.substr(st.size() - t.size()) == t) {
        ans = st.size();
        sum = false;
        break;
      }
    }
    if (sum) {
      ans = s.size() + t.size();
    }
  }

  cout << ans << endl;
}

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

typedef long long ll;

int main() {
	string S;
	ll res = 0;
	cin >> S;
	for(int i = 0; i < (1 << (S.size()-1)); i++) {
		ll tmp;
		tmp = S[0]-'0';
		for(int j = 1; j < S.size(); j++) {
			if(i & (1 << (j-1))) {
				res += tmp;
				tmp = 0;
			}
			tmp *= 10;
			tmp += S[j]-'0';
		}
		res += tmp;
	}
	cout << res << endl;
}


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

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

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1)res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

int main()
{
	string L;
	cin >> L;
	reverse(L.begin(), L.end());
	vector<ll> dp(L.size(), 0);

	// init
	if (L[0] == '0')dp[0] = 1;
	else dp[0] = 3;

	FOR(i, 1, L.size()) {
		if (L[i] == '0') {
			dp[i] = dp[i - 1];
		}
		else {
			(dp[i] += dp[i - 1] * 2) %= MOD;
			(dp[i] += mod_pow(3, i, MOD)) %= MOD;
		}
	}

	cout << dp.back() << endl;
	return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstring>

using namespace std;

void solve()
{
    int n;
    string s;
    cin >> n;
    cout << 0 << endl;
    cin >> s;
    if (s == "Vacant") return;
    int lx = (s[0] == 'M');

    cout << n - 1 << endl;
    cin >> s;
    if (s == "Vacant") return;
    int rx = (s[0] == 'M');
    int l = 0, r = n - 1;

    for( ; ; ) {
        int mid = (l + r) / 2;
        cout << mid << endl;
        cin >> s;
        if (s == "Vacant") return;

        int should = lx;
        int x = (s[0] == 'M');

        if (mid % 2 != l % 2) {
            should = 1 - lx;
        }

        if (should == x) {
            lx = x;
            l = mid;
        } else {
            rx = x;
            r = mid;
        }
    }
}

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


Measured memory_bytes: 852
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 1e+9;

int main(){
	int n;
	while( cin >> n , n ){
		int d[11][11], v=0, s[11]={0};
		
		for(int i=0 ; i < 11 ; i++ ){
			for(int j=0 ; j < 11 ; j++ ){
				d[i][j] = (i==j)? 0 : INF;
			}
		}
		for(int i=0 ; i < n ; i++ ){
			int a,b,c;
			cin >> a >> b >> c;
			d[a][b] = c;
			d[b][a] = c;
			v = max( max( v , a ) , b );
		}

		for(int k=0 ; k <= v ; k++ ){
			for(int i=0 ; i <= v ; i++ ){
				for(int j=0 ; j <= v ; j++ ){
					d[i][j] = min( d[i][j] , d[i][k]+d[k][j] );
				}
			}
		}

		int ans = INF;
		for(int i=0 ; i <= v ; i++ ){
			int cost = 0;
			for(int j=0 ; j <= v ; j++ ){
				cost += d[i][j];
			}
			s[i] = cost;
			ans = min( ans , cost );
		}
		for(int i=0 ; i <= v ; i++ ){
			if( s[i] == ans ){
				cout << i << " " << ans << endl;
				break;
			}
		}
	}
}

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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(a) a.begin(), a.end()
#define ll long long
#define mod 1e9+7

using namespace std;

void remove(string& str, const string& replace) {
  size_t pos = 0;
  while ((pos = str.find(replace, pos)) != string::npos) {
    str.replace(pos, replace.length(), "");
  }
}

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

  remove(s, "eraser");
  remove(s, "erase");
  remove(s, "dreamer");
  remove(s, "dream");

  cout << (s.empty() ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
package main

import "fmt"

func isPrime(x int) bool {
	if x < 2 {
		return false
	}

	for i := 2; i*i <= x; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

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

	for {
		if isPrime(x) {
			fmt.Println(x)
			return
		}
		x++
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	string s, t; cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.length(); i++) {
		ans += (s[i] != t[i]);
	}
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 3792
#include <algorithm>
#include <iostream>

using namespace std;

constexpr static int MAXV = 200 * 100;
bool reach[MAXV];

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

    int val = 0;
    reach[0] = true;
    for (int i = 0; i < n; i++) {
        int s;
        cin >> s;
        for (int j = MAXV - 1; j >= 0; j--)
            if (reach[j]) {
                reach[j + s] = true;
                if ((j + s) % 10 != 0)
                    val = max(val, j + s);
            }
    }
    cout << val << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b,c,d;
    string s,s1;
    cin >> a >>b;
    if(a*b%2==0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    return 0;
} 

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

int main(int argc, char const *argv[]) {
  int input_num = 10;

  list<int> ls;

  int height = 0;
  for (size_t i = 0; i < input_num; i++) {
    cin >> height;
    ls.push_back(height);
  }

  ls.sort(std::greater<int>());

  list<int>::iterator it = ls.begin();
  for (int i = 0; i < 3; i++) {
    cout << *it << endl;
    it++;
  }

  return 0;
}



Measured memory_bytes: 3088
n, k = map(int, input().split())
data = list(map(int, input().split()))

for i in range(n-k):
    # if data[i:i+k][0] < data[i+1:i+k+1][-1]:
    # print("-----------------")
    # print( data[i:i+k] )
    # print( data[i+1:i+k+1] )

    # print( data[i] )
    # print( data[k+i] )
    # print("-----------------")

    if data[i] < data[k+i]:
        print("Yes")
        # print( data[i:i+k] )
        # print( data[i+1:i+k+1] )
    else:
        print("No")


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

using namespace std;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int n;
ld   m , a[maxn];

int main(){
    migmig
    cin >> n >> m;
    ld sum = 0 ;
    for(int i = 0 ; i < n ; i ++){
        cin >> a[i];
        sum += a[i];
    }
    for(int i = 0 ; i < n ; i ++){

    }
    sum/=4*m;
    int cnt = 0 ;
    for(int i = 0 ; i < n ; i ++){
        if(a[i] >= sum){
            cnt++;
        }
    }
    if(cnt >= (int)m){
        cout << "Yes";
    }
    else{
        cout << "No";
    }


    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize,
    }

    let digit = n.to_string().len();
    if n.to_string().chars().skip(1).all(|x| x == '9') {
        println!("{}", (n.to_string().chars().nth(0).unwrap() as usize - 48) + 9 * (digit-1))
    } else {
        println!("{}", (n.to_string().chars().nth(0).unwrap() as usize - 48) - 1 + 9 * (digit - 1))
    }

    println!("", );
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << A * B / 2 << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1<<28;

int main(){

    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string ans;
    //初期化
    char RL = 'R';
    if(sx > tx){
        swap(sx, tx);
        RL = 'L';
    }
    char UD = 'U';
    if(sy > ty){
        swap(sx, tx);
        UD = 'D';
    }  
    //１回目の行き
    for(ll i = sx; i < tx; i++){
        ans += RL;
    }
    //はんてん
    if(RL == 'R'){
        RL = 'L';
    }else{
        RL = 'R';
    }

    for(ll i = sy; i < ty; i++){
        ans +=UD;
    }
    //はんてん
    if(UD == 'U'){
        UD = 'D';
    }else{
        UD = 'U';
    }
    //１回目の帰り
    for(ll i = sx; i < tx; i++){
        ans += RL;
    }
    if(RL == 'R'){
        RL = 'L';
    }else{
        RL = 'R';
    }
    //すこし行きすぎる
    for(ll i = sy; i <= ty; i++){
        ans += UD;
    }
    if(UD == 'U'){
        UD = 'D';
    }else{
        UD = 'U';
    }

    //2回目の行き帰り（大外を通る）
    for(ll i = sx; i <= tx; i++){
        ans += RL;
    }
    //はんてん
    if(RL == 'R'){
        RL = 'L';
    }else{
        RL = 'R';
    }

    for(ll i = sy; i <= ty; i++){
        ans += UD;
    }
    //ゴールへ少し戻る
    ans+= RL;
    ans+= UD;

    if(UD == 'U'){
        UD = 'D';
    }else{
        UD = 'U';
    }

    for(ll i = sx; i <= tx; i++){
        ans += RL;
    }
    //はんてん
    if(RL == 'R'){
        RL = 'L';
    }else{
        RL = 'R';
    }

    for(ll i = sy; i <= ty; i++){
        ans += UD;
    }
    ans+= RL;

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...) \
  { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
 public:
  void solve() {
    i64 n;
    cin >> n;
    if (n & 1) {
      cout << 0;
      return;
    }
    i64 ans = 0;
    n /= 2;
    while (n) {
      ans += n / 5;
      n /= 5;
    }
    cout << ans << '\n';
  }
} NSPACE;
int main() {
  FPEN;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
    	int pal = 0;
        int d1, d2, d4, d5;
        int x = sc.nextInt();
        int y = sc.nextInt();
        for(int i = x; i <= y; i++){
            d1 = i/10000;
            d2 = (i/1000)%10;
            d4 = (i%100)/10;
            d5 = i%10;
            if(d1 == d5 && d2 == d4)
                pal++;
        }
      	System.out.println(pal);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define lli long long int
#define timesave                    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
	timesave;
    
    lli x, a, b;
    
    cin >> x >> a >> b;
    
    x = x-a;
    
    cout << x%b << endl;
	
    
 	return 0;   
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    long total = 0;
    
    if(a<=0 && b>=0) {
      System.out.println("Zero");
    } else {
      for(int i=a; i<b+1; i++) {
        if(i<0) {
          total++;
        }
      }
      if(total % 2 == 0) {
        System.out.println("Positive");
      } else {
        System.out.println("Negative");
      }
    }
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  string A, B, C;
  cin >> N >> A >> B >> C;
  int ans = 0;
  REP(i,N){
    if(A[i] != B[i] && B[i] != C[i] && A[i] != C[i])
      ans += 2;
    else if(A[i] == B[i] && B[i] == C[i])
      continue;
    else
      ans += 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
s = input()
ans = 'AC'

if s[0] != 'A':
    ans = 'WA'
if s[2:-1].count('C') != 1:
    ans = 'WA'
if s[1] == 'C' or s[-1] == 'C':
    ans = 'WA'
reps = s.replace('A', 'a').replace('C', 'c')    
if reps != s.lower():
    ans = 'WA'

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int f(int n, int k) {
    if(n == 1) return 0;
    else return (f(n-1,k) + k) % n;
}

signed main() {
    int n, k, m;
    while(cin >> n >> k >> m, n || k || m) {
        cout << (f(n-1, k) + m) % n + 1 << endl;
    }
    return 0;
}

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

#include <atcoder/mincostflow>
using namespace atcoder;


void solve(long long N, long long K, std::vector<std::vector<long long>> A){
    // 0..N-1: rows
    // N..2N-1: cols
    // 2N: s
    // 2N+1: t
    mcf_graph<long long, long long> g(2*N+2);
    int s_index = 2 * N;
    int t_index = 2 * N + 1;

    // サンプルより。「K以下」だから選ばなくても OK と。
    // we can "waste" the flow
    g.add_edge(s_index, t_index, N * K, 1e9);

    for (int i = 0; i < N; i++) {
        int row_index = i;
        g.add_edge(s_index, row_index, K, 0);
        for (int j = 0; j < N; j++) {
            int col_index = N + j;
            if (i == 0) {
                g.add_edge(col_index, t_index, K, 0);
            }
            g.add_edge(row_index, col_index, 1, 1e9 - A[i][j]);
        }
    }
    auto p = g.flow(s_index, t_index, N * K);
    long long cap = p.first;
    long long cost = p.second;
    long long result = N * K * (long long)1e9 - cost;
    cout << result << endl;

    vector<string> result_map(N, string(N, '.'));
    for (auto e: g.edges()) {
        if (e.from != s_index && e.to != t_index && e.flow != 0) {
            result_map[e.from][e.to - N] = 'X';
        }
    }
    for (int i = 0; i < N; i++) {
        cout << result_map[i] << endl;
    }
}

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


Measured memory_bytes: 3984
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import numpy as np

n, k = map(int, readline().split())
a = np.array(list(map(int, readline().split())), np.int64)
a = np.sort(a)
z = a[a == 0]
p = a[a > 0]
m = a[a < 0]


def check(mid):
    cnt = 0
    # 0以上のとき
    if mid >= 0:
        cnt += len(z) * n
    cnt += np.searchsorted(a, mid // p, side='right').sum()
    cnt += (n - np.searchsorted(a, (-mid - 1) // (-m), side='right')).sum()
    cnt -= np.count_nonzero(a * a <= mid)
    return cnt // 2


left = -10 ** 18
right = 10 ** 18
while left + 1 < right:
    mid = (left + right) // 2
    if check(mid) >= k:
        right = mid
    else:
        left = mid
print(right)


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

alice = 0
bob = 0

for i in range(n):
    if i%2 == 0 :
        alice += max(a)
        del a[a.index(max(a))]
    else :
        bob += max(a)
        del a[a.index(max(a))]
print(alice - bob)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vii         vector<pair<int,int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define endl '\n'
#define int long long int
using namespace std;

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int n;cin >> n;
    vi in(n);
    int sum =0;
    FOR(i, n)cin >> in[i], sum += in[i];
    const int sz = (2000*2000/2) + 2000 + 1;
    if(n == 1){
        cout << in[0];
        return 0;
    }
    bitset<sz> dp;
    bitset<sz> prev;
    prev[0] = 1;
    FOR(i, n){
        dp = prev;
        dp |= (prev << in[i]);
        swap(dp, prev);
    }
    int mid = (sum+1)/2;
    while(true){
        if(prev[mid]){
            cout << mid;
            return 0;
        }
        mid++;
    }

} 




Measured memory_bytes: 1280
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }
        Arrays.sort(d);
        int x = d[n / 2] - d[n / 2 - 1];
        System.out.println(x);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 25664
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let line = read_as_vec::<usize>();
    let (n, k) = (line[0], line[1]);
    let mut cur_lamps = read_as_vec::<i64>();

    for _ in 0..k {
        let mut v: Vec<i64> = vec![0; n];

        for i in 0..n {
            let left = cmp::max(0, i as i64 - cur_lamps[i]) as usize;
            let right = cmp::min(n, i + cur_lamps[i] as usize) + 1;
            v[left] += 1;
            if right < n {
                v[right] -= 1;
            }
        }

        let mut cur = 0;
        for i in 0..n {
            cur += v[i];
            v[i] = cur;
        }
        cur_lamps = v;
        if cur_lamps.iter().all(|x| *x == n as i64) {
            break;
        }
    }

    for i in 0..n {
        print!("{} ", cur_lamps[i]);
    }
}


Measured memory_bytes: 5236
#include "bits/stdc++.h"
#define REP(i,n,N) for(ll i=n; i<N; i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;

int main() {
	string s;
	int a,b,c,d;
	vector<vector<char>> board(10,vector<char>(10));
	while(1){
		cin >> s;
		if(s[0]=='#')break;
		cin >> a >> b >> c >> d;
		REP(i,0,10)REP(j,0,10) board[i][j]='?';
		int column=0;
		int row=0;

		//board作成
		REP(i,0,s.size()){
			if(s[i]=='/'){
				column++;
				row=0;
				continue;
			}
			if(s[i]=='b'){
				board[column][row]='b';
				row++;
				continue;
			}
			int num=(s[i]-'0');
			REP(j,0,num){
				board[column][row] = '.';
				row++;
			}
		}

		board[a-1][b-1]='.';
		board[c-1][d-1]='b';

		string ans;
		REP(i,0,10){
			if(board[i][0]=='?') break;
			int count=0;
			REP(j,0,10){
				if(board[i][j]=='?'){
					if(count!=0) ans.push_back(count+'0');
					ans.push_back('/');
					count=0;
					break;
				}
				if(board[i][j]=='.'){
					count++;
					continue;
				}
				if(board[i][j]=='b'){
					if(count!=0) ans.push_back(count+'0');
					ans.push_back('b');
					count=0;
				}
			}
		}
		if(ans.back()=='/')ans.pop_back();
		p(ans);

	}
	return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, b) for (int i = 0; i < b; i++)
#define repl(i, a, b) for (ll i = a; i <= b; i++)
#define ppi pair<int, int>
#define scl(n) scanf("%d", &n);
#define pcl(n) printf("%d\n", n)
#define pcl1(n) printf("%lld ", n)
#define FastRead                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0)
bool comp(ppi a, ppi b)
{
    return a.first < b.first;
}
int a[102];
vector<int>v;
int main()
{
    FastRead;
    int x, n,i = 0;
	bool cnt=0,cnt1=0;
    cin >> x >> n;
    while (i < n)
    {
        int p;
        cin >> p;
        a[p] = p;
        i++;
    }
    for (int j = 0; j <=101; j++)
    {
		if(a[j]==0) 
		{
			v.pb(j);
			if(j==x) cnt1=1;
		}
    }
	int px=lower_bound(v.begin(),v.end(),x)-v.begin()-1;
	int qx=upper_bound(v.begin(),v.end(),x)-v.begin();
	if(n==0 || cnt)
	{
		cout<<x<<endl;
		return 0;
	}
	else if (cnt1)
	{
		cout<<x<<endl;
	}
    else if(abs(v[qx]-x)<abs(v[px]-x)) 
	{
			cout<<v[qx]<<endl;
	}
	else cout<<v[px]<<endl;		
    return 0;
}


Measured memory_bytes: 3644
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int S=2e5+10;
LL dp0[S];
LL dp1[S];
LL dp2[S];
LL dp3[S];
LL dp4[S];
LL A[S];
int main() {
	int L;
	cin >> L;
	for(int i=1;i<=L;i++){
		cin >> A[i];
	}
	for(int i=1;i<=L;i++){
		dp0[i]=dp0[i-1]+A[i];
	}
	for(int i=1;i<=L;i++){
		LL d=0;
		if(A[i]==0){
			d=2;
		}
		else if(A[i]%2){
			d=1;
		}
		dp1[i]=min(dp0[i],dp1[i-1]+d);
	}
	for(int i=1;i<=L;i++){
		LL d=0;
		if(A[i]%2==0){
			d=1;
		}
		dp2[i]=min(dp1[i],dp2[i-1]+d);
	}
	for(int i=1;i<=L;i++){
		LL d=0;
		if(A[i]==0){
			d=2;
		}
		else if(A[i]%2){
			d=1;
		}
		dp3[i]=min(dp2[i],dp3[i-1]+d);
	}
	for(int i=1;i<=L;i++){
		dp4[i]=min(dp3[i],dp4[i-1]+A[i]);
	}
	cout << dp4[L] << endl;

	return 0;
}



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

int main() {
	using std::cin;
	int n, m;

	std::vector<std::string> blue, red;

	scanf("%d\n", &n);
	blue.resize(n);
	for (int i = 0; i < n; i++)
		cin >> blue[i];

	scanf("%d\n", &m);
	red.resize(m);
	for (int i = 0; i < m; i++)
		cin >> red[i];

	int r = 0;
	for (int i = 0; i < n - 1; i++) {
		int count = 1;
		for (int j = i + 1; j < n; j++) {
			if (blue[i] == blue[j]) ++count;
		}
		for (int k = 0; k < m; k++) {
			if (blue[i] == red[k]) --count;
		}
		r = std::max(r, count);
	}

	printf("%d\n", r);

	return 0;
}


Measured memory_bytes: 3236
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var n = Console.ReadLine();

            if(n == "ABC")
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("ABC");
            }
            

        }


        public int ReadInputOneLine()
        {
            return int.Parse(Console.ReadLine());
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ParseIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }


        public List<double> ParseDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ParseLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 17328
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <stdexcept>
using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  cout << ((B%A == 0)?(A+B):(B-A)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

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


int main() {
	int n, w;
	while(cin >> n >> w, n||w) {
		int cnt[11]={};
		int maxi=0;
		rep(i, n) {
			int v;
			cin >> v;
			cnt[v/w]++;
			maxi = max(maxi, cnt[v/w]);
		}
		double ink = 0.01;
		int k = 0;
		for(int i=0; i<11; i++) {
			if(cnt[i]>0) k=i;
		}
		rep(i,11) {
			if(cnt[i]==0) continue;
			ink += 1. * (k-i) * cnt[i] / k / maxi;
		}
		cout << fixed << setprecision(8) << ink << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
N,K = map(int,input().split())

A = list(map(int,input().split()))
one = 0
for i in range(len(A)):
    if A[i] == 1:
        one = i
        
zenhan = one - 0
kouhan = N-1 - one

if zenhan%(K-1) != 0:
    kouhan -= (K-1 - zenhan%(K-1))

print(-(-zenhan//(K-1)) - (-kouhan//(K-1)))

Measured memory_bytes: 52604