akhauriyash/Code-Regression huggingface dataset:
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	H := readInt()
	W := readInt()

	a := make([][]int, H)
	for i := range a {
		a[i] = make([]int, W)
		for j := range a[i] {
			a[i][j] = readInt() % 2
		}
	}

	x1 := make([]int, 0, H*W)
	y1 := make([]int, 0, H*W)
	x2 := make([]int, 0, H*W)
	y2 := make([]int, 0, H*W)
	pi := 0
	pj := 0
	for i := 0; i < H; i++ {
		if i%2 == 0 {
			for j := 0; j < W; j++ {
				if i == 0 && j == 0 {
					continue
				}
				if a[pi][pj] == 1 {
					x1 = append(x1, pi)
					y1 = append(y1, pj)
					x2 = append(x2, i)
					y2 = append(y2, j)
					a[i][j] = (a[i][j] + a[pi][pj]) % 2
					a[pi][pj] = 0
				}
				pi, pj = i, j
			}
		} else {
			for j := W - 1; j >= 0; j-- {
				if a[pi][pj] == 1 {
					x1 = append(x1, pi)
					y1 = append(y1, pj)
					x2 = append(x2, i)
					y2 = append(y2, j)
					a[i][j] = (a[i][j] + a[pi][pj]) % 2
					a[pi][pj] = 0
				}
				pi, pj = i, j
			}
		}

	}
	println(len(x1))
	for i := range x1 {
		println(x1[i]+1, y1[i]+1, x2[i]+1, y2[i]+1)
	}

}

// -----------------------------------------------------------------------------


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s1,s2;
	cin>>s1>>s2;
	for(int i=0;i<n;i++)
	{
		cout<<s1[i]<<s2[i];
	}
	return 0;
}

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

int N, ma, f, a[100], cn[101];

int main(){
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> a[i];
		if(ma < a[i]) ma = a[i];
	}
	for(int i=0; i<N; i++) cn[a[i]]++;
	if(ma % 2 == 0){
		for(int i=ma; i>ma/2; i--){
			if(cn[i] < 2) f = 1;
		}
		if(cn[ma/2] != 1) f = 1;
		for(int i=0; i<ma/2; i++){
			if(cn[i] > 0) f = 1;
		}
	}else{
		for(int i=ma; i>(ma+1)/2; i--){
			if(cn[i] < 2) f = 1;
		}
		if(cn[(ma+1)/2] != 2) f = 1;
		for(int i=0; i<=ma/2; i++){
			if(cn[i] > 0) f = 1;
		}
	}
	cout << (f?"Impossible":"Possible") << endl;
	return 0;
}


Measured memory_bytes: 256
s=input()

f=True
for i in range(len(s)-1):
	if s[i]==s[i+1]:
		f=False
		print(i+1,i+2)
		break

if f:
	for i in range(len(s)-2):
		if s[i]==s[i+2]:
			f=False
			print(i+1,i+3)
			break

if f:print(-1,-1)


Measured memory_bytes: 3188
from sys import stdin
import collections
N=int(stdin.readline().rstrip())
data=[(x) for x in stdin.readline().rstrip().split()]
ans=0
if len(set(data)) == 1:
    ans=len((data[1::2]))
else:
    evenc = collections.Counter(data[0::2])
    even_num = evenc.most_common()[0][1]
    alle_num=len(data[0::2])
    
    oddc = collections.Counter(data[1::2])
    odd_num = oddc.most_common()[0][1]
    allo_num=len(data[1::2])
    
    if evenc.most_common()[0][0] == oddc.most_common()[0][0]:
        ans=min((N-(evenc.most_common()[1][1]+odd_num)),(N-(oddc.most_common()[1][1]+even_num)))
    
    else:
        ans=N-(even_num+odd_num)
            
    
print(ans)

Measured memory_bytes: 23900
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        if((a > x)||(a + b < x)){
            System.out.println("NO");
        }
        else{
            System.out.println("YES");
        }
    }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll>mp;
int a,b,c,d;
ll f(ll n)
{
    if(n==0)return 0;
    if(n==1)return d;
    if(mp.find(n)!=mp.end())return mp[n];
    ll res=2e18;
    if(!(n%2))res=f(n>>1)+a;
    else res=min(f(n>>1)+a+d,f((n+1)>>1)+a+d);
    int t=n%3;
    res=min(res,f(n/3)+b+1ll*d*t);
    if(t)res=min(res,f((n+2)/3)+b+1ll*d*(3-t));
    t=n%5;
    res=min(res,f(n/5)+c+1ll*d*t);
    if(t)res=min(res,f((n+4)/5)+c+1ll*d*(5-t));
    if(1.0*n*d<=1e18)res=min(res,n*d);
    mp[n]=res;
    return res;
}
int main()
{
    int _;
    scanf("%d",&_);
    while(_--)
    {
        ll n;
        scanf("%lld%d%d%d%d",&n,&a,&b,&c,&d);
        mp.clear();
        printf("%lld\n",f(n));
    }
    return 0;
}

