akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    string s;
    cin >> s;
    string ans;
    for (int i = 0; i < (int)s.size(); i++){
        if (s[i] == 'B'){
            if (!ans.empty()){
                ans.pop_back();
            }
        } else {
            ans.push_back(s[i]);
        }
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;

#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld\n",x)
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define F first
#define S second
#define f(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const ll mod = 1000000007;
const ll inf = (ll)5e16;
const ld eps = 1e-12;
const ll N = 1000005;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}
ll n, t[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    f(i, n)
    {
        cin  >> t[i];
    }
    ll ans = t[0];
    for(ll i = 1; i < n; i++)
    {
        ll gg = __gcd(t[i], ans);
        ans = (t[i] / gg) * (ans);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] nums = scanner.nextLine().split(" ");

        int N = Integer.parseInt(nums[0]);
        int Y = Integer.parseInt(nums[1]);
        int smallY = Y / 1000;
        int target = smallY - N;

        for (int i = 0; (i * 9) <= target; i++) {
            for (int j = 0; (i * 9 + j * 4) <= target; j++) {
                int z = isMeet(N, Y, i, j);
                if (z != -1) {
                    System.out.println(i + " " + j + " " + z);
                    System.exit(0);
                }
            }
        }
        System.out.println("-1 -1 -1");
    }

    public static int isMeet(int N, int Y, int x, int y) {
        int z = N - x - y;
        if (z >= 0 && Y == (10000 * x + 5000 * y + 1000 * z)) {
            return z;
        } else {
            return -1;
        }
    }
}

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

using namespace std;

const int MAXN = 3000 + 5;

long long a[MAXN];

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    long long n, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ans += a[i];
    }
    cout << ans - n << endl;
    return 0;
}


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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define all(x) begin(x),end(x)

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

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld EPS = 1e-9;


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

    vi ns;

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;
        ns.push_back(n);
    }

    int ma = *max_element(all(ns)) * 2;
    vi prime(ma+1, 1);
    prime[0] = prime[1] = 0;
    for (int i = 2; i * i <= ma; ++i) {
        if (!prime[i]) continue;
        for (int j = 2*i; j <= ma; j += i) {
            prime[j] = 0;
        }
    }

    REP(i, ma) {
        prime[i+1] += prime[i];
    }

    for (int n : ns) {
        cout << prime[2*n] - prime[n] << endl;
    }

    return 0;
}



Measured memory_bytes: 3740
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    r=INT()
    if r<1200:
        print('ABC')
    elif r<2800:
        print('ARC')
    else:
        print('AGC')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
import itertools
N = int(input())
ls = []
for i in range(N):
    A = int(input())
    ls.append([])
    for j in range(A):
        ls[i].append(list(map(int, input().split())))

ans = 0
for p in itertools.product((0, 1), repeat=N):
    flag = 1
    for i in range(N):
        if p[i] == 1:
            for x, y in ls[i]:
                x -= 1
                if p[x] != y:
                    flag = 0
    if flag == 1:
        ans = max(ans, sum(p))

print(ans)


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

using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vb = vector<bool>;
using vs = vector<string>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const ld eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i, a, b) for (ll i=(a); i<(b);i++)
#define FORD(i, a, b) for (ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll activities[100005][3] = {0};
ll scoreAfterDay[100005][3] = {0};

int main() {
	cin.sync_with_stdio(0);

	ll n;
	cin >> n;

	FOR(i, 1, n + 1) {
		ll a, b, c;
		cin >> a >> b >> c;
		activities[i][0] = a;
		activities[i][1] = b;
		activities[i][2] = c;
	}

	FOR(i, 1, n + 1) {
		FOR(j, 0, 3) {
			ll max = 0;
			FOR(k, 0, 3) {
				if (k != j) {
					ll tmp = scoreAfterDay[i - 1][k] + activities[i][j];
					if (tmp > max)
						max = tmp;
				}
			}
			scoreAfterDay[i][j] = max;
		}
	}
	cout << max(max(scoreAfterDay[n][0], scoreAfterDay[n][1]), scoreAfterDay[n][2]);
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll n;
cin>>n;
ll a[n];
for (ll i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
cout << a[n - 1] - a[0] << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = in.nextInt();
        }

        int mx = 0;
        int cur = 0;
        for (int i = 0; i < n - 1; i++) {
            if (h[i] >= h[i + 1]) {
                cur++;
            } else {
                mx = Math.max(cur, mx);
                cur = 0;
            }
        }
        mx = Math.max(cur, mx);
        System.out.println(mx);
    }
}

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

