akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int x;
	cin >> x;

	vector<int> v(x + 1);
	v[1] = 1;
	for (int i = 2; i <= x; i++) {
		int t = i * i;
		while (t <= x) {
			v[t] = 1;
			t *= i;
		}
	}

	for (int i = x; i >= 1; i--) {
		if (v[i]) {
			out(i);
			return 0;
		}
	}

	return 0;
}

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


int main(){

    int n;
    string s;
    cin >> n >> s;
    string str = s;
    if (str.substr(0, n/2) == str.substr(n/2, n)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
    int K;
    cin >> K;
    int a,b;
    if(K%2==0){
        a=K/2;
        b=K/2;
        cout << a*b << endl;
    }
    else{
        a=K/2+1;
        b=K/2;
        cout << a*b<< endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int64_t> L(n);
    copy_n(istream_iterator<int64_t>(cin), n, L.begin());

    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            for (int k = j + 1; k < n; k++){
                vector<int64_t> A = {L[i], L[j], L[k]};
                sort(A.begin(), A.end());
                if (A[0] == A[1] or A[1] == A[2])
                    continue;
                if (A[0] + A[1] > A[2])
                    ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,N) for(ll i=0; i<N; i++)
using namespace std;
using ll = long long;
int main(){
    double W, H, x, y; cin >> W >> H >> x >> y;

    if(W/2 == x && H/2 == y ) cout << W*H/2 << " " << 1 << endl;
    else cout << W*H/2 << " " << 0 << endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

ll memo[64][64];
ll ncr(ll n , ll r){
	if(memo[n][r])return memo[n][r];
	long long ans = 1;
	int d[64] = {0};
	for(int i = 1 ; i <= r ; i++) d[i] = 1;
	for(int i = 0 ; i < r  ; i++){
		ans *= n-i;
		for(int j = 1 ; j <= r ; j++)
			if(d[j] && ans % j == 0){
				ans /= j;
				d[j] = 0;
			}
	}
	return memo[n][r] = ans;
}

string f(ll n,ll bit,ll m){
	if(bit == 0) return string(n,'0');
	ll cur = 0;
	for(int i = bit ; i <= n ; i++){
		ll next = cur+ncr(i-1,bit-1);
		if(m <= next && m >= cur+1) return f(i-1,bit-1,m-cur) + "1" + string(n-i,'0');
		cur = next;
	}
}
int main(){
	ll n,m;
	while(cin >> n >> m && (n||m) ){
		int bit = n;
		ll cur = 0;
		for(int i = 0 ; i <= n ; i++){
			ll next = cur + ncr(n,i);
			if(m <= next && m >= cur+1){ bit = i; break;}
			cur = next;
		}
		m -= cur;
		string r = f(n,bit,m);
		for(int i = 0 ; i < r.size() ; i++) cout << r[r.size()-1-i];
		cout << endl;
	}
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextInt();
		long[] ints = new long[n];
		int[] values = new int[n];
		for (int i = 0; i < n; i++) {
		    ints[i] = sc.nextInt();
		    values[i] = sc.nextInt();
		}
		long max = 0;
		long base = 0;
		long next = 0;
		for (int i = 0; i < 35; i++) {
		    if (base >= k) {
		        break;
		    }
		    long target = (k ^ next) | base;
		    base = next;
		    next = next * 2 + 1;
		    if (target > k) {
		        continue;
		    }
		    long total = 0;
		    for (int j = 0; j < n; j++) {
		        if ((target | ints[j]) <= target) {
		            total += values[j];
		        }
		    }
		    max = Math.max(total, max);
		}
	    long total = 0;
	    for (int j = 0; j < n; j++) {
	        if ((k | ints[j]) <= k) {
	            total += values[j];
	        }
	    }
	    max = Math.max(total, max);
	    System.out.println(max);
	}
}
	


Measured memory_bytes: 88280
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  vector<int> v;
  rep(i, s.size()) {
    if(s[i] == 'R') {
      v.push_back(i);
    }
  }
  int ans = 0;
  rep(i, v.size()) {
    if(v[i] >= v.size()) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4440
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;  
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
    
//defines
typedef long long ll;
typedef long double ld;

ll a,b,c,n,m,k;

ll t=1;

void solve()
{
    string s;cin>>s;
    c=0;
    for(auto p:s)c+=(p-'0');
    cout<<((c%9LL)==0?"Yes":"No");
 if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

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

using namespace std;

typedef long long lint;

lint n, p;

lint rez;

int main()
{
    rez = 1;
    cin >> n >> p;

    if(n == 1)
    {
        cout << p << "\n";

        return 0;
    }

    for(int i = 2; 1LL * i * i <= p; i ++)
    {
        int x = 0;
        while(p % i == 0)
            x ++, p /= i;

        rez = rez * pow(i, x / n);

    }

    cout << rez << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    multiset<int> color_tails;
    REP(i, N) {
        auto itr = color_tails.upper_bound(-A[i]);
        if(itr == color_tails.end()) {
            color_tails.insert(-A[i]);
        } else {
            color_tails.erase(itr);
            color_tails.insert(-A[i]);
        }
    }

    cout << color_tails.size() << endl;
    return 0;
}


Measured memory_bytes: 8296
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(); // sankousyo
    int M = sc.nextInt(); // algori
    int X = sc.nextInt(); // 理解度
    int[] yen = new int[N]; // yen
    int[][] ji = new int[N][M]; // 実力
    for(int i=0; i<N ;i++){
      yen[i] = sc.nextInt(); 
      for(int j=0; j<M ;j++){
        ji[i][j] = sc.nextInt(); 
      }
    }
    int min = Integer.MAX_VALUE;
    for(int i = 0 ; i < Math.pow(2,N) ; i++) {
      int[] aa = new int[M];
      int sum = 0;
      for(int j = 0 ; j < N ; j++) {
        if((1 & (i>>j)) == 1) {
          sum += yen[j];
          for(int k =0; k<M ; k++){
            aa[k] += ji[j][k];
          }
        }
        boolean bf = true;
        for(int l =0; l<M ; l++){
          if(aa[l]<X){
            bf = false;
          }
        }
        if(bf==true){min = Math.min(min, sum);}
      }
    }
    if(min==Integer.MAX_VALUE){
      System.out.println(-1); 
    }else{
      System.out.println(min); 
    }
  }

}





Measured memory_bytes: 37616
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;
int n,m;
int a[233333],b[233333];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i]-i;
	}
	sort(b+1,b+n+1);
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=abs(a[i]-b[(n+1)/2]-i);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    int max=0;
    int min=1000;
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
      min=Math.min(min,a[i]);
      max=Math.max(max,a[i]);
    }
    sc.close();
    System.out.println(max-min);
  }
}

Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