Measured memory_bytes: 4620
#include<stdio.h>
    int main(void){
    int W,H,x,y,r;
    
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    
    if(W<x+r||H<y+r||0>x-r||0>y-r){
    printf("No\n");
    }
    else{
    printf("Yes\n");
    }
    return 0;
    }


Measured memory_bytes: 2056
#include <stdio.h>
#include <vector>
using namespace std;

int main(void) {
	int N;
	scanf("%d", &N);
	vector<int> a(N + 1);
	for (int i = 1; i <= N; i++) {
		scanf("%d", &a.at(i));
	}
	vector<bool> b(N + 1, true);
	int i = 1, count = 0;
	while (b.at(i)) {
		b.at(i) = false;
		count++;
		i = a.at(i);
		if (i == 2) {
			printf("%d\n", count);
			return 0;
		}
	}
	printf("-1\n");
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int h,w;
    int check = 0;
    while(cin >> h >> w, h||w){
        rep(i,h){
            if(i % 2 == 0) check = 0;
            else check = 1;
            rep(j,w){
                if(check == 0){
                    cout << '#';
                    check = 1;
                }else{
                    cout << '.';
                    check = 0;
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	if (a*b > c*d) {
		cout << a * b << endl;
	}
	else if (a*b < c*d) {
		cout << c * d << endl;
	}
	else {
		cout << a * b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    cout << (m1 != m2) << endl;
}


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

typedef long long ll;
typedef long double ld;

const int inf = 1e9;

int n, x;
string s;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>s;
	n = s.size();
	if(s[n-1]=='s')s += "es";
	else s += "s";
	cout<<s<<endl;	
	return 0;
}


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

int main()
{
    int n, m, e, a[101] = {0}, b[101] = {0}, c[101] = {0}, d[101] = {0};

    cin >> n;

    cin >> m;
    for( int i = 0; i < m; i++ )
    {
        cin >> e;
        a[e]++;
    }

    cin >> m;
    for( int i = 0; i < m; i++ )
    {
        cin >> e;
        b[e]++;
    }

    cin >> m;
    for( int i = 0; i < m; i++ )
    {
        cin >> e;
        c[e]++;
    }

    for( int i = 1; i <= n; i++ )
        if( a[i] == 0 && c[i] >= 1 || b[i] >= 1 && c[i] >= 1 )
            d[i]++;

    int cnt = 0;
    for( int i = 1; i <= n; i++ )
        if( d[i] >= 1 )
            cnt++;
    
    cout << cnt << endl;

    return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m;
	cin>>n>>m;
	vector<ll> a[m];
	for(ll i=0;i<m;i++)
	{
		ll k;
		cin>>k;
		for(ll j=0;j<k;j++)
		{
			ll s;
			cin>>s;
			a[i].push_back(s-1);
		}
	}
	ll p[m];
	for(ll i=0;i<m;i++){
		cin>>p[i];
		p[i]%=2;
	}
	ll ans=0;
	for(ll i=0;i<(1<<n);i++)
	{
		ll Ans[n];
		memset(Ans,0,sizeof(Ans));
		for(ll j=0;j<n;j++)
		{
			if ((i&(1<<j))>0)
			{
				Ans[j]++;
			}
		}
		
		bool flg=true;
		for(ll i=0;i<m;i++)
		{
			ll k=a[i].size();
			ll cnt=0;
			for(ll j=0;j<k;j++)
			{
				cnt+=Ans[a[i][j]];
			}
			if ((cnt%2)!=p[i])
				flg=false;
		}
		if (flg)
			ans++;
	}
	cout<<ans;

}

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

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

ll ans;
void gcd(ll a,ll b){
    if (!b) {
        ans -= a;
        return;
    }
    ll cur = (a/b) * 2 * b;
    ans += cur;
    gcd(b,a%b);
}
int main(){
    IOS();
    ll n,x;
    cin >> n >> x;
    if (x > n/2) x = n - x;

    ans = n + 2 * x;
    ll y = n - 2 * x;
    if (x < y) swap(x,y);
    gcd(x,y);
    cout << ans << endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;
  vector<vector<int>> d(N, vector<int>(N, 1000000));
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      d[i][j] = min({abs(j - i), abs(j - X) + abs(i - Y) + 1, abs(j - Y) + abs(i - X) + 1});
      //cout << d[i][j] << ' ';
    }
    //cout << endl;
  }
  vector<int> count(N, 0);
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      count[d[i][j]]++;
    }
  }
  for (int i = 1; i < N; i++){
    cout << count[i] << endl;
  }
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double eps = 1e-10;
const int MOD = 1000000007;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
    cin.tie(0);
    cout << fixed << setprecision(10);
    int n; cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;++i) {
      cin >> h[i];
    }
    vector<int> dp(n, MOD);
    dp[0] = 0;
    for(int i=0;i<n-1;++i) {
      dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
      dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }
    dp[n-1] = min(dp[n-1], dp[n-2] + abs(h[n-1] - h[n-2]));
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String s = sc.next();
    String t = sc.next();
    String ans = "";
    for (int i = 0; i <= N; i++) {
      String tmp = s + t.substring(i);
      if (s.compareTo(tmp.substring(0, N)) == 0 && t.compareTo(tmp.substring(tmp.length() - N, tmp.length())) == 0) {
        ans = tmp;
      }
    }
    System.out.println(ans.length());
  }
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

