akhauriyash/Code-Regression huggingface dataset:
#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};
typedef pair<int, int> P;
constexpr int L = 1123;
constexpr int N = 112;
int dist[N][L];
queue<P> que[L];
int r[N];
int c[N];
int R, C, n;
int d(int i, int j) {
	return abs(r[i] - r[j]) + abs(c[i] - c[j]);
}
int main() {
	cin >> R >> C >> n;
	if (R == 1 && C == 1) {
		cout << 0 << endl; return 0;
	}
	for (int i : range(N))for (int j : range(L))dist[i][j] = L;
	for (int i : range(n)) {
		cin >> r[i] >> c[i];
		int cost = r[i] + c[i] - 2;
		que[cost].push({ i,cost });
		chmin(dist[i][cost], cost);
	}
	for (int cost : range(L)) {
		while (que[cost].size()) {
			int v, l; tie(v, l) = que[cost].front(); que[cost].pop();

			if (cost > dist[v][l])continue;
			for (int u : range(n)) {
				int need = d(u, v) - l - 1;
				if(need <=0)need = 0;
				if (chmin(dist[u][need], cost + need)) {
					que[cost+need].push({ u,need });
				}
			}
			if (cost + 1 < L&&l + 1 < L) {
				if (chmin(dist[v][l + 1], cost + 1)) {
					que[cost + 1].push({ v,l + 1 });
				}
			}
		}
	}
	int ret = L;
	for (int i : range(n)) {
		for (int l : range(L)) {
			int cost = R - r[i] + C - c[i] - l;
			if (cost < 0)cost = 0;
			chmin(ret, dist[i][l] + cost);
		}
	}
	cout << ret << endl;
	return 0;
}



Measured memory_bytes: 4580
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    int N;
  string s;
    cin >> N>>s;
    if(3200<=N){
    cout << s;
}else{
    cout <<"red";}

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{   int n;
    cin>>n;
    int a[n];
    int i,flag=1;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
    {
        if(a[i]%2==1 || a[i]%3==0 || a[i]%5==0 );
        else {flag=0;break;}
    }
    if(flag) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;

    return 0;
}


Measured memory_bytes: 256
(defun is-kaibun (str)
  (string= str (reverse str)))

(defun is-strong-kaibun (str)
  (let ((len (length str)))
    (and (is-kaibun str)
         (is-kaibun (subseq str 0 (/ (- len 1 ) 2)))
         (is-kaibun (subseq str (- (/ (+ len 3) 2) 1) len)))))

(defun print-y-n (bool)
  (if bool
      (princ "Yes")
      (princ "No")))

(print-y-n (is-strong-kaibun (read-line)))

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

