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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

int r, c, n, ck1, ck2;

vector<ii> vec[4];

bool cmp(const ii &a, const ii &b){
    return a.fi > b.fi;
}

stack<int> st;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> r >> c >> n;
    for(int i = 1; i <= n; i++){
        int x1, y1, x2, y2;
        ck1 = 0, ck2 = 0;
        cin >> x1 >> y1 >> x2 >> y2;
        if(x1 == 0 || x1 == r)
            ck1 = 1;
        if(y1 == 0 || y1 == c)
            ck1 = 1;
        if(x2 == 0 || x2 == r)
            ck2 = 1;
        if(y2 == 0 || y2 == c)
            ck2 = 1;
        if(ck1 && ck2){
            ck1 = 0, ck2 = 0;
            if(x1 == 0 || x1 == r){
                if(x1 == 0)
                    vec[0].pb({y1, i});
                else
                    vec[2].pb({y1, i});
                ck1 = 1;
            }
            if(ck1 == 0 && (y1 == 0 || y1 == c)){
                if(y1 == 0)
                    vec[3].pb({x1, i});
                else
                    vec[1].pb({x1, i});
            }
            if(x2 == 0 || x2 == r){
                if(x2 == 0)
                    vec[0].pb({y2, i});
                else
                    vec[2].pb({y2, i});
                ck2 = 1;
            }
            if(ck2 == 0 && (y2 == 0 || y2 == c)){
                if(y2 == 0)
                    vec[3].pb({x2, i});
                else
                    vec[1].pb({x2, i});
            }
        }
    }
    sort(vec[0].begin(), vec[0].end()); sort(vec[1].begin(), vec[1].end()); sort(vec[2].begin(), vec[2].end(), cmp); sort(vec[3].begin(), vec[3].end(), cmp);
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < vec[i].size(); j++){
                if(!st.empty() && vec[i][j].se == st.top())
                    st.pop();
                else
                    st.push(vec[i][j].se);
        }
    }
    if(st.size() != 0)
        cout << "NO\n";
    else
        cout << "YES\n";
}


Measured memory_bytes: 2536
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

constexpr LL INF = 1e13;

int main() {

    int N;
    cin >> N;

    vector<long long> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];

    vector<long long> dp(N, INF);
    dp[0] = 0;

    for (int i = 1; i < N; i++) {
        for (int j = 1; j <= 2; j++) {
            int f = max(0, i - j);
            dp[i] = min(dp[i], dp[f] + abs(h[f] - h[i]));
        }
    }


    cout << dp[N - 1] << endl;

    return 0;
}



























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

int main() {
        int n;
        scanf("%d", &n);
        vector<int> a;
        a.push_back(0);
        rep(i, n) {
                int b; scanf("%d", &b);
                a.push_back(b);
        }
        a.push_back(0);
        int ans = 0;
        for (int i = 1; i < n + 2; i ++) ans += abs(a[i] - a[i - 1]);
        for (int i = 1; i <= n; i ++) {
                printf("%d\n", 
                        ans
                        - abs(a[i] - a[i - 1])
                        - abs(a[i + 1] - a[i])
                        + abs(a[i + 1] - a[i - 1])
                );
        }
        return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define int long long
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 2005;
int n, dep[N];
bool a[N];
vector<int> g[N];
int sumDep[N], minSum[N], cnty[N];
typedef pair<int, int> ii;
bool cmp(ii a, ii b) {
	if (a.fi == b.fi) return a.se > b.se;
	return a.fi < b.fi;
}
void dfs(int u, int p) {
	sumDep[u] = 0, cnty[u] = 0;
	if (a[u]) cnty[u]++;
	
	vector<ii> lol;
	int sumy = 0;
	
	fa (v, g[u]) if (v != p) {
		dep[v] = dep[u] + 1;
		dfs(v, u);
		
		sumDep[v] += cnty[v];
		minSum[v] += cnty[v];
		
		sumDep[u] += sumDep[v];
		cnty[u] += cnty[v];
		
		lol.pb(ii(sumDep[v], minSum[v]));
		sumy += sumDep[v];
//		cout << "v = " << v << " sumDep = " << sumDep[v] << " minSum = " << minSum[v] << "\n";
	}
	
	sort(lol.begin(), lol.end(), cmp);
	if (lol.size()) {
		ii xd = lol.back();
		sumy -= xd.fi;
		if (sumy < xd.se) minSum[u] = xd.se - sumy;
		else minSum[u] = 0;
	} else minSum[u] = 0;
//	cout << "minSum[" << u + 1 << "] = " << minSum[u] << " sumDep = " << sumDep[u] << " dep = " << dep[u] << "\n";
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	fw (i, 0, n) {
		char c;
		cin >> c;
		a[i] = c - '0';
	}
	fw (i, 1, n) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[u].pb(v), g[v].pb(u);
	}
	int ans = inf;
	fw (u, 0, n) {
//		cout << "root = " << u << "\n";
		dep[u] = 0;
		dfs(u, -1);
		if (sumDep[u] & 1) continue;
		if (minSum[u] == 0) ans = min(ans, sumDep[u] >> 1);
	}
	if (ans == inf) cout << "-1";
	else cout << ans;
	return 0;
}

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