void dfs(const vector<vector<int64_t>>& adjs, vector<int64_t>& depth, int64_t v,
         int64_t p) {
    for (auto u : adjs[v]) {
        if (u == p) {
            continue;
        }

        depth[u] = depth[v] + 1;
        dfs(adjs, depth, u, v);
    }
}

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

    vector<vector<int64_t>> adjs(n);
    for (auto _ : irange(0L, n - 1)) {
        int64_t a, b;
        cin >> a >> b;
        --a;
        --b;
        adjs[a].push_back(b);
        adjs[b].push_back(a);
    }

    vector<int64_t> depth(n, 0L);
    dfs(adjs, depth, 0, -1);

    auto n1 = count_if(depth.begin(), depth.end(),
                       [](int64_t d) { return d % 2 == 0; });
    auto n2 = n - n1;

    int64_t r = 0;
    if (n1 > n2) {
        r = 1;
        swap(n1, n2);
    }

    vector<int64_t> ans(n);
    if (n1 <= n / 3) {
        int64_t k1 = 3, k2 = 1;
        for (auto i : irange(0L, n)) {
            if (depth[i] % 2 == r || k2 > n) {
                ans[i] = k1;
                k1 += 3;
            } else {
                ans[i] = k2;
                ++k2;
                if (k2 % 3 == 0) {
                    ++k2;
                }
            }
        }
    } else {
        int64_t k1 = 1, k2 = 2, k3 = 3;
        for (auto i : irange(0L, n)) {
            if (depth[i] % 2 == r) {
                if (k1 <= n) {
                    ans[i] = k1;
                    k1 += 3;
                } else {
                    ans[i] = k3;
                    k3 += 3;
                }
            } else {
                if (k2 <= n) {
                    ans[i] = k2;
                    k2 += 3;
                } else {
                    ans[i] = k3;
                    k3 += 3;
                }
            }
        }
    }

    const auto* delim = "";
    for (auto a : ans) {
        cout << delim << a;
        delim = " ";
    }
    cout << "\n";
}

Measured memory_bytes: 23936
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	x := make([]int, 30)
	for _, ss := range s {
		x[ss-'A']++
	}

	flg := true
	for _, xx := range x {
		if !(xx == 0 || xx == 2) {
			flg = false
		}
	}

	if flg {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;i++) cin >> h[i];
  vector<int> dp(n,0);
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
  }
  cout << dp[n-1] << endl;
  return 0;
}


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