int main() {
  int N,X,ans=0;
  cin >> N >> X;
  vector<int>vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  for(int i=0; i<N; i++){
    if(X<vec[i]){
      break;
    }
    else{
    ans++;
    X -= vec[i];
    }
  }
  if(ans == N && X>0){
    ans--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll n;cin>>n;
	ll p = n/3;
	ll q = n/5;
	ll r = n/15;
	ll sum = n*(n+1)/2;
	ll sum1 = 3*p*(p+1)/2;
	ll sum2 = 5*q*(q+1)/2;
	ll sum3 = 15*r*(r+1)/2;
	sum = sum-sum1-sum2+sum3;
	cout<<sum<<endl;
}

Measured memory_bytes: 3648
#!python3

import numpy as np

# input
N, S = list(map(int, input().split()))
A = list(map(int, input().split()))

MOD = 998244353


def add_elements(w, i):
    a = A[i]
    w[a:] += w[:-a].copy()
    if a <= S:
        w[a] += i + 1
    w %= MOD


def main():
    w = np.zeros(S + 1, dtype=int)
    ans = 0
    for i in range(N):
        add_elements(w, i)
        ans = (ans + w[S]) % MOD
    
    print(ans)


if __name__ == "__main__":
    main()


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

#define MAX 20000000
#define FOR(i,m,n) for(int i = (m); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) v.begin(),v.end()


typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

int main(){
	
	int n,x,dp[MAX];
	vi v;
	cin>>n;

	REP(i,n){
		cin>>x;
		v.pb(x);
	}
	dp[0]=0;
	dp[1]=abs(v[1]-v[0]);
	FOR(i,2,n){
		dp[i]=min(dp[i-1]+ abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
	}
	cout<<dp[n-1]<<endl;

	return 0;
	
}

Measured memory_bytes: 2808
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
ll mod=1E9+7;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)

ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

int main(){
    ll K=ii();
    ll A=ii();
    ll B=ii();
    REP(i,A,B+1){
        if(i%K==0){
            ose("OK");
            return 0;
        }
    }
    ose("NG");

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
bool isEven(int i){
    int num=i;
    bool bl=false;
    if(num%2==0) bl=true;
    
    return bl;
}
int main(){
    int n;
    int counter1, counter2=0;
    pair<int, int> p;
    p = make_pair(1,0);
    cin >> n;
        for(int i=n; i>0; --i){
            int num=i;
            counter1=0;
            while(isEven(num)){
                counter1++;
                num=num/2;
            }
            if(counter1>counter2){
                counter2 = counter1;
                p = make_pair(i, counter2);
            }
        }
    cout << p.first << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll k,a,b,bis=1;
  cin >> k >> a >> b;
  if(a+1>=b){
    cout << k+1<<endl;
  }else{
    if(k<=a){
      cout <<k+1 << endl;
    }else{
      k-=a-1;
      bis = a+(k/2)*(b-a);
      if(k%2==1) bis++;
      cout << bis << endl;
    }
  }
}


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

bool p[1000000];

int main(){
	int c,n;
	while(cin >> n){
		c = 0;
		for(int i = 2; i <= sqrt(n); i++){
			for(int j = 2; i * j <= n; j++){
				p[i*j] = true;
			}
			
		}
		for(int i = 2; i <= n; i++){
			if(p[i] == 0){
				c++;
				
			}
		}
		cout << c << endl;
	}
	
	return 0;
}

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

using namespace std;

typedef long long ll;
ll a[6], n, f[6] = {0};

ll bruteForce() {
	ll res = -1;
	ll flow = 0;
	memset(f, 0, sizeof f);
	f[0] = n;
	while (flow < n) {
		res++;
		flow += f[5];
		f[5] = 0;
		for (int i = 5; i >= 1; --i) {
			if (f[i - 1] + f[i] <= a[i]) {
				f[i] += f[i - 1];
				f[i - 1] = 0;
			}
			else {
				f[i] = a[i];
				f[i - 1] -= f[i];
			}
		}
	}
	return res;
}

ll solve() {
	ll res = 0, amin = 1e15 + 7;
	for (int i = 1; i <= 5; ++i)
		amin = min(amin, a[i]);
	res = 4 + n / amin + (n % amin != 0);
	return res;
}

int main() {
	cin >> n;
	for (int i = 1; i <= 5; ++i)
		cin >> a[i];
	cout << solve();	
	return 0;
}


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

int main() {
  int N,count=0,now=0;
  cin >> N;
  vector<int> a(N+1);
  a.at(0)=1;
  for(int i=1;i<N+1;i++){
    cin >> a.at(i);
  }
  for(;;){
    if(now==2){
      cout << count-1 << endl;
      break;
    }
    if(count >= N){
      cout << -1 << endl;
      break;
    }
    count++;
    now=a.at(now);
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int N; cin >> N;
  bool seven = false;
  if(N%10 == 7){
    seven = true;
  } else if (N/100 == 7){
    seven = true;
  } else if ((N/10)%10 == 7){
    seven = true;
  }
  if(seven){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main() {
  long N;
  cin>>N;
  long a[5];
  for(int i=0;i<5;i++) cin>>a[i];
  sort(a,a+5);
  long ans=4;
  //cout<<a[0]<<endl;
  if(N%a[0]==0) ans += N/a[0];
  else ans += N/a[0]+1;
  cout<<ans<<endl;

  }


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll ans = max({a * c, a * d, b * c, b * d});
    cout << ans << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3644
N, K = map(int, input().split())
S = input()
a = []
if S[0] == '0':
    a.append(0)
cnt = 1
for i in range(1, N):
    if S[i] != S[i - 1]:
        a.append(cnt)
        cnt = 1
    else:
        cnt += 1

a.append(cnt)
a.append(0)
a.append(0)

ans = s = sum(a[:2*K + 1])
for i in range(2*K + 2, len(a), 2):
    s += a[i] + a[i - 1] - a[i - 2*K - 1] - a[i - 2*K - 2]
    ans = max(ans, s)
print(ans)



Measured memory_bytes: 4596
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MOD 1000000007
#define MAXN 100006
typedef long long LL;
int a[MAXN];
LL Quick(LL a,LL b,LL c)
{
	LL ans=1;
	a=a%c;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%c;
		a=(a*a)%c;
		b/=2;
	}
	return ans;
}
int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		int flag1=0,flag2=0;
		memset(a,0,sizeof(a));
		for(int i=0;i<n;i++)
		{
			int t;
			scanf("%d",&t);
			a[t]++;
			if(t>=n)
				flag1=1;
			if(n&1)
			{
				if(t&1)
					flag2=1;
			}
				
			else
			{
				if(!(t&1))
					flag2=1;
			}
		}
		if(flag1)
		{
			printf("0\n");
			continue;
		}
		if(flag2)
		{
			printf("0\n");
			continue;
		}
		if(n&1)
		{
			if(a[0]!=1)
			{
				printf("0\n");
				continue;
			}
		}
		else
		{
			if(a[0]!=0)
			{
				printf("0\n");
				continue;
			}
		}
		int cnt=1;
		LL m=n/2;
		LL sum;
		if(n&1)
		{
			for(int i=2;i<n;i+=2)
			{
				if(a[i]!=2)
				{
					cnt=0;
					break;
				}
					
			}
			if(cnt)
			{
				sum=Quick(2,m,MOD);
				printf("%lld\n",sum);
			}	
			else
			{
				printf("0\n");
				continue;
			}
		}
		else
		{
			for(int i=1;i<n;i+=2)
			{
				if(a[i]!=2)
				{
					cnt=0;
					break;
				}
					
			}
			if(cnt)
			{
				sum=Quick(2,m,MOD);
				printf("%lld\n",sum);
			}	
			else
			{
				printf("0\n");
				continue;
			}
		}
	}
	return 0;	
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int main(int argc, char const *argv[])
{
	int n;
	while(scanf("%d", &n) != EOF)
	{
		if (n == 0) break;
		int ans = 0;
		bool NA = true;
		REP(i,n)
		{
			int k;
			scanf("%d", &k);
			if (k > 1)
			{
				ans++;
				NA = false;
			}
			else if (k == 1)
			{
				ans++;
			}
		}
		if (NA)
		{
			printf("NA\n");
		}
		else
		{
			printf("%d\n", ans+1);
		}
	}
	return 0;
}

Measured memory_bytes: 3188
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);
    
    int t;
    cin >> t;
    
    for(int i = 0; i < t; i++) {
    	
        lint a, b, c, d;
        cin >> a >> b >> c >> d;
      	
      	if (b > d || b > a) {
        	cout << "No\n";
          	continue;
        }
      
      	if (b - 1 <= c) {
            cout << "Yes\n";
          	continue;
        }
      
      	lint g = gcd(b, d);
      	if (a % b + (b - 1 - a % b) / g * g <= c) cout << "Yes\n";
      	else cout << "No\n";

    }

	return 0;
}


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

int main() {
  int n;
  cin>>n;
  priority_queue<double, vector<double>, greater<double> > v;
  for (int i=0; i<n; i++) {
    int a;
    cin>>a;
    v.push(a);
  }

  double ans = 0.0;
  while (v.size() >= 2) {
    double v1 = v.top(); v.pop();
    double v2 = v.top(); v.pop();
    ans = (v1 + v2) / 2.0;
    v.push(ans);
  }
  printf("%.9lf\n", ans);
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ((A + B) > (C + D)) cout << "Left" << endl;
  else if ((A + B) == (C + D)) cout << "Balanced" << endl;
  else if ((C + D) > (A + B)) cout << "Right" << endl;
}

Measured memory_bytes: 256
w,h,n = map(int, input().split())

L = 0
R = w
D = 0
U = h

for _ in range(n):
    x,y,a = map(int, input().split())
    if a==1:
        L = max(L,x)
    if a==2:
        R = min(R,x)
    if a==3:
        D = max(D,y)
    if a==4:
        U = min(U,y)
    #print(L, R, D, U)

x = max(0, R-L)
y = max(0, U-D)
#print(x, y)
ans = x*y

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int n, A[50];


int solve (int i, int m){
  if (m==0)return 1;
  if (i>=n)return 0;
  int res = solve(i + 1,m)||solve(i + 1,m - A[i]);
  return res;
}

int main(){
  int q,M,i;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M))printf("yes\n");
    else printf("no\n");
  }

  return 0;
}