int main() {
  int n;
  while(cin >> n) {
    n %= 39 ;
    if(n == 0) cout << "3C39" << endl;
    else if(1<=n && n<=9)cout << "3C0" << n << endl;
    else cout << "3C" << n << endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>

void InsertionSort(int A[], int N, int g);
void shellSort(int A[],int n);

int cnt;
int A[1000000];

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

void InsertionSort(int A[], int N, int g)
{

	int i,j,v;
	
	for(i=g;i<N;i++){
	
		v = A[i];
		j = i-g;
		
		while (j >= 0 && A[j] > v){
			
			A[j+g] = A[j];
			j=j-g;
			cnt++;

		}
		
		A[j+g] = v;
	
	}

}

void shellSort(int A[], int n)
{
	int G[100];
	int m;
	G[0]=1;
	
	for(m=1; 3*G[m-1]+1 <= n; m++){
		
		G[m] = 3*G[m-1]+1;
	}
	printf("%d\n",m);
	
	cnt=0;
	
	for(int i=m-1; i >=0 ; i--){
		if(i<m-1) printf(" ");
		printf("%d",G[i]);
		InsertionSort(A, n, G[i]);
	}	
	printf("\n");
}


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

using ll=long long;
int main()
{
    long X,Y,A,B,C;

    cin >> X >> Y >> A >> B >> C ;
    ll p[A],q[B],r[C];
    ll tmp[X+Y];
    for(int i=0;i<A;i++){
        cin >> p[i];
    }
    for(int i=0;i<B;i++){
        cin >> q[i];
    }
    for(int i=0;i<C;i++){
        cin >> r[i];
    }
    sort(p,p+A,greater<ll>());
    sort(q,q+B,greater<ll>());
    sort(r,r+C,greater<ll>());
    int j,k;
    for(j=0;j<X;j++){
        tmp[j]=p[j];
    }for(k=0;k<Y;j++,k++){
        tmp[j]=q[k];
    }
    sort(tmp,tmp+X+Y);
    for(j=0;j<X+Y && j<C && tmp[j]<r[j];j++){
        tmp[j]=r[j];
    }
    for(j=1;j<X+Y;j++){
        tmp[0]+=tmp[j];
    }
    cout << tmp[0] << endl;

}

Measured memory_bytes: 3968
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<iomanip>
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vii;
typedef vector<pii> vp;
typedef vector<string> vs;
Def inf = sizeof(Def) == sizeof(ll) ? 2e18 : 1e9+10;
signed main(){
	int n;
	cin>>n;
	while(n--){
		int y,m,d;
		cin>>y>>m>>d;
		int co=0;
		while(!(y==1000&&m==1&&d==1)){
			d++;
			if(y%3==0||m%2){
				if(d==21){
					d=1;
					m++;
				}
			}else{
				if(d==20){
					d=1;
					m++;
				}
			}
			if(m==11){
				m=1;
				y++;
			}
			co++;
		}
		cout<<co<<endl;
	}
}








Measured memory_bytes: 3088
/*** 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)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll A[200010];
    ll F[200010];
    rep(i,0,N) cin >> A[i];
    rep(i,0,N) cin >> F[i];
    ll lv = -1, rv = INF;
    sort(A, A+N);
    sort(F, F+N, greater<ll>());
    while(rv - lv > 1){
        ll mid = (rv + lv) / 2;
        ll cnt = 0;
        rep(i,0,N){
            ll v = mid / F[i];
            if(v < A[i]) cnt += A[i] - v;
        }
        if(cnt <= K){
            rv = mid;
        }else{
            lv = mid;
        }
    }
    print(rv);


}

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

int main(){
    string s;
    cin >> s;
    if(s == "SUN")cout << 7;
    if(s == "MON")cout << 6;
    if(s == "TUE")cout << 5;
    if(s == "WED")cout << 4;
    if(s == "THU")cout << 3;
    if(s == "FRI")cout << 2;
    if(s == "SAT")cout << 1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int l, r, d;
  cin >> l >> r >> d;
  int ans = r/d - (l-1)/d;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner *bufio.Scanner

func printIt() {
	n := nextInt()
	m := nextInt()
	l := nextInt()

	ma := make([][]int, n)
	for r := 0; r < n; r++ {
		nums := make([]int, m)
		for c := 0; c < m; c++ {
			nums[c] = nextInt()
		}
		ma[r] = nums
	}

	mb := make([][]int, m)
	for r := 0; r < m; r++ {
		nums := make([]int, l)
		for c := 0; c < l; c++ {
			nums[c] = nextInt()
		}
		mb[r] = nums
	}
	ans := make([][]int, n)
	for i := 0; i < n; i++ {
		ans[i] = make([]int, l)
	}
	for tr := 0; tr < n; tr++ {
		for tc := 0; tc < l; tc++ {
			sum := 0
			for i := 0; i < m; i++ {
				sum += ma[tr][i] * mb[i][tc]
			}
			ans[tr][tc] = sum
		}
	}

	for r := 0; r < n; r++ {
		for c := 0; c < l; c++ {
			if c != 0 {
				fmt.Print(" ")
			}
			fmt.Print(ans[r][c])
		}
		fmt.Println()
	}
}

func nextInt() int {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(1)
	}
	return num
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



Measured memory_bytes: 1556
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <unordered_map>
#include <unordered_set>

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

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

//#define int long long

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
//typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

inline int nextInt()
{
    int x = 0;
    char c = getchar();
    int mi = (c == '-');
    if (c == '-') c = getchar();
    while ('0' <= c && c <= '9')
    {
        x = 10 * x + c - '0';
        c = getchar();
    }
    if (mi) return x * -1;
    return x;
}

int n, m;
vector<int> s;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n;
    if (n == 3)
    {
        cout << 2 << " " << 5 << " " << 63 << endl;
        return 0;
    }
    int nn = n;
    ll summ = 0;
    for (int i = 2; i < 30000; i++)
    {
        if (n > 2 && ((i % 2) == 0 || (i % 3) == 0))
        {
            s.push_back(i);
            summ += i;
            //cout << summ << endl;
            n--;
        }
    }
    for (int j = s[nn - 3] + 1; j <= 30000; j++)
    {
        for (int k = j + 1; k <= 30000; k++)
        {
            if (j % 2 == 0 || j % 3 == 0)
            {
                if (k % 2 == 0 || k % 3 == 0)
                {
                    if ((summ + j + k) % 6 == 0)
                    {
                        //cout << summ << " " << j + k << endl;
                        for (int i = 0; i < nn - 2; i++)
                        {
                            cout << s[i] << " ";
                        }
                        cout << j << " " << k;
                        return 0;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int s[] = new int[1000000];

		for (int i = 1; i <= 100; i++) {
			for (int j = 1; j <= 100; j++) {
				for (int k = 1; k <= 100; k++) {
					int num = i * i + j * j + k * k + i * j + j * k + k * i;
					s[num]++;
				}
			}
		}

		for (int i = 1; i <= n; i++) {
			System.out.println(s[i]);
		}
	}
}

Measured memory_bytes: 39564
import sys
# from collections import defaultdict, deque
import math

# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 998244353

def solve():
    n, k = getList()
    nums = getList()

    print(sum(sorted(nums)[:k]))
def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 62544
#include<stdio.h>

int main(){
    long int a,b,c,d;
    long int ans1,ans2,ans3,ans4;

    scanf("%ld %ld %ld %ld",&a,&b,&c,&d);

    ans1 = a * c;
    ans2 = a * d;
    ans3 = b * c;
    ans4 = b * d;

    if(ans1 >= ans2 && ans1 >= ans3 && ans1 >= ans4){
        printf("%ld\n",ans1);
    }else if(ans2 >= ans1 && ans2 >= ans3 && ans2 >= ans4){
        printf("%ld\n",ans2);
    }else if(ans3 >= ans1 && ans3 >= ans2 && ans3 >= ans4){
        printf("%ld\n",ans3);
    }else{
        printf("%ld\n",ans4);
    }

    return;
}

Measured memory_bytes: 1728
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[][] a = new int[n][2];
        for(int i=0;i<n;i++){
            a[i][0] = Integer.parseInt(sc.next());
            a[i][1] = i+1;
        }
        Arrays.sort(a,new Comparator<int[]>(){

            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[0]-o2[0];
            }
        });

        StringJoiner sj = new StringJoiner(" ");
        for(int i=0;i<n;i++){
            sj.add(String.valueOf(a[i][1]));
        }
        System.out.println(sj.toString());
        sc.close();
    }
    
}

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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  ll n;
  cin >> n;

  if(n == 3){
    cout << 61 << '\n';
    return 0;
  }

  ll dp[n + 1][4][4][4][4];
  ll ans = 0;

  string tmp = "ACGT";

  for(int i = 4; i <= n; i++){
    for(int p = 0; p < 4; p++){
      for(int q = 0; q < 4; q++){
        for(int r = 0; r < 4; r++){
          for(int s = 0; s < 4; s++){
            dp[i][p][q][r][s] = 0;
            if(p == 0 && q == 2 && r == 1) continue;
            if(p == 2 && q == 0 && r == 1) continue;
            if(p == 0 && q == 1 && r == 2) continue;
            if(q == 0 && r == 2 && s == 1) continue;
            if(q == 2 && r == 0 && s == 1) continue;
            if(q == 0 && r == 1 && s == 2) continue;
            if(p == 0 && r == 2 && s == 1) continue;
            if(p == 0 && q == 2 && s == 1) continue;
            if(i == 4){
              dp[4][p][q][r][s] = 1;
            }else{
              for(int t = 0; t < 4; t++){
                dp[i][p][q][r][s] += dp[i - 1][t][p][q][r];
                dp[i][p][q][r][s] %= mod;
              }
            }
            if(i == n) ans = (ans + dp[i][p][q][r][s]) % mod;
          }
        }
      }
    }
  }

  cout << ans << '\n';
}


Measured memory_bytes: 512
"""
・c1~cnについて全体のxorをとるとき、それぞれのcについて各bitで１が奇数個立っているとそのbitが１、偶数個立っているとそのbitが０になる
　→　xorは順番を入れ替えても答えは変わらない

・0 xor N = N、A xor~B = (0 xor ~A-1) xor (0 xor ~B)

・それぞれの偶数nについて、n xor (n+1) = 1 (下位１ビットだけが異なるから)
"""


A, B = map(int, input().split())

def solve(n):

    if n == 0:
        return 0

    nums = (n + 1) % 4

    if nums == 0:
        return 0

    if nums == 1:
        return n

    if nums == 2:
        return 1 # xが偶数で、X ^ (x+1) = 1 なので

    if nums == 3:
        return 1 ^ n


print( solve(A-1) ^ solve(B))

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

bool isprime(int n, int k)
{
	if (k * k > n) { return true; }

	if (n % k == 0){ return false; }

	return isprime(n, k + 1);
}

int main()
{
	const int DATASETS = 10000;

	int n[10000], p[10000], c1 = 0, c2 = 2, c3 = 0;

	while (c1 < 10000)
	{
		if (isprime(c2, 2) == true)
		{
			c3 += c2;

			p[c1] = c3;

			c1++;
		}

		c2++;
	}

	c1 = 0;

	while (true)
	{
		cin >> n[c1];

		if (n[c1] == 0) { goto Exit; }

		c1++;
	}

Exit:;

	for (int i = 0; i < c1; i++)
	{
		cout << p[n[i] - 1] << endl;
	}

	return 0;
}

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

int main() {
  int h,w;cin>>h>>w;
  vector<string> list(h);
  for(int i=0;i<h;i++) {
    cin >> list.at(i);
  }
  for (int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      if(list.at(i).at(j)=='.') {
        int count=0;
        if(i-1>=0) {
          string temp = list.at(i-1);
          if(j-1>=0) {
            if(temp.at(j-1)=='#') {
              count++;
            }
          }
          if(temp.at(j)=='#') {
            count++;
          }
          if(j+1<w) {
            if(temp.at(j+1)=='#') {
              count++;
            }
          }
        }

        if(j-1>=0) {
          if(list.at(i).at(j-1)=='#') {
            count++;
          }
        }
        if(j+1<w) {
          if(list.at(i).at(j+1)=='#') {
            count++;
          }
        }

        if(i+1<h) {
          string temp = list.at(i+1);
          if(j-1>=0) {
            if(temp.at(j-1)=='#') {
              count++;
            }
          }
          if(temp.at(j)=='#') {
            count++;
          }
          if(j+1<w) {
            if(temp.at(j+1)=='#') {
              count++;
            }
          }
        }
        cout << count;
      }
      else {
        cout << list.at(i).at(j);
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
N = int(input())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
  
print(num2alpha(N).lower())

Measured memory_bytes: 9176
N = int(input())
red = [list(map(int,input().split())) for i in range(N)]
blue = [list(map(int,input().split()))  for i in range(N)]

red = sorted(red, key=lambda x: x[0])
blue = sorted(blue, key=lambda x: x[0])


ans = 0

red_candidate = []
flag = False
for i in blue:
    red_candidate = []
    for j in range(len(red)):
        if i[0] <= red[j][0]:
            break
        else:
            if red[j][1] < i[1]:
                red_candidate.append([red[j][1], j])
                flag = True

    tmp_red_ymax_index = 0
    red_candidate = sorted(red_candidate, key=lambda x: -x[0])

    if flag:
       del  red[red_candidate[0][1]] 
       ans += 1
       flag = False
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define FOR(n) for(int i=0;i<n;i++)
#define For(i,n) for(int i=0;i<n;i++)
#define ll long long
ll mob=1000000007;
int main()
{

int a,s;
  cin>>a>>s;
  if(a==s)
   cout<<"Yes";
  else 
    cout<<"No";












return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>using vv = vector<vector<T>>; template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    if (N * A <= B) {
        write(N * A);
    }
    else {
        write(B);
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int a,b,c[1000001],d[31],e[1000001],i,j,m;
int main(void)
{
	scanf("%d %d",&a,&b);
	while(a!=0 && b!=0){
		m=0;
		for(i=0;i<a;i++){
			scanf("%d",&d[i]);
		}
		for(i=0;i<=b;i++){
			c[i]=0;
			e[i]=1;
		}
		c[0]=1;
		for(i=0;i<a;i++){
			for(j=0;j<=b;j++){
				if(c[j]==1 && j+d[i]<=b){
					c[j+d[i]]=1;
				}
			}
		}
		for(i=2;i*i<=b;i++){
			if(e[i]==1){
				for(j=i;j<=b;j=j+i){
					e[j]=0;
				}
			}
		}
		for(i=2;i<=b;i++){
			if(m<i && c[i]==1 && e[i]==1){
				m=i;
			}
		}
		if(m==0){
			printf("NA\n");
		}
		else{
			printf("%d\n",m);
		}
		scanf("%d %d",&a,&b);
	}
	return 0;
}

Measured memory_bytes: 8852
/*hello! guys~*/
#include <bits/stdc++.h>
using namespace std;
int pailie(int a)
{
	return a*(a-1)/2;
}
int main(void){
    int n,m;
	scanf("%d%d",&n,&m);
	
	printf("%d",pailie(n)+pailie(m));
	
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  string s[n], r = "Three";
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == "Y") {
      r = "Four";
      break;
    }
  }
  cout << r << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
using namespace std;
typedef pair<int,int> p;
typedef long long ll;
int a,b,c,d,e,f;
int dp[3100][3100];
int main(){
	cin>>a>>b>>c>>d>>e>>f;
	dp[0][0]=1;
	for(int i=0;i<=f;i++){
		for(int j=0;j<=i;j++){
			if(!dp[i][j])continue;
			if(i+a*100<=f)dp[i+a*100][j]=1;
			if(i+b*100<=f)dp[i+b*100][j]=1;
			if(i+c<=f)dp[i+c][j+c]=1;
			if(i+d<=f)dp[i+d][j+d]=1;
		}
	}
	int all=100*a,suger=0;
	for(int i=1;i<=f;i++){
		for(int j=0;j<=i;j++){
			if(dp[i][j]&&e*(i-j)/100>=j){
				if(j*all>=i*suger){
					all=i;suger=j;
				}
			}
		}
	}
	cout<<all<<" "<<suger<<endl;
	return 0;
}

Measured memory_bytes: 35584
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/

void solve()
{
    ll n;
    cin>>n;

    ll b[n+1],a[n];
    f(i,n+1) cin>>b[i];
    f(i,n) cin>>a[i];

    ll ans=0;

    f(i,n)
    {
        ll v=min(a[i],b[i]);
        ans+=v;
        a[i]-=v;
        b[i]-=v;

        v=min(a[i],b[i+1]);
        ans+=v;
        b[i+1]-=v;
    }

    cout<<ans<<"\n";

    return;
}

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

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 1792
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;



int main()
{

	int N; cin >> N;

	vector<int> A = vector<int>(N, 0);
	vector<int> B = vector<int>(N, 0);
	vector<int> C = vector<int>(N, 0);

	vector<int> AtoB = vector<int>(N);

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

	sort(A.begin(), A.end());

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

	sort(B.begin(), B.end());

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

	sort(C.begin(), C.end());

	int a = 0, b = 0;
	ll ans = 0;

	for (int i = 0; i < N; ++i)
	{

		while (a < N&&A[a] < B[i]) { ++a; }
		
		AtoB[i] = a;

	}
	
	ll sumb = 0;

	for (int i = 0; i < N; ++i)
	{

		while (b < N&&B[b] < C[i])
		{
			sumb += AtoB[b];
			++b; 
		}
		
		ans += sumb;

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/random.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;
namespace rnd = boost::random;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> D;

  invec<int> c(26);
  vector<vector<int>> s(D, vector<int>(26));
  for (auto&& i : s)
    for (auto&& j : i)
      cin >> j;
  vector<int> t(D), highest;
  ll high = -9999999999, cost = 0;
  rnd::mt19937 mt;
  rnd::uniform_int_distribution rnd_plan(1, 26);
  rnd::uniform_real_distribution<> dist2(0.0, 1.0);

  REP(i, 26) {
    cost += c[i];
  }

  const int tier = cost;
  
  int lastf[26] = {0};
  REP(i, D) {
    pair<int, int> cand = {-999999999, 0};
    
    REP(j, 26)
      cand = max(cand, make_pair(s[i][j] + c[j] * (i + 1 - lastf[j]), j));
    t[i] = cand.second + 1;
    
    const int plan = t[i] - 1;
    lastf[plan] = i + 1;
  }  
  
  const int ITER = 1177721600 / D;
  double temp = 0.5;
  constexpr double ALPHA = 0.1;
  const double temp_down = temp * pow(ALPHA, 1.0 / (double)ITER);
  
  REP(loop, ITER) {
    int r = 0;
    int last[26] = {0};
    
    const int update = loop % D;
    const int told = t[update];
    t[update] = (loop != 0) ? rnd_plan(mt) : t[update];
    
    REP(i, D) {
      const int plan = t[i] - 1;
      r += s[i][plan];
      cost -= c[plan] * (i + 1 - last[plan]);
      last[plan] = i + 1;
      r -= cost;
      cost += tier;
    }
    
    if (r > high) {
      high = r;
      highest = t;
    }
    else if (dist2(mt) > exp((double)(r - high) / 128.0 / temp))
      t[update] = told;
    cost = tier;
    temp *= temp_down;
  }
  
  for (auto i : highest)
    cout << i << endl;
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}


Measured memory_bytes: 4180
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    int a,b;
    cin >> a;
    cin >> b;
    if(a+b==3)  cout << 3;
    else if(a+b==5) cout << 1;
    else    cout << 2;
}   

Measured memory_bytes: 764
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
from bisect import bisect_left
#from copy import deepcopy
#import heapq
#import math
#import string

setrecursionlimit(10**6)
input=stdin.readline

n,s=map(int,input().split())
a=[int(i) for i in input().split()]
nows=0
ans=2<<20
left=0
for right in range(n):
    nows+=a[right]
    while left<=right and right<n:
        if nows>=s:
            ans=min(ans,right-left+1)
            nows-=a[left]
            left+=1
        else: break
        #print(nows)
print(ans%(2<<20))


Measured memory_bytes: 16284
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <string>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long int ll;

int alpha[30];
bool f(string s){
  char c=s[0];
  for(int i=1;i<s.size();i++){
    if(s[i]!=c) return false;
  }
  return true;
}
int main(void){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    alpha[s[i]-'a']++;
  }

  int res=111;
  for(int i=0;i<30;i++){
    int tmp=0;
    int t=-1;
    int j;
    for(j=0;j<s.size();j++){
      if(s[j]=='a'+i){
        tmp=max(tmp,j-t-1);
        t=j;
      }
    }
    tmp=max(tmp,j-t-1);
    res=min(res,tmp);
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;

const int INF = 1e9;
const int M = 100;
const int N = 2 * 2 * M * M;

vector<int> E[N];
int flow[N], cap[N], to[N];
bool used[N];

const int s = 0, t = N - 1;

int e = 0;

void addEdge(int v, int u, int c) {
    E[v].push_back(e);
    E[u].push_back(e ^ 1);

    cap[e] = c;
    cap[e ^ 1] = 0;

    to[e] = u;
    to[e ^ 1] = v;

    e += 2;
}

int push(int v, int cur_flow) {
    if (v == t || cur_flow == 0) {
        return cur_flow;
    }

    used[v] = true;
    for (int edge : E[v]) {
        if (!used[to[edge]]) {
            int a = push(to[edge], min(cur_flow, cap[edge] - flow[edge]));
            if (a > 0) {
                flow[edge] += a;
                flow[edge ^ 1] -= a;
                return a;
            }
        }
    }
    return 0;
}

int main() {
#if __APPLE__
    //freopen("F.in", "r", stdin);
    //freopen("F.out", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    vector<string> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];

        for (int j = 0; j < m; ++j) {
            if (a[i][j] == 'o') {
                addEdge(i + 1, n + j + 1, 1);
                addEdge(n + j + 1, i + 1, 1);
            }
            if (a[i][j] == 'S') {
                addEdge(s, i + 1, INF);
                addEdge(s, n + j + 1, INF);
            }
            if (a[i][j] == 'T') {
                addEdge(i + 1, t, INF);
                addEdge(n + j + 1, t, INF);
            }
        }
    }

    int ans = 0;
    int curflow;
    while ((curflow = push(s, INF)) > 0) {
        ans += curflow;
        memset(used, 0, sizeof used);
    }

    if (ans >= INF) ans = -1;
    printf("%d\n", ans);
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[1000000];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for (int i=1;i<=n;i++) {
        cin>>a[i];
    }
    int num=0;
    for (int i=2;i<n;i++){
        int b[]={a[i-1],a[i],a[i+1]};
        sort(b,b+3);
        if (a[i]==b[1])num++;
    }
    cout<<num<<endl;
}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define BR putchar('\n')
#define MS0(ar) memset(ar, 0, sizeof(ar))
#define MS1(ar) memset(ar, -1, sizeof(ar))
#define F first
#define S second
#define MP make_pair
#define MT make_tuple
#define IO(name) freopen(name".in", "r", stdin);freopen(name".out", "w", stdout)

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef complex<double> CD;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VL;

void R(int &x) { scanf("%d", &x); }
void R(LL &x) { scanf("%lld", &x); }
void R(ULL &x) { scanf("%llu", &x); }
void R(double &x) { scanf("%lf", &x); }
void R(LD &x) { scanf("%Lf", &x); }

template <typename T> void R(T &t) { cin >> t; }
template <typename A, typename B> void R(pair<A, B> &x) {
  R(x.F);
  R(x.S);
}

template <typename T> void R(vector<T> &ar) {
  for (auto &it : ar)
    R(it);
}

template <typename T, typename... Args> void R(T &t, Args &... args) {
  R(t);
  R(args...);
}

void W(const char &c) { putchar(c); };
void W(const int &x) { printf("%d", x); }
void W(const LL &x) { printf("%lld", x); }
void W(const ULL &x) { printf("%llu", x); }
void W(const double &x) { printf("%lf", x); }
void W(const LD &x) { printf("%Lf", x); }

template <typename T> void W(const T &t) { cout << t; }
template <typename T> void W(const vector<T> &ar) {
  for (size_t i = 0; i < ar.size(); ++i) {
    W(ar[i]);
    putchar(" \n"[i + 1u == ar.size()]);
  }
}
template <typename T, typename... Args>
void W(const T &t, const Args &... args) {
  W(t);
  W(args...);
}
#define BR putchar('\n')

template <typename T> void Min(T &x, T v) { x = min(x, v); }
template <typename T> void Max(T &x, T v) { x = max(x, v); }
//}}}
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int maxn = 100010;

int main() {
  int n;
  string a, b;
  cin >> n >> a >> b;
  string ans = a + b;
  for (int i = 1; i <= n; ++i) {
    if (a.substr(n - i) == b.substr(0, i))
      ans = a + b.substr(i);
  }
  cout << ans.size() << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, a, b, out;

    cin >> n >> a >> b;
    out = n * a;
    if (out <= b)
    {
        cout << out << endl;
    }
    else
    {
        cout << b << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int N = 202020;
typedef pair<int, int> Pairs;

inline char get(void) {
  static char buf[100000], *S = buf, *T = buf;
  if (S == T) {
    T = (S = buf) + fread(buf, 1, 100000, stdin);
    if (S == T) return EOF;
  }
  return *S++;
}
template<typename T>
inline void read(T &x) {
  static char c; x = 0; int sgn = 0;
  for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
  for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
  if (sgn) x = -x;
}
 
Pairs p[N];
int n, m, ans;
int S[N << 2], T[N << 2];

inline void PushUp(int p) {
  S[p] = S[p << 1] + S[p << 1 | 1];
  T[p] = max(T[p << 1], S[p << 1] + T[p << 1 | 1]);
}
void Build(int p, int l, int r) {
  if (l == r) {
    S[p] = l == 0 ? 0 : -1;
    T[p] = 0; return;
  }
  int mid = l + r >> 1;
  Build(p << 1, l, mid);
  Build(p << 1 | 1, mid + 1, r);
  PushUp(p);
}
void Add(int pos, int w) {
  int p = 1, l = 0, r = m;
  while (l < r) {
    int mid = l + r >> 1;
    if (pos <= mid) {
      p = p << 1; r = mid;
    } else {
      p = p << 1 | 1; l = mid + 1;
    }
  }
  T[p] = max(0, S[p] += w);
  while (p >>= 1) PushUp(p);
}

int main(void) {
  read(n); read(m);
  for (int i = 1; i <= n; i++) {
    read(p[i].first); read(p[i].second);
    p[i].second = m + 1 - p[i].second;
  }
  sort(p + 1, p + n + 1);
  Build(1, 0, m);
  for (int i = 1; i <= n; i++) {
    Add(p[i].second, 1);
    ans = max(ans, T[1] - p[i].first);
  }
  printf("%d\n", max(ans, n - m));
  return 0;
}
 


Measured memory_bytes: 8064
#include <iostream>

using namespace std;

int main(){
	int h, w;

	while(1){
		cin >> h >> w;

		if(h==0 && w==0){
			break;
		}

		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if(i%2==0){
					if(j%2==0) cout << '#';
					else cout << '.';
				} 
				if(i%2!=0){
					if(j%2==0) cout << '.';
					else cout << '#';
				}
			}
			cout << endl;
		}

		cout << endl;
	}
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N;
    string S;
    cin >> N >> S;

    char c = S[0];
    ll cnt = 1;
    REP(i,1,N) {
        if(c != S[i]) ++cnt;
        c = S[i];
    }
    PR(cnt);


    return 0;
}

/*



*/

Measured memory_bytes: 512
import Control.Arrow
import Data.Foldable
import Data.Graph
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as B

solve :: Int -> Int -> V.Vector B.ByteString -> Int
solve h w ss = sum $ map ((\s -> length (filter (== '#') s) * length (filter (== '.') s)) . flattenSCC) $ stronglyConnComp $ map (\i -> (ss !! toIndex i, toIndex i, neighbors $ toIndex i)) [0..w*h-1]
  where
    toIndex :: Int -> (Int,Int)
    toIndex n = (n `mod` w, n `div` w)

    fromIndex :: (Int,Int) -> Int
    fromIndex (x,y) = y * w + x

    (!!) :: V.Vector B.ByteString -> (Int,Int) -> Char
    vec !! (x,y) = (vec V.! y) `B.index` x

    neighbors (x,y) =
      [(x',y') |
        (ix,iy) <- [(0,1),(0,-1),(1,0),(-1,0)],
        let x' = x + ix, let y' = y + iy,
        0 <= x' && x' < w, 0 <= y' && y' < h,
        ss !! (x',y') /= ss !! (x,y)
      ]

main = do
  let readInt = fmap (second B.tail) . B.readInt

  hw <- V.unfoldrN 2 readInt <$> B.getLine
  ss <- V.replicateM (hw V.! 0) B.getLine
  print $ solve (hw V.! 0) (hw V.! 1) ss


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

int main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel" << endl;
    else cout << "consonant" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

typedef long long int int64;

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  if(k==0){
    printf("%lld\n",(int64)n*n);
    return;
  }
  int64 ans=0;
  for(int b=k+1;b<=n;b++){
    ans+=(int64)(n/b)*(b-k);
    if(n%b>=k){
      ans+=n%b-k+1;
    }
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,count=0;
	cin >> n;
	vector<int> v(n);
	for(auto &x:v) cin >> x;
	for(int i=0;i<n;i++){
		if(v[i] != i+1) count++;
	}
	if(count > 2) cout << "NO\n";
	else cout << "YES\n";
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


import time, random
start = time.time()

D = int(input())
c = list(map(int, input().split()))
s = [None]*D
for i in range(D):
    s[i] = list(map(int, input().split()))
    
current = [0]*26
ans = [None]*D
def greedy(weight=1.0):
    ans = [None]*D
    for i,ss in enumerate(s):
        vs = [None]*26
        for j in range(26):
            vs[j] = (ss[j] + current[j]*weight, j)
            current[j] += c[j]
        vs.sort()
        v = vs[-1][1]
        ans[i] = v+1
        current[v] = 0
    return ans
def val(ans):
    current = [0]*26
    val = 0
    for i,(ss, v) in enumerate(zip(s, ans)):
        for j in range(26):
            current[j] += c[j]
        current[v-1] = 0
        val += ss[v-1] - sum(current)
    return val

ans = greedy()
best = ans
bval = val(ans)
num = 2
ren = 0
w = 1.0
v = val(ans)
while (time.time()-start)<=1.80:
#     print(v)
    index = random.sample(range(D),num)
    prev = index[0]
    tmp = ans[prev]
    tmpans = ans[:]
    for ind in index[1:]:
        ans[prev] = ans[ind]
        prev = ind
    ans[index[-1]] = tmp
    tmpv = val(ans)
    if v<tmpv:
        v = tmpv
    else:
        ren += 1
        if ren>=100:
            num = min(num+1, D)
            res = 0
        ans = tmpans
# print(v)
write("\n".join(map(str, ans)))

Measured memory_bytes: 93336
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    int T, F;
    char c;
    bool front = true;
    string frontS = "";
    for(int i = 0; i < Q; i++){
        cin >> T;
        if(T == 1){
            front = !front;
        }
        if(T == 2){
            cin >> F >> c;
            if ((F == 1 && front) || (F == 2 && !front)){
                frontS.push_back(c);
            }
            else S.push_back(c);
        }
    }
    reverse(frontS.begin(), frontS.end());
    S = frontS + S;
    if(!front) reverse(S.begin(), S.end()); 
    cout << S << endl;
}


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

using namespace std;

template <typename T>
using V = vector<T>;

typedef long double ld;
typedef long long ll;

#define FO(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define FOll(i, N) for (ll (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";
#define MP(x, y) (make_pair((x), (y)))
#define MT(...) make_tuple(__VA_ARGS__)
#define G(i, x) get<i>(x)
#define ALL(x) begin(x), end(x)


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int N, S;
	cin >> N >> S;
	V<int> A(N);
	READALL(A);
	sort(ALL(A));
	int cnt = 0;
	FO(i, N) {
		if (S >= A[i]) {
			S -= A[i];
			++cnt;
		} else {
			S = 0;
			break;
		}
	}
	if (S && cnt) --cnt;
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;
string s;
main()
{
	ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll x;
cin>>x;
vector<pair<ll,ll> > v;
map<ll,ll> m;
for(ll i=-1000;i<=1000;i++)
{
	ll y=pow(i,5);
	m[y]=i;
	v.push_back({y,i});
}
for(ll i=0;i<v.size();i++)
{
	ll z=x+v[i].first;
	//cout<<z<<sp;
	if(m.find(z)!=m.end())
	{
		cout<<m[z]<<sp<<v[i].second;
		break;
	}
}
}

Measured memory_bytes: 4228