int main(){
    int H , W , HH , WW ;
    cin >> H >> W;
    while ( H > 0, W > 0 ){
        for ( HH = H ; HH > 0; HH-- ){
            for ( WW = W ; WW > 0 ; WW-- ){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }    
}



Measured memory_bytes: 3080
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        t: [usize; n],
        v: [f64; n]
    }
    let mut ans = 0.0;
    let mut vt = 0.0;
    let mut tac = vec![0; n + 1];
    for i in 0..n {
        tac[i + 1] = tac[i] + t[i];
    }
    for i in 0..2 * t.iter().cloned().sum::<usize>() {
        let mut a = 1.0;
        for j in 0..n {
            if tac[j] * 2 > i {
                if v[j] + (tac[j] * 2 - i) as f64 / 2.0 - 0.25 < vt {
                    a = -1.0;
                    break;
                }
            } else if tac[j] * 2 <= i && i < tac[j + 1] * 2 {
                if v[j] < vt + 0.5 {
                    a = 0.0;
                }
            }
        }
        if (tac[n] * 2 - i) as f64 / 2.0 - 0.25 < vt {
            a = -1.0;
        }
        ans += (2.0 * vt + 0.5 * a) / 4.0;
        vt += 0.5 * a;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>

int main()
{
    int a;
    std::cin >> a;
    int b = a/1000%10 ,c = a/100%10,d = a/10%10,e=a%10;
    if((b==c)&&(c==d)){
        std::cout<<"Yes"<<std::endl;
    }else if((c==d)&&(d==e)){
        std::cout<<"Yes"<<std::endl;
    }else{
        std::cout<<"No"<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	string A,B,C;
	cin>>A>>B>>C;
	if(A.back()==B.front()&&B.back()==C.front())cout<<"YES";
	else cout<<"NO";
}

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

int main() {
  string a,b,c;
  cin>>a>>b>>c;
  if((a.at(a.size()-1)==b.at(0)) && (b.at(b.size()-1)==c.at(0))) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;

int n,res;
int dx[24],dy[24],dr[24];
int cx[4][6],cy[4][6],cr[4][6],cz[4][6],cc[4];
bool flag[1<<24];
int link[24][24];

void dfs(int bit,int cnt){
	if(flag[bit])return;
	flag[bit]=true;
	res=max(res,cnt);
	for(int i=0;i<4;i++){
		for(int j=0;j<cc[i];j++){
			if((bit >> cz[i][j]) & 1)continue;
			for(int k=j+1;k<cc[i];k++){
				if((bit >> cz[i][k]) & 1)continue;
				int flag2=0;
				for(int l=0;l<cz[i][k];l++){
					if((bit >> l) & 1)continue;
					if(cz[i][j]>l && link[l][cz[i][j]]==1){
						flag2=1;
						break;
					}
					if(link[l][cz[i][k]]==1){
						flag2=1;
						break;
					}
				}
				if(flag2==0){
					int nbit=bit;
					nbit|=1<<cz[i][j];
					nbit|=1<<cz[i][k];
					dfs(nbit,cnt+2);
				}
			}
		}
	}
}

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		res=0;
		memset(flag,false,sizeof(flag));
		memset(link,0,sizeof(link));
		memset(cx,0,sizeof(cx));
		memset(cy,0,sizeof(cy));
		memset(cz,0,sizeof(cz));
		memset(cc,0,sizeof(cc));
		for(int i=0;i<n;i++){
			int c;
			scanf("%d %d %d %d",&dx[i],&dy[i],&dr[i],&c);
			c--;
			cx[c][cc[c]]=dx[i];
			cy[c][cc[c]]=dy[i];
			cr[c][cc[c]]=dr[i];
			cz[c][cc[c]]=i;
			cc[c]++;
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(sqrt(pow(dx[i]-dx[j],2)+pow(dy[i]-dy[j],2))<(double)dr[i]+dr[j]){
					link[i][j]=link[j][i]=1;
				}
			}
		}
		dfs(0,0);
		printf("%d\n",res);
	}
	return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Int2D {
  const int64 x, y;
  Int2D(int64 x, int64 y) : x(x), y(y) {}
  Int2D operator-(Int2D o) const {
    return Int2D(x - o.x, y - o.y);
  }
  int64 CrossProduct(Int2D o) const {
    return x * o.y - y * o.x;
  }
};

int64 CrossProduct(Int2D p1, Int2D p2) {
  return p1.x * p2.y - p1.y * p2.x;
}

bool Colinear(Int2D p1, Int2D p2, Int2D p3) {
  Int2D v12 = p2 - p1;
  Int2D v13 = p3 - p1;
  return CrossProduct(v12, v13) == 0;
}

constexpr int64 P = 998244353;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

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

  int n;
  cin >> n;
  vector<Int2D> ps;
  for (int i = 0; i < n; i++) {
    int64 x, y;
    cin >> x >> y;
    ps.emplace_back(x, y);
  }

  FiniteField r = 0;
  r += 1;
  r += n;

  set<pair<int, int>> visited;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (visited.find(make_pair(i, j)) != visited.end()) {
        continue;
      }

      vector<int> vs({i, j});
      for (int k = j + 1; k < n; k++) {
        if (Colinear(ps[i], ps[j], ps[k])) {
          vs.push_back(k);
        }
      }

      int m = vs.size();
      FiniteField s = 1;
      for (int k = 0; k < m; k++) s *= 2;
      s -= 1;
      s -= m;

      r += s;

      for (int i1 = 0; i1 < vs.size(); i1++) {
        for (int i2 = i1 + 1; i2 < vs.size(); i2++) {
          visited.insert(make_pair(vs[i1], vs[i2]));
        }
      }
    }
  }

  FiniteField ans = 1;
  for (int i = 0; i < n; i++) ans *= 2;
  ans -= r;
  // cout << r.Value() << endl;
  cout << ans.Value() << endl;
}