Measured memory_bytes: 2108
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

using namespace std;
typedef long long int64;

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

  string s,t;
  cin>>s>>t;
  cout<<t<<s<<endl;



  return 0;
}

Measured memory_bytes: 760
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;


int main() {
	int n,k,x,y;
	cin >> n >> k >> x >> y;
	int sum = 0;
	sum += min(k, n) * x;
	if (n > k) sum += (n - k)*y;

	cout << sum << endl;

	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define mi map<int,int>
#define mll map<long long,long long>
#define qi queue<int>
#define pb push_back
#define mod %
#define pow ^
#define pnode struct node
#define pair_int pair<int,int>
#define pair_ll pair<long,long>
#define pq priority_queue

#define N 200001

ll M = (ll)(1e9+7);
vi adj[N+1];

void init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

pair_ll dfs(int i,int par)
{
   ll w=1;
   ll b=1;

   for(auto ele : adj[i])
   {
      if(ele == par)
         continue;

      pair_ll ans = dfs(ele, i);
      
      w = (w * (ans.first + ans.second)) mod M;
      b = (b * ans.first) mod M;
      
   }
   return {w,b};
}

int main()
{
   init();

   int n;
   cin >> n;

   int m = n-1;
   if(m==0)
   {
      cout << 2 << "\n";
      return 0;
   }
   while(m--)
   {
      int x,y;
      cin >> x >> y;
      adj[x].pb(y);
      adj[y].pb(x);
   }

   pair_ll ans = dfs(1,-1);
   cout << (ans.first + ans.second) mod M << "\n";
   
   return 0;
}


Measured memory_bytes: 13696
//NarrowRectanglesEasy.cpp (B)
#include <iostream>
#include <string>
using namespace std;

int main(){
  int W,a,b;
  cin >> W >> a >> b;
  int x = max(a,b) - min(a+W,b+W);
  if(x > 0){
    int Ans = min(abs(b-a-W),abs(b+W-a));
    printf("%d\n",Ans );
  }else{
    printf("0\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int null = -1;

int main() {
  int h, w;
  cin >> h >> w;
  int mat[h][w];
  vector<vector<int>> vech(h);
  vector<vector<int>> vecw(w);

  for (int i = 0; i < h; i++) {
    string S;
    cin >> S;
    for (int j = 0; j < w; j++) {
      char c = S[j];
      if (c == '#') {
        mat[i][j] = -1;
        vech[i].push_back(j);
        vecw[j].push_back(i);
      }
      else mat[i][j] = 1;
    }
  }

  vector<int> hw;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (mat[i][j] == -1) continue;

      int ansh, answ;
      auto hv = vech[i];
      auto wv = vecw[j];

      if (hv.empty()) {
        ansh = w - 1;
      } else {
        if (hv[hv.size() - 1] <= j) {
          ansh = w - 2 - hv[hv.size() - 1];
        } else {
          auto itr = upper_bound(hv.begin(), hv.end(), j);
          int index = distance(hv.begin(), itr);
          if (index == 0) {
            ansh = (*itr) - 1;
          } else {
            ansh = *itr - *(itr - 1) - 2;
          }
        }
      }

      if (wv.empty()) {
        answ = h - 1;
      } else {
        if (wv[wv.size() - 1] <= i) {
          answ = h - 2 - wv[wv.size() - 1];
        } else {
          auto itr = upper_bound(wv.begin(), wv.end(), i);
          int index = distance(wv.begin(), itr);
          if (index == 0) {
            answ = (*itr) - 1;
          } else {
            answ = *itr - *(itr - 1) - 2;
          }
        }
      }
      hw.push_back(ansh + answ + 1);
    }
  }

  // for (int i = 0; i < hw.size(); i++) {
  //   cout << hw[i] << endl;
  // }

  sort(hw.begin(), hw.end());
  reverse(hw.begin(), hw.end());
  cout << hw[0] << endl;
};


Measured memory_bytes: 60152
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner stdIn= new Scanner(System.in);
        int k = stdIn.nextInt();
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        boolean c=false;
        if(a-b>=k){
            c=true;
        }else{
            for(int i=a;i<=b;i++){
                if(i%k==0){
                   c=true; 
                }
            }
        }
        if(c){
            System.out.println("OK");
        }else{
            System.out.println("NG");
        }
    }
}

