akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int h, w;
	char a[100][100];
	cin >> h >> w;
	REP(i, h){
		REP(j, w) cin >> a[i][j];
	}

	vector<int> xh;
	vector<int> xw;

	REP(i, h){
		bool y = true;
		REP(j, w){
			if(a[i][j] != '.') y = false;
		}
		if(y) xh.pb(i);
	}
	REP(j, w){
		bool y = true;
		REP(i, h){
			if(a[i][j] != '.') y = false;
		}
		if(y) xw.pb(j);
	}

	REP(i, h){
		REP(p, xh.size()){
			if(i == xh[p]){
				goto failh;
			}
		}
		REP(j, w){
			REP(q, xw.size()){
				if(j == xw[q]) goto failw;
			}
			cout << a[i][j];
			failw:
			;
		}
		cout << endl;
		failh:
		;
	}
	rtn 0;
}

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




int main(void){
int n,a[10000];
long long int sum=0;
int max=-9999999;
int min=99999999;
scanf("%d",&n);

for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
}

for(int i=0;i<n;i++){
    sum=sum+a[i];
    if(a[i]>=max){max=a[i];}
    if(a[i]<=min){min=a[i];}
}
printf("%d %d %lld\n",min,max,sum);



return 0;
}



Measured memory_bytes: 2120
n , m , k = map(int, input().split())

friend = [[] for i in range(n)]
block = [[] for i in range(n)]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    a-=1
    b-=1
    uf.union(a,b)
    friend[a].append(b)
    friend[b].append(a)

for i in range(k):
    c, d = map(int, input().split())
    c-=1
    d-=1
    block[c].append(d)
    block[d].append(c)

ans=[]

for i in range(n):
    ans1 = uf.size(i)-1
    for j in block[i]:
        if uf.same(i,j):
            ans1-=1
    ans1 -= len(friend[i])
    ans.append(str(ans1))

print(' '.join(ans))


Measured memory_bytes: 51816
#include <stdio.h>
#include <string.h>

int main(){
	int n;
	scanf("%d", &n);
	
	char s[n + 1];
	scanf("%s", &s);
	
	if(n % 2 != 0){
		puts("No");
	}
	else{
		int flag = 1;
		for(int i = 0; i < n / 2; i++){
			if(s[i] != s[i + n / 2]){
				flag = 0;
			}
		}
		if(flag){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1644
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1000000007


vector<int> result((1 << 16), -1);

int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	int d[16];
	vector<int> isdark(101, -1);
	for(int i = 0; i < m; i++){
		cin >> d[i];
		d[i]--;
		isdark[d[i]] = i;
	}
	int v[101][101];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < k; j++){
			cin >> v[i][j];
			v[i][j]--;
		}
	}
	result[(1 << m) - 1] = 0;
	queue<int> qu;
	qu.push((1 << m) - 1);
	while(!qu.empty()){
		int now = qu.front();
		qu.pop();
		for(int j = 0; j < k; j++){
			// 状態nowから、j番目の道を選んだとする
			int next = 0;
			for(int l = 0; l < m; l++){
				// l番目のくらい部屋にいる人が次どこに行くかを考える
				if((now & (1 << l)) == 0) continue;
				int nextroom = v[d[l]][j];
				if(isdark[nextroom] >= 0) next |= (1 << isdark[nextroom]);
			}
			if(result[next] == -1){
				result[next] = result[now] + 1;
				qu.push(next);
			}
		}
	}
	cout << result[0] << endl;
	return 0;
}