Measured memory_bytes: 1152
#include<cstdio>
const int p=1000000007;
int C[505][505],f[505][505];
int abs(int a){return a<0?-a:a;}
int dfs(int n,int x){
	if(!n)return!x;
	int&g=f[n][x];
	if(g)return g-1;
	for(int y=x?x:x+2;y<=n;y+=2){
		int s=0;
		for(int z=0;z<=y;z++)s=(s+1ll*C[y][z]*dfs(n-y,abs((x+z*2-y)/2)))%p;
		g=(g+1ll*C[n][y]*s)%p;
	}
	return g++;
}
int main(){
	int n;scanf("%d",&n);
	for(int i=0;i<=n;i++)
		for(int j=*C[i]=1;j<=i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%p;
	int ans=1ll*(dfs(n-1,0)+dfs(n-1,1))*n%p;
	printf("%d\n",ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, e) for (int i = (s); i < (int)(e); i++)
using namespace std;

int main() {
  int H, W;
  vector<string> S;
  cin >> H >> W;
  rep (i, H) {
    string s;
    cin >> s;
    S.push_back(s);
  }

  rep (i, H) {
    rep (j, W) {
      if (S[i][j] == '#') {
        cout << '#';
        continue;
      }
      vector<int> dh = {-1, 0, 1, 1, 1, 0, -1, -1};
      vector<int> dw = {1, 1, 1, 0, -1, -1, -1, 0};
      int cnt = 0;
      rep (k, 8) {
        int h = dh[k] + i;
        int w = dw[k] + j;
        if (0 <= h && h < H && 0 <= w && w < W) {
          cnt += S[h][w] == '#';
        }
      }
      cout << cnt;
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long Y = sc.nextLong();

        long res = 1;
        long total = X;
        while(total <= Y) {
            res++;
            total *= 2;
        }
        res--;
        System.out.println(res);
    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
using namespace std;

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

      int t=1;
      //cin>>t;
      while(t--)
      {
               int x,y;
               cin>>x>>y;
               if(y<2*x)
                    cout<<"No";
               else if(y==2*x)
                    cout<<"Yes";
               else if(y>4*x)
                    cout<<"No";
               else if(y%2)
                    cout<<"No";
               else
               {
                    cout<<"Yes";
               }

      }
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string N;
    cin >> N;
    int sum = 0;
    for (char c : N) {
        sum += (c - '0');
    }
    if (sum % 9 == 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

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

void dfs(vector<vector<int>>& adj, vector<int>& dist, int ch, int par) {
    if(par == -1) {
        for(auto& x: adj[ch]) {
            dfs(adj, dist, x, ch);
        }
    } else {
        dist[ch] = dist[par] + 1;
        for(auto& x: adj[ch]) {
            if(x != par) {
                dfs(adj, dist, x, ch);
            }
        }
    }
} 

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    --a, --b;
    vector<vector<int>> adj(n);
    for(int i = 0; i < n - 1; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    vector<int> dist1(n, 0), dist2(n, 0);
    dfs(adj, dist1, a, -1);
    dfs(adj, dist2, b, -1);
    int ans = a;
    for(int i = 0; i < n; ++i) {
        if(dist2[i] > dist1[i] && dist2[i] > dist2[ans]) ans = i;
    }
    cout << dist2[ans] - 1;
    return 0;
}

Measured memory_bytes: 11648
MOD = 10**9+7

def add(a,b):
  return (a+b) % MOD

def mul(a,b):
  return (a*b) % MOD

def pow(a,n):
  ans = 1
  mag = a
  for b in reversed(str(bin(n))):
    if b == 'b': break
    if b == '1':
      ans = mul(ans, mag)
    mag = mul(mag, mag)
  return ans

def inv(a):
  return pow(a, MOD-2)

H,W,A,B = map(int,raw_input().split())

factorical = [1]
factorical_inv = [1]
for n in range (1,H+W+1):
  f = mul(factorical[n-1], n)
  factorical.append(f)
  if(n <= max(H,W)):
    factorical_inv.append(inv(f))

def ncr(n,r):
  return mul(mul(factorical[n], factorical_inv[n-r]), factorical_inv[r])

def paths(w,h):
  return ncr(w+h,w)

ans = 0
for i in range(W-B):
  p = mul(paths(H-A-1, B+i), paths(A-1, W-B-1-i))
  ans = add(ans, p)
print ans

Measured memory_bytes: 18564
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);
        Console.WriteLine((b - 1 + a - 1 - 1) / (a - 1));
    }
}


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


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

	int l, r, d;
	cin >> l >> r >> d;
	int cnt = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0) {
			cnt++;
			//i += d;
		}
	}

	cout << cnt << '\n';


	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N)  for (int i = 0; i < (N); i++)

