akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int N, M;
int G[10][10];
int ans = 0;

void dfs(int v, int S) {
    if (S + 1 == 1 << N) {
        ans++;
    }
    rep(i, N) {
        if (G[v][i]) {
            if (S >> i & 1) continue;
            dfs(i, S | 1 << i);
        }
    }
}

int main() {
    cin >> N >> M;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a][b] = G[b][a] = 1;
    }
    dfs(0, 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S,T; cin >> S >> T;
    cout << T << S << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int main(void){
	long long all=0;
  	long long a=0,n=0;
  	cin>>n;
    for(int i=0;i<5;i++){
    	cin>>a;
        if(n%a!=0){all=max(n/a+1,all);}
      	else{
          all=max(n/a,all);
        }
    }
  cout<<all+4<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

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



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)

using namespace std;


int main(void) {

	long long a;

	vector<int> vec;

	cin >> a;

	int min = 9999999;
	int count = 0;
	for (int i = 0; i < a; i++) {
		int temp;
		cin >> temp;

		if (temp <= min) {
			count++;
			min = temp;
		}
	}

	cout << count;


}





Measured memory_bytes: 256
#include <stdio.h>

#define SOUTH 0
#define EAST  1

int town_map[1001][1001];
int table1[1001][1001];
int table2[1001][1001];

int calc_times(int table[1001][1001], int i, int j) {
    int ret = 0;

    if (i > 0) {
        if (town_map[i-1][j] == SOUTH) {
            ret += (table[i-1][j]+1)/2;
        } else if (town_map[i-1][j] == EAST) {
            ret += table[i-1][j]/2;
        }
    }

    if (j > 0) {
        if (town_map[i][j-1] == EAST) {
            ret += (table[i][j-1]+1)/2;
        } else if (town_map[i][j-1] == SOUTH) {
            ret += table[i][j-1]/2;
        }
    }

    return ret;
}

int main() {
    while (1) {
        int i;
        int h, w, n;
        int now_x = 0;
        int now_y = 0;
        scanf("%d %d %d", &h, &w, &n);
        if (h == 0) return 0;
    
        for (i=0;i<h+1;i++) {
            int j;
            for (j=0;j<w+1;j++) {
                table1[i][j] = 0;
                table2[i][j] = 0;
                town_map[i][j] = -1;
            }
        }

        for (i=0;i<h;i++) {
            int j;
            for (j=0;j<w;j++) {
                scanf("%d", &town_map[i][j]);
            }
        }

        table1[0][0] = n-1;
        table2[0][0] = n;
    
        for (i=0;i<h+1;i++) {
            int j;
            for (j=0;j<w+1;j++) {
                table1[i][j] += calc_times(table1, i, j);
                table2[i][j] += calc_times(table2, i, j);
            }
        }
    
        for (i=0;i<h+1;i++) {
            if (table1[i][w] != table2[i][w]) printf("%d %d\n", i+1, w+1);
        }
    
        for (i=0;i<w;i++) {
            if (table1[h][i] != table2[h][i]) printf("%d %d\n", h+1, i+1);
        }
    }
}

Measured memory_bytes: 12768
#include <iostream>
#include <algorithm>
#include <vector>
#include <memory.h>

using namespace std;

int N, M;
int H[100001];

int main() {
  int ma[100001];
  cin >> N >> M;
  for (int i = 1; i <= N; i++) {
    cin >> H[i];
    ma[i] = 0;
  }
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    ma[a] = max(ma[a], H[b]);
    ma[b] = max(ma[b], H[a]);
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (H[i] > ma[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4364
N=int(input())
r=sorted([list(map(int, input().split())) for _ in range(N)], key=lambda q: q[0], reverse=True)
b=sorted([list(map(int, input().split())) for _ in range(N)], key=lambda q: q[1])
ans=0
for rx,ry in r:
	for i in range(len(b)):
		bx,by=b[i]
		if bx>rx and by>ry:
			ans+=1
			b.pop(i)
			break
print(ans)


Measured memory_bytes: 3064
n = int(input())
a, b = [], []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(x+y)
    b.append(x-y)
 
a.sort()
b.sort()
 
ans = max(a[-1]-a[0], b[-1]-b[0])
print(ans)

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))


void solve(){
    string s1,s2;cin>>s1>>s2;
    if(s1.length()!=s2.length()){
        if(s1.length()>s2.length())cout<<"GREATER";
        else cout<<"LESS";
    }
    else{
        bool check=false;
        rep(i,0,s1.length()){

            if((s1[i]-'0')>(s2[i]-'0')){
                cout<<"GREATER";
                check=true;
                break;
            }
            if((s1[i]-'0')<(s2[i]-'0')){
                cout<<"LESS";
                check=true;
                break;
            }
        }
        if(!check)cout<<"EQUAL";
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
array = list(map(int, input().strip().split()))
l = len(array)
list = []
if(l==4):
	ac=array[0]*array[2]
	ad=array[0]*array[3]
	bc=array[1]*array[2]
	bd=array[1]*array[3]

	list.append(ac)
	list.append(ad)
	list.append(bc)
	list.append(bd)

	print(max(list))

else:
  print("")
  
  
  

Measured memory_bytes: 8984
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define int long long int
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;

int n, m;
int a[200010], b[200010], c[200010];
int ans = -1;
VP node[100010];

priority_queue<PII, VP, greater<PII> > q;
int visited[100010];

void dijk()
{
  memset(visited, -1, sizeof visited);
  q.push(MP(0, 1));

  while(!q.empty()){
    PII now = q.top();
    q.pop();
    if(now.S == n){
      ans = max(ans, now.F);
    }
    else if(visited[now.S] == -1){
      visited[now.S] = now.F;

      for(int i = 0; i < node[now.S].size(); i++){
	if(node[now.S][i].F >= now.F){
	  q.push(node[now.S][i]);
	}
      }
    }
  }  
}

signed main()
{
  scanf("%lld%lld", &n, &m);
  for(int i = 0; i < m; i++){
    scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
    
    node[a[i]].PB(MP(c[i], b[i]));
  }
  
  dijk();

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 17748
#include <bits/stdc++.h>
using namespace std;
#define amod 998244353
#define mod 1e9 + 7
#define ll long long

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

  int x, n, a;
  cin >> x >> n;
  set<int> s;

  for (int i = 0; i < n; i++)
  {
    cin >> a;
    s.insert(a);
  }

  a = 0;

  while (true)
  {

    if (!s.count(x - a))
    {
      cout << (x - a) << "\n";
      break;
    }
    else if (!s.count(x + a))
    {
      cout << (x + a) << "\n";
      break;
    }

    a++;
  }

  return 0;
}


Measured memory_bytes: 3640
<?php

$target_count = intval(trim(fgets(STDIN)));

$target_arr = trim(fgets(STDIN));
$count = 0;
for ($i = 1; $i < $target_count;) {
    $prev = $target_arr[$i-1];
    if ($prev != $target_arr[$i]) {
        $count++;
        $i += 2;
    } else {
        $i++;
    }
}

echo $count."\n";


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

using namespace std;

using ll = long long;

using P = complex<long double>;

const long double EPS = 1e-10;
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

//内積
long double dot(P a, P b) {
    return a.real() * b.real() + a.imag() * b.imag();
}

//外積
long double cross(P a, P b) {
    return a.real() * b.imag() - a.imag() * b.real();
}

//直線a1,a2と直線b1,b2の交点計算
P intersection_l(P a1, P a2, P b1, P b2) {
    P a = a2 - a1;
    P b = b2 - b1;
    return a1 + a * cross(b, b1 - a1) / cross(b, a);
}

const long double pi = 3.14159265358979;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> v;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        v.emplace_back(x, y);
    }

    if (n == 2) {
        cout << fixed << setprecision(15) << abs(v[0] - v[1]) / 2 << "\n";
        return 0;
    }

    long double ans = 1e18;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            P mid1 = (v[i] + v[j]) / (long double)2.0;
            P hoge1 = mid1 + (v[i] - v[j]) * polar((long double)1.0, pi / 2);
            for (int k = 0; k < j; ++k) {
                P mid2 = (v[i] + v[k]) / (long double)2.0;
                P hoge2 = mid2 + (v[i] - v[k]) * polar((long double)1.0, pi / 2);
                P tar = intersection_l(mid1, hoge1, mid2, hoge2);
                long double r = abs(tar - v[i]);
                // cerr << r << " " << abs(tar - v[j]) << " " << abs(tar - v[k]) << endl;

                long double maxv = 0;
                for (int l = 0; l < n; ++l) {
                    maxv = max(maxv, abs(v[l] - tar));
                }
                if (maxv > r + EPS) continue;
                ans = min(ans, r);
            }

            P tar = mid1;
            long double r = abs(tar - v[i]);
            long double maxv = 0;
            for (int l = 0; l < n; ++l) {
                maxv = max(maxv, abs(v[l] - tar));
            }
            if (maxv > r + EPS) continue;
            ans = min(ans, r);            
        }
    }
    cout << fixed << setprecision(20) << ans << "\n";
    return 0;
}

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

