akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int N;
    //int A[200001];
    //int B[200001];
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> tasks;

    cin >> N;
    rep(i, N) {
        int A, B;
        cin >> A >> B;
        tasks.push(make_pair(B, A));
    }

    int t = 0;
    while(!tasks.empty()) {
        IFD {
            cout << "t: " << t << " ";
            cout << "(" << tasks.top().first << ", " << tasks.top().second << ")" << endl;
        }
        t += tasks.top().second;
        if(t > tasks.top().first) {
            cout << "No" << endl;
            return 0;
        }
        tasks.pop();
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 2420
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

// ModInt begin

using ll = long long;
template<ll mod>
struct ModInt {
    ll v;
    ll mod_pow(ll x, ll n) const {
        return (!n) ? 1 : (mod_pow((x*x)%mod,n/2) * ((n&1)?x:1)) % mod;
    }
    ModInt(ll a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
    ModInt operator+ ( const ModInt& b ) const {
        return (v + b.v >= mod ? ModInt(v + b.v - mod) : ModInt(v + b.v));
    }
    ModInt operator- () const {
        return ModInt(-v);
    }
    ModInt operator- ( const ModInt& b ) const {
        return (v - b.v < 0 ? ModInt(v - b.v + mod) : ModInt(v - b.v));
    }
    ModInt operator* ( const ModInt& b ) const {return (v * b.v) % mod;}
    ModInt operator/ ( const ModInt& b ) const {return (v * mod_pow(b.v, mod-2)) % mod;}
    
    bool operator== ( const ModInt &b ) const {return v == b.v;}
    bool operator!= ( const ModInt &b ) const {return !(*this == b); }
    ModInt& operator+= ( const ModInt &b ) {
        v += b.v;
        if(v >= mod) v -= mod;
        return *this;
    }
    ModInt& operator-= ( const ModInt &b ) {
        v -= b.v;
        if(v < 0) v += mod;
        return *this;
    }
    ModInt& operator*= ( const ModInt &b ) {
        (v *= b.v) %= mod;
        return *this;
    }
    ModInt& operator/= ( const ModInt &b ) {
        (v *= mod_pow(b.v, mod-2)) %= mod;
        return *this;
    }
    ModInt pow(ll x) { return ModInt(mod_pow(v, x)); }
    // operator int() const { return int(v); }
    // operator long long int() const { return v; }
};

template<ll mod>
ModInt<mod> pow(ModInt<mod> n, ll k) {
    return ModInt<mod>(n.mod_pow(n.v, k));
}

template<ll mod>
ostream& operator<< (ostream& out, ModInt<mod> a) {return out << a.v;}
template<ll mod>
istream& operator>> (istream& in, ModInt<mod>& a) {
    in >> a.v;
    return in;
}

// ModInt end

using mint = ModInt<MOD>;

int main() {
    int N; cin >> N;
    
    mint perm(1);
    for(int i=1; i<N; i++) perm *= mint(i);

    vector<int> X(N);
    for(int i=0; i<N; i++) {
        cin >> X[i];
    }

    mint rev(0), ans(0);
    for(int i=1; i<N; i++) {
        rev += mint(1) / mint(i);
        ans += perm * rev * mint(X[i] - X[i-1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), k = in.nextInt() - 1;
        int[] x = new int[n];
        for(int i = 0; i < n; i++) {
            x[i] = in.nextInt();
        }
        int ans = Integer.MAX_VALUE;
        for(int i = 0; i < n - k; i++) {
            if(x[i] < 0 && 0 < x[i+k]) {
                ans = Math.min(ans, Math.min(-x[i], x[i + k]) * 2 + Math.max(-x[i], x[i + k]));
            } else {
                ans = Math.min(ans, 0 < x[i] ?  x[i + k] : -x[i]);
            }
        }
        System.out.println(ans);
    }
}

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

int main()
{
ll t;
t=1;
while(t--)
{

ll a,b,s=0,k;
cin>>a>>b;
s=a+b;
k=max(a,b);

if(s>=k+(k-1))
cout<<s<<endl;

else
cout<<k+(k-1)<<endl;

}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
#define s(v) v.size()
#define e(v) v.empty()

using namespace std;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
// bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){return (a.second < b.second);} 

int main(){
	// #ifndef ONLINE_JUDGE
 //        freopen("../input.txt", "r", stdin);
 //        freopen("../output.txt", "w", stdout);
 //    #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
    	ll n;
    	cin>>n;
    	vl vec(n);
    	rep(i, n)	cin>>vec[i];
    	ll max = 0, temp = 0;
    	// temp = 1, max = 1;
    	rep(i, n-1){
    		if(vec[i] >= vec[i+1])	temp++;
    		else{
    			if(temp > max)	max = temp;
    			temp = 0;
    		}
    	}
    	if(temp > max)	max = temp;
    	cout<<max;
    }
}

Measured memory_bytes: 1024
import math
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a, b, c = map(str, input().split("/"))
print(2018, b, c, sep="/")


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


int main()
{
  int N;
  vector<long int> L(86+1);
  
  cin >> N;
  
  L.at(0)=2;
  L.at(1)=1;
  
  for(int i=2;i<=N;i++)
  {
    L.at(i) = L.at(i-1) + L.at(i-2);
  }
  
  cout << L.at(N) << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const int MAX_N = 2e5 + 5;

ll arr [MAX_N];

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

  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    arr[i] *= 2;
  }

  for (int i = 1; i < n; i++) {
    arr[i] += arr[i - 1];
  }

  ll targ = arr[n - 1] / 2;
  ll ans = targ;
  for (int i = 0; i < n; i++) {
    ans = min(ans, abs(arr[i] - targ));
  }
  cout << ans << endl;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> arr(n);
    for(auto i = 0 ; i < n ; ++i)
        cin>>arr[i];
    int ans = 0;
    for(auto i = 0 ; i < n; ++i) {
        for(auto j = i + 1; j < n ; ++j) {
            for(auto k = j + 1 ; k < n ; ++k) {
                if(arr[i] != arr[j] && arr[j] != arr[k] && arr[i] != arr[k] && arr[i] + arr[j] > arr[k] && arr[i] + arr[k] > arr[j] && arr[j] + arr[k] > arr[i]) {
//                    cout<<i<<' '<<j<<' '<<k<<endl;
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3620
import sys


m, d = map(int, input().split())

if d < 22:
    print(0)
    sys.exit(0)

ans = 0
for i in range(22, d+1):
    d1 = i % 10
    d10 = (i - d1)/10
    if 2 < d1*d10 < m+1 and d1 > 1 and d10 > 1:
        ans += 1

print(ans)


Measured memory_bytes: 2940
// パーティション
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 100000
//const int INFTY = 2147483647;

int partition(int A[], int p, int r);

int main(void)
{

    int n, pos;
    int A[MAX_N];

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> A[i];
    }

    pos = partition(A, 0, n - 1);

    for(int i = 0; i < n; i++)
    {
        if( i )
        {
            printf(" ");
        }

        if( i != pos )
        {
            printf("%d", A[i]);
        }
        else
        {
            printf("[%d]", A[i]);
        }
    }

    printf("\n");

    return 0;
}

int partition(int A[], int p, int r)
{
    int x = 0, i = 0, tmp = 0;

    x = A[r];
    i = p - 1;

    for(int j = p; j < r; j++)
    {
        if( A[j] <= x )
        {
            i++;

            // A[i] と A[j]を交換
            tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }

    // A[i + 1] と A[r]を交換
    tmp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = tmp;

    return i + 1;
}



Measured memory_bytes: 3584
if __name__ == "__main__":
    n = int(input())
    data = []
    for _ in range(n):data.append(input())
    p =[]
    state = True
    for i in data:
        if len(p) ==0 and i =='Un':state = False
        elif len(p) !=0 and i == 'Un': p.pop()
        if i =='A':p.append(1)
    if len(p) !=0:state = False
    if state :print("YES")
    else:print("NO")

Measured memory_bytes: 7728
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    rep(i,n) a[i] -= i+1;
    sort(all(a));
    int b1 = a[n/2];
    int b2 = a[n/2-1];
    ll ans1 = 0, ans2 = 0;
    rep(i,n) ans1 += abs(a[i]-b1), ans2 += abs(a[i]-b2);
    cout << min(ans1,ans2) << endl;
}


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

class F
{
	static void Main()
	{
		var qs = new int[int.Parse(Console.ReadLine())].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray());

		long a = 0, b = 0;
		var l = new PQ<int>(c: (x, y) => y - x);
		var r = new PQ<int>();
		var s = new List<string>();
		foreach (var q in qs)
		{
			if (q[0] == 2) { s.Add($"{l.First} {a + b}"); continue; }

			if (l.Count == r.Count)
			{
				if (r.Any() && q[1] > r.First)
				{
					l.Push(r.Pop());
					r.Push(q[1]);
				}
				else l.Push(q[1]);
			}
			else
			{
				if (q[1] < l.First)
				{
					r.Push(l.Pop());
					l.Push(q[1]);
					a += r.First - l.First;
				}
				else r.Push(q[1]);
			}
			a += Math.Abs(l.First - q[1]);
			b += q[2];
		}
		Console.WriteLine(string.Join("\n", s));
	}
}

class PQ<T> : List<T>
{
	Comparison<T> _c;
	public T First => this[0];

	public PQ(IEnumerable<T> vs = null, Comparison<T> c = null)
	{
		_c = c ?? Comparer<T>.Default.Compare;
		if (vs != null) foreach (var v in vs) Push(v);
	}

	void Swap(int i, int j) { var o = this[i]; this[i] = this[j]; this[j] = o; }
	void UpHeap(int i) { for (int j; i > 0 && _c(this[(j = (i - 1) / 2)], this[i]) > 0; Swap(i, j), i = j) ; }
	void DownHeap(int i)
	{
		for (int j; (j = 2 * i + 1) < Count; i = j)
		{
			if (j + 1 < Count && _c(this[j], this[j + 1]) > 0) j++;
			if (_c(this[i], this[j]) > 0) Swap(i, j); else break;
		}
	}

	public void Push(T v) { Add(v); UpHeap(Count - 1); }
	public T Pop()
	{
		var r = this[0];
		this[0] = this[Count - 1];
		RemoveAt(Count - 1);
		DownHeap(0);
		return r;
	}
}


Measured memory_bytes: 48372
from collections import deque, defaultdict
n, x, y = map(int, input().split())
x -= 1
y -= 1
edges = [[] for _ in range(n)]
edges[x].append(y)
edges[y].append(x)
for i in range(n-1):
    edges[i].append(i+1)
    edges[i+1].append(i)


def bfs(init_v):
    queue = deque([init_v])
    INF = 10**10
    dist = [INF]*n
    dist[init_v] = 0
    while queue:
        v = queue.popleft()
        for v2 in edges[v]:
            if dist[v2] <= dist[v]+1:
                continue
            dist[v2] = dist[v]+1
            dd[dist[v2]] += 1
            queue.append(v2)


dd = defaultdict(int)
for i in range(n):
    bfs(i)

for i in range(1, n):
    print(dd[i]//2)

Measured memory_bytes: 49244
var i,j:longint;
    n,m,num2,num4:longint;
    ch:char;
    num:array['a'..'z']of longint;
    have:longint;
begin
  readln(n,m);
  for i:=1 to n do
  begin
    for j:=1 to m do
    begin
      read(ch);
      inc(num[ch]);
    end;
    readln;
  end;
  if (n mod 2=1)and(m mod 2=1) then num4:=((n-1)div 2) * ((m-1) div 2) else
  if (n mod 2=0)and(m mod 2=1) then num4:=(  n  div 2) * ((m-1) div 2) else
  if (n mod 2=1)and(m mod 2=0) then num4:=((n-1)div 2) * (  m   div 2) else
  if (n mod 2=0)and(m mod 2=0) then num4:=(  n  div 2) * (  m   div 2);
  for i:=97 to 122 do
  if (num[char(i)]>=4)and(num4>0) then
  begin
    have:=num[char(i)]div 4;
    if have>num4 then
    begin
      num4:=0;
      dec(num[char(i)],num4*4);
    end else
    begin
      dec(num4,have);
      dec(num[char(i)],have*4);
    end;
  end;
  if num4>0 then
  begin
    writeln('No');
    exit;
  end;
  if (n mod 2=1)and(m mod 2=1) then num2:=(n-1) div 2+(m-1) div 2 else
  if (n mod 2=0)and(m mod 2=1) then num2:=n div 2 else
  if (n mod 2=1)and(m mod 2=0) then num2:=m div 2 else
  if (n mod 2=0)and(m mod 2=0) then num2:=0;
  for i:=97 to 122 do
  if (num[char(i)]>=2)and(num2>0) then
  begin
    have:=num[char(i)] div 2;
    if have>num2 then num2:=0 else dec(num2,have);
  end;
  if num2>0 then
  begin
    writeln('No');
    exit;
  end;
  writeln('Yes');
end.

Measured memory_bytes: 128
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return int(input())
from collections import defaultdict, Counter
import bisect

sys.setrecursionlimit(10000000)

n = SI()
xy = [(0,0) for _ in range(n)]
div = defaultdict(int)
for i in range(n):
    x, y = LI()
    xy[i] = (x, y)
if n==1:
    print(1)
else:
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            else:
                div["{}_{}".format(xy[i][0] - xy[j][0], xy[i][1]- xy[j][1])] += 1

    max_ = max(div.values())
    print(n - max_)

Measured memory_bytes: 3692
# coding: UTF-8
N = int(input())
A = list(map(int,input().split()))
count = 0
for i in range(N):
  j=i
  minj=i
  while j<= N-1:
    if A[j] < A[minj]:
      minj = j
    j += 1
  if i != minj:
    v=A[i]
    A[i]=A[minj]
    A[minj]=v
    count += 1
    
print(" ".join(map(str,A)))
print(count)

    



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

int main(){
  int n,a=1,b=9,c=7,d=4;
  for(int i=0; i<4; i++){
    cin >> n;
    if(n==a){
      a=-1;
    }else if(n==b){
      b=-1;
    }else if(n==c){
      c=-1;
    }else if(n==d){
      d=-1;
    }else{
      cout << "NO"; return 0;
    }
  }
  cout << "YES";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define INF 1<<25

using namespace std;

double a,b,c,d,e,f,x,y;
double rmat[2][2];

int main()
{
	while( cin >> a >> b >> c >> d >> e >> f, !cin.eof())
	{
		double delta = 1/(a*e - b*d);

		rmat[0][0] = delta*e;
		rmat[0][1] = -delta*b;
		rmat[1][0] = -delta*d;
		rmat[1][1] = delta*a;


		x = c*rmat[0][0] + f*rmat[0][1];
		y = c*rmat[1][0] + f*rmat[1][1];

		printf("%.3lf %.3lf\n",x,y);

	}

	return 0;
}

Measured memory_bytes: 0
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
h=list(map(int,input().split()))
a=[float("inf")]*n
a[0]=0
for i in range(n-1):
    now=h[i]
    a[i+1]=min(abs(now-h[i+1])+a[i],a[i+1])
    if i+2<n:
        a[i+2]=min(abs(now-h[i+2])+a[i],a[i+2])
print(a[-1])

Measured memory_bytes: 52720
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#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 cy cout << "Yes" << endl
#define cn cout << "No" << endl
typedef long long ll;

void Main()
{
	int N; 
  	string S; 
  	cin >> N >> S;
  	
  	// i = 0 to 9 について	
  	// flag[i] = 1 なら S の中に番号 i が存在
  	// place[i] = j なら S[j] が最初に出現する i
  	vector<int> flag1(10,0);
    vector<int> place1(10,0);
	vector<vector<int>> flag2(10,vector<int>(10,0));
  	vector<vector<int>> place2(10,vector<int>(10,0));
	vector<vector<vector<int>>> flag3(10,vector<vector<int>>(10,vector<int>(10,0)));
  	vector<vector<vector<int>>> place3(10,vector<vector<int>>(10,vector<int>(10,0)));
  
  	rep(i1,10){	
  		rep(j,N){
    		if(	S[j]-'0' == i1){
              flag1[i1] = 1;
              place1[i1] = j;
              break;
        	}
    	}
      	if(flag1[i1] == 1){
          	rep(i2,10){
          		rep3(j,place1[i1]+1, N-1){
					if( S[j] - '0' == i2){
              			flag2[i1][i2] = 1;
              			place2[i1][i2] = j;
                      	break;
                    }
            	}
              	if(flag2[i1][i2] == 1){
      				rep(i3,10){
						rep3(j,place2[i1][i2]+1, N-1){
                  			if( S[j] - '0' == i3){
                      			flag3[i1][i2][i3] = 1;
                      			place3[i1][i2][i3] = j;
                      			break;
                    		}
                		}
            		}
      			}
            }
        }
    }
  	
  	int count = 0;
  	rep(i1,10){
      	if(flag1[i1] == 1){
			rep(i2,10){
              	if(flag2[i1][i2] == 1){
                  	rep(i3,10){
                      	if(flag3[i1][i2][i3] == 1){
        					count++;
                          	// cout << "(" << i1 << "," << i2 << "," << i3 << "): " << place3[i1][i2][i3] << ";  "; 
                        }
                    }
                }
            }
        }
    }
	cout << count << endl;  	
  	return;
}

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int b[1010][1010], w[1010][1010];

int imosb(int si, int sj, int ei, int ej) {
	return b[ei-1][ej-1] - b[si-1][ej-1] - b[ei-1][sj-1] + b[si-1][sj-1];
}
int imosw(int si, int sj, int ei, int ej) {
	return w[ei-1][ej-1] - w[si-1][ej-1] - w[ei-1][sj-1] + w[si-1][sj-1];
}

signed main(){
	int N, K;
	cin >> N >> K;
	for(int i = 0; i < N; ++i) {
		int x, y;
		string s;
		cin >> x >> y >> s;
		bool white = s == "W";
		if (x / K % 2) {
			white = !white;
		}
		if (y / K % 2) {
			white = !white;
		}
		x = x % K + 1;
		y = y % K + 1;
		if (white) {
			w[x][y]++;
		} else {
			b[x][y]++;
		}
	}
	for(int i = 1; i <= K; ++i) {
		for(int j = 1; j <= K; ++j) {
			b[i][j] += b[i][j-1] + b[i-1][j] - b[i-1][j-1];
			w[i][j] += w[i][j-1] + w[i-1][j] - w[i-1][j-1];
		}
	}
	int res = 0;
	for(int i = 1; i<=K; ++i) {
		for(int j = 1; j <=K; ++j) {
			res = max(res, imosw(1, 1, i, j) + imosw(i, j, K+1, K+1) +
					imosb(i, 1, K+1, j) + imosb(1, j, i, K+1));
			res = max(res, imosb(1, 1, i, j) + imosb(i, j, K+1, K+1) +
					imosw(i, 1, K+1, j) + imosw(1, j, i, K+1));
		}
	}
	cout << res << endl;
	return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define out(x) cout << (x) << endl

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    int h, w; string s[51];
    cin >> h >> w;
    rep(i, h) cin >> s[i];
    rep(i, h) rep(j, w){
        if(s[i][j] == '.') continue;
        if(i != 0 && s[i-1][j] == '#') continue;
        if(i < h-1 && s[i+1][j] == '#') continue;
        if(j != 0 && s[i][j-1] == '#') continue;
        if(j < w-1 && s[i][j+1] == '#') continue;
        out("No"); return 0;
    }
    out("Yes");
}

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

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 100005;

int n, k;
int a[N];
int dp[N];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	MMS(dp, '?');
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 1; i - j >= 0 && j <= k; j++) {
			dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#include <climits>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;


int H,W;
char A[10][10];


int main (int argc, char const *argv[])
{
  cin >> H >> W;
  for (size_t j = 1; j <= H; j++)
    for (size_t i = 1; i <= W; i++)
      cin >> A[i][j];

  for (size_t j = 1; j <= H; j++)
    for (size_t i = 1; i <= W; i++)
      if(A[i][j]=='#') {
        if(A[i+1][j]=='#'&&A[i][j+1]=='#') {
          cout << "Impossible" << endl;
          return 0;
        } else if (i==W&&j==H) {
          continue;
        } else if(A[i+1][j]!='#'&&A[i][j+1]!='#') {
          cout << "Impossible" << endl;
          return 0;
        } else if(A[i-1][j]!='#'&&A[i][j-1]!='#'&&(i!=1&&j!=1)) {
          cout << "Impossible" << endl;
          return 0;
        }
      }

  cout << "Possible" << endl;
  return 0;
}


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

void solve(long long N, std::vector<long long> s){
    sort(s.begin(), s.end());
    int sum = 0;
    for ( auto it = s.begin(); it != s.end();  ) {
       auto f = *it;
       it++;
       sum += f;
       it++;
    }
    cout << sum << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(2*N);
    for(int i = 0 ; i < 2*N ; i++){
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


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

const long long INF = 1LL << 60;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a - b + 1) << endl;

    return 0;
}


Measured memory_bytes: 3652
from sys import exit
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A = list(map(int, input().split()))

def noexit():
    print('No')
    exit()

def yesexit():
    print('Yes')
    exit()

setA = set(A)
if 0 in setA:
    if len(setA) == 1: yesexit()
    elif len(setA) == 2 and N%3 == 0:
        A.sort()
        listA = list(setA)
        listA.remove(0)
        neww_list = [0] * (N//3) + [listA[0]] * ((N//3)*2)
        neww_list.sort()
        if A == neww_list:
            yesexit()
        else:
            noexit()
    else: noexit()

if N%3 != 0: noexit()
if len(setA) != 3: noexit()

listA = list(setA)
if listA[0]^listA[1] == listA[2]:
    new_list = [listA[0]]*(N//3) + [listA[1]]*(N//3) + [listA[2]]*(N//3)
    A.sort()
    new_list.sort()
    if A == new_list:
        yesexit()
    else:
        noexit()
else: noexit()

Measured memory_bytes: 60784
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=3e5+100;
const ll mod=998244353;
ll n, A, B, k, fac[maxn], invfac[maxn], ans;
ll mul(ll a, ll b)
{
    return (a*b)%mod;
}
ll pwr(ll num, ll pw)
{
    ll res=1;
    while(pw>0)
    {
        if(pw&1)res=mul(res, num);
        num=mul(num, num);
        pw>>=1;
    }
    return res;
}
ll modinv(ll a)
{
    return pwr(a, mod-2);
}
ll C(ll N, ll K)
{
    return mul(mul(fac[N], invfac[K]), invfac[N-K]);
}
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    fac[0]=invfac[0]=1;
    for(ll i=1; i<maxn; i++)
    {
        fac[i]=mul(fac[i-1], i);
        invfac[i]=modinv(fac[i]);
    }
    cin>>n>>A>>B>>k;
    if(k==0)return cout<<"1\n", 0;
    for(ll acnt=0; acnt<=n && acnt*A<=k; acnt++)
    {
        ll lef=k-(acnt*A);
        if(lef%B)continue;
        ll bcnt=lef/B;
        if(bcnt>n)continue;
        ans=(ans+mul(C(n, acnt), C(n, bcnt)))%mod;
    }
    cout<<ans<<"\n";
    return 0;
}


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

#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
#define FIX <<fixed<<setprecision(10)<<
using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;

class Stack{
private:
int m[1000];
int tp;
public:
    Stack(){
    tp=0;
    }
    void push(int x){
        tp++;
        m[tp]=x;
    }
    int pop(){
        tp--;
        return m[tp+1];
    }
}; 
class Queue{
private:
pair<string,int> m[60000];
int head,tail;
public:
    Queue(){
        head=0;
        tail=0;
    }
    bool isEmpty(){
        return head==tail;
    }
    void enqueue(pair<string,int> x){
        m[tail]=x;
        if(tail +1 ==60000)tail=0;
        else tail++;
    }
    pair<string,int> deque(){
        pair<string,int> x=m[head];
        if(head+1==60000)head=0;
        else head++;
        return x;
    } 
};

int main(){
    int n,q,t=0;
    pair<string,int> y;
    cin>>n>>q;
    Queue queue1;
    pair<string,int> Q[n];
    vector<pair<string,int>> answer(0);
    pair<string,int> k;
    REP(i,n)cin>>Q[i].first>>Q[i].second;
    REP(i,n)queue1.enqueue(Q[i]);
    while(!queue1.isEmpty()){
    
        y=queue1.deque();
        REP(i,q){
        t++;
        y.second--;
        if(y.second==0){
            k.first=y.first;
            k.second=t;
            answer.push_back(k);
            break;
        }
        }
        if(y.second>0)queue1.enqueue(y);
    }
    REP(i,n)cout<<answer.at(i).first<<" "<<answer.at(i).second<<endl;
    }


Measured memory_bytes: 8068
#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+1 ;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 INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;


int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int s,w;
    cin >> s >> w;
    if(s<=w) cout << "unsafe" << endl;
    else cout << "safe" << endl;

}
 

Measured memory_bytes: 3636
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int l = s.size();
    int ans = 0;
    for(int i=1;i<l;++i){
        if(s[i]!=s[i-1]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, M; cin >> N >> M;
    vector<char> C(N, ' ');
    REP(i, 0, M) {
        int s; char c; cin >> s >> c; s--;
        if (C[s] == ' '  || C[s] == c) C[s] = c;
        else {
            cout << -1 << endl;
            return 0;
        }
    }

    REP(i, 0, pow(10, N)) {
        string s = to_string(i);
        if (s.size() != N) continue;
        bool ok = true;
        REP(i, 0, s.size()) {
            if (s[i] != C[i] && C[i] != ' ') ok = false;
        }
        if (ok) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
int main() {
  int n,m,x,y,f=0;
  cin >> n >> m;
  vector<P> v;
  for(int i=0; i<n; i++) {
    string s;
    cin >> s;
    for(int j=0; j<m; j++) {
      if(s[j]=='@') x=i,y=j;
      if(s[j]=='o') v.push_back(P(i,j));
    }
  }
  if(m==1||n==1) {
    if(m==1) {
      swap(x,y);
      for(int i=0; i<v.size(); i++) swap(v[i].F,v[i].S);
    }
    v.push_back(P(0,max(n,m)));
    for(int i=0; i<v.size(); i++)if(v[i].S-i<=y&&y<=v[i].S) f=1;
    v[v.size()-1]=P(0,-1);
    sort(v.begin(),v.end());
    for(int i=0; i<v.size(); i++)if(v[i].S<=y&&y<=v[i].S+v.size()-i-1) f=1;
  } else {
    if(v.size()==1&&((!x||x==n-1||x==v[0].F)&&(!y||y==m-1)||(!x||x==n-1)&&y==v[0].S)) f=1;
    if(v.size()==2) {
      if(!x||!y||x==n-1||y==m-1) f=1;
      if(v[0].F==v[1].F)if(y==1||y==v[0].S+1||y==v[1].S-1||y==m-2) f=1;
      if(v[0].S==v[1].S)if(x==1||x==v[0].F+1||x==v[1].F-1||x==n-2) f=1;
    }
    if(v.size()>=3) f=1;
  }
  cout << (f?"yes":"no") << endl;
  return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    set<int> S;
    int a, b, c;
    cin >> a >> b >> c;
    S.insert(a);
    S.insert(b);
    S.insert(c);
    if (S.size() == 2){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
ll n,m,r;
ll a[210][210];
ll dp[10][(1<<10)];
ll lol[210],iinf;
ll compute(int val,int mask){
	//cout<<val<<endl;
	if(dp[val][mask]!=-1){
		return dp[val][mask];
	}
	//cout<<val<<" "<<(mask)<<" "<<dp[val][mask]<<endl;
	ll i,flag=0;
	dp[val][mask]=iinf;
	rep(i,r){
		//cout<<val<<" "<<i<<" "<<(mask)<<" "<<(mask^(1<<i))<<endl;
		if(mask&(1<<i)){
			
			if(i!=val){
				//cout<<"ca";
				flag=1;
				dp[val][mask]=min(dp[val][mask],compute(i,mask^(1<<val))+a[lol[i]][lol[val]]);
				
			}
		}
	}
	//cout<<val<<" "<<mask^(1<<val)<<" "<<dp[val][mask]<<endl;
	if(!flag)
		dp[val][mask]=0;
	return dp[val][mask];
}
int main(){
    std::ios::sync_with_stdio(false);
   	iinf=inf;
   	iinf*=inf;
    ll i,j,x,y,w,k;
    cin>>n>>m>>r;
    rep(i,r){
    	cin>>lol[i];
    	lol[i]--;
    }
    rep(i,n){
    	rep(j,n){
    		a[i][j]=inf;
    	}
    }
    rep(i,m){
    	cin>>x>>y>>w;
    	x--;
    	y--;
    	a[x][y]=min(a[x][y],w);
    	a[y][x]=a[x][y];
    }
    rep(i,n){
    	a[x][x]=0;
    }
    rep(i,n){
    	rep(j,n){
    		rep(k,n){
    			a[j][k]=min(a[j][k],a[j][i]+a[i][k]);
    		}
    	}
    }
    // rep(i,n){
    // 	rep(j,n){
    // 		cout<<a[i][j]<<" ";
    // 	}
    // 	cout<<endl;
    // }
    rep(i,(1<<r)+10){
    	rep(j,r){
    		dp[j][i]=-1;
	   	}
    }
    ll mini=iinf;
    rep(i,r){
    	mini=min(mini,compute(i,(1<<r)-1));
    	//cout<<dp[i][(1<<r)-1]<<endl;
    }
    cout<<mini<<endl;
    return 0;  
    
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
int main(){
  ll n,m,sum=0;cin>>n>>m;
  priority_queue<int,vi,greater<int>> q;
  rep(i,n){
    int a;cin>>a;sum+=a;
    q.push(a);
  }
  vector<P> v(m);
  rep(i,m){
    int a,b;cin>>a>>b;
    v[i]=make_pair(b,a);
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  rep(i,m){
    int a=v[i].first,b=v[i].second;
    rep(j,b){
    if(q.empty())break;
    if(q.top()>=a)break;
    sum+=a-q.top();
    q.pop();
    }
    if(q.top()>=a)break;
    if(q.empty())break;
  }
  cout<<sum<<endl;
}


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

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}


// std::vector Declaration
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...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int n, k; cin >> n >> k;
   cout << n - k + 1 << endl;

   return 0;
}


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

ll N, A, B;
const int MAX = 1.0e5 + 100;
ll h[MAX];

int main() {
    cin >> N >> A >> B;
    for (int i = 0; i < N; i++) cin >> h[i];

    ll h_max = 0;
    for (int i = 0; i < N; i++) {
        h_max = max(h[i], h_max);
    }

    ll left = 0, right = h_max;
    while (left < right) {
        ll mid = (right + left) / 2;

        ll attack_cnt = 0;
        for (int i = 0; i < N; i++) {
            if (h[i] - mid * B > 0) {
                attack_cnt += (h[i] - mid*B + A - B - 1) / (A - B);
            }
            if (mid < attack_cnt) break;
        }

        if (mid < attack_cnt) left = mid + 1;
        else right = mid;
    }

    cout << right << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

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

using namespace std;

int main() {
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    ll area = w * h;
    double half_area = area / 2.0;
    int mul = 0;
    if(x * 2 == w && y * 2 == h){
        mul = 1;
    }
    cout << half_area << " " << mul << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 30;
static const ll MOD = 1e9 + 7;
static const int MAX_N = 510;
static const int MAX_C = 30;
int D[MAX_C][MAX_C];
int c[MAX_N][MAX_N];
int cost[3][MAX_C]; // cost[i][j] := x+yを3で割ったあまりがiの座標(x,y)をj色にしたときのコストの和

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N, C;
    cin >> N >> C;
    rep(i, C)
    {
        rep(j, C)
        {
            cin >> D[i][j]; // i->jにするのに必要なコスト
        }
    }
    // vector<vector<int>> c(N, vector<int>(N));
    rep(i, N)
    {
        rep(j, N)
        {
            cin >> c[i][j]; // 現在の(i,j)の色
            --c[i][j];
        }
    }

    // (i, j)の余りに応じて全てをc0に変えたときの総コスト
    rep(c0, C)
    {
        rep(i, N)
        {
            rep(j, N)
            {
                cost[(i + j) % 3][c0] += D[c[i][j]][c0];
            }
        }
    }

    int res = INF;
    rep(c0, C)
    {
        rep(c1, C)
        {
            rep(c2, C)
            {
                if (c0 == c1 || c0 == c2 || c1 == c2) {
                    continue;
                }
                int tmp = (cost[0][c0] + cost[1][c1] + cost[2][c2]);
                res = min(res, tmp);
            }
        }
    }
    cout << res << endl;

    return 0;
}

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

int main(){
    string s, t;
    cin >> s;
    cin >> t;
    int count = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == t[i]) count += 1;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3636
def main():
	n=int(input())
	s,t = list(map(str,input().split()))
	new=s[0]
	for i in range(0,n):
		if i == 0:
			new =str(s[i]+t[i])
		else:
			new = str(new+s[i]+t[i])
	print(new)
main()

Measured memory_bytes: 3060
Public Class Program
  Shared Sub Main()
    Const M As Long = 1000000007
    Dim xy() As Long = Array.ConvertAll(Of String, Long)(Console.ReadLine().Split(" "), AddressOf Long.Parse)
    Dim x As Long = xy(0)
    Dim y As Long = xy(1)
    Dim ans As Long = 0
    ' - 1回の移動で x 座標 + y 座標の値は 3 増えます。よって X + Y が 3 の倍数でない時、答えは 0 です。 '
    ' - (1, 2) の移動回数を n 、(2, 1) の移動回数を m とすると、 n + 2m = X, 2n + m = Y の連立方程式が得られます。 '
    '   これより n = (2Y - X) / 3, m = (2X - Y) / 3 となります。移動回数 n, m は正の整数のため、2Y - X < 0, 2X - Y < 0 の時、答えは 0 です。 '
    If (x + y) Mod 3 = 0 AndAlso 2 * y - x >= 0 AndAlso 2 * x - y >= 0 Then
      ' 移動回数の合計は n + m = (X + Y) / 3 です。このうち (1, 2) の移動回数 n の組み合わせは (n + m)Cn になります。 '
      ans = ModNcr((x + y) / 3, (2 * y - x) / 3, M)
    End If
    Console.WriteLine(ans.ToString())
  End Sub
  
  ' 階乗 n! を m で割った余りを求めます。 '
  Shared Function ModFactorial(n As Long, m As Long) As Long
    Dim result As Long = 1
    For i As Long = 1 To n
      result = (result * i) Mod m
    Next
    Return result
  End Function
  
  ' 累乗 x^y を m で割った余りを求めます。 '
  Shared Function ModPow(x As Long, y As Long, m As Long) As Long
    If y = 0 Then Return 1
    If y Mod 2 = 0 Then
      Dim d As Long = ModPow(x, y / 2, m)
      Return (d * d) Mod m
    Else
      Return (x * ModPow(x, y - 1, m)) Mod m
    End If
  End Function
  
  ' 逆元 (n!)^-1 を m で割った余りを求めます。 '
  ' フェルマーの小定理より (n!)^-1 ≡ (n!)^m-2 となります。 '
  Shared Function ModInverse(n As Long, m As Long) As Long
    Return ModPow(ModFactorial(n, m), m - 2, m) Mod m
  End Function
  
  ' 組み合わせ nCr = n! * (r!)^-1 * ((n - r)!)^-1 を m で割った余りを求めます。 '
  Shared Function ModNcr(n As Long, r As Long, m As Long) As Long
    If n < r Then Return 0
    If n = r Then Return 1
    Return ((ModFactorial(n, m) * ModInverse(r, m)) Mod m) * ModInverse(n - r, m) Mod m
  End Function
End Class

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define int long long
#define INF (int)1e9+6
using namespace std;

int g[333][333], sum ,
 dist[333][333],
    p[333][333],
		a[333][333];


main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
            dist[i][j] = INF;
				dist[i][i] = 0;
    }

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++){
            cin >> g[i][j];	
            if(g[i][j])dist[i][j] = g[i][j];
        }
        
       
    for(int k = 1; k <= n; k++)
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= n; j++)
            {
                int nice = dist[i][k] + dist[k][j];
                if(nice < dist[i][j]){cout << "-1";return  0;}
                
                if(nice == dist[i][j] && (i != j && j != k && k != i) )
                {
                a[i][j] = 1;
                }
                
            }

	


    
    for(int i = 1; i <= n; i++)
    {
			for(int j = 1; j <= n; j++)
			{
					if(dist[i][j] != INF)
			{
						sum += dist[i][j] , dist[j][i] = 0;
					if(a[i][j] == 1)
						sum -= dist[i][j];
				
			}
			
			}
    }
    
 
         cout << sum << endl;
            
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, k, q, a;
    cin >> n >> k >> q;
    vector<ll> acum(n+2, 0);
    while (q--) {
        cin >> a;
        acum[0]--;
        acum[a]++;
        acum[a+1]--;
    }
    fore(i,1,n+1) {
        acum[i] += acum[i-1];
        if (acum[i]+k > 0) cout << "Yes\n";
        else cout << "No\n";
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,R; cin>>N>>R;

    cout<< ( N>=10 ? R : R+100*(10-N) )<<"\n";

}

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


Measured memory_bytes: 256