int main(){

    int D, T, S;
    cin >> D >> T >> S;

    if (T*S >= D) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(){

int h, w;
int x, y;
char c;
int flag;

while (1){
scanf("%d %d", &h, &w);

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

for  (y = 0; y < h; y++ ){
        for (x = 0; x < w; x++){
                if      (y % 2 == 0 && x % 2 == 0 ) c = '#';
                else if (y % 2 == 1 && x % 2 == 1 ) c = '#';
                else                                c = '.';

                printf("%c", c);}
                printf("\n");
                        }
                printf("\n");
}
return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[100001];

bool ispoweroftwo(ll x)
{
    return x && !(x & (x-1));
}
ll xorcal(ll n)
{
    if(n%4==0)
        return n;
    if(n%4==1)
        return 1;
    if(n%4==2)
        return n+1;
    if(n%4==3)
        return 0;
}
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
    show(prime[89]);
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

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

ll power(ll A, ll B)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;

    ll y;
    if (B % 2 == 0) {
        y = power(A, B / 2);
        y = (y * y) % mod;
    }

    else {
        y = A % mod;
        y = (y * power(A, B - 1) % mod) % mod;
    }

    return (ll)((y + mod) % mod);
}
int main()
{
    ios_base::sync_with_stdio(false);
    ll p,q,r;
    cin>>p>>q>>r;
    show(min(p+q,min(q+r,p+r)));
    return 0;
}


Measured memory_bytes: 256
import sys

N = int(input())
b = list(map(int, input().split()))
# 1 1 1 2 2 1 2 3 2


# b = map(int, '1 1 1 2 2 1 2 3 2'.split())
# N = len(b)

steps = []
for i in range(N):
    cands = []
    for j in range(N - i):
        if (j + 1) == b[j]:
            cands.append(j)
    if len(cands) == 0:
        print(-1)
        sys.exit()
    else:
        j = cands[-1]
        steps.append(j + 1)
        b = b[:j] + b[j+1:]
for s in steps[::-1]:
    print(s)


Measured memory_bytes: 3064
def main():


	l = list(str(input()))

	ans = 0
	for i in range(len(l)-1):
		if l[i] != l[i+1]:
			ans += 1
	if ans > 0:
		print("Yes")
	else:
		print("No")
	

if __name__ == '__main__':
	main()

Measured memory_bytes: 38336
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		if ((x + y) % 3 > 0) {
			System.out.println(0);
			return;
		}
		int n = (x + y) / 3;
		System.out.println(comb(n, x - n));

	}

	static int comb(int a, int b) {
		if (b < 0 || b > a)
			return 0;

		long result = fact[a];
		int denom = (int) ((long) fact[a - b] * fact[b] % MOD);
		result *= inverce(denom);
		result %= MOD;
		return (int) result;
	}

	static int MOD = 1000000007;
	static int factMax = 2000000 / 3;

	static int[] fact = new int[factMax + 1];
	static {
		fact[0] = 1;
		for (int i = 1; i <= factMax; i++) {
			fact[i] = (int) ((long) fact[i - 1] * i % MOD);
		}
	}

	static int inverce(int x) {
		return power(x, MOD - 2);
	}

	static int power(int x, int e) {
		long result = 1;
		for (long base = x; e > 0; e >>= 1, base = base * base % MOD) {
			if (e % 2 == 1) {
				result *= base;
				result %= MOD;
			}
		}
		return (int) result;
	}
}


Measured memory_bytes: 24788
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<29)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main() {
    int n, MAX = -INF, sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        MAX = max(MAX, t);
        sum += t;
    }
    cout << sum - MAX / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pll pair <ll,ll>
#define Mid ((L+R)/2)
#define Left (2*Node)
#define Right (2*Node+1)

using namespace std;

const ll N = 200200;
const ll M = 4 * N;
const ll Inf = 1e18;

ll n;
ll Dp[N];
ll SegTree[M];
ll Lazy[M];
vector <pll> Range[N];

void Merge(ll Node)
{
    SegTree[Node] = min(SegTree[Left],SegTree[Right]);
}

void Push_Lazy(ll Node)
{
    SegTree[Node] += Lazy[Node];

    if(Left < M)    Lazy[Left] += Lazy[Node];
    if(Right < M)   Lazy[Right] += Lazy[Node];

    Lazy[Node] = 0;
}

void Build(ll Node = 1,ll L = 0,ll R = n + 1)
{
    if(L == R)
    {
        SegTree[Node] = Dp[L];
        return ;
    }

    Build(Left,L,Mid);
    Build(Right,Mid+1,R);

    Merge(Node);
}

void Update(ll i,ll j,ll val,ll Node = 1,ll L = 0,ll R = n + 1)
{
    Push_Lazy(Node);

    if(i > R || L > j)  return ;
    if(i <= L && R <= j)
    {
        Lazy[Node] += val;
        Push_Lazy(Node);
        return ;
    }

    Update(i,j,val,Left,L,Mid);
    Update(i,j,val,Right,Mid+1,R);

    Merge(Node);
}

ll Query(ll i,ll j,ll Node = 1,ll L = 0,ll R = n + 1)
{
    Push_Lazy(Node);

    if(i > R || L > j)      return Inf;
    if(i <= L && R <= j)    return SegTree[Node];

    return min(Query(i,j,Left,L,Mid)
             , Query(i,j,Right,Mid+1,R));
}

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

    ll Sum = 0;

    while(m--)
    {
        ll l,r,a;   scanf("%lld%lld%lld",&l,&r,&a);

        Sum += a;

        Range[l].push_back({r,a});
    }

    Dp[n+1] = 0;
    Update(n+1,n+1,0);

    for(ll i = n; ~i; --i)
    {
        Dp[i] = Query(i+1,n+1);

        Update(i,i,Dp[i]);

        for(pll p : Range[i])   Update(p.first+1,n+1,p.second);
    }

    ll Ans = Inf;

    for(ll i = 0; i <= n + 1; i++)  Ans = min(Ans,Dp[i]);

    cout << Sum - Ans;
}