Measured memory_bytes: 3440
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stdio.h>
#include<queue>
#define pb push_back
#define ppb pop_back
#define nd second
#define st first
#define ll long long
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
int a,b,x;
int main()
{
  cin>>a>>b>>x;
  if(a<=x && a+b>=x)
    puts("YES");
  else
    puts("NO");
  return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , k , m;
int freq[N];
int ok[N];

void solve(int testCase){

    scanf("%d %d" , &n ,&m);

    int ac = 0 , pen = 0;
    for(int i = 0 ; i < m ; i ++){
            int p; scanf("%d" , &p);
            char s[4]; scanf("%s" , s);

            if(s[0] == 'A'){
                     if(ok[p])continue;
                     pen += freq[p];
                     ac ++;
                     ok[p] = 1;
            }
            else {
                    freq[p] ++;
            }
    }

    printf("%d %d\n" , ac , pen);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 1024
#include <vector>
#include <iostream>
#include <algorithm>
#define INF (1LL << 60)
using namespace std;
int n, u[2], mode, tar; long long d, x[30], y[30], ret, seg[33554432], val[14348907]; pair<long long, long long> t[2][14348907];
inline void rec(int pos, long long a, long long b) {
	if (pos == tar) {
		t[mode][u[mode]++] = make_pair(a, b); return;
	}
	rec(pos + 1, a + x[pos], b + y[pos]);
	rec(pos + 1, a - x[pos], b - y[pos]);
	rec(pos + 1, a, b);
}
inline long long query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) return INF;
	if (a <= l && r <= b) return seg[k];
	long long lch = query(a, b, k << 1, l, (l + r) >> 1);
	long long rch = query(a, b, (k << 1) + 1, (l + r) >> 1, r);
	return min(lch, rch);
}
int main() {
	scanf("%d%lld", &n, &d);
	for (int i = 0; i < n; i++) scanf("%lld%lld", &x[i], &y[i]);
	mode = 0; tar = n / 2; rec(0, 0, 0);
	mode = 1; tar = n; rec(n / 2, 0, 0);
	sort(t[1], t[1] + u[1]);
	for (int i = 0; i < u[1]; i++) val[i] = t[1][i].first;
	for (int i = 0; i < u[1]; i++) seg[i + 16777216] = t[1][i].second;
	for (int i = u[1]; i < 16777216; i++) seg[i + 16777216] = INF;
	for (int i = 16777215; i >= 1; i--) seg[i] = min(seg[2 * i], seg[2 * i + 1]);
	for (int i = 0; i < u[0]; i++) {
		if (t[0][i].second > 0) continue;
		int pl = lower_bound(val, val + u[1], -t[0][i].first - d) - val;
		int pr = upper_bound(val, val + u[1], -t[0][i].first + d) - val;
		long long res = query(pl, pr, 1, 0, 16777216);
		ret = max(ret, -t[0][i].second - res);
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 825860
def array_integer(a)
	0.upto(a.count) {|x|
		a[x] = a[x].to_i
	}
	return a
end

n = STDIN.gets
n = n.to_i

a = array_integer(STDIN.gets.split(" "))

(n-1).downto(0) {|i|
	print a[i]
	if i != 0 then
		print " "
	else
		print "\n"
	end
}



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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> hp(n,0);
    rep(i,n) cin>>hp[i];
    sort(hp.begin(),hp.end());
    ll ans=0;
    rep(i,n-k) ans+=hp[i];
    cout<< ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

template <typename T> using duo = std::pair<T, T>;
template <typename T> using vec = std::vector<T>;
using ll = long long;
using pii = duo<int>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T)vec<std::pair<T,int>>zipi(const vec<T>&x,int s=0){int N=x.size();vec<std::pair<T,int>>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  string S;
  for (char c : in<string>()) {
    if (c == 'B') {
      if (S.size()) S.pop_back();
    } else {
      S.push_back(c);
    }
  }
  pr(S);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int N;
	vector<int> As;
	vector<int> Bs;
	vector<int> Cs;

	cin >> N;

	int a;
	for (int ni = 0; ni < N; ni++){
		cin >> a;
		As.push_back(a-1);
	}

	int b;
	for (int ni = 0; ni < N; ni++){
		cin >> b;
		Bs.push_back(b);
	}

	int c;
	for (int ni = 0; ni < N - 1; ni++){
		cin >> c;
		Cs.push_back(c);
	}

	int ans = 0;
	for (int ni = 0; ni < N; ni++){
		ans += Bs[As[ni]];
		if (ni > 0 && As[ni-1] == As[ni] - 1){
			ans += Cs[As[ni-1]];
		}
	}


	printf("%d",ans);

	return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

S = "abcdefghijkl"
N = 0
def rec(s):
    if len(s) == N:
        print(''.join(s))
        return
    for i in range(len(set(s))+1):
        s.append(S[i])
        rec(s)
        s.pop()
    

def main():
    global N
    N = int(input().strip())
    rec([])

if __name__ == '__main__':
    main()


Measured memory_bytes: 58328
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (long long i = a; i < n; i++)
#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define debug(a) cout << a << endl
#define pr(a) printf("%d ",a)
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define ull unsigned long long
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf=0x3f3f3f3f;
const int MAXN = 1e5 + 10;
const int mode=1e9+7;
int H,W;
char mp[1005][1005];
int dp[1005][1005];
int main()
{
	IO;
	cin>>H>>W;
	for(int i=0;i<H;++i)
		for(int j=0;j<W;++j)
		{
			cin>>mp[i][j];
		}
	dp[0][0]=1;
	for(int i=0;i<H;++i)
		for(int j=0;j<W;++j)
		{
			if(i-1>=0&&mp[i-1][j]=='.')
			dp[i][j]=(dp[i][j]+dp[i-1][j])%mode;
			if(j-1>=0&&mp[i][j-1]=='.')
			dp[i][j]=(dp[i][j]+dp[i][j-1])%mode;
		}
	cout<<dp[H-1][W-1]<<endl;
 } 


Measured memory_bytes: 5248
Module Module1

    Sub Main()

        'Dim S As String = Console.ReadLine()
        'Dim L As New List(Of String)({"Sunny", "Cloudy", "Rainy"})
        'Dim i As Integer

        'L.Add("Sunny")

        'For i = 0 To L.Count - 2
        '    If L(i) = S Then
        '        Console.WriteLine(L(i + 1))
        '        Exit For
        '    End If
        'Next

        ''Console.ReadLine()

        Dim s As String = Console.ReadLine()
        Dim l(3) As String
        Dim i As Integer

        l(0) = "Sunny"
        l(1) = "Cloudy"
        l(2) = "Rainy"
        l(3) = "Sunny"

        For i = 0 To 2
            If l(i) = s Then
                Console.WriteLine(l(i + 1))
                Exit For
            End If
        Next

        'Console.ReadLine()

    End Sub

End Module



Measured memory_bytes: 20432
#include<stdio.h>

int n;
int a[1000];
int b[1000];
int i;
int j;

int main(void){
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		}
	for(i=n;i>0;i--){
		printf("%d",a[i]);
		if(i-1 != 0){
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 608
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <time.h>
#include <stdio.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) a.begin(), a.end()

template<typename T>
void vdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		if (i == size - 1) {
			cout << da[i] << endl;
		}
		else {
			cout << da[i] << ' ';
		}
	}
}
template<typename T>
void vvdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		vdeb(da[i]);
	}
}

