akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
using namespace std;


#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<VV> VVV;


int main() {
	long long int a, b, c, d, e, k;
	int y = 0;
	cin >> a >> b >> c >> d >> e >> k;
	if ((b - a) > k) {
		y = 1;
	}
	if ((c - a) > k) {
		y = 1;
	}
	if ((d - a) > k) {
		y = 1;
	}
	if ((e - a) > k) {
		y = 1;
	}
	if ((c - b) > k) {
		y = 1;
	}
	if ((d - b) > k) {
		y = 1;
	}
	if ((e -b) > k) {
		y = 1;
	}
	if ((d - c) > k) {
		y = 1;
	}
	if ((e - c) > k) {
		y = 1;
	}
	if ((e - d) > k) {
		y = 1;
	}
	if (y == 0) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}

}


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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> vec(n);
  for(int i=0;i<n;i++){   
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int sum=0;
  for(int i=0;i<k;i++){
    sum+=vec.at(i);
  }
  cout<<sum<<endl;
  return 0;
}
  

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll d[5003];
ll c[5003];
int main(void)
{
	ll k,q;
	scanf("%lld%lld",&k,&q);
	for(ll i=0;i<k;i++)
	{
		scanf("%lld",&d[i]);
	}
	while(q--)
	{
		ll n,x,m;
		scanf("%lld%lld%lld",&n,&x,&m);
		ll ans=n-1;
		ll sum=0;
		ll zero=0;
		for(ll i=0;i<k;i++) 
		{
			c[i]=d[i]%m;
			if(c[i]==0) zero++;
			sum+=c[i];
		}
		ans-=((n-1)/k)*zero;
		ll dn=((n-1)/k)*sum;
		for(ll i=0;i<(n-1)%k;i++)
		{
			dn+=c[i];
			if(c[i]==0) ans--;
		}
		ans-=(dn+x)/m-x/m;
		printf("%lld\n",ans);
	}
}

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

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

    string s,t;
    cin >> s;
    cin >> t;

    for(int i = 0; i < n; i++) {
        cout << s[i] << t[i];
    }
    cout << '\n';
    
    return 0;
}

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

#define REP(i,j,k) for( int i=j; i<k; i++ )
#define rep(i,j) REP(i,0,j)

using namespace std;

typedef long int LI;

int main(){
	
	string s;
	cin >> s;
	
	int n = s.size();
	
	int even = 0;
	rep(i,n)
		if( s[i] == '0' + i%2 ) even++;
	
	int odd = 0;
	rep(i,n)
		if( s[i] == '1' - i%2 ) odd++;
	
	cout << min(even,odd) << endl;
	
	return 0;
	
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	if( (a==b && a!=c) || (a==c && b!=c) || (b==c && a!=c) )
	{
		cout<<"Yes"<<endl;		
	}	
	else cout<<"No"<<endl;
} 

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll x, n;
  cin >> x >> n;
  vll a(n);
  rep(i, n){
    cin >> a[i];
  }
  ll y = INF;
  ll ans = -1;
  rep(i, 102){
    bool f = 1;
    rep(j, n){
      if(i == a[j]){
        f = 0;
        break;
      }
    }
    if(f){
      if(chmin(y, abs(i-x))){
        ans = i;
      }
    }
  }
  print(ans);
}


Measured memory_bytes: 3656
N,K=map(int, input().split())
kosu = []
for i in range(N):
  kosu.append(0)
for i in range(K):
  d = int(input())
  A=list(map(int, input().split()))
  for t in range(d):
    kosu[A[t]-1] += 1
print(len([1 for x in kosu if x==0]))