Measured memory_bytes: 25216
#include<stdio.h>

int n,size[101],t[101][101],cost[101][101],distance[101];

void spp(int x,int y){
  int i;
  distance[x]=y;

  for(i=0;i<size[x];i++){
    if(distance[t[x][i]]>y+cost[x][i]) spp(t[x][i],y+cost[x][i]);
  }
}

int main(){
  int i,j;
  scanf("%d",&n);

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

    for(j=0;j<size[a];j++){
      scanf("%d",&t[a][j]); 
      scanf("%d",&cost[a][j]);
    }
  }

  for(i=0;i<n;i++) distance[i]=114514810;
  spp(0,0);
  for(i=0;i<n;i++){
    printf("%d %d\n",i,distance[i]);
  }
  return 0;
}

Measured memory_bytes: 680
def main():
    N, C, K = map(int, input().split())
    T = list(int(input()) for _ in range(N))

    T.sort()

    ans = 0
    temp = T[0]
    cnt = 1

    for i in range(1,N):
        if temp + K < T[i] or C == cnt:
            ans += 1
            temp = T[i]
            cnt = 1
        else:
            cnt += 1

    ans += 1
    return (ans)

print(main())

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

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

bool DEBUG=0;
const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	string s,t; cin>>s>>t; int cnt=0;
	forn(i,0,s.length()){
		if(s[i]!=t[i]) cnt++;
	}
	cout<<cnt;
	
	return 0;
}


Measured memory_bytes: 3812
from itertools import accumulate
n = int(input())
XS = tuple(tuple(map(int, input().split())) for _ in range(n))
X, S = zip(*XS)
A = tuple(accumulate(S))
B = tuple(a-x for x, a in zip(X, A))
A = [0] + list(A)
X = list(X) + [0]
C = tuple(a-x for x, a in zip(X, A))[:-1]
m = float("inf")
ans = 0
for b, c in zip(B, C):
  m = min(m, c)
  ans = max(ans, b-m)
print(ans)

Measured memory_bytes: 68900
#include<bits/stdc++.h>
using namespace std;
int i,i0,n,m;
string s[10005],ans;
queue<string>xa,bx,ba,xx;
int main()
{
    scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		cin>>s[i];
		if(s[i][0]=='B'&&s[i][s[i].length()-1]=='A')ba.push(s[i]);
		else if(s[i][0]=='B')bx.push(s[i]);
		else if(s[i][s[i].length()-1]=='A')xa.push(s[i]);
		else ans+=s[i];
	}
	bool f=0;
	while(xa.size()||bx.size()||ba.size())
	{
		if(!f)
		{
			if(xa.size())ans+=xa.front(),xa.pop(),f=1;
			else if(ba.size())ans+=ba.front(),ba.pop(),f=1;
			else ans+=bx.front(),bx.pop(),f=0;
		}
		else
		{
			if(ba.size())ans+=ba.front(),ba.pop(),f=1;
			else if(bx.size())ans+=bx.front(),bx.pop(),f=0;
			else ans+=xa.front(),xa.pop(),f=1;
		}
	}
	int cnt=0;
	for(i=0;i<ans.size()-1;i++)if(ans[i]=='A'&&ans[i+1]=='B')cnt++;
	printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>




int main(){
	int N,K;
	int S[100];
	int B;
	int count;
	int h=1;

	int i,j;

	scanf("%d %d",&N,&K);

	while((N!=0)&&(K!=0)){
		h=1;
		for(i=0;i<K;i++){
			scanf("%d",&S[i]);
		}

		for(i=0;i<N;i++){
			for(j=0;j<K;j++){
				scanf("%d",&B);
				if(h==1){
					S[j]=S[j]-B;
					if(S[j]<0){
						h=0;
						printf("No\n");
					}
				}
			}
		}
		if(h==1){
			printf("Yes\n");
		}


		scanf("%d %d",&N,&K);
	}

	return 0;

}

Measured memory_bytes: 736
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int x, y, z;
	long long int asum=0, a, b[100000],b1[100000],c1[100000], c[100000], d;
	scanf("%d %d %d", &x, &y, &z);
	multimap<long long int, int> dmp;
	for(int i=0; i<x+y+z; i++){
		scanf("%lld %lld %lld", &a, &b[i], &c[i]);
		asum=asum+a;
		b[i]=b[i]-a;
		c[i]=c[i]-a;
		d=b[i]-c[i];
		dmp.insert(make_pair(d, i));
	}
	int l=0;
	for(auto itr=dmp.begin(); itr!=dmp.end(); itr++){
		int i=itr->second;
		b1[l]=b[i];
		c1[l]=c[i];
      
		l++;
	}
	priority_queue<long long int, vector<long long int>, greater<long long int> > que, queb;
	long long int cmax[100000], bmax[100000];
	cmax[0]=0;
	bmax[0]=0;
	for(int i=0; i<z; i++){
		que.push(c1[i]);
		cmax[0]=cmax[0]+c1[i];
	}
	for(int i=1; i<=x; i++){
		que.push(c1[z+i-1]);
		long long int c0=que.top();
		que.pop();
		cmax[i]=cmax[i-1]+c1[z+i-1]-c0;
	}
	for(int i=0; i<y; i++){
		queb.push(b1[x+y+z-1-i]);
		bmax[0]=bmax[0]+b1[x+y+z-1-i];
	}
	for(int i=1; i<=x; i++){
		queb.push(b1[x+z-i]);
		long long int b0=queb.top();
		queb.pop();
		bmax[i]=bmax[i-1]+b1[x+z-i]-b0;
	}
	long long int max=cmax[0]+bmax[x];
  
	for(int i=1; i<=x; i++){
		if(max<cmax[i]+bmax[x-i]) max=cmax[i]+bmax[x-i];
	}
 
	max=max+asum;
	printf("%lld\n", max);
	return 0;
}