int main(){
  int n,k,count=0;
  cin >> n >> k;
  vector<int> v(n,0);
  r(i,n){
    cin >> v.at(i);
    count+=min(v.at(i),k-v.at(i));
  }
  cout << 2*count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long long int n, m;
	cin >> n >> m;
	
	if( n == 1 and m == 1 )
		cout << 1;
	else if( n == 1 and m > 1 )
		cout << m-2;
	else if( n > 1 and m == 1 )
		cout << n-2;
	else if( n == 2 or m == 2 )
		cout << 0;
	else
		cout << (n-2)*(m-2);
}

Measured memory_bytes: 3552
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >>c;
    if(a < c && c < b){
        cout << "Yes" << endl;
    }else if(a > c && c > b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer n = scan.nextInt();
        Integer k = scan.nextInt();
        Long array[] = new Long[n];
        
        for(int i=0;i<n;i++)
            array[i] = scan.nextLong();
        Arrays.sort(array,Collections.reverseOrder());

        //for(long i : array)
          //  System.out.println(i);

        long count = 0;
        for(int i=0;i<n;i++){
            if(k > 0){
                k--;
            }else{
                count += array[i];
            }
        }

        System.out.println(count);
    }

    static int factorial(int n){
        if(n == 0){
          return 1;
        }
        return n * factorial(n-1);
      }
}