int max(int a,int b){
	if(a>b)return a;
	return b;
}

int min(int a,int b){
	if(a<b)return a;
	return b;
}

int compare_char(char *a,char *b){
	return strcmp(a,b);
}

int intsort(const void *a, const void *b){
	return *(int*)b - *(int*)a;
	/*qsort(a,aの配列数,sizeof(int),intsort);*/
}

int longsort(const void *a, const void *b){
	long *A=(long *)a;
	long *B=(long *)b;
	if(*A>*B) return -1;
	if(*A<*B) return 1;
	return 0;
}

int main(){
  int i,j,H,W,p,cnt=0,size,Ans=0,x;
  vector<int> map(1002001);
  queue<int> que;
  set<int> se;
  char ss[1001];
  scanf("%d",&H);
  scanf("%d",&W);
  for(i=0;i<H;i++){
    scanf("%s",ss);
    for(j=0;j<W;j++){
      if(ss[j]=='#'){
        map[i*W+j]=1;
        cnt++;
        que.push(i*W+j);
        auto check=se.insert(i*W+j);
      }else{
        map[i*W+j]=0;
      }
    }
  }
  size=H*W-1;
  while(1){
    j=que.size();
    if(j==0)break;
    for(i=0;i<j;i++){
      p=que.front();
      que.pop();
      if(p>=W){
        auto check=se.insert(p-W);
        if(check.second){
          map[p-W]=1;
          que.push(p-W);
          cnt++;
        }
      }
      if(p<=size-W){
        auto check=se.insert(p+W);
        if(check.second){
          map[p+W]=1;
          que.push(p+W);
          cnt++;
        }
      }
      x=p%W;
      if(x!=0){
        auto check=se.insert(p-1);
        if(check.second){
          map[p-1]=1;
          que.push(p-1);
          cnt++;
        }
      }
      if(x!=W-1){
        auto check=se.insert(p+1);
        if(check.second){
          map[p+1]=1;
          que.push(p+1);
          cnt++;
        }
      }
    }
    Ans++;
  }
  printf("%d\n",Ans-1);
  return 0;
}

Measured memory_bytes: 55168
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=110;

ll N,M;

bool used[MAX_N];