Measured memory_bytes: 35504
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;
 
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */
 
int main() {
    int N; cin >> N;
    bool G[N][N];
    if(N % 2 == 1) {
        rep(i, N) {
            rep(j, N) {
                G[i][j] = false;
                if(i != j && j != N - i - 2)
                    G[i][j] = true;
            }
        }
        
    }else {
        rep(i, N) {
            rep(j, N) {
                G[i][j] = false;
                if(j != i && j != N - i - 1)
                    G[i][j] = true;
            }
        }
       
    }
    int cnt = 0;
    rep(i, N) {
        rng(j, i + 1, N) {
            if(G[i][j]) ++cnt;
        }
    }
    cout << cnt << endl;
    rep(i, N) {
        rng(j, i + 1, N) {
            if(G[i][j]) cout << i + 1 << ' ' << j + 1 << endl;
        }
    }
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        FastReader in = new FastReader();
        test a=new test();
        a.solve(in,out);
        out.close();
    }
}
class test{
    public void solve(FastReader in, PrintWriter out){
       int n=in.nextInt();
       int k=in.nextInt();
       ArrayList<Integer> my =new ArrayList<>();
       for(int i=0;i<k;i++){
           int d =in.nextInt();
           for(int j=0;j<d;j++){
               my.add(in.nextInt());
           }
       }int c=0;
       for(int i=1;i<=n;i++){
           if(!my.contains(i)){
               c++;
           }
       }
       out.println(c);
    }

}