Measured memory_bytes: 98128
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second

typedef long long int lli;
typedef pair<int,int> P;

const int INF=1<<30;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	while(cin >> N&&N){
		vector<vector<int> > schedule(31);
		REP(i,0,N){
			int F;
			cin >> F;
			REP(j,0,F){
				int a;
				cin >> a;
				schedule[a].push_back(i);
			}
		}
		vector<vector<int> > dp[31];
		REP(day,0,31){
			dp[day].resize(N);
			REP(person,0,N) dp[day][person].push_back(person);
		}
		int ans=-1;
		REP(day,1,31){
			REP(person,0,N) dp[day][person]=dp[day-1][person];
			for(const int &x:schedule[day]){
				for(const int &y:schedule[day]){
					for(const int&z:dp[day][y]){
						bool flag=true;
						for(const int &w:dp[day][x]){
							if(z==w){
								flag=false;
								break;
							}
						}
						if(flag) dp[day][x].push_back(z);
					}
				}
			}
			REP(person,0,N) if(dp[day][person].size()==N){
				ans=day;
				break;
			}
			if(ans!=-1) break;
		}
		/*
		REP(i,0,N){
			REP(j,0,dp[3][i].size()) cout << dp[3][i][j] << ' ';
			cout << endl;
		}
		*/
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1588
#include <iostream>
#include <utility>
using namespace std;
int main()
{
    long long N, M, count;
    cin >> N >> M;
    if (N > M) swap(N, M);
    if (N == 1) {
        if (M == 1) count = 1;
        else count = M - 2;
    } else {
        count = (N-2) * (M-2);
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

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

        for (int j = 0; j < a[i]; j++) {
            int xi, yi;
            cin >> xi >> yi;
            x[i].push_back(xi - 1);
            y[i].push_back(yi);
        }
    }

    int res = 0;
    for (int i = 0; i < (1 << n); i++) {
        int r = 0;
        bool valid = true;
        for (int j = 0; j < n; j++) {
            if ((i & (1 << j)) > 0) {
                r++;

                for (int k = 0; k < a[j]; k++) {
                    if (((i & (1 << x[j][k])) == 0 && y[j][k] == 1)
                            || ((i & (1 << x[j][k])) > 0 && y[j][k] == 0)) {
                        valid = false;
                    }
                }
            }
        }

        if (valid && res < r) {
            res = r;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
n=int(input())
alist=[]
blist=[]
for i in range(n):
    a, b = map(int,input().split())
    alist.append(a)
    blist.append(b)

alist=sorted(alist)
blist=sorted(blist)

if n%2==1:
    center=(n-1)//2
    answer=blist[center]-alist[center]+1
    print(answer)
else:
    #print(alist, blist)
    mae=(alist[(n//2)-1]+alist[(n//2)])/2
    ato=(blist[(n//2)-1]+blist[(n//2)])/2
    #print(mae, ato)
    print(int((ato-mae)*2+1))

Measured memory_bytes: 102104
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};
int N;

double memo[310][310][310];
double solve(int x, int y, int z){
  if(memo[x][y][z] != -1) return memo[x][y][z];
  double res = 0;
  double exp_num = 1.0 * N / (x+y+z);
  if(x != 0) res += (solve(x-1, y, z) + exp_num) * x / (x+y+z);
  if(y != 0) res += (solve(x+1, y-1, z) + exp_num) * y / (x+y+z);
  if(z != 0) res += (solve(x, y+1, z-1) + exp_num) * z / (x+y+z);
  return memo[x][y][z] = res;
}

int main(void){
  cin >> N;
  int a = 0, b = 0, c = 0;
  for(int i = 0; i < N; i++){
    int A; cin >> A;
    if(A == 1) a++;
    if(A == 2) b++;
    if(A == 3) c++;
  }
  for(int i = 0; i < 310; i++){
    for(int j = 0; j < 310; j++){
      for(int k = 0; k < 310; k++){
        memo[i][j][k] = -1;
      }
    }
  }
  memo[0][0][0] = 0;
  cout << fixed << setprecision(10) << solve(a, b, c) << endl;

}


Measured memory_bytes: 233088
n = int(input())

min_cnt = float('inf')
for i in range(0, n+1, 9):
    cnt = 0
    t = i
    while t >= 9:
        cnt += t % 9
        t //= 9
    cnt += t

    t = (n-i)
    while t >= 1:
        cnt += t % 6
        t //= 6
    cnt += t

    if cnt < min_cnt:
        min_cnt = cnt
print(min_cnt)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long

int main() {
  double a,b;
  cin >>a>>b;

  cout << a/b << endl;
  
}

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

    //入力部
    int n;
    int a[100];
    cin >> n;
    for(int i=0;i<n;i++)cin >> a[i];

    //計算部
    sort(a,a+n); //ソート関数でソートします(今回の配列長ならバブルソートでも可)
    reverse(a,a+n);// 昇順から降順に反転
    int even = 0, odd = 0; //偶数、奇数それぞれの要素の総和を格納する変数を用意
    for(int i=0;i<n;i++){
        if(i%2) odd += a[i]; // 奇数個目の要素なら
        else even += a[i]; // 偶数個目の要素なら
    }

    //出力部
    cout << even-odd << endl;
    return 0;
}

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

int main(int argc, char *argv[])
{
    int m1, d1, m2, d2;
    int ans = 0;

    std::cin >> m1 >> d1;
    std::cin >> m2 >> d2;

    if (m1 != m2) {ans = 1;}

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] t = new int[n];
        int[] x = new int[n];
        int[] y = new int[n];

        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        int sx = 0;
        int sy = 0;
        int prev_t = 0;
        boolean possible = true;
        for (int i = 0; i < n; i++) {
            int gx = x[i];
            int gy = y[i];
            int cur_t = t[i] - prev_t;
            int man_dist = Math.abs(sx - gx) + Math.abs(sy - gy);
            if ((man_dist > cur_t) || (man_dist % 2 != cur_t % 2)) {
                possible = false;
                break;
            }

            sx = gx;
            sy = gy;
            prev_t = t[i];
        }

        System.out.println((possible)? "Yes": "No");
    }
}

Measured memory_bytes: 91320
public class Main {

  private static void solve() {

    char[] s = ns();
    int n = s.length;
    for (int i = 0; i < n; i++) {
      s[i] -= '0';
    }

    long[][] dp = new long[n + 1][2];
    dp[0][1] = 1;

    for (int i = 0; i < n; i++) {
      dp[i + 1][0] = Math.min(dp[i][0] + s[i], dp[i][1] + (10 - s[i]));
      dp[i + 1][1] = Math.min(dp[i][0] + s[i] + 1, dp[i][1] + (9 - s[i]));
    }
    System.out.println(dp[n][0]);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 73156
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

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

  if (n == 0) {
    cout << '0' << endl;
    return 0;
  }

  string res = "";
  while (n != 0) {
    if (n % -2 == 0) res = '0' + res;
    else {
      res = '1' + res;
      --n;
    }
    n /= -2;
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    String a=sc.nextLine();
    double i=Double.parseDouble(a);
    int sum=0;
    for(double j=1;j<=3;j++){
      sum+=(int) Math.pow(i,j);
    }
    System.out.println(sum);
  }
}

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

int main(){
  long k;  cin >> k;
  if(k%2==0 || k%5==0){
    cout << "-1\n";
    return 0;
  }

  long sevens = 7, ans = 1;
  while(sevens % k != 0){
    sevens = (sevens * 10 + 7) % k;
    ans++;
  }
  
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int x=sc.nextInt();
		int[] a = new int[N];
		for(int i=0; i<N; i++){
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);

		int k=0;
		int i=0;
		

		while(i<N){
			x-=a[i];
			i++;
			k++;
			if(x<0){
				k--;
				break;
			}
		}
		if(i==N && x>0) k--;

		System.out.println(k);
	}
}


Measured memory_bytes: 22100
#include <stdio.h>

int main(void)
{
    int h, w;
    int i, j;
    int row;

    while (1){
        row = 1;
        scanf("%d %d", &h, &w);
        /*w = h = 0 のとき終了*/
        if (h == 0 && w == 0){
            break;
        /*w が偶数のとき*/
        }else if (w % 2 == 0){
            /*列ごと*/
            for (i = 1; i <= h; i++){
                /*奇数列目*/
                if (row % 2 == 1){
                    for (j = 1; j <= (w / 2); j++){
                        printf("#.");
                    }
                /*偶数列目*/
                }else{
                    for (j = 1; j <= (w / 2); j++){
                        printf(".#");
                    }
                }
                printf("\n");
                row++;
            }
        /*w が奇数のとき*/
        }else{
            /*列ごと*/
            for (i = 1; i <= h; i++){
                /*奇数列目*/
                if (row % 2 == 1){
                    for (j = 1; j <= ((w - 1) / 2); j++){
                        printf("#.");
                    }
                    printf("#");
                /*偶数列目*/
                }else{
                    for (j = 1; j <= ((w - 1) / 2); j++){
                        printf(".#");
                    }
                    printf(".");
                }
                printf("\n");
                row++;
            }
        }
        
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 588
def abc175a_rainy_season():
    s = input()
    if s.count('RRR') != 0:
        print(3)
    elif s.count('RR') != 0:
        print(2)
    elif s.count('R') != 0:
        print(1)
    else:
        print(0)


abc175a_rainy_season()

Measured memory_bytes: 9092
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}
int main(){
    ll N;
    cin>>N;
    ll N2 = N;
    ll sn = 0;
    rep(i,0,11){
        sn += N%10;
        N/=10;
    }
    YN(N2%sn == 0);
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> V(N);
	for (int i = 0; i < N; i++) {
		char a;
		int b;
		cin >> a >> b;
		if (a == 'S')
			b += 100;
		if (a == 'H')
			b += 200;
		if (a == 'C')
			b += 300;
		if (a == 'D')
			b += 400;
		V[i] = b;
	}

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

	for (int j = 1; j <= 4; j++){
		for (int i = 1; i <= 13; i++) {
			if (V[13 * j - 14 + i] != j * 100 + i) {
				char c;
				if (j == 1)
					c = 'S';
				if (j == 2)
					c = 'H';
				if (j == 3)
					c = 'C';
				if (j == 4)
					c = 'D';
				cout << c << " " << i << endl;
				V.insert(V.begin() + (13 * j - 13), 0);
			}
		}
	}
}



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

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

    vector<int> a(n);
    for (int &x : a) cin >> x;
    
    double res = 0;
    for (int x : a) res += 1.0 / x;
    
    cout << 1.0 / res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a;
	int R;
	scanf("%d",&a);
	while(a!=-1){
		R=1150;
		if(20<=a){
			R+=1250;
		} else if(10<=a){
			R+=(a-10)*125;
		}
		if(a>=30){
			R+=1400;
			R+=(a-30)*160;
		} else if(20<=a){
			R+=(a-20)*140;
		}
		printf("%d\n",4280-R);
		scanf("%d",&a);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
 
int main(){

	int a,b;
    cin >> a >> b;
    if(a==b){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

const int kN = 2e5+7;

int n;
long long res;
int a[kN], b[kN];

int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
        if (b[i] < a[i]) {
            cout << "-1" << endl;
            return 0;
        }
    }
    int flag = 1;
    while (flag) {
        flag = 0;
        for (int i = 0; i < n; ++i) {
            int bt = b[(i-1+n)%n]+b[(i+1)%n];
            if (b[i]-bt >= a[i]) {
                int k = (b[i]-a[i])/bt;
                res += k;
                b[i] -= k*bt;
                flag = 1;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        if (a[i] != b[i]) {
            cout << "-1" << endl;
            return 0;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
# include <iostream>


template <typename integer>
integer _gcd(integer a, integer b) {
    if (b != 0) return _gcd(b, a%b);
    else return a;
}

template <typename integer>
integer gcd (integer a, integer b) {
    if (a > b) return _gcd(a, b);
    return _gcd(b, a);
}


template<typename integer>
integer lcm(integer a, integer b) {
    return (a * b) / gcd(a, b);
}


using namespace std;


int main () {
    long long a, b, c, d; cin >> a >> b >> c >> d;

    long long na = a - ((a/c) + (a/d) - (a/lcm(c, d)));
    long long nb = b - ((b/c) + (b/d) - (b/lcm(c, d)));

    long long ans = nb - na;
    if (a % c != 0 and a % d != 0) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
bool search(int A[],int x,int n){
	int i=0;
	A[n]=x;
	while(A[i]!=x){
		i++;
		if(i==n){
			return 0;
		}
	}
		return 1;
}
	
			
int main(){
	int n,q;
	int S[100000],T[10000];
	int cnt=0;
	
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>S[i];
	}
	std::cin>>q;
	for(int i=0;i<q;i++){
		std::cin>>T[i];
	}
	for(int i=0;i<q;i++){
		if(search(S,T[i],n)){
			cnt++;
		}
	}
	std::cout<<cnt<<"\n";
}


Measured memory_bytes: 3092
# coding: utf-8
# Your code here!

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)

s = list(input().upper())
for i in range(1, 27):
    if num2alpha(i) in s:
        continue
    else:
        print(num2alpha(i).lower())
        break
else:
    print("None")

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll powmod(ll a, ll b) {
	a %= MOD;
	ll res = 1;
	while (b > 0) {
		if (b % 2 == 1)res = res * a % MOD;
		a = a * a % MOD;
		b /= 2;
	}
	return res;
}

ll f[210000];
void cominit() {
	f[0] = 1;
	REP(i, 200000)f[i + 1] = f[i] * (i + 1) % MOD;
}

ll com(ll n, ll r) {
	if (n < r)return 0;
	return f[n] * powmod(f[r] * f[n - r], MOD - 2) % MOD;
}

ll perm(ll n, ll r) {
	return f[n] * powmod(f[n - r], MOD - 2) % MOD;
}
int main() {
	cominit();
	ll n, k;
	cin >> n >> k;
	REPO(i, k) {
		cout << com(n - k + 1, i) * com(k - 1, i - 1) % MOD << endl;
	}
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	string s;
	cin>>s;
	if((s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]) || (s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]) || (s[0]==s[3] && s[1]==s[2] && s[0]!=s[1]))
	{
		cout<<"Yes";
	}
	else 
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	static int change = 0;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		StringBuilder sb = new StringBuilder();
		
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if (b * 2 > a) {
			System.out.println("0");
		} else {
			System.out.println(a - b * 2);
		}
	}

}


Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        long A = cin.nextlong;
        var B = cin.nextlong;
        var C = cin.nextlong;

        if (C <= A)
        {
            WriteLine(C + B);
        }
        else
        {
            var ans = A;
            C -= A;
            if (C <= B)
            {
                WriteLine(ans + C + B);
            }
            else
            {
                WriteLine(ans + 2 * B + 1);
            }
        }
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 11220
#include <iostream>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
using namespace std;

int main(){
    long long n, a, b;
    cin >> n >> a >> b;
    if(b < a) swap(a, b);
    if((b - a) % 2 == 0){
        cout << ((b-a)/2) << '\n';
    } else {
        cout << min(
            min(
                b-1,
                n-a
               ),
            min(
                a + (b-a-1)/2,
                (n-b) + (b-a+1)/2
               )
            ) << '\n';
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b=0;
  string s;
  cin>>s;
  for(int i=0;i<3;i++){
    if(s[i]==s[i+1]) b=1;
  }
  if(b!=1) cout<<"Good\n";
  else cout<<"Bad\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>

using namespace std;


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

	double a, b, c;
	a = L / 3.0;
	b = a;
	c = L - (2 * a);

	printf("%.6f",a*b*c);
	return 0;
}

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

int main(void){

    int n,m,M,i;
    long long int s;  
    scanf("%d", &n);
    int a[n];

    for(i=0;i<n;i++){
        scanf("%d", &a[i]);
       // printf("%d\n",a[i]);
        if(i==0){
            m=a[0];
            M=a[0];
            s=a[0];
        }else{
            s=s+a[i];
            if(m>a[i]) m=a[i];
            if(M<a[i]) M=a[i];
        }
    }

    printf("%d %d %lld\n",m,M,s);

    return 0;
}



Measured memory_bytes: 2100
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int a = s.nextInt();
    int b = s.nextInt();
    int c = s.nextInt();
    int divisors = 0;
    for (int i = a; i <= b; i++) {
      if (c % i == 0)
        divisors++;
    }
    System.out.println(divisors);
  }
}



Measured memory_bytes: 26328
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;

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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll h, w;
	cin >> h >> w;
	Matrix a(h, Array(w, 0)), b(h, Array(w, 0));
	REP(i, h) REP(j, w) cin >> a[i][j];
	REP(i, h) REP(j, w) cin >> b[i][j];

	vector<vector<bitset<40000>>> dp(h, vector<bitset<40000>>(w, bitset<40000>(0)));

	dp[0][0] |= (bitset<40000>(1) << (20000 + a[0][0] - b[0][0]));
	dp[0][0] |= (bitset<40000>(1) << (20000 - a[0][0] + b[0][0]));

	REP(i, h) {
		REP(j, w) {
			if (i + 1 < h) {
				dp[i + 1][j] |= (dp[i][j] << abs(a[i + 1][j] - b[i + 1][j]));
				dp[i + 1][j] |= (dp[i][j] >> abs(a[i + 1][j] - b[i + 1][j]));
			}
			if (j + 1 < w) {
				dp[i][j + 1] |= (dp[i][j] << abs(a[i][j + 1] - b[i][j + 1]));
				dp[i][j + 1] |= (dp[i][j] >> abs(a[i][j+1] - b[i][j+1]));
			}
		}
	}

	ll ans = INF;
	REP(i, 39999) {
		if ((dp[h - 1][w - 1] & (bitset<40000>(1) << i)) != 0) {
			chmin(ans, abs(20000 - i));
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 33784
n = int(input())
XL = [[int(x) for x in input().split()] for _ in range(n)]
XL.sort(key=lambda xl: xl[0] + xl[1])
count = 0
while len(XL) > 0:
    count += 1
    limit = XL[0][0] + XL[0][1]
    while len(XL) > 0 and XL[0][0] - XL[0][1] < limit:
        XL.pop(0)
print(count)


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

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

	string A,B ,C ;
	cin >> A;
	cin >> B;
	cin >> C;
	
	int count = 0;
	for(int i=0; i< N; i++) {
		if (A[i] == B[i]) {
			if(A[i] == C[i]) {
			continue;
			} else {  // A != C
				C[i] = A[i];
				count++;
			}
		} else if (A[i] == C[i]) {  // A != B, A == C
			B[i] = A[i];
			count++;
		} else if (B[i] == C[i]) {
			A[i] = B[i];
			count++;
		} else {  //  // A != B, A != C, B != C
			count += 2;
		}
	}	
		
	cout << count;

}


Measured memory_bytes: 256
// this program implements Dinitz's algorithm

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

const int N = 110;
const int M = 2010;

struct Edge {
	int to, cap, next;
} es[M];

int S, T;  // source, sink
int SIZE = 0; // number of edges
int h[N]; // pointer to edge list
int dist[N], queue[N]; // for calculating shortest path

// add forward and backtracked edge
void add(int u, int v, int cap) {
	int i = SIZE++;
	es[i].to = v;
	es[i].cap = cap;
	es[i].next = h[u];
	h[u] = i; 
	int j = SIZE++;
	es[j].to = u;
	es[j].cap = 0;
	es[j].next = h[v];
	h[v] = j; 
}

// returns whether find a path from S to T
bool bfs() {
	int front = 0, back = 0;
	memset(dist, -1, sizeof(dist));
	queue[back++] = S;
	dist[S] = 0;
	while (front < back) {
		int x = queue[front++];
		for (int i = h[x]; i != -1; i = es[i].next)
			if (es[i].cap > 0) {
				int y = es[i].to;
				if (dist[y] == -1) {
					dist[y] = dist[x] + 1;
					queue[back++] = y;
				}
			}
		if (dist[T] != -1)
			return true;
	}
	return false;
}

// returns the flow pushed from x to T
int dfs(int x, int flow) {
	if (x == T) return flow;
	int dy = dist[x] + 1, ret = 0;
	for (int i = h[x]; i != -1 && flow > 0; i = es[i].next) {
		int y = es[i].to;
		if (dist[y] != dy) continue;
		int f = dfs(y, std::min(flow, es[i].cap));
		if (f != 0) {
			es[i].cap -= f;
			es[i^1].cap += f;
			ret += f;
			flow -= f;
		}
	}
	if (flow > 0)
		dist[x] = -1;
	return ret;
}

void run() {
	int n, m, u, v, c;
	scanf("%d%d", &n, &m);
	memset(h, -1, sizeof(h));
	S = 0, T = n - 1;
	for (int i = 0; i < m; i++) {
		scanf("%d%d%d", &u, &v, &c);
		add(u, v, c);
	}
	int flow = 0;
	while (bfs())
		flow += dfs(S, 0x3fffffff);
	printf("%d\n", flow);
}

int main() {
	run();
}

Measured memory_bytes: 2760
#include <iostream>
#include <fstream>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <iterator>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=1e5+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

ll ds[N],dt[N],ans[N];

vector<pair<int,pii> >g[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m,s,t;
    cin>>n>>m>>s>>t;
    while(m--){
        int u,v,a,b;
        cin>>u>>v>>a>>b;
        g[u].push_back({v,{a,b}});
        g[v].push_back({u,{a,b}});
    }
    for(int i=1;i<=n;i++){
        ds[i]=INF;
        dt[i]=INF;
    }
    queue<int>q;
    q.push(s);
    ds[s]=0;
    while(!q.empty()){
        int v=q.front();
        q.pop();
        for(int i=0;i<g[v].size();i++){
            int to=g[v][i].x;
            int len=g[v][i].y.x;
            if(ds[to]>ds[v]+len){
                ds[to]=ds[v]+len;
                q.push(to);
            }
        }
    }
    q.push(t);
    dt[t]=0;
    while(!q.empty()){
        int v=q.front();
        q.pop();
        for(int i=0;i<g[v].size();i++){
            int to=g[v][i].x;
            int len=g[v][i].y.y;
            if(dt[to]>dt[v]+len){
                dt[to]=dt[v]+len;
                q.push(to);
            }
        }
    }
    ans[n]=ds[n]+dt[n];
    for(int i=n-1;i;i--){
        ans[i]=min(ans[i+1],ds[i]+dt[i]);
    }
    for(int i=1;i<=n;i++){
        cout<<(ll)1e15-ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 1e18+7;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main(){
  cout<<fixed<<setprecision(20);
  cin.tie(0);ios::sync_with_stdio(false);
  string s;
  int q;
  cin>>s>>q;
  int t,f;
  int flag=1;
  char c;
  deque<char> ans;
  rep(i,s.size()){
    ans.push_back(s[i]);
  }
  rep(i,q){
    cin>>t;
    if(t==1){
      flag^=1;
    }else{
      cin>>f>>c;
      f--;
      if(flag^f){
        ans.push_front(c);
      }else{
        ans.push_back(c);
      }
    }
  }
  int n=ans.size();
  if(flag){
    rep(i,n){
      cout<<ans[i];
    }
  }else{
    repr(i,n){
      cout<<ans[i];
    }
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 976