Measured memory_bytes: 12156
s = input()
s2 = s[::-1]
# print(s2)

if s != s2:
    print('No')
    exit(0)

partial_s = s[0:((len(s) - 1) // 2)]
# print(partial_s)
partial_s2 = partial_s[::-1]
if partial_s != partial_s2:
    print('No')
    exit(0)

partial_ss = s[((len(s) + 3) // 2) - 1:]
# print(partial_s2)
partial_ss2 = partial_s[::-1]
if partial_ss != partial_ss2:
    print('No')
    exit(0)
print('Yes')


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

int main(){
int n;
int s[13];
int h[13];
int c[13];
int d[13];
int i;
char mark;
int  rank;

for (i=0; i<13; i++){
        s[i]=0;
        h[i]=0;
        c[i]=0;
        d[i]=0;
}

 scanf("%d", &n);

for (i=0; i< n; i++){
        /* printf(" %d\n", i); */
        scanf (" %c %d", &mark, &rank);
        if     (mark == 'S') s[rank-1]=1;
        if     (mark == 'H') h[rank-1]=1;
        if     (mark == 'C') c[rank-1]=1;
        if     (mark == 'D') d[rank-1]=1;
}

for (i=0; i< 13; i++){
        if (s[i] == 0) printf("S %d\n", i+1);
}
for (i=0; i< 13; i++){
        if (h[i] == 0) printf("H %d\n", i+1);
}
for (i=0; i< 13; i++){
        if (c[i] == 0) printf("C %d\n", i+1);
}
for (i=0; i< 13; i++){
        if (d[i] == 0) printf("D %d\n", i+1);
}
return 0;}

Measured memory_bytes: 596
{
  const main = (input: string) => {
    const r = reader(input)
    const N = r.n()
    const a: { [i: number]: [number, number][] } = {}
    const na = Array.from(Array(N), (v, k) => k)

    for (let i = 0; i < N; i++) {
      const A = r.n()

      a[i] = []
      for (let j = 0; j < A; j++) {
        const [x, y] = r.ns()

        a[i].push([x - 1, y])
      }
    }

    const last = 1 << N
    let res = 0

    for (let k = 0; k < last; k++) {
      const ans = _decToBin(k, N)

      const ok = na.every(i => {
        if (ans[i] === 0) {
          // 不親切
          return a[i].some(([x, y]) => ans[x] !== y)
        } else {
          // 正直
          return a[i].every(([x, y]) => ans[x] === y)
        }
      })

      if (ok) {
        res = Math.max(
          res,
          ans.reduce((p, c) => p + c, 0)
        )
      }
    }
    console.log(res)
  }

  const _decToBin = (dec: number, pad: number) =>
    ('0'.repeat(pad) + dec.toString(2))
      // .padStart(pad, '0')
      .slice(-pad)
      .split('')
      .map(Number)

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')

  main(getInput())
}


Measured memory_bytes: 10576
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 1000000007
void MOD(int &x){if(x>=mod)x-=mod;}
#define maxn 2010
#define inf (1<<30)
int main(){
	int a,b,c;
	in(a);in(b);in(c);
	if(b<=4)puts("Heisei");
	 else puts("TBD"); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(){
    ll n,m;cin>>n>>m;
    vl dp(n+1,INF);
    dp[0]=0;
    rep(i,m){
        ll cc;cin>>cc;
        fore(j,cc,n)chmin(dp[j],dp[j-cc]+1);
    }
    cout<<dp[n]<<endl;
}

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



Measured memory_bytes: 3364
#include <bits/stdc++.h> 
#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>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	int a, b; CI a >> b;
	CO a + b / 2 EN;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,y;
  cin >> n>>y;
  for(int i=0;i<=n;i++){
    for(int j=0;j+i<=n;j++){
      int man = i*10000;
      int sen5 = j*5000;
      int N = n-i-j;
      if(y==man+sen5+1000*N){
        cout << i<<" "<< j <<" "<< N;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1";
         
}

Measured memory_bytes: 256