int main(){
	int n,k,s;
	cin >> n >> k >> s;
	vector<int> ans(n);
	rip(i,k,0) ans[i] = s;
	if(s == 1000000000){
		rip(i,n,k) ans[i] = 1;
	}
	else{
		rip(i,n,k) ans[i] = s+1;
	}
	vdeb(ans);
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<utility>
#include<deque>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<numeric>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

string dream = "dream";
string erase = "erase";
string er = "er";
string s;
int n = 0;

int main(void) {
	cin >> s;
	n = s.size();
	string ret = "YES";

	for (int i = 0; i < n; i += 5) {
		string tmp = s.substr(i, 5);
		if (tmp == dream) {
			if (s.substr(i + 5, 5) == erase)
				continue;
			else if (s.substr(i + 5, 2) == er)
				i += 2;
		}
		else if (tmp == erase) {
			if (s.substr(i + 5, 5) == erase)
				continue;
			else if (s.substr(i + 4, 2) == er)
				i += 1;
		}
		else {
			ret = "NO";
			break;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0) {
				break;
			}

			for(int i = 0; i < H; i++) {
				if(i % 2 == 0) {
					for(int j = 0; j < W; j++) {
						if(j % 2 == 0) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
				} else {
					for(int j = 0; j < W; j++) {
						if(j % 2 == 0) {
							System.out.print(".");
						} else {
							System.out.print("#");
						}
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 35228
#include<iostream>
#include<string>
using namespace std;
int main(){

  string A,B,C;
  cin>>A>>B>>C;
  if(A[A.length()-1]!=B[0]){
  
    cout<<"NO";
    return 0;
  }
  if(B[B.length()-1]!=C[0]){
  
    cout<<"NO";
    return 0;
  }
  cout<<"YES";
  return 0;
}

Measured memory_bytes: 3612
from sys import stdin

S = stdin.readline().rstrip()

cond1 = S[0] == 'A'
cond2 = S.count('C', 2, -1) == 1
cond3 = S.replace('A', '').replace('C', '').islower()

if cond1 and cond2 and cond3:
    print('AC')
else:
    print('WA')


Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
	char s[100];
	int i=0,j=0;
	scanf("%s",s);
	while(1){
		if(s[i]=='\0'){
			printf("Yes\n");
			break;
		}
		if(s[i]=='U'||s[i]=='D'){
			j++;
		}
		if(i%2==0){
			if(s[i]=='R'){
				j++;
			}
		}
		if(i%2==1){
			if(s[i]=='L'){
				j++;
			}
		}
		i++;
		if(i!=j){
			printf("No\n");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1 << 30;
ll ans = 0;
ll ch[31][100100]={};
ll chh[31][100100]={};
ll chhh[100100]={};

int main()
{
ll n,c;
cin >> n>>c;

rep(i, n)
{
    ll s,t,c;
    cin >> s>>t>>c;
    if(ch[c][s]==0)ch[c][s]=1;
    else ch[c][s]=0;
    if(ch[c][t]==0)ch[c][t]=-1;
    else ch[c][t]=0;
}
rep1(i,c+1)rep1(j,100100){
    if(ch[i][j]==1){
        if(ch[i][j-1]!=-1){
            ch[i][j]=0;
            ch[i][j-1]=1;
        }
        else {
            ch[i][j]=0;
            ch[i][j-1]=0;
        }
    }
}
rep1(i,c+1)rep(j,100100){
    if(j==0) chh[i][j]=ch[i][j];
    else chh[i][j]=ch[i][j]+chh[i][j-1];
}
rep1(i,c+1)rep1(j,100100){
    chhh[j]+=chh[i][j];
}
rep1(j,100100){
    if(ans<chhh[j])ans=chhh[j];
}
/* for (int i = 0; i < 20; ++i) {
    cout << chh[1][i] << " ";
}cout  << endl;
for (int i = 0; i < 20; ++i) {
    cout << chh[2][i] << " ";
}cout  << endl;
 */
cout << ans << endl;

return 0;
}

Measured memory_bytes: 48768
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> lpair;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct Integer{
public:

    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;} //最小公倍数

    bool isPrime(ll x){
        if(x < 2) return false;
        if(x == 2) return true;
        if(x % 2 == 0) return false;
        for(ll i = 3;i <= sqrt(x) + 1;i += 2) if(x % i == 0) return false;
        return true;
    }

    bool isSquare(ll x){
        ll lv = 0, rv = x+1;
        while(rv - lv > 1){
            ll mid = (lv + rv) / 2;
            if(mid * mid >= x){
                rv = mid;
            }else{
                lv = mid;
            }
        }
        if(rv * rv == x){
            return true;
        }else{
            return false;
        }
    }

    vector<ll> divisor(ll M){ //約数の全列挙
        vector<ll> dd;
        for(ll i = 1; i * i <= M; i++){
            if(M % i == 0){
                dd.push_back(i);
                if(i * i != M){
                    dd.push_back(M / i);
                }
            }
        }
        sort(dd.begin(), dd.end());
        return dd;
    }

    vector<ll> factor(ll M){ //素因数分解
        vector<ll> dd;
        if(M == 1){
            dd.push_back(1);
            return dd;
        }
        for(ll i = 2; i*i <= M; i++){
            while(M % i == 0){
                dd.push_back(i);
                M /= i;
            }
        }
        if(M != 1) dd.push_back(M);
        sort(dd.begin(), dd.end());
        return dd;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    Integer it;
    vector<ll> dd = it.divisor(N);
    ll ans = INF;
    for(auto &e: dd){
        ans = min(ans, (e-1) + (N/e-1));
    }
    print(ans);


}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-

import bisect

n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))
print(ans)


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

int main(int argc, char const *argv[]) {
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(b*d, max(a*c, max(a*d, b*c))) << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int n,m;
  cin >> n >> m;
  ll k = 0;
  REP(i,m){
    ll x;cin >> x;
    k += x;
  }
  k <= n ? cout << n-k << endl : cout << -1 << endl;

  


  

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

template <class T> T permutation(ll n, ll k) { T f(1); for (ll i=0; i<k; ++i, --n) f *= n; return f; }
template <class T> T factorial(ll n) { return permutation<T>(n,n); }
template <class T> T binomial(ll n, ll k) { return permutation<T>(n,k) /= factorial<T>(k); }

template <ll Mod>
class modint {
    public:
    ll n=0;
    modint(){}
    modint(ll n):n(n){ clamp(); }
    modint& operator = (modint const& a) = default;
    modint& operator = (int a) { n = a; clamp(); return *this; }
    modint operator - () { modint t = *this; t.n = -t.n; t.clamp(); return t; }
    modint& operator *= (modint const& a) { n *= a.n; clamp(); return *this; }
    modint& operator *= (ll a) { n *= a; clamp(); return *this; }
    modint& operator /= (modint const& a) { *this *= a.inv(); return *this; }
    modint& operator += (modint const& a) { n += a.n; if (n >= Mod) n -= Mod; return *this; }
    modint& operator -= (modint const& a) { n -= a.n; if (n < 0) n += Mod; return *this; }
    modint& operator %= (modint const& a) { n %= a.n; clamp(); return *this; }
    friend modint operator * (modint a, modint b) { modint t(a); t.n *= b.n; t.clamp(); return t; }
    friend modint operator + (modint a, modint b) { modint t(a); t.n += b.n; t.clamp(); return t; }
    friend modint operator - (modint a, modint b) { modint t(a); t.n -= b.n; t.clamp(); return t; }
    friend ostream& operator << (ostream& os, modint const& a) { os << a.n; return os; }
    friend bool operator == (modint const& a, int b) { return a.n == b; }
    void clamp() { n %= Mod; if (n < 0) n += Mod; }
    modint inv() const { return this->pow(Mod-2); }
    ll get() { return n; }
    modint pow(ll p) const {
        ll a=1, e=n;
        while (p > 0) {
            if (p&1) { a *= e; a %= Mod; }
            e *= e; e %= Mod; p >>= 1;
        }
        return modint(a);
    }
};

const ll Mod = (ll)1e9+7;
using mint = modint<Mod>;
int main() {
    fastio;
    ll N;
    cin >> N;
    mint ans;
    mint all = mint(10).pow(N);
    ans = all;
    ans -= mint(9).pow(N);
    ans *= 2;
    ans -= all;
    ans += mint(8).pow(N);
    cout << ans.get() << endl;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    int N,K,h[100000],a;
	cin >> N >> K;
	for(int i=1;i<=N;i++){cin >> h[i];}
a=0;
for(int i=1;i<=N;i++){if(h[i]>=K){a=a+1;}}
cout << a << endl;

return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    int ans=0;
    for(int i=0;i<n-2;i++){
        if((v[i]>v[i+1]&&v[i+1]>v[i+2]) || (v[i]<v[i+1]&&v[i+1]<v[i+2]))ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//   PIGMEISTER™   //

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define MAX 100005

int main()
{
    jaldi;
    
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = min(k, a);
    k -= (a+b);
    if (k > 0) {
        ans -= k;
    }
    cout << ans << '\n';
    
    return 0;
}


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

int main(){
  long N,M;
  cin>>N>>M;
  string a,b;
  cin>>a>>b;
  string s;
  long L;
  bool flag=true;
  int gcd=0;
  int S=min(N,M);
  for (int g=1;g<=S;g++){
    if (N%g==0&&M%g==0){
      gcd=g;
    }
  }
  long n=N/gcd;
  long m=M/gcd;
  L=n*m*gcd;
  long k,l;
  k=m;
  l=n;
  for (int i=0;i<gcd;i++){
    if (a[l*i]==b[k*i]){
      flag=flag&&true;
    }
    else{
      flag=flag&&false;
    }
  }
  if (flag==true){
    cout<<L;
  }
  else {
    cout<<-1;
  }
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int ans[100010];
vector<pair<int, int>> to[100000];

void dfs(int v, int p, int c){
  int color = 1;
  for(auto u: to[v]){
    int x = u.first; int y = u.second;
    if(x==p) continue;
    if(c == color) color++;
    ans[y] = color;
    dfs(x, v, color);
    color++;
  }
}
    

int main(){
  int N; cin >> N;
  rep(i, N-1){
    int a, b; cin >> a >> b; a--; b--;
    to[a].push_back({b, i});
    to[b].push_back({a, i});
  }
  dfs(0, -1, 0);
  int kind = 0;
  rep(i, N){
    kind = max(kind, (int)(to[i].size()));
  }
  cout << kind << endl;
  rep(i, N-1){
    cout << ans[i] << endl;
  }
 
}

Measured memory_bytes: 9344
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long[][] dp= new long[11][1010];
		int n, s;
		dp[0][0]=1;
		for(int i=0; i<=100; i++) {
			for(int j=9; j>=0; j--) {
				for(int k=0; k<=1000-i; k++) {
					dp[j+1][k+i]+=dp[j][k];
				}
			}
		}
		while(sc.hasNext()) {
			n=sc.nextInt();
			s=sc.nextInt();
			if(n==0 && s==0)	break;
			System.out.println(dp[n][s]);
		}
        
	}
}


Measured memory_bytes: 27204
#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define diff(a,b) (a>b?a-b:b-a)
const int N=1e6+5;
void pairsort(int a[], int b[], int n){
    pair<int, int> pairt[n];
    for (int i = 0; i < n; i++) 
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
    sort(pairt, pairt + n);
    for (int i = 0; i < n; i++) 
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
int isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
long long C(int n, int r) {
    if(r>n-r) 
        r=n-r;
    long long ans=1;
    for(int i=1;i<=r;i++){
        ans*=n-r+i;
        ans/=i;
    }
    return ans;
}
int mod = 1e9+7;
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
int n,m;
int32_t main()
{
    IOS;
    cin>>n>>m;
    cout<<(n*(n-1))/2+(m*(m-1))/2;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int d;
    cin >> d;
    if (d == 25)
        cout << "Christmas";
    else if (d == 24)
        cout << "Christmas Eve";
    else if (d == 23)
        cout << "Christmas Eve Eve";
    else
        cout << "Christmas Eve Eve Eve";
}

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

int main(){
  ll N, K;
  cin >> N >> K;
  ll ans = 0;
  for(ll a = 1; a <= N; a++){
    ll mod = a % K;
    if(2*mod % K) continue;
    ll nb = (N + mod)/K;
    ll nc;
    if(mod){
      nc = (N - mod)/K + 1;
    } else {
      nc = (N - mod)/K;
    }
    ans += nb*nc;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string S,T;
int main()
{
	cin >> S;
	cin >> T;
	int ans = 0;
	for (int i = 0; i <= 2; i++)
	{
		if (S[i] == T[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
readline = sys.stdin.readline #文字列入力のときは注意

n,q = [int(i) for i in readline().split()]
p = []
x = []
arr = [[] for i in range(n)]
ans = [0 for i in range(n)]
omosa = [0 for i in range(n)]

for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    arr[a-1].append(b-1)
    arr[b-1].append(a-1)
for i in range(q):
    tmpp,tmpx = [int(i) for i in readline().split()]
#    p.append(tmpp-1)
#    x.append(tmpx)
    omosa[tmpp-1] += tmpx

#for i in range(q):
#    omosa[p[i]] +=x[i]

def dfs(start, oya, weight): #weightは自分より上のノードの重さの和
    ans[start] = weight + omosa[start]
    for child in arr[start]:
        if child != oya:
            dfs(child, start, ans[start])
 
dfs(0,-1,0)
print(*ans)


Measured memory_bytes: 236928
#include <stdio.h>

int main(void){
    
    int Mt[10], i, j, tmp;
    for(i=0; i<10; i++) {
        scanf("%d", &Mt[i]);
    }
    //高い順にソート
    for(i=0; i<10; i++) {
        for(j=i+1; j<10; j++) {
            if(Mt[i] < Mt[j]){
                tmp = Mt[i];
                Mt[i] = Mt[j];
                Mt[j] = tmp;
            }
        }
    }
    printf("%d\n%d\n%d\n", Mt[0], Mt[1], Mt[2]);
    return 0;
}


Measured memory_bytes: 2088
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <climits>
#include <set>

//#define int long long
typedef long long ll;
//using ll = long long;
//using R = double;

//#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define MOD 1000000007

const int INF = int(1e9);

using namespace std;

typedef vector<int> V;
typedef vector<V> VV;

//const int DAT_SIZE = (1 << 18) - 1;
const int MAX_SIZE = 1 << 17;
//const int MAX_SIZE = 4;

int N, Q;

ll data[2 * MAX_SIZE - 1], datb[2 * MAX_SIZE - 1];

void add(int a, int b, int x, int k, int l, int r)
{
    if (a <= l && r <= b) {
        data[k] += x;
    }
    else if (l < b && a < r) {
        datb[k] += (min(b, r) - max(a, l)) * x;
        add(a, b, x, k * 2 + 1, l, (l + r) / 2);
        add(a, b, x, k * 2 + 2, (l + r) / 2, r);
    }
}

ll sum(int a, int b, int k, int l, int r)
{
    if (b <= l || r <= a) {
        //printf("a = %d, b = %d, k = %d, l = %d, r = %d, ret = 0\n", a, b, k, l, r);
        return 0;
    }
    else if (a <= l && r <= b) {
        //printf("a = %d, b = %d, k = %d, l = %d, r = %d, ret = %d\n", a, b, k, l, r, data[k] * (r - l) * datb[k]);
        //return data[k] * (r - l) * datb[k];
        return data[k] * (r - l) + datb[k];
    }
    else {
        ll res = (min(b, r) - max(a, l)) * data[k];
        res += sum(a, b, k * 2 + 1, l, (l + r) / 2);
        res += sum(a, b, k * 2 + 2, (l + r) / 2, r);
        //printf("a = %d, b = %d, k = %d, l = %d, r = %d, ret = %d\n", a, b, k, l, r, res);
        return res;
    }
}

signed main()
{
    cin >> N >> Q;

    //int n_ = 1;
    //while (n_ < N) n_ *= 2;
    N = MAX_SIZE;
    int com, s, t, x;
    REP(i,Q) {
        cin >> com;
        if (com == 0) {
            cin >> s >> t >> x;
            //printf("s = %d, t = %d, x = %d\n", s, t, x);
            s--; t--;
            add(s, t + 1, x, 0, 0, N);
        } else {
            cin >> s;
            //printf("s = %d\n", s);
            s--;
            cout << sum(s, s + 1, 0, 0, N) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 5460
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
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 input()

from collections import defaultdict, deque

def main():
    N, M = LI()
    edges = defaultdict(set)
    for _ in range(M):
        a, b = LI_()
        edges[a].add(b)
        edges[b].add(a)
    quads = set()
    sixes = 0
    for i, e in edges.items():
        c = len(e)
        if c % 2 == 1:
            return False
        if c >= 6:
            sixes += 1
        if c == 4:
            quads.add(i)
    if sixes > 0:
        return True
    if len(quads) > 2:
        return True
    if len(quads) < 2:
        return False
    s = quads.pop()
    t = quads.pop()
    for v0 in edges[s]:
        q = deque([v0])
        visited = {s, t}
        while len(q) > 0:
            v = q.pop()
            for to in edges[v]:
                if v != v0 and to == s:
                    return True
                if to not in visited:
                    q.append(to)
                    visited.add(to)

    return False

print('Yes' if main() else 'No')

Measured memory_bytes: 40804
#include<cstdio>
using namespace std;
const int N = 1E5+5;
int n,h[N],dp[N];
inline int min(int a,int b) {return a>b?b:a;}
int abs(int x) {
	if(x<0)return -x;
	return x;
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",h+i);
	dp[0]=0,dp[1]=0,dp[2]=abs(h[1]-h[2]);
	for(int i=3;i<=n;++i) {
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
		
	}
	printf("%d\n",dp[n]);
}

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

using namespace std;

#define ll long long
#define endl '\n'
#define pb push_back
#define inf 1e9

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

    if (s[k-1] == 'A')
        s[k-1] = 'a';
    if (s[k-1] == 'B')
        s[k-1] = 'b';
    if (s[k-1] == 'C')
        s[k-1] = 'c';

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
//xsharawi is back
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAD
#include <bits/stdc++.h>
using namespace std;
typedef string s;
typedef long long ll;
typedef long double ld;
#if !defined(ONLINE_JUDGE)
#include "C:\debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define ins insert
#define vl vector<ll>
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int main(){
    speed;
    s ss , dd;
    cin >> ss >> dd;
    ll n = (ll) ss.size() , ans = 0;
    for( ll i = 0; i < n; i++ ){
    	if( ss[i] != dd[i] ) ans++;
    }
    cout << ans << endl;
















return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 3748
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d,t;
  cin >> a >> b >> c >> d;
  t=a+b-(c+d);
  if(t>0)
    cout << "Left" << endl;
  else if(t==0)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>

typedef int		BOOL;
#define TRUE	1;
#define FALSE	0;

typedef struct Word
{
	char	word[31];
	int		page;
}	WORD;

WORD wordArray[100];

void input();
	BOOL is_smaller(char *, int, int);
void output();

int main()
{
    input();
    output();
	
	return 0;
}

void input()
{
	int 	cnt1, cnt2;
	char	tempWord[31];
    int		tempPage;
	
	while(scanf("%s %d", tempWord, &tempPage) != EOF)
	{
		for(cnt1 = 0; cnt1 < 100; cnt1++)
		{
			if(wordArray[cnt1].page == 0)
			{
				wordArray[cnt1].page = tempPage;
				strcpy(wordArray[cnt1].word, tempWord);
				break;
			}
			else if(is_smaller(tempWord, tempPage, cnt1))
			{
				for(cnt2 = 98; cnt2 >= cnt1; cnt2--)
				{
					strcpy(wordArray[cnt2 + 1].word, wordArray[cnt2].word);
					wordArray[cnt2 + 1].page = wordArray[cnt2].page;
				}
				strcpy(wordArray[cnt1].word, tempWord);
				wordArray[cnt1].page = tempPage;
				break;
			}
		}
	}
}

BOOL is_smaller(char *tempWord, int input_page, int cnt)
{
	if(strcmp(tempWord, wordArray[cnt].word) < 0)
	{
		return TRUE;
	}
	else if(strcmp(tempWord, wordArray[cnt].word) == 0)
	{
		if(input_page < wordArray[cnt].page)
		{
			return TRUE;
		}
		else
		{
			return FALSE;
		}
	}
	else
	{
		return FALSE;
	}
}

void output()
{
	int		output_cnt = 0;
	char	last_print_word[31] = "";

	while(wordArray[output_cnt].page != 0)
	{
		if(strcmp(last_print_word, "") == 0)
		{
			printf("%s\n", wordArray[output_cnt].word);
			strcpy(last_print_word, wordArray[output_cnt].word);
		}
		else if(strcmp(wordArray[output_cnt].word, last_print_word) != 0)
		{
			printf("\n%s\n", wordArray[output_cnt].word);
			strcpy(last_print_word, wordArray[output_cnt].word);
		}
		else
		{
			printf(" ");
			
		}
		printf("%d", wordArray[output_cnt].page);
		output_cnt++;
	}
	printf("\n");
}

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

int n, k;
string s;

int main() {
    cin >> n >> k;
    cin >> s;
    // -- 
    vector< pair<char, int> > seg;
    for(int i = 0; i < n; i++) {
        if( i == 0 || (s[i] != seg.rbegin()->first) ) {
            seg.push_back( {s[i], 0} );
        }
        (seg.rbegin()->second)++;
    }
    // --
    int currentHappy = 0;
    for(auto &p : seg) {
        currentHappy += (p.second-1);
    }
    // --
    int d = (seg.size() - 1) / 2;
    currentHappy += (min(d, k) * 2);
    currentHappy += ((k > d) && !(seg.size() & 1));
    //
    cout << currentHappy;
}

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


int main()
{
    int a,b,n;
    while(cin>>a>>b>>n)
    {
        int i,num=1;
        int x=max(a,b);
        for(i=x;i<n;i=i+x)
            num++;
        cout<<num<<endl;
    }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

var a, b, k int64

func main() {
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&k)

	if a+b <= k {
		fmt.Print("0 0")
	} else if k <= a {
		fmt.Printf("%d %d", a-k, b)
	} else {
		fmt.Printf("0 %d", b-(k-a))
	}
}


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

struct Node{
    int key, priority;
    Node *left, *right;
};

Node *rightRotate(Node *t){
    Node *s = t->left;
    t->left = s->right;
    s->right = t;
    return s; 
}

Node *leftRotate(Node *t){
    Node *s = t->right;
    t->right = s->left;
    s->left = t;
    return s; 
}

Node *insert(Node *t, int key, int priority){
    if(t==NULL){
        Node *n = new Node();
        n->key = key;
        n->priority = priority;
        n->left = n->right = NULL;
        return n;
    } 
    if(t->key == key) return t; 
    
    if(t->key > key){
        t->left = insert(t->left, key, priority);
        if(t->priority < t->left->priority) t = rightRotate(t);
    }
    else{
        t->right = insert(t->right, key, priority);
        if(t->priority < t->right->priority) t = leftRotate(t);
    }
    return t;
}

Node *delNode(Node* t, int key);
Node *delSearch(Node *t, int key){
    if(t == NULL) return NULL;

    if(t->key > key) t->left = delSearch(t->left, key);
    else if(t->key < key) t->right = delSearch(t->right, key);
    else return delNode(t, key);
    return t;
}

Node *delNode(Node* t, int key){
    if(t->left == NULL && t->right == NULL) return NULL;
    else if(t->left == NULL) t = leftRotate(t);
    else if(t->right == NULL) t = rightRotate(t);
    else{
        if(t->left->priority > t->right->priority)
            t = rightRotate(t);
        else
            t = leftRotate(t);
    }
    return delSearch(t, key);
}


Node *find(Node* node, int key){
    while(node!=NULL && key!=node->key){
        if(key < node->key) node = node->left;
        else node = node->right;
        }
    return node;
}
void inorder(Node *u){
    if(u==NULL) return;
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
}
void preorder(Node *u){
    if(u==NULL) return;
    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}
void print(Node *root){
    inorder(root);
    cout << endl;
    preorder(root);
    cout << endl;
}



int main(){
    Node *root=NULL;
    int n,key,priority;
    string com;

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> com;
        if(com == "print"){
            print(root);
        }
        else{
            cin >> key;
            if(com == "find"){
             Node *u = find(root, key);
             if(u != NULL) cout << "yes" << endl;
            else cout << "no" << endl;
            }  
            else if(com == "delete"){
            root = delSearch(root, key);
            }
            else if(com == "insert"){
            cin >> priority;
            root = insert(root, key, priority);
            }
        }
    }
    return 0;
}



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

int main() {
    int s;cin>>s;
    int a[s+1]{};
    a[0]=1;
    for (int i=3;i<=s;i++)
        a[i]=(a[i-1]+a[i-3])%1000000007;
    cout<<a[s]<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int a, b;
    cin >> a >> b;
    if(a < 6) cout << 0 << endl;
    else if(a <= 12) cout << b/2 << endl;
    else cout << b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n,k; cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll res=1e10;
    if(n==k){
        ll tmp=0;
        ll nax=0;
        rep(i,n){
            if(nax>=a[i]){
                tmp+=nax-a[i]+1;
                nax++;
            }
            chmax(nax, a[i]);
        }
        cout<<tmp<<endl;
        return 0;
    }

    rep(i, 1<<n){
        ll num=0;
        rep(j,n){
            if((i>>j) & 1) num++;
        }
        if(num<k) continue;
        ll tmp=0;
        ll nax=0;
        rep(j,n){
            if((i>>j) & 1){
                if(nax>=a[j]){
                    tmp+=nax-a[j]+1;
                    nax++;
                }
            }
            chmax(nax, a[j]);
        }
        chmin(res, tmp);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
def solve():
  H, W, N = map(int, input().split())
  ans = [0]*10
  dic = defaultdict(lambda: defaultdict(lambda: 0))
  for i in range(N):
    x,y = map(int, input().split())
    x -= 1
    y -= 1
    for i in range(x-1,x+2):
      for j in range(y-1,y+2):
        if i>0 and i<H-1 and j>0 and j<W-1:
          if dic[i][j]>0:
            ans[dic[i][j]] -= 1
          dic[i][j] += 1
          ans[dic[i][j]] += 1
  total = (H-2)*(W-2)
  ans[0] = total - sum(ans[1:])
  return ans
print(*solve(),sep='\n')

Measured memory_bytes: 255272