Measured memory_bytes: 9196
#include<stdio.h>
int main()
{
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    scanf("%d",&K);
    printf("%d\n",a[K-1]);
    return(0);
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n = II()
    A = LI()

    memo = {}
    for a in A:
        memo[a] = memo.get(a, 0) + 1

    def choose2(a):
        if a == 0: return 0
        return a * (a-1) // 2

    # print(memo)
    ans = 0
    for k, v in memo.items():
        ans = ans + choose2(v)
    # print(ans)

    for a in A:
        print(ans - choose2(memo[a]) + choose2(memo[a] - 1))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 26140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
#define f first
#define s second
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll x, y, a, b, c, t, ans;
vector<ll> r, g, co;
priority_queue<ll, vector<ll>, greater<ll> > pqr, pqg;

void ppq(priority_queue<ll, vector<ll>, greater<ll> > pq) {
	while (!pq.empty()) {
		cout << pq.top() << " ";
		pq.pop();
	}
	cout << "\n";
}

int main() {
	fastio; cin >> x >> y >> a >> b >> c;
	FOR(i, 1, a) {cin >> t; r.pb(t);}
	FOR(i, 1, b) {cin >> t; g.pb(t);}
	FOR(i, 1, c) {cin >> t; co.pb(t);}
	sort(r.begin(), r.end(), greater<ll>());
	sort(g.begin(), g.end(), greater<ll>());
	sort(co.begin(), co.end());
	FOR(i, 0, x-1) pqr.push(r[i]);
	FOR(i, 0, y-1) pqg.push(g[i]);
	while (!co.empty() and co.back() > min(pqr.top(), pqg.top())) {
		if (pqr.top() < pqg.top()) {
			pqr.pop(); pqr.push(co.back());
		} else {
			pqg.pop(); pqg.push(co.back());
		}
		co.pop_back();
	}
	while (!pqr.empty()) {
		ans += pqr.top(); pqr.pop();
	}
	while (!pqg.empty()) {
		ans += pqg.top(); pqg.pop();
	}
	cout << ans;
}



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

int main()
{
  int N;
  std::cin >> N;
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    int tmp;
    std::cin >> tmp;
    while (tmp % 2 == 0)
    {
      tmp /= 2;
      ans++;
    }
  }
  std::cout << ans << std::endl;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

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

int main() {
    cin >> n >> m;
    maxi = max(n, m);
    mini = min(n, m);
    if (maxi - mini >= 2) {
        END(0)
    }

    if (maxi == mini) {
        MSG(((mod_fact(maxi) * mod_fact(mini)) % MOD) * 2 % MOD)
    } else {
        MSG((mod_fact(maxi) * mod_fact(mini)) % MOD)
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
        int i,n1,n2;
        char o[51],e[51];

        scanf("%s",o);
        scanf("%s",e);

        n1 = 0;
        n2 = 0;
        while(o[n1]!='\0')
                n1++;
        while(e[n2]!='\0')
                n2++;

        if(n1>n2){
                for(i=0;i<n2;i++)
                        printf("%c%c",o[i],e[i]);
                printf("%c",o[n1-1]);
        }
        else{
                for(i=0;i<n1;i++)
                        printf("%c%c",o[i],e[i]);
        }
        printf("\n");

        return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n, k int
	var s string
	fmt.Scan(&n)
	fmt.Scan(&s)
	fmt.Scan(&k)

	buf := make([]byte, n)
	for i := 0; i < n; i++ {
		if s[i] == s[k-1] {
			buf[i] = s[i]
		} else {
			buf[i] = '*'
		}
	}
	fmt.Println(string(buf))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int x,i,ans1,ans2,ans3;
  cin>>x;
  rep(i,1000){
    if(i*i>x){
      break;
    }
    ans1=i*i;
  }
  rep(i,1000){
    if(i*i*i>x){
      break;
    }
    ans2=i*i*i;
  }
  rep(i,1000){
    if(i*i*i*i*i>x){
      break;
    }
    ans3=i*i*i*i*i;
  }
  cout<<max({ans1,ans2,ans3})<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

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

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

int main(){
    string s;
    cin >> s;
    vector<int> cnts(3);
    rep(i, s.size()){
        int index = s[i] - 'a';
        cnts[index] ++;
    }
    sort(cnts.begin(), cnts.end());
    if(abs(cnts[0] - cnts[2]) < 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

vl a(3007);
vvl flag(3007,vl(3007));
vvl dp(3007,vl(3007));

ll f(int l,int r){
	if(flag[l][r])return dp[l][r];
	flag[l][r]=1;
	if(l==r)return dp[l][r]=a[l];
	return dp[l][r]=max(a[l]-f(l+1,r),a[r]-f(l,r-1));
}

signed main(){
    gearup;
    int n;cin >> n;
    rep(i,n)cin>>a[i];
    out(f(0,n-1));
}



Measured memory_bytes: 141952
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
string s;
void MAIN() {
	cin>>s;
	if(s=="ABC")cout<<"ARC";
	else cout<<"ABC";
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int str_cmp(const void *a, const void *b)
{
	return strcmp(*(char **)a, *(char **)b);
}

int main()
{
	int N;
	scanf("%d", &N);
	char str[N + 1][11];
	char **sort;
	sort = (char**)malloc(sizeof(char*) * N);
	int i = 0;
	int len;
	while (i < N)
	{
		scanf("%s", str[i]);
		len = strlen(str[i]);
		sort[i] = (char*)malloc(sizeof(char) * (len + 1));
		strcpy(sort[i], str[i]);
		i++;
	}
	qsort(sort, N, sizeof *sort, str_cmp);

	i = 0;
	int max[N];
	int top = 0;
	int n = 1;
	while (i < N)
	{
		max[i] = 0;
		if (i != N - 1)
		{
			if (strcmp(sort[i], sort[i + 1]) == 0)
				n++;
			else if (strcmp(sort[i], sort[i + 1]))
			{
				max[i] = n;
				if (max[i] >= top)
					top = max[i];
				n = 1;
			}
		}
		else if (i == N - 1)
		{
			max[i] = n;
			if (max[i] >= top)
					top = max[i];
		}
		i++;
	}
	// printf("--------------\n");
	i = 0;
	while (i < N)
	{
		// printf("%d %s %d\n", i, sort[i], max[i]);
		if (max[i] == top)
			printf("%s\n", sort[i]);
		i++;
	}
	return (0);
}


Measured memory_bytes: 12652
n=int(input())
a=list(map(int,input().split()))
g=[]
count=0
for i in range(n):
    if(a[i]%2==0):
        g.append(a[i])
    else:
        continue
for j in range(len(g)):
    if(g[j]%5 == 0 or g[j]%3==0):                                                                             count+=1
    else:
        print("DENIED")
        exit()
if(count == len(g)):
    print("APPROVED")
else:
    print("a")

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

using namespace std;

bool isCheck(string s)
{
    int l = 0,r = s.size()-1;
    while(l < r)
    {
        while(s[l] == 'x' && l < r)
            l++;
        while(s[r] == 'x' && r > l)
            r--;

        if(l >= r)
            return true;

        if(s[l] != s[r])
            return false;

        l++;
        r--;

    }

    return true;
}

long long int Create(string s)
{
    long long int sum = 0;

    if(s.size() == 1)
        return 0;

    int l = 0,r = s.size()-1;
    while(l < r)
    {
        int left = 0,right = 0;
        while(s[l] == 'x') {
            l++;
            left++;
        }
        while(s[r] == 'x')
        {
            r--;
            right++;
        }

        sum += abs(left-right);
        l++;
        r--;
    }
    return sum;
}

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

    if(!isCheck(s))
    {
        cout<<-1<<endl;
    } else {
        cout<<Create(s)<<endl;
    }

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String inputE = sc.next();
		String inputO = sc.next();
		String[] inputESplit = inputE.split("");
		String[] inputOSplit = inputO.split("");
		boolean flg = false;
		int j = 0;
		int k = 0;
		for (int i = 0; i < inputESplit.length + inputOSplit.length; i++) {
			if (!flg) {
				System.out.print(inputESplit[j]);
				j++;
				flg = !flg;
			} else {
				System.out.print(inputOSplit[k]);
				k++;
				flg = !flg;
			}
		}
	}
}


Measured memory_bytes: 21716
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
//#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                        
using namespace std;
                        
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                        
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define complex complex228
#define count count228
#define sin sin228
#define list list228

const int N = 200 * 1000 + 228;

int a[N], b[N];

ghost main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) cin >> b[i];
	set< pair<int, int> > s;
	for (int i = 0; i < n; ++i) {
		if (a[i] != b[i]) {
			s.insert({b[i], i});
		}
	}
	int cnt = 0;
	while (!s.empty()) {
		pair<int, int> p = *s.rbegin();
		s.erase(p);
		int i = p.second;
		int bn = b[(i + 1) % n];
		int bp = b[(i - 1 + n) % n];
		int kek = min((b[i] - a[i]) / (bn + bp), (b[i] - max(bn, bp)) / (bn + bp) + 1);
		b[i] -= (bn + bp) * kek;
		if (kek == 0) {
			cout << -1 << '\n';
			return 0;
		}
		cnt += kek;
		if (b[i] <= 0) {
			cout << -1 << '\n';
			return 0;
		}
		if (a[i] != b[i]) s.insert({b[i], i});
	}
	cout << cnt << '\n';
    return 0;
} // kek ;
// Ого! Кажетсья это $#@!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


Measured memory_bytes: 17920
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<pair<int, int> > ba(n); REP(i, n) cin >> ba[i].second >> ba[i].first;
  sort(ALL(ba));
  long long sum = 0;
  REP(i, n) {
    sum += ba[i].second;
    if (sum > ba[i].first) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 1792
#define scanf_s scanf
//#include <string>
#include <stdio.h>
//#include <math.h>
//#include <stack>
//#include <queue>
//#include <list>
#include <vector>
#include <iostream>
using namespace std;
#define MAX 10000000000
int cou = 0;
void merge(int A[], int left, int mid, int right)
{
	int i = 0, j = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L, R;
	for (i = 0; i < n1; i++) { L.push_back(A[left + i]); }
	for (i = 0; i < n2; i++) { R.push_back(A[mid + i]); }
	L.push_back(MAX); R.push_back(MAX);
	i = 0;
	j = 0;
	for (int k = left; k < right; k++) {
		if (L.at(i) <= R.at(j)) {
			A[k] = L.at(i); i++;
		}
		else {
			A[k] = R.at(j); j++; 
		}
		cou++;
	}
}
void mergeSort(int A[], int left, int right)
{
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}
int main(void)
{
	int n, S[500000];
	scanf_s("%d", &n);
	for (int i = 0; i < n; i++) { scanf_s("%d", &S[i]); }
	mergeSort(S, 0, n);
	for (int i = 0; i < n; i++) { 
		if (i != 0) { printf(" "); }
		printf("%d", S[i]);
	}
	printf("\n%d\n", cou);
}

Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
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;}

int main(){
  int A, B; cin >> A >> B;
  for(int i=1; i<=100000; i++){
    if(i*8/100==A && i*10/100==B){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {


	int n, k;
	cin >> n >> k;

	int ans = 1;

	rep(i, 0, n) {
		if (ans < k) {
			ans = ans * 2;
		}
		else {
			ans = ans + k;
		}
	}

	cout << ans << endl;

	return 0;
}


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

long long int n, m, dp[1001][1001];char matrix[1001][1001];

int recursive(int x, int y){
	if(x>=n||y>=m)return 0;
	if(dp[x][y]==-1)return 0;
	if(dp[x][y])return dp[x][y];
	if(x==n-1&&y==m-1)return 1;
	if(matrix[x][y+1]!='#'&&matrix[x+1][y]!='#')dp[x][y]=(recursive(x+1, y)+recursive(x, y+1))%1000000007;
	else if(matrix[x][y+1]!='#')dp[x][y]=recursive(x, y+1)%1000000007;
	else if(matrix[x+1][y]!='#')dp[x][y]=recursive(x+1, y)%1000000007;
	if(dp[x][y]==0){
		dp[x][y]=-1;
		return 0;
	}
	return dp[x][y];
}

int main(void){
	cin>>n>>m;
	for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>matrix[i][j];
	memset(dp, 0, 1001*1001*sizeof(long long int));
	cout<<recursive(0, 0);

	
	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

void solve(){
    int n,k,q;
    cin>>n>>k>>q;
    vi right(n+1,0);
    
    for(int i=0;i<q;i++){
        int x;
        cin>>x;
        right[x]++;
    }
    for(int i=1;i<=n;i++){
        if(q-right[i]<k){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
        cout<<endl;
    }
}



int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h> 
using namespace std ; 
#define ll long long int 
#define pb push_back
#define ff first 
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second 
#define S(x) scanf("%d",&x) 
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()

int main(){
	ll A , B ; 
	ll ans = 0 ; 
    cin>>A>>B ; 	
	
	ans = (B - 1)/(A - 1) ; 

	if(((B - 1)%(A - 1)) != 0)
		ans++ ; 
		
	cout<<ans<<"\n" ;
}

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

int main(void)
{
	int i,j,c;
	int n,m,a=1000;
	int posx,posy;
	char dir;
	int dis;
	int cx,cy;
	char map[21][21];
	
	while(a)
	{
		scanf("%d ",&n);
		if(n==0)break;
		
		posx = 10;
		posy = 10;
		
		for(i=0;i<=20;i++){
			for(j=0;j<=20;j++){
				map[i][j] = 0;
			}
		}
		
		for(i=0;i<n;i++){
			scanf("%d %d ",&cx,&cy);
			map[cx][cy] = 2;
		}
		
		scanf("%d ",&m);

		for(i=0;i<m;i++){
			scanf("%c %d ",&dir,&dis);
			if(dir=='N'){
				for(j=1;j<=dis;j++){
					posy++;
					map[posx][posy]=1;
				}
			}else if(dir=='E'){
			  for(j=1;j<=dis;j++){
					posx++;
					map[posx][posy]=1;
				}
			}else if(dir=='S'){
			  for(j=1;j<=dis;j++){
					posy--;
					map[posx][posy]=1;
				}
			}else if(dir=='W'){
			  for(j=1;j<=dis;j++){
					posx--;
					map[posx][posy]=1;
				}
			}
			
		}

		c=0;
		for(i=0;i<=20;i++){
			for(j=0;j<=20;j++){
				if(map[i][j] == 2)c++;
			}
		}
		
		if(c==0){printf("Yes\n");}
		else{printf("No\n");}
		
	}
	return 0;
}
				
				

Measured memory_bytes: 0
#include <iostream>

int main(int argc, char const* argv[])
{
    int k, s;
    std::cin >> k >> s;

    int result = 0;
    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k; ++j) {
            int rem = s - i - j;

            if(0 <= rem && rem <= k)
            {
                result++;
            }
        }
    }
    std::cout << result << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
  #define pb push_back
#define f first
#define s second
  #define MAXN 100005
using namespace std;
int arr[MAXN];
int main()
{
	std::ios::sync_with_stdio(false);
	string s;
	cin>>s;
	for(int i=0; i<3; i++) {
		if(s[i]=='1') s[i]='9';
		else if(s[i]=='9') s[i]='1';
	}
	cout<<s<<endl;


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	string s;
	int min=INF,ans=0;
	cin>>s;
	for(int i=0;i<s.size()-3+1;i++){
		int dim=stoi(s.substr(i,3));
		if(abs(dim-753)<min){
			min=abs(dim-753);
		}
		DEB(dim)END
	}
	cout<<min<<endl;
	return 0;
}

Measured memory_bytes: 256
//96a
#include<stdio.h>
int main(){
	int X,Y,A,B,C;
	while(~scanf("%d%d%d%d%d",&A,&B,&C,&X,&Y)){
		if((A+B)/2<C){
			printf("%d\n",A*X+B*Y);
		}
		else{
			int m;
			if(X>Y){
				if(X*2*C<Y*2*C+(X-Y)*A){
				m=X*2*C;
			}
			else	
				m=Y*2*C+(X-Y)*A;
			}
			if(X<=Y){
				if(Y*2*C<X*2*C+(Y-X)*B){
				m=Y*2*C;}
			else
				m=X*2*C+(Y-X)*B;
			}
			printf("%d",m);
		}
	}
} 

Measured memory_bytes: 256
#include<cstdio>
int a[200005],n;
long long ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",a+i);
	if(a[1]){puts("-1");return 0;}
	for(int i=2;i<=n;++i)if(a[i]<=a[i-1])ans+=a[i];
	else if(a[i]==a[i-1]+1)ans++;
	else {puts("-1");return 0;}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
package main

import (
	"fmt"
	"io"
	"os"
)

func routine(r io.Reader, w io.Writer) {
	// # フレーム数a、ピン数b、ボールを投げた回数
	var N, D, X int
	fmt.Fscanf(r, "%d\n", &N)
	fmt.Fscanf(r, "%d %d\n", &D, &X)
	sum := 0
	for i := 0; i < N; i++ {
		var a int
		fmt.Fscanf(r, "%d\n", &a)
		for d := 1; d <= D; d += a {
			sum++
		}
	}
	sum += X
	fmt.Fprint(w, sum)
}

func main() {
	routine(os.Stdin, os.Stdout)
}


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

class Program {
  static void Main() {
    var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int x1 = arr[0];
    int y1 = arr[1];
    int x2 = arr[2];
    int y2 = arr[3];
    int dx = x2 - x1;
    int dy = y2 - y1;
    int x3 = x2 - dy;
    int y3 = y2 + dx;
    int x4 = x1 - dy;
    int y4 = y1 + dx;
    Console.WriteLine($"{x3} {y3} {x4} {y4}");
  }
}

Measured memory_bytes: 13396
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    string s, t;

    cin >> s >> t;

    for(int i = 0; i < s.length(); i++) {
        if(s.substr(i, s.length() - i) + s.substr(0, i) == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<tuple>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;

#define DEBUG 1



int main() {

	
	int x, a;
	cin >> x >> a;
	if (x < a) {
		cout << "0" << endl;
	}
	else
	{
		cout << "10" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int sum(int x)
{
    int ans=0;
    while(x)
    {
        ans+=x%10;
        x/=10;
    }
    return ans;
}
int main()
{
    scanf("%d",&n);
    int ans=1e9;
    for(int i=1;i<n;i++)
        ans=min(ans,sum(i)+sum(n-i));
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
    int sum = 0;
    char ch;
 
    while(true)
    {
        while((ch = getchar()) != '\n'){
            sum += ch - '0';
        }
        if(sum == 0)
            break;
        else{
            printf("%d\n",sum);
            sum = 0;
        }
    }
}


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

const long mod = 1000000007;
long n, k;
int main() {
  cin >> n >> k;
  long sum = 0;
  for (int i = k; i <= n + 1; ++i) {
    sum = (sum + i * (n - i + 1) + 1) % mod;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3636
fn main() {
    let mut n = read();
    let mut vec = read_line();
    n += 2;
    vec.insert(0, 0);
    vec.push(0);

    let mut total = 0;
    for i in 1..n as usize {
        let dif = (vec[i - 1] - vec[i]).abs();
        total += dif;
    }

    for i in 1..(n - 1) as usize {
        let left = vec[i - 1];
        let center = vec[i];
        let right = vec[i + 1];

        if left <= center && center <= right {
            println!("{}", total);
        } else if left >= center && center >= right {
            println!("{}", total);
        } else {
            let dif1 = (left - center).abs();
            let dif2 = (center - right).abs();
            let dif3 = (left - right).abs();
            println!("{}", total - dif1 - dif2 + dif3);
        }
    }

}

fn read() -> i32 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_line() -> Vec<i32> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v = s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();
    return v;
}


Measured memory_bytes: 5244
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;cin >> h >> w;
  vector<int> c(26);
  for(int i=0;i<h;i++){
    string s;cin >> s;
    for(int j=0;j<w;j++){
      c[s[j]-'a']++;
    }
  }
  if(h%2==0&&w%2==0){
    for(int i=0;i<26;i++){
      if(c[i]%4!=0){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
  else{
    int x,y,z;
    if(h%2==1&&w%2==1){
      x=1,y=h/2+w/2,z=(h/2)*(w/2);
      for(int i=0;i<26;i++){
        if(c[i]%4==1||c[i]%4==3){
          c[i]--;
          break;
        }
      }
    }
    else{
      if(h%2==1){
        swap(h,w);
      }
      x=0,y=h/2,z=(h/2)*(w/2);
    }
    int cnt=0;
    for(int i=0;i<26;i++){
      if(c[i]%4==2){
        cnt++;
        c[i]-=2;
        if(cnt==y){
          break;
        }
      }
    }
    for(int i=0;i<26;i++){
      if(c[i]%4!=0){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define M 6400
bool dp[80][80][M];
int a[80][80];
int b[80][80];

int main(){
   int h, w;
   cin>>h>>w;
   rep(i, h) rep(j, w) cin>>a[i][j];
   rep(i, h) rep(j, w) cin>>b[i][j];

   rep(i, h){  
      rep(j, w){
         int l=abs(a[i][j]-b[i][j]);
         rep(k, M) dp[i][j][k]=0;
         if(i==0 && j==0){
            dp[i][j][l]=1;                                                                                       }   
         else{
            for(int k=0; k<M; k++) if(i!=0 && dp[i-1][j][k] || j!=0 && dp[i][j-1][k]){
               dp[i][j][max(k-l, -(k-l))]=1;
               if(k+l<M) dp[i][j][k+l]=1;
            }
         }
      }
   }

   int p=0;
   for(p=0; p<M; p++) if(dp[h-1][w-1][p]==1) break;

   cout<<p<<endl;
   return 0;
}


Measured memory_bytes: 43680
#include <iostream>
#include <atcoder/dsu>

using namespace std;
using namespace atcoder;

int main() {
  int N, Q;
  cin >> N >> Q;
  dsu d(N);
  for (int i = 0; i < Q; i++) {
    int t, u, v;
    cin >> t >> u >> v;
    if (t == 0) d.merge(u, v);
    else if (t == 1) {
      int ans = (d.same(u, v)) ? 1 : 0;
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
#include <unistd.h>
#include <random>

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      int A, B, T;
      cin >> A >> B >> T;
      cout << (T/A)*B << endl;
}


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


int cmp(const int *a,const int *b){

return *a > *b ? -1 : *a < *b ? 1 : 0 ;
}
//qsort(pa,n,sizeof(int),(int(*)(const void* ,const void*))cmp);

long long int memo[100];
long long int fib(int n){
  if(n<=1){
    return n;
  }
  else{
    return fib(n-1)+fib(n-2);
  }
}

long long int fib2(int n){
  if(n<=1){
    return n;
  }
  if(memo[n]!=0){
    return memo[n];
  }
    return memo[n]=fib(n-1)+fib(n-2);

}


int main(void){
  int h,a;
  scanf("%d%d",&h,&a);
  if(h%a==0){
    printf("%d",h/a);
    return 0;
  }
  else{
    printf("%d",h/a+1);
  }



  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;

int main(){
    ll H;
    cin>>H;
    int digit=log2(H);
    cout<<(ll)pow(2,digit+1)-1<<endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll  A,B,C,D,E,F,G,H,K,L,M,N,P,Q,R,W,X,Y,Z;
string S,T;

int main(){
  cin >> S;
  cout << (S[3]==S[2] && S[4]==S[5] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#52????????????????????????
ary = Array.new
mark = Array.new(["S", "H", "C", "D"])

for i in 0..3
	arytemp = Array.new(13) {|j| "#{mark[i]} #{j+1}" }
	ary = ary + arytemp
end


#gets????????????????????????
arygets = Array.new

for k in 1..gets.to_i
	arygets << gets.chomp
end

puts ary - arygets

Measured memory_bytes: 8648
n,k = gets.chomp.split.map(&:to_i)
p = gets.chomp.split.map(&:to_i)

rs  = [0]
p.each_with_index do |v,i|
  rs.push p[i] if i == 0
  rs.push rs[i] + p[i] if i != 0
end

diff = n - k
search = (0..diff).to_a
result = []
search.each do |i|
  value = rs[i+k] - rs[i]
  result.push value
end

puts (result.max + k) / 2.to_f


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
  cin.sync_with_stdio(false);
  int n;
  while(cin >> n, n) {
    vector<int> w(n);
    rep(i, n) cin >> w[i];

    int dp[n][n] = {};
    rep(i, n - 1) if (abs(w[i] - w[i + 1]) < 2) dp[i + 1][i] = 2;

    repl(i, 2, n) {
      rep(j, n - i) {
        rep(k, i) {
          maxch(dp[j + i][j], dp[j + k][j] + dp[j + i][j + k + 1]);
        }
        if (dp[j + i - 1][j + 1] == i - 1) maxch(dp[j + i][j], dp[j + i - 1][j + 1] + ((abs(w[j] - w[j + i]) < 2) ? 2 : 0));
      }
    }
    cout << dp[n - 1][0] << endl;
  }

  return 0;
}

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

int a[200005];

int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + 1 + n);
	for(int i = 1; i <= n; i++) {
		if(a[i] == a[i + 1]) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[30][30];
ll dp[25][2100000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        REP(j, N) {
            cin >> A[i][j];
        }
    }
    dp[0][0] = 1;
    ll p = pow(2LL, N);
    REP(b, p) {
        ll i = __builtin_popcount(b);
        REP(j, N) {
            if (((b >> j) & 1) == 1)
                continue;
            if (A[i][j] == 0)
                continue;
            dp[i + 1][b | (1LL << j)] += dp[i][b];
            dp[i + 1][b | (1LL << j)] %= MOD;
        }
    }
    cout << dp[N][p - 1] << endl;
    return 0;
}

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

void nextnum(string&num,int m){
	for(int i=num.size()-1;i>=0;--i){
		if(num.at(i)<m+'0'-1){
			++num.at(i);
			for(int j=i;j<num.size();++j)num.at(j)=num.at(i);
			break;
		}
	}
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m,q; cin>>n>>m>>q;
	vector<vector<int>>abcd(q,vector<int>(4));
	for(auto&&i:abcd)for(auto&&j:i)cin>>j;
	string num; for(int i=1;i<n;++i)num+='0'; num+='0'-1;
	string lim; for(int i=0;i<n;++i)lim+='0'+m-1;
	int ans=0;
	while(num!=lim){
		nextnum(num,m);
		int tans=0;
		for(auto&&i:abcd){
			if(i.at(2)!=num.at(i.at(1)-1)-num.at(i.at(0)-1))continue;
			tans+=i.at(3);
		}
		ans=max(ans,tans);
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 3624