class FastReader{
    BufferedReader br;
    StringTokenizer st;

    public FastReader(){
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next(){
        while(st==null || !st.hasMoreElements()){
            try{
                st=new StringTokenizer(br.readLine());
            }
            catch(IOException e){
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt(){
        return Integer.parseInt(next());
    }

    Long nextLong(){
        return Long.parseLong(next());
    }

    double nextDouble(){
        return Double.parseDouble(next());
    }
    String nextLine(){
        String str="";
        try{
            str=br.readLine();
        }
        catch(IOException e){
            e.printStackTrace();
        }
        return str;
    }
}



Measured memory_bytes: 33732
N = int(input())
P = list(map(int, input().split()))

c = 0
for i in range(N - 1):
    f = P[i]
    l = P[i + 1]
    if f < l:
        P[i] = l
        P[i+1] = f
        c += 1

print(N - c)

Measured memory_bytes: 75472
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <complex>
#include <stdio.h>
#include <unordered_set>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL MAXN = 1e5 + 1;
const LL MAXS = 100 + 1;
const LL MAXT = 100 + 1;

void ok()
{
	cout << "Alice";
	exit(0);
}

void bad()
{
	cout << "Borys";
	exit(0);
}

void draw()
{
	cout << "Draw";
	exit(0);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);


	int n, a, b;
	cin >> n >> a >> b;

	int x = abs(a - b);
	if (x & 1)
		bad();
	else
		ok();

	return 0;
}

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

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

    long long L0 = 2;
    long long L1 = 1;
    if(N==1){
        cout << 1 << endl;
    }
    else {
        long long L;

        for (int i = 2; i < N + 1; i++) {
            L = L0 + L1;
            L0 = L1;
            L1 = L;
        }
        cout << L << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] dp = new int[101][101];
		int linenum = 0;
		while(sc.hasNext()) {
			String s = sc.next();
			String[] nums = s.split(",");
			for(int i=0;i<nums.length;i++) {
				dp[51-nums.length+i*2][linenum+1] = Integer.valueOf(nums[i]);
			}
			linenum++;
		}
		for(int y=1;y<=100;y++) {
			for(int x=1;x<100;x++) {
				dp[x][y] += Math.max(dp[x-1][y-1],dp[x+1][y-1]);
			}
		}
		int ans = 0;
		for(int i=0;i<=100;i++) {
			ans = Math.max(ans,dp[i][100]);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 19196
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
 
public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        string ans = (int.Parse(Reader.ReadLine())<1200?"ABC":"ARC");
        Console.WriteLine(ans);
    }





    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"

1000

";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}

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

namespace ConsoleApp84
{

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());//マスの一辺の数
            int A = int.Parse(Console.ReadLine());//白色マス目の数

            int Number = N * N;//全体のマス目の数
            int Answer = Number - A;

            Console.WriteLine(Answer);

        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
//vector<vector<int>> a(5, vector<int>(5, 0)) 5*5-0
int main(){
    int x, y;
    cin >> x >> y;

    int flag = 0;
    if(y % 2 == 1){//奇数弾く
        flag = 0;
    }else{
        for(int i = 0; i <= x; i++){
            if(2 * i + 4*(x - i) == y){
                flag = 1;
                break;
            }
        }
    }

    

    if(flag == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			double a = scan.nextDouble();
			double b = scan.nextDouble();
			if(a < 35.5 && b < 71.0){
				System.out.println("AAA");
			}else if(a < 37.5 && b < 77.0){
				System.out.println("AA");
			}else if(a < 40.0 && b < 83.0){
				System.out.println("A");
			}else if(a < 43.0 && b < 89.0){
				System.out.println("B");
			}else if(a < 50.0 && b < 105.0){
				System.out.println("C");
			}else if(a < 55.0 && b < 116.0){
				System.out.println("D");
			}else if(a < 70.0 && b < 148.0){
				System.out.println("E");
			}else{
				System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 20516
#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 f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;

	cout<<n+pow(n,2)+pow(n,3)<<endl;



	return 0;
}


Measured memory_bytes: 4304
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;


int main(){
    int n, m;
    cin >> n >> m;
    int cnt_ac[n] = {0}, cnt_wa[n] = {0};
    vector<string> s(m);
    for(int i = 0; i < m; i++){
        int p;
        string s;
        cin >> p >> s;
        if(s == "AC") cnt_ac[p-1] = 1;
        else if(cnt_ac[p-1] == 1 && s == "WA") continue;
        else cnt_wa[p-1] += 1;
    }

    int ac = 0, pen = 0;
    for(int i = 0; i < n; i++){
        if(cnt_ac[i] == 1){
            ac += 1;
            pen += cnt_wa[i];
        }
    }
    cout << ac << " " << pen << endl;
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>

using namespace std;

const int mod = 1000000007;

int main() {
    //freopen("output.txt", "w", stdout);
    ll sum = 0;

    ll n, k;
    cin >> n >> k;

    for (ll i=k-1; i<=n; i++) {
        ll cs = (i+1) * (2*n - i);
        cs /= 2;
        cs =1 + cs - (i*(i+1))/2;
        cs = cs % mod;
        //cout << cs << endl;
        sum = (sum + cs)%mod;
    }
    cout << sum % mod << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;


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

	int n, x, y;	cin >> n >> x >> y;
	vector <int> v(n, 0);
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			v[min(abs(i - j), abs(i - x) + abs(j - y) + 1)]++;
		}
	}

	for (int i = 1; i < n; i++) {
		cout << v[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long int
#define mod 1000000007
#define inf (1LL<<60)
#define f(i,a,b) for (int i= a; i <b; ++i)
using namespace std;
int a[17][17];
int dp[(1<<16)];
int sum[(1<<16)];
int calculatesum(int n)
{
    for(int i=1;i<=((1<<n)-1);i++)
    {
        dp[i]=inf;
        for(int j=0;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if((i&(1<<j))!=0&&(i&(1<<k))!=0)
                    sum[i]+=a[j][k];
            }
        }
        //cout<<sum[i]<<" ";
    }
}
int solve(int mask)
{
   if(mask==0)
    return 0;
   if(dp[mask]!=inf)
     return dp[mask];
   int ans=0;
   for(int submask=mask;submask!=0;submask=(submask-1)&mask)
   {
       ans=max(ans,sum[submask]+solve(mask^submask));
   }
   return dp[mask]=ans;
}
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
        cin>>a[i][j];
     calculatesum(n);
    cout<<solve((1<<n)-1);

}



Measured memory_bytes: 1280
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

#define FOR(i,n) for(ll i=0;i<n;i++) 
#define RFOR(i,n) for(ll i=n-1;i>=0;--i)
#define COUT(str) cout << str << endl

//入力
int A,B ;


int main() {

	

	cin >> A >> B;

	if (A == 1) A = 14;
	if (B == 1) B = 14;

	if (A > B) COUT("Alice");
	else if (A < B) COUT("Bob");
	else if (A == B) COUT("Draw");	

	return 0;
}


Measured memory_bytes: 384
L = sorted(list(map(int,input().split())),reverse=True)
m = (L[0]-L[1]) % 2 - (L[0] - L[2]) % 2
if m == 0:
    print(L[0]+(-L[1]-L[2])//2)
else:
    print(L[0]+(-L[1]-L[2]+3)//2)


Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
	char num[11];
	int i, j;
	
	while (scanf("%s", num) != EOF){
		for (i = 0; i < 10; i++){
			num[i] -= '0';
		}
		
		for (i = 9; i; i--){
			for (j = 0; j < i; j++){
				num[j] = (num[j] + num[j + 1]) % 10;
			}
		}
		
		printf("%d\n", num[0]);
	}
	
	return (0);
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

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

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int a;
  scanf("%d",&a);
  int arr[a];
  int i;
  for(i=0;i<a;i++)	scanf("%d",&arr[i]);
  int flag=0;
  int count=0;
  for(i=0;i<a;i++)
  {
    if(flag<=arr[i])
    {
    	count++;
      	flag=arr[i];
    }
  }
  printf("%d",count);}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
vector<ll> ed[100005];
ll h[100005];
int main()
{
    ll n,m,u,v,ans=0;
    cin>>n>>m;
    rep1(i,n) cin>>h[i];
    rep(i,m)
    {
        cin>>u>>v;
        ed[u].pb(h[v]);
        ed[v].pb(h[u]);
    }
    rep1(i,n) sort(ed[i].begin(),ed[i].end());
    rep1(i,n)
    {
        if(ed[i].size()==0) ans++;
        else
        {
            if(ed[i].back()<h[i]) ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 10228
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int N,W;
    cin >> N >> W;
    vector<int> w(N+1,0),v(N+1,0);
    rep(i,N) cin >> w[i+1] >> v[i+1];
    ll dp[101][100010];
    //ll dp[101][1000];

    rep(i,N+1){
        rep(j,W+1){
            dp[i][j] = 0;
        }
    }

    reps(i,1,N+1){
        rep(j,W+1){
            if(j-w[i] >= 0)
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]] + v[i]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }

    // rep(i,N+1){
    //     rep(j,W+1){
    //         cout << dp[i][j] <<" ";
    //     }
    //     cout << endl;
    // }
    cout << dp[N][W] << endl;

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int count = 0;
  for (int i = 0; i < s.length()/2; ++i) {
    if (s[i] != s[s.length() - 1 - i]) ++count;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n)cin >> a[i];
	vector<int> sum(n+1);
	rep(i,n)sum[i+1] = sum[i] + a[i];
	auto get_sum = [&](int l,int r){
		l = max(l,0ll);
		r = min(r,n);
		return sum[r] - sum[l];
	};
	auto max_4 = [](int x,int y,int z,int w){
		return max(max(x,y),max(z,w));
	};
	auto min_4 = [](int x,int y,int z,int w){
		return min(min(x,y),min(z,w));
	};
	int ret = 1e18;
	// l c r
	for(int c = 2;c <= n-2;c++){
		vector<int> boundary_l;
		{
			int top = c+1,bot = -1;
			while(top - bot > 1){
				int mid = (top + bot)/2;
				if(get_sum(0,mid) < get_sum(mid,c))bot = mid;
				else top = mid;
			}
			boundary_l = {bot,top};
		}
		vector<int> boundary_r;
		{
			int top = n+1,bot = c-1;
			while(top - bot > 1){
				int mid = (top + bot)/2;
				if(get_sum(c,mid) < get_sum(mid,n))bot = mid;
				else top = mid;
			}
			boundary_r = {bot,top};
		}
		for(auto l:boundary_l)for(auto r:boundary_r){
			int tmp = max_4(get_sum(0,l),get_sum(l,c),get_sum(c,r),get_sum(r,n)) - min_4(get_sum(0,l),get_sum(l,c),get_sum(c,r),get_sum(r,n));
			ret = min(ret,tmp);
		}
		
	}
	cout << ret << endl;
	return 0;
}

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

int main() {
	int n,k;
  	cin>>n>>k;
  
  	string s;
  	cin>>s;
  
  	k--;
  if(s[k]=='A'){
  	s[k]='a';
  }
  
  else if(s[k]=='B'){
  	s[k]='b';
  }
  
  else if(s[k]=='C'){
  	s[k]='c';
}
  
  cout<<s<<endl;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr double INF=1e100;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

double dist(int x0,int y0,int r0,int x1,int y1,int r1)
{
	return max(sqrt(pow(x0-x1,2)+pow(y0-y1,2))-(r0+r1),0.);
}

int main()
{
	for(int x0,y0,x1,y1;cin>>x0>>y0>>x1>>y1;){
		int n; cin>>n;
		vi xs(n+2),ys(n+2),rs(n+2);
		rep(i,n) cin>>xs[i]>>ys[i]>>rs[i];
		xs[n]=x0; ys[n]=y0; rs[n]=0;
		xs[n+1]=x1; ys[n+1]=y1; rs[n+1]=0;

		vvd g(n+2,vd(n+2));
		rep(i,n+2) rep(j,n+2) g[i][j]=dist(xs[i],ys[i],rs[i],xs[j],ys[j],rs[j]);

		vd ds(n+2,INF); ds[n]=0;
		vi vis(n+2);
		rep(_,n+2){
			int i=-1;
			rep(j,n+2) if(!vis[j]) if(i==-1 || ds[i]>ds[j]) i=j;
			vis[i]=1;
			rep(j,n+2)
				ds[j]=min(ds[j],ds[i]+g[i][j]);
		}
		printf("%.9f\n",ds[n+1]);
	}
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl

bool F[50][30];

signed main() {
  while(true) {
    int N; cin >> N;
    if(N == 0) break;
    memset(F, 0, sizeof(F));
    REP(i,N) {
      int M; cin >> M;
      REP(j,M) {
        int x; cin >> x;
        F[i][x - 1] = true;
      }
    }
    vector<set<int>> info(N);
    REP(i,N) info[i].insert(i);
    int ans = -1;
    REP(d,30) {
      REP(i,N) {
        for(int j = i + 1; j < N; ++j) {
          if(F[i][d] && F[j][d]) {
            // cerr << "merge " << i + 1 << " " << j + 1 << endl;
            info[i].insert(info[j].begin(), info[j].end());
            info[j].insert(info[i].begin(), info[i].end());
          }
        }
      }
      // cerr << "*****" << endl;
      // REP(i,N) {
      //   cerr << "[" << i + 1 << "] =";
      //   for(int num : info[i]) cerr << " " << num + 1;
      //   cerr << endl;
      // }
      bool ok = false;
      REP(i,N) {
        if(info[i].size() == N) {
          ok = true;
        }
      }
      if(ok) {
        ans = d + 1;
        break;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3176
import math

n, d = map(int, input().split())
x = []

def check_distance(vec1, vec2):
  ssum = 0
  root = 0
  for i in range(len(vec1)):
    ssum += (abs(vec1[i]-vec2[i])**2)
    root = math.sqrt(ssum)
  return root.is_integer()


ans = 0
for i in range(n):
  x.append(list(map(int, input().split())))
  
for i in range(n):
  for j in range(n):
    if i == j:
      continue
    if check_distance(x[i], x[j]):
      ans += 1
      
print(ans//2)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n,i,j,k;
  cin>>n>>k;
  long int a[n];
  long long int dp[n]={0};
  for(i=0;i<n;i++)
  {
   	cin>>a[i]; 
  }
  i=0;
  dp[0]=0;
  dp[1]=abs(a[0]-a[1]);
  for(i=2;i<n;i++)
  {
    long int x;
    x=INT_MAX;
    for(j=1;j<=k;j++)
    {
      if(i>=j)
      {
      if(x > dp[i-j] + abs(a[i]-a[i-j]))
         {
           x=dp[i-j] + abs(a[i]-a[i-j]);
         }
       }
      else
       {
       	break; 
       }
    }	
  	dp[i]=x;           
  }
  cout<<dp[n-1];
}	

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+100;
int a,b;

int main()
{

  cin>>a>>b;
  if(a%2==0||b%2==0)
  {
      cout<<"No"<<endl;
  }
  else
  {
      cout<<"Yes"<<endl;
  }


	return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        // Kの入力
        int k = int.Parse(Console.ReadLine());
        // A、Bの入力
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        int num = 1;
        int max = b;
        int min = a;
        int distance = 0;

        bool OK = false;

        if (a > b)
        {
            max = a;
            min = b;
        }

        while (true)
        {
            //倍数
            distance = k * num;
            num++;
            if (min <= distance && distance <= max)
            {
                OK = true;
                break;
            }
            if (max < distance)
            {
                break;
            }
        }

        if (OK)
        {
            //出力:OK
            Console.WriteLine("OK");
        }
        else
        {
            //出力:NG
            Console.WriteLine("NG");
        }
    }
    
}


Measured memory_bytes: 27476
import sys
N, Y = map(int, input().split())

for i in range((Y // 10000) + 1):
    for j in range((Y // 5000) + 1):
        tmp = N - i - j
        if tmp >= 0:
            ans = (i * 10000) + (j * 5000) + ((N - i - j) * 1000)
            if ans == Y:
                print(i, j, tmp)
                sys.exit()
print(-1, -1, -1)

Measured memory_bytes: 3064