vector<int> v[100010];

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

  bool used[n+1]={};
  int num[n+1]={};
  for(int i=0;i<n+m-1;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    v[a].push_back(b);
    used[b]=true;
    num[b]++;
  }
  int start=1;
  for(int i=0;i<n;i++){
    if(used[i]==true);
    else start=i;
  }
  queue<int> Q;
  Q.push(start);
  int par[n+1]={};
  while(!Q.empty()){
    int now=Q.front();
    Q.pop();
    for(int i=0;i<v[now].size();i++){
      int u=v[now][i];
      num[u]--;
      if(num[u]==0){
        Q.push(u);
        par[u]=now+1;
      }
    }
  }

  for(int i=0;i<n;i++) cout<<par[i]<<endl;



  return 0;
}


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

using namespace std;

int main() {
	long long i, n, t[100000]{ 1 }, a[100000]{ 1 }, m[100000]{ 1 }, s[100000]{ 1 }, ans = 1;

	cin >> n;

	for (i = 0; i < n; i++) {
		t[i] = 1;
		a[i] = 1;
		m[i] = 1;
		s[i] = 1;
	}
	
	for (i = 0; i < n; i++) {
		cin >> t[i];
		if (i == 0) {
			m[i] = t[i];
		}
		else {
			if (t[i] > t[i - 1]) {
				m[i] = t[i];
			}
		}	
	}
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0) {
		}
		else {
			if (a[i] < a[i - 1]) {
				m[i - 1] = a[i - 1];
			}
		}
		if (i == n - 1) {
			if (n == 1 && t[0] != a[0]) {
				cout << "0" << endl;
				return 0;
			}
			else {
				m[i] = a[i];
			}
		}
	}
	

	for (i = 0; i < n; i++) {
		if (t[i] < a[i]) {
			s[i] = t[i];
		}
		else {
			s[i] = a[i];
		}
		if (m[i] > s[i]) {
			cout << "0" << endl;
			return 0;
		}
	}

	for (i = 0; i < n; i++) {
		ans *= (s[i] - m[i]) + 1;
		ans %= 1000000007;
		if (ans == 0) {
			ans += 1000000007;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3456
MOD=10**9+7
def facinv(N):
    fac,finv,inv=[0]*(N+1),[0]*(N+1),[0]*(N+1)
    fac[0]=1;fac[1]=1;finv[0]=1;finv[1]=1;inv[1]=1
    for i in range(2,N+1):
        fac[i]=fac[i-1]*i%MOD
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        finv[i]=finv[i-1]*inv[i]%MOD
    return fac,finv,inv

fac,finv,inv=facinv(2*(10**6))

#nCr
def COM(n,r):
    if n<r or r<0:
        return 0
    else:
        return ((fac[n]*finv[r])%MOD*finv[n-r])%MOD

K=int(input())
S=input()
L=len(S)
M=L+K
ans=0
for i in range(M):
    if i<L-1:
        continue
    c=COM(i,L-1)
    l=pow(25,i-(L-1),MOD)
    r=pow(26,M-i-1,MOD)
    ans=(ans+c*l%MOD*r%MOD)%MOD
print(ans)

Measured memory_bytes: 135772
n = int(input())
h = list(map(int, input().split()))

ans = "Yes"

if n == 1:
        print("Yes")
        exit()

if n == 2:
        if h[0] - h[1] >= 2:
                print("No")
                exit()
        else:
                print("Yes")
                exit()

sh = set(h)
if len(sh) == 2:
        big = max(sh)
        small = min(sh)
        if big - small >= 2:
                print("No")
                exit()
        else:
                print("Yes")
                exit()
tmp = 0
for i in range(1, n):
        if h[i-1] - h[i] >= 2:
                ans = "No"
                break
        else:
                if h[i-1] > h[i]:
                        if h[i] >= tmp:
                                tmp = h[i]
                        else:
                                print("No")
                                exit()





print(ans)


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

class RangeSumQuery {
public:
	int n;
	vector<int> d;
	RangeSumQuery(int m) {
		for (n = 1; n < m; n *= 2);
		d.assign(n * 2, 0);
	}
	void add(int i, int x) {
		d[n + i] += x;
		for (int j = (n + i) / 2; j > 0; j >>= 1)
			d[j] = d[j * 2] + d[j * 2 + 1];
	}
	//[l, r)
	int query(int l, int r) {
		int sum = 0;
		for (; l && l + (l&-l) <= r; l += l&-l)
			sum += d[(n + l) / (l&-l)];
		for (; l < r; r -= r&-r)
			sum += d[(n + r) / (r&-r) - 1];
		return sum;
	}
	int get(int i) { return d[n + i]; }
};

signed main() {
	int n, q; cin >> n >> q;
	RangeSumQuery RSQ(n);
	rep(i, 0, q) {
		int com, x, y; cin >> com >> x >> y;
		if (com == 0)RSQ.add(x, y);
		else cout << RSQ.query(x, y + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3812
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0196

"""
import sys
from sys import stdin
from heapq import heappop, heappush
input = stdin.readline


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break

        pq = []
        for seq in range(n):
            temp = input().split()
            team_name = temp[0]
            temp = temp[1:]
            win_count = temp.count('0')
            lose_count = temp.count('1')
            heappush(pq, (-win_count, lose_count, seq, team_name))

        while pq:
            _, _, _, team_name = heappop(pq)
            print(team_name)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7848
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll a,b,c;

int main(){
	cin>>a>>b>>c;
	if(a==b&&b==c&&a%2==0){
		cout<<"-1"<<endl;
		return 0;
	}
	for(int i=0;i<10000000000;i++){
		if(a%2==1||b%2==1||c%2==1){
			cout<<i<<endl;
			return 0;
		}
		ll t=a,s=b,u=c;
		a=(s+u)/2;
		b=(t+u)/2;
		c=(t+s)/2;
	}
}

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int h, w; cin >> h >> w;
    vector<string> v(h);
    rep(i, h) cin >> v[i];
    rep(i, h) {
        rep(j, 2) cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    ll a,b,x;
    cin>>a>>b>>x;
    if(x <= a+b && x >= a)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

char col[2][3] = { "RY", "GB" };

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, d;
    cin >> H >> W >> d;

    vector<string> S(H, string(W, ' '));
    rep(y, H)rep(x, W) {
        int Y = x + y;
        int X = x - y;
        Y = Y % (2 * d) / d;
        X = X % (2 * d);
        if (X < 0)X += 2 * d;
        X /= d;
        S[y][x] = col[Y][X];
    }

    rep(y, H)cout << S[y] << endl;
}


Measured memory_bytes: 768
function main(input){
	
var [n, ...sn]=input.split("\n");

const result = {AC: 0, WA: 0, TLE: 0, RE: 0}
for (const s of sn) {
  result[s] += 1
}
console.log(`AC x ${result['AC']}`)
console.log(`WA x ${result['WA']}`)
console.log(`TLE x ${result['TLE']}`)
console.log(`RE x ${result['RE']}`)
  
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 44268
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  n, k = map(int, readline().split())
  s = input()
  small = s[k-1].lower()
  print(s[:k-1] + small + s[k:])
  
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5076
N, K = map(int, input().split())
x = list(map(int, input().split()))

ans = 10**18
for i in range(N-K+1):
    y0 = x[i]
    yk = x[i+K-1]
    if yk < 0:
        ans = min(ans, abs(y0))
    elif y0 <= 0 and 0 <= yk:
        ans = min(ans, yk-2*y0, 2*yk-y0)
    else:
        ans = min(ans, yk)

print(ans)


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

long long ShellSort(int elem[], int num)
{
    int i, j, k;
    int h;
    int target;
    long long cnt = 0;
    vector<int> vect;

    for (h = 1; ;) {
        if (h <= num) {
            vect.push_back(h);
        }
        else {
            break;
        }
        h = 3 * h + 1;
    }

    h = vect.size() - 1;
    cout << h+1 << endl;
    for (i = h; i >= 0; i--) {
        int g = vect[i];
        if (i != h) {
            cout << " ";
        }
        cout << g;
        for (j = g; j < num; j++) {
            target = elem[j];
            for (k = j - g; k >= 0; k -= g) {
                if (elem[k] > target) {
                    elem[k + g] = elem[k];
                    ++cnt;
                }
                else {
                    break;
                }
            }
            elem[k + g] = target;
        }
    }
    cout << endl;

    return cnt;
}

int main(void)
{
    int i;
    long long cnt;
    int num;
    int elem[1000000];

    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        scanf("%d", &elem[i]);
    }

    cnt = ShellSort(elem, num);

    cout << cnt << endl;
    for (i = 0; i < num; i++) {
        cout << elem[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 5140
#include <iostream>

using namespace std;

int main(void){
	int p[3],ju[2];
	for(int i=0;i<3;++i) cin>>p[i];
	for(int j=0;j<2;++j) cin>>ju[j];
	int ans = 1e9;
	for(int i=0;i<3;++i){
		for(int j=0;j<2;++j){
			ans = min(p[i] + ju[j] - 50, ans);
		}
	}
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

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

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

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

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

    while(1) {
        ll n, y, x;
        cin >> n >> y >> x;
        if(!n) break;
        y--, x--;

        // ほどいていったときの印がついている位置のyの遷移
        ll h = 1LL<<n;
        vector<ll> transy(1, y);
        REP(i, n) {
            if(y < h/2) {
                y = h/2 - y - 1;
            } else {
                y -= h/2;
            }
            transy.push_back(y);
            h /= 2;
        }

        string ans = "";
        for(ll i=n-1, h=2, w=1LL<<n; i>=0; --i, h*=2, w/=2) {
            // transy[i] で LR どちらを選ぶか決められる
            if(transy[i] < h/2) {
                if(x < w/2) {
                    ans += "L";
                    x = w/2-1 - x;
                } else {
                    ans += "R";
                    x = w-1 - x;
                }
            } else {
                if(x < w/2) {
                    ans += "R";
                } else {
                    ans += "L";
                    x = x - w/2;
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}



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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T, class U>
std::ostream& operator<<(std::ostream &os, const std::pair<T, U> &p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}
 
template <class T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v) {
    os << "[";
	for (int i = 0; i < v.size(); ++i) {
        if (i) {
            if (i % 5 == 0) {
                os << ",\n ";
            } else {
                os << ", ";
            }
        }
		os << v[i];
	}
	os << "]";
	return os;
}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll result = 0;
    int L = 0;
    for (char c: S) {
        if (c == 'S') {
            L = 0;
        } else if (c == 'R') {
            ++L;
        }
        amax(result, L);
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,k;
int p[100005],q[100005],ip[100005],iq[100005],A[100005],iA[100005],T[100005];
int rtem[100005];
inline void mul(int *a,int *b,int *c){
	for(int i=1;i<=n;i++)rtem[i]=a[b[i]];
	for(int i=1;i<=n;i++)c[i]=rtem[i];
}
inline void inv(int *a,int *b){
	for(int i=1;i<=n;i++)b[a[i]]=i;
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)scanf("%d",&q[i]);
	for(int i=1;i<=n;i++)A[i]=T[i]=i;
	inv(p,ip); inv(q,iq);
	mul(T,q,T); mul(T,ip,T); mul(T,iq,T); mul(T,p,T);
	for(int i=1;i<=(k-1)/6;i<<=1,mul(T,T,T))if(((k-1)/6)&i)mul(A,T,A);
	inv(A,iA);
	mul(A,p,T); mul(T,iA,p);
	mul(A,q,T); mul(T,iA,q);
	k=(k-1)%6+1;
	if(k==1){for(int i=1;i<=n;i++)printf("%d ",p[i]); return 0;}
	for(int i=3;i<=k;i++){
		inv(p,ip);
		mul(q,ip,T);
		swap(p,q);
		swap(q,T);
	}
	for(int i=1;i<=n;i++)printf("%d ",q[i]);
	return 0;
}


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

int main() {
	int n;
	cin>>n;
	
	int ar[n],ans=0;
	for(int i=0;i<n;i++){
		cin>>ar[i];
		if(i>1){
			vector<int> v;
			v.push_back(ar[i-2]);
			v.push_back(ar[i-1]);
			v.push_back(ar[i]);
			sort(v.begin(),v.end());
			if(ar[i-1]==v[1]) ans++;
		}
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 256
import math
def div(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
def is_primeplus(n):
    if n == 1:
        return 1
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            return 0
    return 1
a,b = map(int,input().split())
c = list(set(div(a)) & set(div(b)))
ans = 0
for i in range(len(c)):
    if is_primeplus(c[i]):
        ans += 1
print(ans)

Measured memory_bytes: 5164
N,K=input().split()
N=int(N)
K=int(K)
def hoge(X, n):
    if (int(X/n)):
        return hoge(int(X/n), n)+str(X%n)
    return str(X%n)
tenn = N
enn= hoge(tenn, K)
print(len(enn))

Measured memory_bytes: 3060
N, Y = map(int, input().split())
ans = "-1 -1 -1"
for a in range(N+1):
  for b in range(N-a+1):
    c = N-a-b
    if a*10000+b*5000+c*1000 == Y:
      ans = "%d %d %d"%(a,b,c)
print(ans)




Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;

ll exgcd(ll a, ll b, ll & x, ll & y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll d = exgcd(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
ll inv(ll a, ll MOD)
{
	ll x, y;
	exgcd(a, MOD, x, y);
	x = (x % MOD + MOD) % MOD;
	return x;
}
ll fac[200010];
void init(int p)
{
	fac[0] = 1;
	for (int i = 1; i <= p; i++) fac[i] = fac[i - 1] * i % mod;
}
ll lucas2(ll n, ll m)
{
	ll ret = 1, a, b;
	while (n && m)
	{
		a = n % mod, b = m % mod;
		if (a < b) return 0;
		ret = ret * fac[a] % mod * inv(fac[b] * fac[a - b] % mod, mod) % mod;
		n /= mod, m /= mod;
	}
	return ret;
}
int main()
{
	ll x, y, n, m;

	scanf("%lld%lld%lld%lld", &n, &m, &x, &y);
	ll ans = 0;
	init(200005);
	ll z = y, p = n + m - 2;
	for (ll i = 0; i <= n - x - 1; i++)
	{
		ans = ans + lucas2(z + i - 1, i) * lucas2(p - z - i, n - 1 - i) % mod;
		ans %= mod;
		//printf("1  %lld  %lld\n", i, ans);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a;
  int b;
  cin >> a >> b;
  if ((a+b) % 2 == 0){
     cout << (a+b)/2 << endl;
   }
  else{
    cout << (a+b+1)/2 << endl;
   }
}

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

int N, K, H[100005], dp[100005];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> K;
	for (int i = 1; i <= N; i++) cin >> H[i];
	memset(dp, 127, sizeof dp);
	dp[1] = 0;
	for (int i = 2; i <= N; i++)
		for (int j = max(1ll, i - K); j < i; j++)
			dp[i] = min(dp[i], dp[j] + llabs(H[i] - H[j]));
	cout << dp[N] << '\n';
}


Measured memory_bytes: 1792
import heapq

n=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)

timelist=[] #ステージが代わるごとに更新
importlist=[0]
before=A[0]
flag=True

for a in A[1:]:
    if before!=a: #世代交代 importlistをtimelistに追加
        for v in importlist:
            if v<n:
                heapq.heappush(timelist,v)
        importlist=[]
    before=a
    if len(timelist)!=0:
        v=heapq.heappop(timelist)
        if v<n:
            heapq.heappush(timelist,v+1)
        else:
            flag=False
            break
        importlist.append(v+1)
    else:    
        flag=False
        break
print("Yes" if flag else "No")

Measured memory_bytes: 119884
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<int>())
using namespace std;
int main()
{
  speed_up;
  ll n, m, sum = 0;
  cin>>n;
  ll a[n];
  for(auto &i: a)
  {
      cin>>i;
      sum +=i;
  }
  ll d = sum;
  cin>>m;
  while(m--)
  {
      ll p, x;
      sum = d;
      cin>>p>>x;
      sum = sum - a[p-1] + x;
      cout<<sum<<endl;

    }


  return 0;
}


Measured memory_bytes: 3616
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                int H = sc.nextInt(), W = sc.nextInt();
                                if (H == 0 && W == 0) {
                                        break;
                                }
                                for (int i = 0; i < H; i++) {
                                        for (int j = 0; j < W; j++) {
                                                if (i == 0 || j == 0 || i == H - 1 || j == W - 1) {
                                                        System.out.print("#");
                                                } else {
                                                        System.out.print(".");
                                                }
                                        }
                                        System.out.println("");
                                }
                                System.out.println("");
                        }
                }
        }
}

Measured memory_bytes: 32900
N = int(input())
graph = [[300] * (N+1) for _ in range(N+1)] # 1行目と1列目は使わない
edges = []
for i in range(N+1):
    graph[i][i] = 0
for i in range(1, N+1):
    S = list(str(input()))
    for j in range(len(S)):
        if S[j] == '1':
            edges.append((i, j+1))
            graph[i][j+1] = graph[j+1][i] = 1
for k in range(N+1):
    for i in range(N+1):
        for j in range(i+1, N+1):
            x = graph[i][k] + graph[k][j]
            if x < graph[i][j]:
                graph[i][j] = graph[j][i] = x
# 二部グラフかどうかの判定のために0か1の色を塗る
colors = [None] * (N+1)
colors[1] = 0
que = [1]
while que:
    x = que.pop()
    for i in range(1, N+1):
        if graph[x][i] != 1 or x == i:
            continue
        if colors[i] is None:
            colors[i] = 1 - colors[x]
            que.append(i)

# 二部グラフかどうか
is_bg = all(colors[a] != colors[b] for a, b in edges)
if not is_bg:
    print(-1)
    exit()
print(max(max(x[1:]) for x in graph[1:]) + 1)

Measured memory_bytes: 6240
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {

	n, m := oneInt(), oneInt()

	brokens := []int{}
	for i := 0; i < m; i++ {
		brokens = append(brokens, oneInt())
	}

	ans := calc(n, brokens)

	//fmt.Println(ans)
	fmt.Println(ans)
}

func calc(n int, brokens []int) int64 {
	if n == 1 {
		return int64(1)
	}

	dp := make([]int64, n+1)

	for i := 0; i < len(brokens); i++ {
		dp[brokens[i]] = -1
	}

	if dp[1] == -1 && dp[2] == -1 {
		dp[1] = 0
		dp[2] = 0
	} else if dp[1] == -1 {
		dp[1] = 0
		dp[2] = 1
	} else if dp[2] == -1 {
		dp[1] = 1
		dp[2] = 0
	} else {
		dp[1] = 1
		dp[2] = 2
	}

	for i := 3; i < n+1; i++ {
		if dp[i] == -1 {
			dp[i] = 0
		} else {
			dp[i] = dp[i-1] + dp[i-2]
          dp[i] %= (1e9+7)
		}
		//fmt.Printf("%#v\n", dp)

	}
	return dp[n] 
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func scanNums(n int) (nums []int) {
	str := readLine()
	s := strings.Split(str, " ")
	for i := 0; i < n; i++ {
		num, _ := strconv.Atoi(s[i])
		nums = append(nums, num)
	}
	return nums
}

func scanStrings(len int) (strs []string) {
	for i := 0; i < len; i++ {
		strs = append(strs, oneStr())
	}
	return strs
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


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

using namespace std;
using ll = long long;

int n, k;


vector<vector<int>> f(vector<pair<int,int>> a) {

    int n = a.size();
    vector<vector<int>> sum(k + 1, vector<int>(k + 1));
    for(int i = 0; i < n; i++)sum[a[i].first + 1][a[i].second + 1]++;
    // prvec(sum);
    for(int i = 0; i < k; i++) {
        for(int j = 0; j < k; j++) {
            sum[i + 1][j + 1] += sum[i + 1][j] + sum[i][j + 1] - sum[i][j];
        }
    }
    return sum;
}

int get(int x1, int y1, int x2, int y2, vector<vector<int>>& sum) {
    return sum[y2][x2] - sum[y2][x1] - sum[y1][x2] + sum[y1][x1];
}



int main()
{
    cin >> n >> k;
    vector<pair<int,int>> w, b;
    for(int i = 0; i < n; i++) {
        int x, y; char c; cin >> x >> y >> c;
        if(c == 'B')x += k;
        c = 'W';
        x %= k * 2, y %= k * 2;
        if(x >= k && y >= k)x -= k, y -= k;
        if(x >= k && y < k)x -= k, c = 'B';
        if(x < k && y >= k)y -= k, c = 'B';
        if(c=='W')w.push_back({y, x});
        else b.push_back({y, x});
    }

    vector<vector<int>> wsum = f(w), bsum = f(b); 

    int nax = 0;
    for(int i = 0; i <= k; i++) {
        for(int j = 0; j <= k; j++) {
            {
                int curb = get(0, 0, i, j, bsum) + get(i, j, k, k, bsum);
                int curw = get(i, 0, k, j, wsum) + get(0, j, i, k, wsum);
                nax = max(nax, curw + curb);
            }

            {
                int curw = get(0, 0, i, j, wsum) + get(i, j, k, k, wsum);
                int curb = get(i, 0, k, j, bsum) + get(0, j, i, k, bsum);
                nax = max(nax, curw + curb);
            }
        }
    }

    cout << nax << endl;

}

Measured memory_bytes: 12260
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n, k) for (int i = n; i < k; i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(24) << fixed << p << endl;
#define vi vector<int>
#define printv(v)                      \
    for (int i = 0; i < v.size(); i++) \
        P(v[i]);
#define printt(a, b) cout << a << " " << b << endl;
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    return a % b == 0 ? b : gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b; //先に割り算をして掛けられる数を小さくして掛け算を行う
}

bool pairCompare(const pair<int, int> &firstElof, const pair<int, int> &secondElof)
{
    return firstElof.second < secondElof.second;
}

void solve()
{
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> vs;
    rep(i,h){
        string s;
        cin >> s;
        vs.push_back(s);
    }
    int count = 0;
    for(int i = 0; i < (1<<h);i++){
        for(int j = 0;j < (1<<w);j++){
            int bcount = 0;
            rep(k,h)rep(l,w){
                if(i & (1<<k) && j & (1<<l) && vs[k][l] == '#') bcount++;
            }
            if(bcount == k)count++;
        }
    }
    P(count);
}

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


Measured memory_bytes: 3604
#include <set>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

typedef long long ll;

const int maxn = 210000;

struct edge
{
	int u,v;
	ll w;
};

vector<ll> g[maxn];
edge g2[maxn << 1];
int p[maxn];

int find(int x)
{
	if (x != p[x]) p[x] = find(p[x]);
	return p[x];
}

void insert(int n,int x, int y)
{
	g[x].push_back(y);
	g[1].push_back(y + (n - x + 1) * 2);
}

int id;

void add(int u, int v, ll w)
{
	g2[++id].v = v;
	g2[id].u = u;
	g2[id].w = w;
}

bool comp(const edge & a, const edge & b)
{
	return a.w < b.w;
}

int main(int argc, char * argv[])
{
	int n, q;
	scanf("%d%d", &n, &q);
	for (int i = 1; i <= q; ++i)
	{
		int a1, b1;
		ll c1;
		scanf("%d%d%lld", &a1, &b1, &c1);
		a1++;
		b1++;
		add(a1, b1, c1);
		insert(n, a1, c1 + 1);
		insert(n, b1, c1 + 2);
	}
	static set<ll> s;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 0; j < g[i].size(); ++j)
			s.insert(g[i][j] - 2 * i);
		add(i, i%n + 1, 2 * i + (*(s.begin())));
	}
	for (int i = 1; i <= n; ++i) p[i] = i;
	sort(g2 + 1, g2 + id + 1, comp);
	ll ans = 0;
	for (int i = 1; i <= id; ++i)
	{
		int u = find(g2[i].u);
		int v = find(g2[i].v);
		if (u != v)
		{
			p[u] = v;
			ans += g2[i].w;
		}
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 60396
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
	
bool solve() {
	int n; cin>>n; vector<int> B,C;
	vector<int> A(n); REP (i,n) {
		int x; cin >> x;
		if (x > 0) B.pb(x);
		else C.pb(x);
	}
	sort(ALL(B)), sort(ALL(C));
	reverse(ALL(C));
	if (C.size() == 0) {
		A = B;
	} else if (B.size() == 0) {
		A = C;
	} else {
		A[0]=B[0];
		A[1]=C[0];
		int pos = 2;
		FOR (i,1,B.size()) {
			A[pos] = B[i];
			pos++;
		}
		FOR (i,1,C.size()) {
			A[pos] = C[i];
			pos++;
		}
	}
	int sm,bg; sm = min(A[0],A[1]), bg = max(A[0],A[1]);
	pair<int,int> ans[n-1];
	FOR (i,2,n) {
		if (A[i] > 0) {
			ans[i-2].F = sm,ans[i-2].S=bg;
			sm = sm-bg, bg = A[i];
		} else {
			ans[i-2].F = bg,ans[i-2].S=sm;
			bg = bg-sm, sm = A[i];
		}
	}
	ans[n-2]={bg,sm};
	cout << ans[n-2].F-ans[n-2].S << endl;
	REP (i,n-1) {
		cout << ans[i].F << " " << ans[i].S << endl;
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}


Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;


int main(){
    llong x;
    cin >> x;
    llong ans;
    ans = 2*(x/11);
    if(1 <= x%11 and x%11 <7) ans+=1;
    if( 7<= x%11) ans +=2;
    cout << ans << endl;
}

Measured memory_bytes: 256
comp :: Eq a => (a,a) -> Bool
comp (a,b) = a == b

compList :: Eq a => [a] -> [a] -> [Bool]
compList [] _ = []
compList _ [] = []
compList ss ts = map comp $ zip ss ts

main :: IO ()
main = do
    s <- getLine
    t <- getLine

    let ans = length $ filter (==False) $ compList s t
    print ans

Measured memory_bytes: 20020
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int x = N % 500;
    if( x <= A) System.out.println("Yes");
    else System.out.println("No");
  }
}

Measured memory_bytes: 21716
#include <stdio.h>
int main(void){
    // Your code here!
    char a,b;
    
    scanf(" %c %c",&a,&b);
    
    if((a == 'H' && b == 'H') || (a == 'D' && b == 'D')){
        printf("H\n");
    }
    else{
        printf("D\n");
    }
    
    return 0;
}


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

int main(){
	int n;
	cin>>n;
	int ar[n];
	int dp[n];
	int k;
	cin>>k;
	for (int i=0;i<n;i++)
	cin>>ar[i];
	dp[0]=0;
	for (int i=1;i<n;i++){
		int mini=1000000007;
		if (i-k<0){
			for (int j=0;j<i;j++)
				mini=min(mini,(dp[j]+abs(ar[j]-ar[i])));
			dp[i]=mini;
		}
		else{
			for (int j=i-k;j<i;j++)
			mini=min(mini,(dp[j]+abs(ar[j]-ar[i])));
			dp[i]=mini;
		}
	}
			
		
		


			
			
	
	cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < n; i++) {
	int s;
	cin >> s;
	a.push_back(s);
  }
  sort(a.begin(), a.end());
  cout << a.back() - a.front() << endl;
  return 0;
}



Measured memory_bytes: 256