int main(){
  cin>>N;
  ll atmp,btmp;
  P red[N],blue[N];
  for(ll i=0;i<N;i++){
    cin>>atmp>>btmp;
    red[i].first=btmp;
    red[i].second=atmp;
  }
  sort(red,red+N,greater<>());
  ll ctmp,dtmp;
  for(ll i=0;i<N;i++){
    cin>>ctmp>>dtmp;
    blue[i].first=ctmp;
    blue[i].second=dtmp;
  }
  sort(blue,blue+N);
  ll ans=0;
  for(ll i=0;i<N;i++){
    for(ll j=0;j<N;j++){
      if(red[j].first<blue[i].second&&red[j].second<blue[i].first&&!(used[j])){
        used[j]=true;
        ans++;
        break;
      }
    }
  }

  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const int N = 26;
const int D = 365;

int d;

int c[N];
int s[D][N];

vi t;

int last[N];
int evaluate(const vi& t){
    memset(last, 0, sizeof last);
    int ret = 0;
    FOR(i,t.size()){
        ret += s[i][t[i]];
        last[t[i]] = i+1;

        FOR(j,N){
            ret -= c[j] * (i+1 - last[j]);
        }
    }
    return ret;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    cin>>d;
    FOR(i,N)cin>>c[i];
    FOR(i,d){
    	FOR(j,N){
    		cin>>s[i][j];
    	}
    }

    FOR(i,d){
        int x;
        cin>>x;
        t.pb(x-1);
    }

    int q;
    cin>>q;
    while(q--){
        int a,b;
        cin>>a>>b;
        t[a-1] = b-1;
        cout << evaluate(t) << endl;
    }

    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

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

	vector<char> S(N);
	for(int i=0; i<N; i++)
		cin >> S[i];

	if(find(S.begin(), S.end(), 'Y') != S.end())
		cout << "Four" << endl;
	else
		cout << "Three" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int A, B, ans;
    scanf("%d %d", &A, &B);
    if (A >= B + 1) {
        ans = 2 * A -1;
    } else if (A <= B - 1) {
        ans = 2 * B - 1;
    } else if (A == B) {
        ans = 2 * A;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;


int main() {
    int a,b;
    cin >> a >> b;
    if(a == b) {
        cY
    }else {
        cN
    }
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

immutable long mod = 10^^9 + 7;
immutable int inf = mod;

void main(){
    auto s = readln.split;

    auto stack = new SList!int;
    int x, y, res;

    foreach(si ; s){
        if(si == "+" || si == "-" || si == "*"){
            x = stack.front; stack.removeFront;
            y = stack.front; stack.removeFront;

            if (si == "+") {
                res = x + y;
            }
            else if (si == "-") {
                res = y - x;
            }
            else{
                res = x * y;
            }

            stack.insert(res);
        }
        else {
            stack.insert(si.to!int);
        }
    }

    int ans = stack.front;
    writeln(ans);
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 2720
def main():
	N = int(input())
	cnt = 0
	ans = "No"
	for n in range(N):
		D = list(map(int,input().split()))
		if D[0] == D[1]:
			cnt += 1
			if cnt >= 3:
				ans = "Yes"
				break
		else:
			cnt = 0
	print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
N = int(input())
s = []
t = []
for i in range (N):
  inin = input().split()
  s.append(str(inin[0]))
  t.append(int(inin[1]))
X = str(input())

k = False
Ans = 0
for i in range(N):
  if k == True:
    Ans += t[i]
  if s[i] == X:
    k = True
    
print(Ans)

Measured memory_bytes: 3064
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
// long long -> lint
using lint = long long;
// fast cin and cout from hitonanode-san's code
// w/o 71 ms -> w/ 18 ms (tested on ABC148-D with C++14(GCC 5.4.1))
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

int main(){
    // input
    int N;
    string S;
    cin >> N >> S;

    // calc
    lint ans = 0;
    int R=0, G=0, B=0;
    for( int i=0; i<N; i++ ){
        if( S[i] == 'R' ) R++;
        if( S[i] == 'G' ) G++;
        if( S[i] == 'B' ) B++;
    }

    for( int i=0; i<N; i++ ){
        if( S[i] == 'R' ) R--;
        if( S[i] == 'G' ) G--;
        if( S[i] == 'B' ) B--;
        int R2 = R;
        int G2 = G;
        int B2 = B;
        for( int j=i+1; j<N; j++ ){

            if( S[j] == 'R' ) R2--;
            if( S[j] == 'G' ) G2--;
            if( S[j] == 'B' ) B2--;
            if( S[i] == S[j] ) continue;

            if( S[i] == 'R' && S[j] == 'G' ) ans += B2;
            if( S[i] == 'R' && S[j] == 'B' ) ans += G2;
            if( S[i] == 'G' && S[j] == 'R' ) ans += B2;
            if( S[i] == 'G' && S[j] == 'B' ) ans += R2;
            if( S[i] == 'B' && S[j] == 'R' ) ans += G2;
            if( S[i] == 'B' && S[j] == 'G' ) ans += R2;

            if( 2*j-i < N ){
                if( S[2*j-i] != S[i] && S[2*j-i] != S[j] ) ans--;
            }

        }
    }

 
    // out
    cout << ans << endl;
} 

Measured memory_bytes: 3676
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <cmath>
#include <math.h>
using namespace std;

struct cubes {
  int n;
  int e;
  int w;
  int s;
  int t;
  int b;
};

void spin(cubes* cube){
  int tmp;
      tmp = cube->n;
      cube->n = cube->e;
      cube->e = cube->s;
      cube->s = cube->w;
      cube->w = tmp; 
}

void roll(cubes* cube, char dst){
  int tmp;
  switch(dst){
    case 'N' :
      tmp = cube->b;
      cube->b = cube->n;
      cube->n = cube->t;
      cube->t = cube->s;
      cube->s = tmp; 
      break;
    case 'E' :
      tmp = cube->b;
      cube->b = cube->e;
      cube->e = cube->t;
      cube->t = cube->w;
      cube->w = tmp; 
      break;
    case 'W' :
      tmp = cube->b;
      cube->b = cube->w;
      cube->w = cube->t;
      cube->t = cube->e;
      cube->e = tmp; 
      break;
    case 'S' :
      tmp = cube->b;
      cube->b = cube->s;
      cube->s = cube->t;
      cube->t = cube->n;
      cube->n = tmp; 
      break;
    default : break;
  }
}

int main(){
  cubes cube[100];
  cubes* cube1,*cube2;
  int cnt=0;
  int a,b,n;
  bool same;
  string s = "SSSSWWW";
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> cube[i].t >> cube[i].s >> cube[i].e >> cube[i].w >> cube[i].n >> cube[i].b;
  }
  same = 0;
  for(int c=0;c<n;c++){
    if(c==(n-1)) break;
    for(int c2=c+1;c2<n;c2++){  
      cube1 = &cube[c];
      cube2 = &cube[c2];
      for(int i=0;i<s.size();i++){
        roll(cube1,s[i]);
        for(int j=0;j<4;j++){
          if((cube1->t==cube2->t)&&(cube1->b==cube2->b)&&(cube1->n==cube2->n)&&(cube1->e==cube2->e)&&(cube1->w==cube2->w)&&(cube1->s==cube2->s)){
            same = 1;
          }
          spin(cube1);
        }
      }
    }
  }
  if(same==1){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}



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

int main() {
  
  char str[1024];
  char ope[256];
  char obj[1024];
  int q;
  int a, b;
  char temp;

  scanf("%s", str);
  scanf("%d", &q);

  for(int i = 0; i < q; ++i) {
    scanf("%s", ope);
    if( strcmp("replace", ope) == 0 ) {
      scanf("%d %d", &a, &b);
      scanf("%s", obj);
      for(int j = a; j <= b; ++j) {
	str[j] = obj[j-a];
      }
    }
    else if( strcmp("reverse", ope) == 0 ) {
      scanf("%d %d", &a, &b);
      for(int j = a; j <= (a+b)/2; ++j) {
	temp = str[j]; str[j] = str[a+b-j]; str[a+b-j] = temp;
      }
    }
    else if( strcmp("print", ope) == 0 ) {
      scanf("%d %d", &a, &b);
      for(int j = a; j <= b; ++j) {
	printf("%c", str[j]);
      }
      printf("\n");
    }
    else {
      printf("nya------\n");
    }
      
  }
  
  return 0;
}

Measured memory_bytes: 1156
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
#define lson(x) (x << 1)
#define rson(x) (x << 1 | 1)
using namespace std;
const int MAXN = 1e6 + 10;
typedef long long ll;

int n, cnt = 0;

struct point { //点的基本数据结构
    int x, y;
    friend istream& operator>>(istream& in, point& a)
    {
        in >> a.x >> a.y;
        return in;
    }
};
struct Line {
    point a, b;
    int mark;
    Line() {}
    Line(point _a, point _b, int _mark)
    {
        a = _a, b = _b, mark = _mark;
    }
    bool operator<(const Line& p)
    {
        if (a.y != p.a.y)
            return a.y < p.a.y;
        return mark != p.mark ? mark < p.mark : a.x < p.a.x;
    }
};

struct SegTree {
    int l, r;
    ll len;
    //  sum: 被完全覆盖的次数；
    //  len: 区间内被截的长度。
} tree[MAXN << 2];

void build_tree(int x, int l, int r)
{
    tree[x].l = l, tree[x].r = r;
    tree[x].len = 0;
    if (l == r)
        return;
    int mid = (l + r) >> 1;
    build_tree(lson(x), l, mid);
    build_tree(rson(x), mid + 1, r);
    return;
}

void pushup(int x)
{
    tree[x].len = tree[x << 1].len + tree[x << 1 | 1].len;
    //      合并儿子信息
}

void edit_tree(int x, ll id, int c)
{
    int l = tree[x].l, r = tree[x].r;
    if (l == id && id == r) {
        tree[x].len += c;
        return;
    }
    int mid = (l + r) >> 1;
    if (id <= mid)
        edit_tree(lson(x), id, c);
    else
        edit_tree(rson(x), id, c);
    pushup(x);
}

int query(int x, int L, int R)
{
    int l = tree[x].l, r = tree[x].r;
    if (L <= l && r <= R)
        return tree[x].len;
    int mid = (l + r) >> 1;
    int res = 0;
    if (L <= mid)
        res += query(lson(x), L, R);
    if (R > mid)
        res += query(rson(x), L, R);
    return res;
}
vector<Line> l;
vector<int> X;
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        point a, b;
        cin >> a >> b;
        if (a.x != b.x) {
            if (a.x > b.x)
                swap(a, b);
            X.push_back(a.x), X.push_back(b.x);
            l.push_back(Line(a, b, 2));
        } else {
            if (a.y > b.y)
                swap(a, b);
            X.push_back(a.x);
            l.push_back(Line(a, a, 1));
            l.push_back(Line(b, b, 3));
        }
    }
    
    sort(l.begin(), l.end());
    sort(X.begin(), X.end());

    n = unique(X.begin(), X.end()) - X.begin(); //去重
    X.erase(X.begin() + n, X.end());
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    build_tree(1, 1, n); //根据X[]的坐标建立线段树

    int ans = 0;
    for (int i = 0; i < l.size(); i++) {
        if (l[i].mark!=2) {
            int id = lower_bound(X.begin(), X.end(), l[i].a.x) - X.begin();
            int c = l[i].mark == 3 ? -1 : 1;
            edit_tree(1, id+1, c);
        } else {
            int id1 = lower_bound(X.begin(), X.end(), l[i].a.x) - X.begin();
            int id2 = lower_bound(X.begin(), X.end(), l[i].b.x) - X.begin();
            ans += query(1, id1+1, id2+1);
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 10292
//
//  homework.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;


int main(int argc, const char* argv[]) {

  int n, m;
  std::cin >> n >> m;
  int a[m];
  int assignment_day = 0;
  for (int i = 0; i < m ; i++) {
    std::cin >> a[i];
    assignment_day += a[i];
  }
  if (n>=assignment_day) {
    std::cout << n-assignment_day << std::endl;
  }
  else {
    std::cout << -1 << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll ans = 0, tmp = 0;
    rep(i, N) {
        if (A[i] == 0) {
            ans += tmp / 2;
            tmp = 0;
        }
        else {
            tmp += A[i];
        }
    }
    ans += tmp / 2;;

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 500000;
int n, q;
ll pos[maxn + 10], a[maxn + 10], mind[maxn + 10];
int main() {
	scanf("%d%lld", &n, &pos[0]);
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", &a[i]);
		pos[i] = min(pos[i - 1], abs(pos[i - 1] - a[i]));
	}
	mind[n + 1] = 1;
	for (int i = n; i >= 1; --i) {
		if (mind[i + 1] <= abs(mind[i + 1] - a[i])) mind[i] = mind[i + 1];
		else mind[i] = mind[i + 1] + a[i];
	}
	scanf("%d", &q);
	while (q--) {
		int x; scanf("%d", &x);
		printf("%s\n", pos[x - 1] >= mind[x + 1] ? "YES" : "NO");
	}
}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;



signed main()
{
    string s;

    cin >> s;
    s[5] = ' ';
    s[13] = ' ';

    cout << s << endl;
}


Measured memory_bytes: 256
import sys
a,b=[int(x) for x in input().split()]
reverse=0
if(a<=0 and b>=0):
    print("Zero")
    sys.exit()
if(a>0):
    print("Positive")
    sys.exit()
if(b-a)%2:
    print("Positive")
    sys.exit()
print("Negative")



Measured memory_bytes: 3064
n = int(input())
ln = list(map(int, input().split()))

a = ln[-1]
check = 'T'
for i in range(n-2,-1,-1): # n-1, n-2, n-3 ... 0
    if ln[i] <= a :
        a = ln[i]
    elif ln[i]-1 == a:
        a = ln[i]-1
    else:
        check = 'F'
        break
if check == 'T':
    print('Yes')
else:
    print('No')

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

ll solve() {
    ll N;
    cin >> N;
    map<ll, ll> m;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        m[A[i]]++;
    }
    ll s = 0;
    for ( auto p : m ) {
        ll x = p.second;
        s += x*(x-1)/2;
    }
    for ( int i = 0; i < N; i++ ) {
        ll y = m[A[i]]-1;
        cout << s - y << "\n";
    }
    return 0;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
long long b[100][12];
int main()
{
	for(int i=2;i<11;i++){
		b[0][i]=1;
		for(int j=1;b[j-1][i]<=1e9;j++){
			b[j][i]=b[j-1][i]*i;
		}
	}
	int n,k;cin>>n>>k;
	int i=0;
	while(b[i][k]<=n){++i;}
	cout<<i;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        s: String,
    }
    if s.len() == 3 {
        let s = s.chars().rev().collect::<String>();
        println!("{}", s);
    } else {
        println!("{}", s);
    }
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    char s[105][105];
    int h, w;
    cin >> h >> w;
    vector<vector<int>> dp(h+1, vector<int>(w+1, INF));

    rep(i, h){
        rep(j, w){
            cin >> s[i][j];
        }
    }

    dp[0][0] = 0;
    rep(i, h){
        rep(j, w){
            if(i+1 < h){
                dp[i+1][j] = min(dp[i+1][j], dp[i][j] + (s[i+1][j] != s[i][j]));
            }
            if(j+1 < w){
                dp[i][j+1] = min(dp[i][j+1], dp[i][j] + (s[i][j+1] != s[i][j]));
            }
        }
    }

    int ans = dp[h-1][w-1] + (s[0][0] == '#') + (s[h-1][w-1] == '#');
    cout << ans/2 << endl;

    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n;
    cin>>n;
    cout<<48-n<<NL;
    return 0;
}


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

int main()
{
    int N, M;
    cin>>N>>M;
    vector<int> S(N);
    for (int &s: S)
        cin>>s;
    vector<int> T(M);
    for (int &t: T)
        cin>>t;

    vector<long long> A(N+1, 1LL);
    for (int i=0; i<M; i++)
    {
        vector<long long> P(N+1);
        P.swap(A);
        A[0] = 1LL;
        for (int j=0; j<N; j++)
            A[j+1] = (A[j] + P[j+1] - (S[j]==T[i] ? 0 : P[j]) + 1000000007LL)%1000000007LL;
    }
    cout<<A[N]<<endl;
}


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

int main() {
    int n, co = 0;
    bool f = false;
    cin >> n;
    vector<int> ans(n, 0);
    for (int x = 1; x < sqrt(n); ++x) {
        for (int y = 1; y < sqrt(n); ++y) {
            for (int z = 1; z < sqrt(n); ++z) {
                if (x * x + y * y + z * z + x * y + z * x + y * z <= n)
                    ans[(x * x + y * y + z * z + x * y + z * x + y * z) - 1]++;
            }
        }
    }
    rep(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h> 
using namespace std; 
#define PI 3.14159265358979323846
  
double circumference(double r) 
{ 
    double cir = 2*PI*r; 
    return cir; 
} 
  
// driver function 
int main() 
{ 
  double r = 5; 
    cin>>r;
  cout <<fixed<<setprecision(20)<<circumference(r); 
  return 0; 
}  

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
const int N = 200;

int n, a[N], b[N], f1[N], f2[N];

int main()
{
    memset( f1, 0, sizeof( f1 ) );
    memset( f2, 0, sizeof( f2 ) ); 

    scanf( "%d", &n );

    for( int i = 1; i <= n; i ++ )
        scanf( "%d", &a[i] );
    for( int i = 1; i <= n; i ++ )
        scanf( "%d", &b[i] );

    for( int i = 1; i <= n; i ++ )
        f1[i] = f1[i-1] + a[i];

    for( int i = 1; i <= n; i ++ )
        f2[i] = max( f2[i-1], f1[i] ) + b[i];

    printf( "%d\n", f2[n] );

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    
    int ruc[3001];
    int gvr[3001];
    ruc[0] = 1;
    
    for(int i=0; i<=f; i++) {
        if(ruc[i]) {
            if(i+c <= f) ruc[i+c]=1;
            if(i+d <= f) ruc[i+d]=1;
        }
    }
    
    int ans = 0;
    for(int j=0; j<=f; j++) {
        if(ruc[j]) {
            ans=j;
        }
        gvr[j] = ans;
    }
    
    int ansa = 0, ansb = 0;
    long double best = -0.1;
    
    for(int ia=0; 100*ia*a<=f; ia++) {
        for(int ib=0; 100*ia*a + 100*ib*b<=f; ib++) {
            int A = (ia*a + ib*b)*100;
            int r = f - A;
            int mall = (ia*a + ib*b)*e;
            int B = gvr[min(r,mall)];
            if(A > 0) {
                long double bt = double(B) / (A+B);
                if(bt > best) {
                    best = bt;
                    ansa = A;
                    ansb = B;
                }
            }
        }
    }
    
    cout<< ansa + ansb << ' ' << ansb <<'\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
static const int mod = 1e9 + 7;

ll N;
map<ll, ll> M;

ll func(ll s){
	if(s == 0) return M[s] = 1;
	if(s == 1) return M[s] = 2;
	if(M[s]) return M[s];
	return M[s] = (func(s / 2) + func((s - 1) / 2) % mod + func((s - 2) / 2)) % mod;
}

int main(void){
	cin >> N;
	int ans = func(N);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] moji = in.nextString().toCharArray();
			int len = moji.length;
			int[] s = new int[len];
			for (int i = 0; i < len; i++) {
				s[i] = (int)(moji[i]-'a');
			}
			long k = in.nextLong();
			if (k > len * 26) {
				k = k % 26 + 26 * len;
			}
			for (int i = 0; i < len; i++) {
				if (k >= 26-s[i] && s[i]!=0) {
					k -= (26-s[i]);
					s[i] = 0;
				}
			}

			while (k > 0) {
				s[len-1]++;
				s[len-1] %= 26;
				k--;
			}

			StringBuffer sb = new StringBuffer();
			for (int i = 0; i < len; i++) {
				sb.append((char)(s[i]+'a'));
			}
			out.println(sb.toString());

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 27476
/* Akshat Sharma @akshat98 */
#include <iostream>
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp   make_pair
#define pb   push_back
#define F    first
#define S    second
#define ll   long long
#define MOD  1000000007
#define MAX  1000000001
#define vi   vector<int>
#define vl   vector<ll>
#define vpi  vector<pair<int,int> >
#define vpl  vector<pair<ll,ll> >
#define rep(i,a,b) for(i=a;i<b;i++)
#define reqp(i,a,b) for(i=a;i<=b;i++)
#define ren for(i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;


int main()
{
	#ifndef ONLINE_JUDGE
	//freopen("input_file.txt", "r", stdin);
	//freopen("output_file.txt", "w", stdout);
	#endif
	int i,j,k,l,n,test_case,m,r,x;
	test_case=1;
	//cin>>test_case;
	while(test_case--){
		cin>>x;
		cout<<fixed<<setprecision(4)<<3.14159*2*x<<"\n";


	}
	
	return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int n; cin >> n;
   V<int> a(n);
   for (int i = 0; i < n; i++) {
      cin >> a[i];
   }

   map<int,int> cnt;
   for (int i = 0; i < n; i++) cnt[a[i]]++;

   int maxa = *max_element(a.begin(), a.end());
   int mina = *min_element(a.begin(), a.end());
   if (maxa % 2 == 0) {
      if (cnt[maxa / 2] != 1) {
         cout << "Impossible" << endl;
         return 0;
      }
      for (int i = maxa / 2 + 1; i <= maxa; i++) {
         if (cnt[i] < 2) {
            cout << "Impossible" << endl;
            return 0;
         }
      }
      if (mina < maxa / 2) {
         cout << "Impossible" << endl;
         return 0;
      }
   } else {
      if (cnt[(maxa+1) / 2] != 2) {
         cout << "Impossible" << endl;
         return 0;
      }
      for (int i = (maxa+1) / 2 + 1; i <= maxa; i++) {
         if (cnt[i] < 2) {
            cout << "Impossible" << endl;
            return 0;
         }
      }
      if (mina < (maxa+1) / 2) {
         cout << "Impossible" << endl;
         return 0;
      }
   }

   cout << "Possible" << endl;

   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ins insert
#define vi vector<int>
const int mxN=2e5;
 
int main () 
{
    string n;
    ll sum=0;
    cin >> n;
    for(int i=0;i<n.length();i++)
        sum+=n[i]-'0';
    if(sum%9==0)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 3680
#include"stdio.h"
#include"iostream"
#include"cmath"
using namespace std;
int a,b;
int main(){
    cin>>a>>b;
    if(a>0) printf("Positive\n");
    else if(a==0||(a<0&&b>0)) printf("Zero\n");
    	 else if((abs(b)-abs(a))%2!=0) printf("Positive\n");
    		  else printf("Negative\n");
    return 0;
}

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

int main() {
    int A,B; 
    cin >> A >>B;
    int num = 1; 
    int taps = 0;
    while(true) {
        if(num >= B) {
            break;
        }
        num += A-1;
        ++taps;
    }
    cout << taps << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	private static final String ArrayList = null;

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

		ArrayList<Integer> right = new ArrayList<Integer>();
		ArrayList<Integer> left = new ArrayList<Integer>();

		String[] tmpArray = br.readLine().split(" ");
		//最初は右半分に
		right.add(Integer.parseInt(tmpArray[0]));
		//あとは交互に追加
		for(int i = 1; i < n; i++){
			if(i % 2 == 1){
				right.add(Integer.parseInt(tmpArray[i]));
			}
			else {
				left.add(Integer.parseInt(tmpArray[i]));
			}
		}

		//入力の個数によってどちらから出力するかが変わる
		if(n % 2 == 0){
			for(int i = right.size() - 1; i >= 0 ; i--){
				System.out.print(right.get(i));
				if(i != 0){
					System.out.print(" ");
				}
			}

			if(left.size() > 0){
				System.out.print(" ");
			}

			for(int i = 0; i < left.size(); i++){
				System.out.print(left.get(i));
				if(i != left.size() - 1){
					System.out.print(" ");
				}
			}

			System.out.println();
		}
		else {
			for(int i = left.size() - 1; i >= 0 ; i--){
				System.out.print(left.get(i));
				if(i != 0){
					System.out.print(" ");
				}
			}

			if(right.size() > 0 && left.size() != 0){
				System.out.print(" ");
			}

			for(int i = 0; i < right.size(); i++){
				System.out.print(right.get(i));
				if(i != right.size() - 1){
					System.out.print(" ");
				}
			}

			System.out.println();
		}
	}

}


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

int main() {
    string S;
    cin >> S;
    long T = 0;
    long min_T = (long)S.size();

    for(int i = 0; i < S.size(); i++)
    {
        if(S[i] != S[i + 1])
        {
            T = (long)max(i + 1, (int)S.size() - (i + 1));
            min_T = (long)min(T, min_T);
        }
    }

    cout << min_T << endl;
    return 0;
}


Measured memory_bytes: 512
def main():
    S = input()
    K = int(input())
    idx = 0
    num = ""

    count_one = 0
    for i in range(len(S)):
        if S[i] == "1":
            count_one += 1
        else:
            idx = i
            num = S[i]
            break

    if count_one >= K:
        print("1")
    else:
        print(num)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    if((B - A - 1) % 2 == 1){
        cout << "Alice" << endl;
    }else{
        cout << "Borys" << endl;
    }
    return 0;
}

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

int main() {
    char b;
    cin>>b;
    cout << (b=='A'? 'T':(b=='T'? 'A':(b=='G'? 'C':'G'))) <<endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> food(M);
  
  for (int i = 0; i < N; i++){
    int K;
    cin >> K;
    for (int j = 0; j < K; j++){
      int A;
      cin >> A;
      food.at(A-1)++;
    }
  }
  
  int count = 0;
  for (int i = 0; i < M; i++) {
    if (food.at(i) == N) {
      count++;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=100010;

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

    ll n;
    cin>>n;
    ll count=0;
    string s="No";
    ll ar[n],br[n];
    for(ll i=0;i<n;++i){
        ll a,b;
        cin>>a>>b;
        if(a==b){++count;}
        else{count=0;}
        if(count>=3){
            s="Yes";
        }
    }
    cout<<s;

    return (0);
}


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

int main() {
	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if (x + r <= W && x - r >= 0 && y + r <= H && y - r >= 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3108
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = list(map(int,read().split()))

if(a[0] != 0):
    print(-1)
    exit()

if(n==1):
    print(0)
    exit()

ans = a[-1]
for i in range(n-2,-1,-1):
    if(a[i+1] - a[i] == 1):
        continue
    elif(a[i+1] - a[i] > 1):
        print(-1)
        exit()
    ans += a[i]

print(ans)

Measured memory_bytes: 104992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}


void cerrall(const vector<bool>& a){rep(i,a.size()) cerr << i << " " << (a[i]? "True" : "False") << "\n"; cerr << "\n";}
template<class T> void cerrall(const vector<T>& a){for(auto& t : a) cerr << t << " "; cerr << "\n";}
template<class T> void cerrall(const set<T>& a){for(auto& t : a) cerr << t << " "; cerr << "\n";}
template<class T> void cerrall(const multiset<T>& a){for(auto& t : a) cerr << t << " "; cerr << "\n";}
template<class T, class U> void cerrall(const vector<pair<T,U>>& a){rep(i,a.size()) cerr << i << " : " << a[i].first << " " << a[i].second << "\n";}
template<class T, class U> void cerrall(const map<T,U>& a){for(auto& t : a) cerr << t.first << " " << t.second << "\n";}
template<class T, class U> void cerrall(const unordered_map<T,U>& a){for(auto& t : a) cerr << t.first << " " << t.second << "\n";}

template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}

template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

int main(){
    int n;cin >> n;
    vi a(n), b(n);
    rep(i,n) cin >> a[i] >> b[i];

    sort(all(a));
    sort(all(b));
    int ans;
    if(n&1){
        int l = a[n/2], r = b[n/2];
        ans = r - l + 1;
    }else{
        int l = a[n/2]+a[n/2-1], r = b[n/2] + b[n/2-1];
        ans = r - l + 1;
    }
    cout << ans << endl;
}

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

int main()
{
	int H, W;
	scanf("%d%d", &H, &W);
	char a[H+1][W+1];
	int i, j, k;
	for (i = 0; i < H; i++) 
		scanf("%s", a[i]);

	int tate[W], yoko[H];
	int judge;
	for (i = 0; i < H; i++) {
		for (j = 0, judge = 0; j < W; j++) {
			if (a[i][j] == '#')
				judge = 1;
		}
		if (judge == 0) 
			yoko[i] = 1;
		else
			yoko[i] = 0;
	}
	for (j = 0; j < W; j++) {
		for (i = 0, judge = 0; i < H; i++) {
			if (a[i][j] == '#')
				judge = 1;
		}
		if (judge == 0)
			tate[j] = 1;
		else
			tate[j] = 0;
	}

	for (i = 0; i < H; i++) {
		if (yoko[i] == 1)
			continue;
		for (j = 0; j < W; j++) {
			if (tate[j] == 1) 
				continue;
			printf("%c", a[i][j]);
		}
		putchar('\n');
	}

	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>

long long c[2001][2001];

int main(void)
{
	int n;
	long long ans = 0;
	c[0][0] = 1;
	c[1][0] = c[1][1] = 1;
	for (int i = 2; i <= 2000; i++)
	{
		c[i][0] = c[i][i] = 1;
		for (int j = 1; j < i; j++)
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % 1000000007;
	}
	scanf("%d", &n);
	for (int i = 1; i <= n / 3; i++)
		ans = (ans + c[n - 2 * i - 1][n - 3 * i]) % 1000000007;
	printf("%lld\n", ans);
	return 0;
}

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

aScore = 0
bScore = 0

for _ in range(n):
    a, b = input().split()
    if a > b:
        aScore += 3
    elif b > a:
        bScore += 3
    else:
        aScore += 1
        bScore += 1

print("{} {}".format(aScore,bScore))


Measured memory_bytes: 5596
cards = [[0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0]]
suit_dic = {'S':0, 'H':1, 'C':2, 'D':3}
suits_list = ['S', 'H', 'C', 'D']
n = input()
while (n>0):
	n -= 1
	suit, number = raw_input().split()
	cards[suit_dic.get(suit)][int(number) - 1] = 1
for i in range(0, 4):
	for j in range(0, 13):
		if cards[i][j] == 0:
			print suits_list[i], j+1

		

Measured memory_bytes: 4268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

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

  vector<string> s(n);
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  cin >> m;
  vector<string> t(m);
  rep(i,m) cin >> t[i];

  int ans = 0;
  for(int i = 0; i < n; i++){
    int c = 0;
    for(int j = 0; j < n; j++){
      if(s[i] == s[j]) c++;
    }
    for(int j = 0; j < m; j++){
      if(s[i] == t[j]) c--;
    }
    ans = max(ans, c);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){

  int n;

  while(cin >> n, n){
    int ans = 0,a,b,c,d;

    for(long int i=0;i<n;i++){
      cin >> a >> b >> c >> d;
      a += b + c;

      if(a > 160 || d > 25);
      else if(a > 140 || d > 20) ans += 1600;
      else if(a > 120 || d > 15) ans += 1400;
      else if(a > 100 || d > 10) ans += 1200;
      else if(a > 80 || d > 5) ans += 1000;
      else if(a > 60 || d > 2) ans += 800;
      else ans += 600;

    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
/*
 Sarthak Jain
*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;
int min(int a,int b){
	return (a<b)?a:b;
}
int max(int a,int b){
	return (a>b)?a:b;
}
int fp(int a,int b){
	if(b==0) return 1;
	int x=fp(a,b/2);
	x=(x*x)%mod;
	if(b&1) x=(x*a)%mod;
	return x;
}
int add(int &a,int b)
{
	a=(a+b+mod)%mod;
}




signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 int n,k;
 cin>>n>>k;
 cout<<min(n%k,abs(n%k-k));
}

Measured memory_bytes: 256