akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int  m[200] = {};

    int a,b,c,d;
    cin >> a >> b >> c >> d;

    m[a]++;
    m[b]--;
    m[c]++;
    m[d]--;
    rep(i,1,101)m[i] += m[i-1];
    int ans = 0;
    rep(i,0,101){
   
        if(m[i] == 2)ans++;
    }    
    P(ans);
	return  0;
}

Measured memory_bytes: 256
def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b
def lmc(a, b):
    return a * b // gcd(a, b)

a, b, c, d = map(int, input().split())
c_m = b // c - (a - 1) // c
d_m = b // d - (a - 1) // d
cd_m = b // (lmc(c, d)) - (a - 1) // (lmc(c, d))
ans = b - a + 1 - (c_m + d_m - cd_m)
print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<": "<<a<<endl;
#else
#define tr(a)    
#endif
#define int 		long long
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;

void solve(){
	int N;
	cin>>N;
	int n=N;
	vi x(N);
	vi y(N);
	rep(i,0,N)cin>>x[i];
	sort(all(x));
	partial_sum(all(x),y.begin());
	int ans=0;
	for(int i=n-1;i>=0;i--){
		if(i==n-1 or y[i]*2>=x[i+1])ans++;
		else break;
	}
	cout<<ans;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1792
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro nlet (name args &body body)
  (labels ((ensure-list (x) (if (listp x) x (list x))))
    (let ((args (mapcar #'ensure-list args)))
      `(labels ((,name ,(mapcar #'car args) ,@body))
         (,name ,@(mapcar #'cadr args))))))

(defmacro split-ints-and-bind (vars string &body body)
  (let ((pos1 (gensym "POS"))
	(pos2 (gensym "POS"))
	(str (gensym "STR")))
    (labels ((expand (vars &optional (init-pos1 t))
	       (if (null vars)
		   body
		   `((let* ((,pos1 ,(if init-pos1 0 `(1+ ,pos2)))
			    (,pos2 (position #\space ,str :start ,pos1 :test #'char=))
			    (,(car vars) (parse-integer ,str :start ,pos1 :end ,pos2)))
		       ,@(expand (cdr vars) nil))))))
      `(let ((,str ,string))
         (declare (string ,str))
	 ,@(expand vars)))))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

;; Hauptteil

(defun main ()
  (let* ((d (read))
         (required-score (floor (read) 100))
         (ps (make-array d :element-type 'uint32))
         (max-scores (make-array d :element-type 'uint32)))
    (dotimes (i d)
      (split-ints-and-bind (p c) (read-line)
        (setf (aref ps i) p
              (aref max-scores i) (+ (floor c 100) (* p (+ i 1))))))
    (let ((min-num most-positive-fixnum))
      (dotimes (bits (expt 2 d))
        (let ((num 0)
              (score 0))
          (dotimes (i d)
            (when (= 1 (ldb (byte 1 i) bits))
              (incf score (aref max-scores i))
              (incf num (aref ps i))))
          (if (>= score required-score)
              (setf min-num (min num min-num))
              (let ((idx -1)
                    (delta most-positive-fixnum))
                (dotimes (i d)
                  (when (zerop (ldb (byte 1 i) bits))
                    (let ((tmp-delta (ceiling (- required-score score) (+ i 1))))
                      (when (and (< tmp-delta (aref ps i))
                                 (< tmp-delta delta))
                        (setf idx i
                              delta tmp-delta)))))
                (incf num delta)
                (when (and (/= idx -1)
                           (< num min-num))
                  (setf min-num num))))))
      (println min-num))))

#-swank(main)


Measured memory_bytes: 16744
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<min(a*n,b)<<'\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int a,b;
    cin >> a >> b;
    int ans=max(a-2*b,0);
    cout << ans;

    return 0;
}

Measured memory_bytes: 3596
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, k, a[MAXN];
ld ev[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    FOR(i,1,n) {
        cin >> a[i];
        ev[i] = (ld) (a[i] + 1) / 2;
    }
    ld sum = 0;
    FOR(i,1,k-1) sum += ev[i];
    ld res = 0;
    FOR(i,k,n) {
        sum += ev[i] - ev[i-k];
        res = max(res, sum);
    }
    cout << fixed << setprecision(9) << res;
    return 0;
}


Measured memory_bytes: 2560
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double T = sc.nextDouble();
        double A = sc.nextDouble();
        int[] H = new int[N];
        double[] dif = new double[N];
        for(int i = 0; i < N; i++){
            H[i] = sc.nextInt();
            dif[i] = Math.abs(A  - (T - 0.006 * H[i]));
        }

        double min = 100000;
        int minIndex = 0;
        for(int i = 0; i < N; i++){
            if(min > dif[i]){
                min = dif[i];
                minIndex = i;
            } 
        }
        System.out.println(minIndex+1);
    }
}

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

ll solve(vector<int>& dq,int st, int end, vector<vector<ll>>& dp){
	if(st > end)
		return 0;
	if(dp[st][end] != -1)
		return dp[st][end];

	//dp[st][end] = max(max(solve(dq, st+1, end-1, dp), solve(dq, st+2, end, dp)) + dq[st], max(solve(dq, st+1, end-1, dp), solve(dq, st, end-2, dp)) + dq[end]);
	dp[st][end] = max(dq[st] - solve(dq, st+1, end, dp), dq[end] - solve(dq, st, end-1, dp));
	
	return dp[st][end];
}

int main(){
	int n;cin>>n;
	vector<int> dq;
	for(int i = 0; i < n; i++){
		int t;cin>>t;
		dq.push_back(t);
	}
	vector<vector<ll> > dp(n, vector<ll>(n,-1));
	dp[0][n-1] = solve(dq, 0, n-1, dp);
	
	cout<<dp[0][n-1]<<endl;
	return 0;
}

Measured memory_bytes: 71040
#include <iostream>

using namespace std;

int a, b;
bool isLeap(int y){
  return (!(y%4) && y%100 || !(y%400));
}
bool check(){
  bool f = false;
  for(int i = a; i <= b; i++){
    if(isLeap(i)){
      cout << i << endl;
      f = true;
    }
  }
  if(!f)cout << "NA" << endl;
}
int main(){
  for(int i = 0;cin >> a >> b, a||b; i++){
    if(i)cout << endl;
    check();
  }
  return 0;
}

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

int main(){
int a,b,q;
cin>>a>>b>>q;
vector<ll> s(a+2),t(b+2);
s[0] = t[0]  = -1e12;
s[a+1] = t[b+1] = 1e12;
for(int i=1;i<=a;i++)cin>>s[i];
for(int i=1;i<=b;i++)cin>>t[i];
for(int i=0;i<q;i++){
	ll x;
	cin>>x;
	auto it = lower_bound(s.begin(),s.end(),x);
	ll a1  = it-s.begin();
	auto it2 = lower_bound(t.begin(),t.end(),x);
	ll b1 = it2-t.begin();
	//cout<<a1<<' '<<b1<<endl;
	ll res = 1e12;
	ll aa[2] = { s[a1-1],s[a1]};
	ll bb[2] = { t[b1-1],t[b1]};
	for(int j=0;j<2;j++){
		for(int k=0;k<2;k++){
			res = min(res,abs(aa[j]-bb[k])+min(abs(aa[j]-x) ,abs(bb[k]-x) )  );
		}
	}
	cout<<res<<endl;
}



	return 0;
}


Measured memory_bytes: 2944
import java.util.*;
import java.io.*;

public class Main {
    
    static String str;
    static int t;
    static int[] dp;
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        long n=Long.parseLong(st.nextToken());
        long x=Long.parseLong(st.nextToken());
        long gcd=1;
        long t_n=n;
        while(true){
            if(n>x){
                n=n%x;
                if(n==0){ gcd=x; break; }
            }
            else{
                x=x%n;
                if(x==0){ gcd=n; break; }
            }
        }System.out.println((t_n-gcd)*3);
    }
}


Measured memory_bytes: 8148
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 100000;
const int INF = 1e9 + 5;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N;
	cin >> N;
	
	vector<int> ans;
	while (true) {
		if (N % 2 != 0) {
			ans.push_back(1);
			N = (N - 1) / -2;
		}
		else {
			ans.push_back(0);
			N = N / -2;
		}
		if (N == 0) break;
	}
	
	for (int i = ans.size() - 1; i >= 0; i--) cout << ans[i];
	cout << "\n";
	
	/**** Note MAXN ****/
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100
int main() { 
   int m[MAX+1][MAX+1];
   int p[MAX+1];
   int n, ans;
   int i, j, k, l;

   scanf("%d", &n);
   for (i = 1; i <= n; ++i) {
	  scanf("%d %d", &p[i - 1], &p[i]);
   }

   for (i = 1; i <= n; ++i) {
	  m[i][i] = 0;
   }

   for (l = 2; l <= n; ++l) {
	  for (i = 1; i <= n - l + 1; ++i) {
		 j = i + l - 1;
		 m[i][j] = 100000000000000000000;
		 for (k = i; k <= j - 1; ++k) {
			if (m[i][j] < m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j])
			   ans = m[i][j];
			else
			   ans = m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];
			m[i][j] = ans;
		 }
	  }
   }
   printf("%d\n", m[1][n]);
   return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

bool is_kai(string s){
    for(int i=0;i<s.size()/2;i++) if(s[i] != s[s.size()-i -1]) return false;
    return true;
}
signed main()
{   
    gearup;
    double d; cin >> d;
    double res = d/3;
    cout << fixed << setprecision(10) << res*res*res << endl;
}

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

int main()
{
	int n,k,a=0;
	string s;
	cin>>n>>k>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]!=s[i+1])
		{
			a++;
		}
	 } 
	 int ans=n-a;
	 while(k&&a)
	 {
	 	if(a==2)
	 	{
	 		ans++;
		  } 
		  else
		  {
		  	ans+=2;
		  }
		  k--;
		  a-=2;	 
	 } 
	 cout<<min(ans,n-1)<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define sf(n) scanf("%lld", &n);
#define sff(n,m) scanf("%lld %lld", &n, &m)
#define pf(n) printf("%lld\n", n)
#define pff(n,m) printf("%lld %lld\n", n, m)
#define mem(a) memset(a, 0, sizeof(a))
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
#define pi 2*acos(0.0)
#define F first
#define S second
#define EPS 1e-9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


void change(string s)
{

	// Finding the length of the string
	int n = s.length();

	// To store the number of replacement operations
	int cc = 0;

	for(int i=0;i<n/2;i++)
	{

		// If the characters at location
		// i and n-i-1 are same then
		// no change is required
		if(s[i]== s[n-i-1])
			continue;

		// Counting one change operation
		cc+= 1;

		// Changing the character with higher
		// ascii value with lower ascii value
		if(s[i]<s[n-i-1])
			s[n-i-1]= s[i] ;
		else
			s[i]= s[n-i-1] ;
	}
	cout<<cc<<endl;
	//cout<<s<<endl;
}
// Driver code
int main()
{
string s ;
cin>>s;
change((s));
return 0;
}
//contributed by Arnab Kundu


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 k = sc.nextInt();
		String[] a = new String[k];
		for(int i = 0; i < k; i++){
			a[i]=sc.next();
		}
		for(int i = n; i<10*n;i++){
			String b=Integer.toString(i);
			boolean contain=true;
			for(String m:a){
				if(b.contains(m)){
					contain=false;
					break;
				}
			}
			if(contain==true){
				System.out.println(b);
				return;
			}
		}
	}
}

Measured memory_bytes: 23892
n = int(raw_input())
arr = raw_input()  
v = list(map(int,arr.split(' ')))
su=0
mod=1000000007
for i in v:
    su+=i
su=su*su
x=0
for i in v:
    x+=i*i
ans=(su-x)/2
ans=(ans + mod)%mod
print ans
    


Measured memory_bytes: 87180
#include <iostream>

using namespace std;

void solve()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int sum = a + b + c + d;
	cout << sum / 60 << endl;
	cout << sum % 60 << endl;
}

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

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

using namespace std;

int main(){
    int n,ans = 0;
    cin >> n;
    for(int i = 1;i <= n;i++){
        int cal = i,count = 0;;
        for(;cal;){
            cal /= 10;
            count++;
        }
        if(count % 2 != 0)ans += 1;
    }
    cout << ans;
    return 0;
}

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

//#define DEBUG

using namespace std;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


void solve(){
    uint64_t W, H , X, Y ;
    cin >> W >> H >> X >> Y;
    uint64_t surface =  W * H;    
    double ans = surface / 2.0;
    if( X * 2 == W && Y * 2 == H){
        cout << ans << " 1" << endl;
    }else{
        cout << ans << " 0" << endl;
    }
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 3784
pos = gets.chomp.chars
dists = Array.new(pos.size, 0)
res = Array.new(pos.size, 0)
change_points = []
current = 'R'

dist = 0

pos.each_with_index do |c, idx|
    if c != current
        dist = 0
        # R => L shift point
        change_points << idx if c == 'L'
        current = c
    end
    dists[idx] = dist
    dist = (dist + 1) % 2
end

current = 'R'
next_change_idx = 0

pos.each_with_index do |i, idx|
    if i != current
        current = i
        if i == 'R'
            next_change_idx = [next_change_idx + 1, change_points.size - 1].min
        end
    end
    change_point = change_points[next_change_idx]

    n = -1

    if i == 'R'
        if dists[idx].even?
            n = change_point - 1
            res[change_point - 1] += 1
        else
            n = change_point
            res[change_point] += 1
        end
    else
        if dists[idx].even?
            n = change_point
            res[change_point] += 1
        else
            n = change_point - 1
            res[change_point - 1] += 1
        end
    end

    # puts "#{idx}(dist=#{dists[idx]}) => {#{n}}"
end
puts res.join(' ')

Measured memory_bytes: 11900
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	const int N = 753;
	int answer = INT_MAX;
	string S; cin >> S;
	for(int i = 0; i < S.size()-2; ++i){
		int n = stoi(S.substr(i, 3));
		answer = min(answer, abs(N-n));
	} 
	cout << answer << endl;
}


Measured memory_bytes: 256
from heapq import heappush, heappop

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
h = []

maxv = A[0] + B[0] + C[0]


def inv(v):
    return maxv - v


pushed = [[[] for _ in range(Y)] for _ in range(X)]
heappush(h, (0, 0, 0, 0))
for _ in range(K):
    invv, i, j, k = heappop(h)
    print(inv(invv))
    if i + 1 < X and k not in pushed[i + 1][j]:
        heappush(h, (inv(A[i + 1] + B[j] + C[k]), i + 1, j, k))
        pushed[i + 1][j].append(k)
    if j + 1 < Y and k not in pushed[i][j + 1]:
        heappush(h, (inv(A[i] + B[j + 1] + C[k]), i, j + 1, k))
        pushed[i][j + 1].append(k)
    if k + 1 < Z and k + 1 not in pushed[i][j]:
        heappush(h, (inv(A[i] + B[j] + C[k + 1]), i, j, k + 1))
        pushed[i][j].append(k + 1)

Measured memory_bytes: 88732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1LL<<60;
const int INF = 1LL<<17;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll bit[500500];
ll n;
#define N 500010

ll sum(ll i){
    ll res=0;
    while(0<i){
        res += bit[i];
        i -= i&-i;
    }
    return res;
}
void add(ll i, ll x){
    while(i<=n){
        bit[i] += x;
        i += i&-i;
    }
}


// int sum(int i){
//     int res=0;
//     for(;i>0;i-=i&-i)res+=bit[i];
//     return res;
// }
ll rsum(ll l, ll r){
    return sum(r)-sum(l-1);
}
vector<vector<ll>> qr(N), qri(N);
vector<ll> a(N), c(N), res(N);
int main(){
    ll q;   cin >> n >> q;


    rep(i, n) cin >> c[i+1];
    
    rep(i, q){
        ll a, b;    cin >> a >> b;
        qr[b].push_back(a);
        qri[b].push_back(i);
    }

    FOR(i, 1, n+1){
        if(a[c[i]]>0) add(a[c[i]], -1);
        add(i, 1);
        a[c[i]] = i;
        rep(j, qr[i].size()){
            res[qri[i][j]] = rsum(qr[i][j], i);
        }
    }
    rep(i, q) cout << res[i] << endl;
}


Measured memory_bytes: 62672
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int gcd(int a, int b){
  if (a%b == 0) return(b);
  else return(gcd(b, a%b));
}
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> points(n);
  for (int i=0; i<n; i++) {
    cin >> points[i];
  }
  int ans = abs(x-points[0]);
  for (int i=1; i<n; i++) {
    ans = gcd(ans, abs(x-points[i]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
N=int(input())
*A,=sorted(map(int,input().split()))
*B,=sorted(map(int,input().split()))
*C,=sorted(map(int,input().split()))

lenc=len(C)

from bisect import *

cnt=0
for b in B:
    in_a = bisect_left(A, b)
    in_c = bisect_right(C, b)
    cnt+= in_a*(lenc-in_c)

print(cnt)

Measured memory_bytes: 29300
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin >> s;
  int ans = 0;
  rep(i,s.size()){
      FOR(j,i,s.size()){
          bool ok = true;
          FOR(k,i,j+1){
              if(s[k] != 'A' &&s[k] != 'G' &&s[k] != 'C' &&s[k] != 'T'  )ok = false;
          }
          if(ok ){
              ans = max(ans, j-i+1);
          }
      }
  }
  cout<< ans << endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


int main() {
    int N;  cin >> N;
    vector<string> S(N);  rep(i, N) cin >> S[i];
 
    rep(i, N) sort(all(S[i]));

    map<string, ll> T;
    rep(i, N) {
        T[S[i]]++;
    }

    ll cnt = 0;
    for (auto &p : T) {
        ll tmp = p.second;
        cnt += tmp*(tmp-1)/2;  // tmp_C_2
    }
 
    print(cnt);
 
    return 0;
}

Measured memory_bytes: 18176
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
using namespace std;

const int maxn=2e3+10;
int n,k,ans=1e9,res;
vector<int> g[maxn<<1];

void dfs(int pos,int fa,int dep){
	if(dep>k&&pos<=n)
		++res;
	for(int i=0;i<g[pos].size();++i)
		if(g[pos][i]!=fa)
			dfs(g[pos][i],pos,dep+1);
}

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1,u,v;i<n;++i){
		scanf("%d%d",&u,&v);
		g[u].push_back(n+i);
		g[n+i].push_back(u);
		g[v].push_back(n+i);
		g[n+i].push_back(v);
	}
	for(int i=1;i<2*n;++i){
		res=0;
		dfs(i,0,0);
		if(res<ans)
			ans=res;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 768
from _collections import deque
n,m,k=map(int,input().split())
import sys
sys.setrecursionlimit(10**9) #再帰の上限をあげる

fre=[[] for _ in range(n+1)]
bro=[[] for _ in range(n+1)]

for i in range(m):
    a,b=map(int,input().split())
    fre[a].append(b)
    fre[b].append(a)

for i in range(k):
    a, b = map(int, input().split())
    bro[a].append(b)
    bro[b].append(a)

ans=[]

x=[-1]*(n+1)

def s(y):
    global i
    if x[y]>0:
        return
    x[y]=i
    for j in fre[y]:
        if x[j]==-1:
            s(j)

for i in range(1,n+1):
    s(i)

g=[0]*(n+1)
for i in range(1,n+1):
    g[x[i]]+=1
for i in range(1,n+1):
    g[i]=g[x[i]]

for i in range(1,n+1):
    aa=g[i]-1
    aa-=len(fre[i])
    for j in bro[i]:
        if x[i]==x[j]:
            aa-=1
    ans.append(str(aa))
print(" ".join(ans))



Measured memory_bytes: 379652
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

using ll = long long;
using namespace std;

int main() {
    int N;
    cin >> N;
    map<int, int> m;
    REP(i, N) {
        int k;
        cin >> k;
        m[k]++;
    }

    cout << m.size() << endl;
    return 0;
}


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

using namespace std;

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int ans=0,x;
  for(int i=1;i<=N;i++){
    x=(i%100000)/10000+(i%10000)/1000+(i%1000)/100+(i%100)/10+(i%10);
    if(x>=A && x<=B)  ans+=i;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int ans=0;
    int now=1;
    while(now<b){
        now+=a-1;
        ans++;
    }
    cout<<ans<<endl;
}


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

int main() {
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

typedef long long ll;

int main() {
  ll x;
  cin >> x;

  ll ans = x / 11 * 2;
  if (x % 11 > 6) ans += 2;
  else if (x % 11 > 0) ans += 1;
  
  // 解答
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
al = list(map(int,input().split()))

from collections import defaultdict
dic = defaultdict(int)
for a in al:
    dic[a] += 1

l = [i for i in dic.values()]
l = sorted(l)

a = len(l) - k

ans = 0
for i in range(max(a,0)):
    ans += l[i]

print(ans)

Measured memory_bytes: 34428
#include<cstdio>
#include<iostream>
#include<cctype>
using namespace std;
int main(){
    char ch;
    
    while(1){
        scanf("%c", &ch);
        
        if(isalpha(ch)){
            if(islower(ch)) printf("%c", toupper(ch));
            else if(isupper(ch)) printf("%c", tolower(ch));
        }
        else printf("%c",ch);
        
        if(ch == '\n') break;
    }
    return 0;
}




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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll n,k;
	cin>>n>>k;
	vector<ll> vl(n);
	FOR(i,0,n)cin>>vl[i];
	sort(all(vl));
	ll cnt = 0;
	FOR(i,0,k) cnt+=vl[i];
	cout<<cnt<<Endl;
	return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {

    int A, B, K;
    cin >> A >> B >> K;
    vector<int> x;
    for (int i = 1; i <= 100; ++i) {
        if(A%i ==0&&B%i==0){
            x.push_back(i);
        }
    }
    cout << x[x.size()-K] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    int in[n] = {};
    rep(i, 0, m) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
        in[y]++;
    }

    int dist[n] = {};
    queue<int> que;
    rep(i, 0, n) {
        if (in[i] == 0) que.push(i);
    }
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (auto nv : g[v]) {
            in[nv]--;
            if (in[nv] == 0) {
                que.push(nv);
                dist[nv] = max(dist[nv], dist[v] + 1);
            }
        }
    }
    int ans = -1;
    rep(i, 0, n) ans = max(ans, dist[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	int n;cin>>n;
	string s;
	cin>>s;
	int dp[n][n];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(s[i]!=s[j]) dp[i][j]=0;
			else dp[i][j]=((i>=1&&j>=1)?dp[i-1][j-1]:0)+1;
		}
	}
	int ans=0;
	for(int i=0;i<n;i++){
		int now;
		for(int j=0;j<n;j++){
			if(i>=j) continue;
			now=min(dp[i][j],j-i);
			ans=max(ans,now);
		}
	}
	cout<<ans;
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 97920
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#define ALL(a) (a).begin(),(a).end()

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>que;

int main() {
  ll N,A;
  cin>>N>>A;
  ll x[N];
  FOR(i,0,N-1){
    cin>>x[i];
    x[i]=x[i]-A;
  }

  ll dp[20001][51];
  FOR(i,0,20000){
    FOR(j,0,50){
      dp[i][j]=0;
    }
  }

  dp[10000][0]=1;

  FOR(i,1,N){

    FOR(j,0,20000){
      if(dp[j][i-1]>=1){
        dp[j][i]=dp[j][i]+dp[j][i-1];

        dp[j+x[i-1]][i]=dp[j+x[i-1]][i]+dp[j][i-1];
      }
    }

  }

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


return 0;
 
}

Measured memory_bytes: 8192
#include <cstdio>
#include <algorithm>
using namespace std;
int a[100000+10],n;
int cnt;
#define GG return printf("No"),0
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	if (a[n]-a[1]>1) GG;
	if (a[1]==a[n]) return printf("%s",n==a[1]+1||n>=a[1]*2?"Yes":"No"),0;
	for(int i=1;i<=n;++i) if (a[i]==a[1]) ++cnt;
	if (cnt>a[1]) GG;
	return printf("%s",(n-cnt)>=(a[n]-cnt)*2?"Yes":"No"),0;
}

Measured memory_bytes: 512
def judge():
    cnt = 0  # 今何連続でゾロ目が出ているか記録しておきます
 
    for _ in range(N):
        x, y = map(int, input().split())
        if x == y:
            # ゾロ目ストリークが1増えました
            cnt += 1
        else:
            # ゾロ目ストリークが切れました
            cnt = 0
 
        if cnt == 3:
            # 3連続になった瞬間、return True していいです
            return True
    
    # ダメでした
    return False
 
N = int(input())
 
if judge():
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define MOD 1000000007
#define ll long long
#define MAX 10001

int cmpfunc(const void *a, const void *b){
    return (*(int*)a - *(int*)b);
}

int main(void){
    int a,b,c;
    int i;
    scanf("%d %d %d",&a,&b,&c);
    if((10*b+c)%4==0) printf("YES\n");
    else printf("NO\n");
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<vector<long>> H(N, vector<long>(2));
 
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> H.at(i).at(j);
    }
  }
  vector<pair<long, long> > pairs(N);
  for (int i = 0; i < N; i++) {
    pairs[i] = make_pair(H.at(i).at(0)+H.at(i).at(1),H.at(i).at(0)-H.at(i).at(1) );
   }
  
  
  sort(pairs.begin(), pairs.end());
  
  int ans=0;
  int t=pairs[0].second;
  
  for (int i = 0; i < N; i++) {
    
      if(t<=pairs[i].second){
 
          
          ans++;
          t=pairs[i].first;
        
      }
  }
  

      cout<<ans<<endl;



}

  






Measured memory_bytes: 7424
/* ex5_3
   shu_t */

#include<stdio.h>
//1<=H,W<=100
#define SIZE 100

int main(void){
  char square[SIZE][SIZE];//for input
  char sub_square[SIZE][SIZE];//for judge black or white
  int i,j;//roop variable
  int new_line;//checking whether start a new line
  int row,column;
  
  //input row and column
  scanf("%d %d",&row,&column);
  
  for(i=0;i<row;i++){
    for(j=0;j<column;j++){
      //input square in array of square
      scanf(" %c",&square[i][j]);
      //formatting sub_square with 'b'
      sub_square[i][j]='b';
    }
  }
  //check the row consisted of only '.'
  for(j=0;j<column;j++){
    for(i=0;i<row;i++){
      if(square[i][j]=='#'){//contain '#'
        break;
      }else if(i==row-1){//don't contain '#'
        for(i=0;i<row;i++){
          sub_square[i][j]='w';
        }
      }
    }
  }
  //check the column consisted of only '.'
  for(i=0;i<row;i++){
    for(j=0;j<column;j++){
      if(square[i][j]=='#'){//contain '#'
        break;
      }else if(j==column-1){//don't contain '#'
        for(j=0;j<column;j++){
          sub_square[i][j]='w';
        }
      }
    }
  }
  //output the answer
  for(i=0;i<row;i++){
    for(j=0;j<column;j++){
      if(sub_square[i][j]=='b'){
        printf("%c",square[i][j]);
        new_line = 1;//check whether start a new line
      }
    }
    if(new_line == 1){//if c==0, keep
      printf("\n");
      new_line = 0;//formatting
    }  
  }
  return 0;
}

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

#define ll long long

using namespace std;

int main(){

    int n;

    cin >> n;

    if(n%2 == 0) cout << (n/2) * (n/2) << endl;
    else cout << (n/2) * (n/2 + 1) << endl; 

    return 0;
}

Measured memory_bytes: 256
N, K = map(int,input().split())
A = list(map(int,input().split()))
A = [0] + A
L = []
S = set()
i = 1
cnt = 0
while (not i in S) and cnt != K:
    S.add(i)
    L.append(i)
    cnt += 1
    i = A[i]

if cnt == K:
    print(i)
else:
    j = L.index(i)
    ans = L[(j + (K - j) % (cnt - j)) % cnt]
    print(ans)

Measured memory_bytes: 32376
#include<stdio.h>
#include<math.h>
int main() {
  int a, b, c, d, l, n, x, z;
  scanf("%d %d %d %d %d", &l, &a, &b, &c, &d);
  n = ceil((double)a / (double)c);
  x = ceil((double)b / (double)d);
  if(n >= x) {
    z = l - n;
  }else{
    z = l - x;
  }
  printf("%d\n", z);
  return 0;
}

Measured memory_bytes: 600
import java.util.*;
import java.io.*;
import static java.lang.System.in;

public class Main {
    static ArrayList<Integer>[] rec;
    static int[] size, id;
    public static void main(String[] args)throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double ans = 0.0, k = 380000.0;
        for(int i=0;i<n;i++){
            double mount = sc.nextDouble();
            String kind = sc.next();
            if(kind.equals("JPY")) ans += mount;
            else ans += k*mount;
        }
        System.out.println(ans);
    }
}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

ll a , b , c ;

int main() {
  cin >> a >> b >> c ;
  ll m = b / c - ( a ) / c ;
  if( a % c == 0 ) m++ ;
  cout << m ;
  return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int num_place, num_spell;
string S;

bool can_reach(int goal, int start, string s, vector<char>& spells, vector<char>& dirs){
    //goalは左端か右端のみ
    for (int i = 0; i < num_spell; ++i){
        if (spells[i] == s[start]){
            start += (dirs[i] == 'R' ? 1 : -1);
        }
        //cout << start << endl;
        if (s[start] == '_'){
            return start == goal;
        }
    }
    return false;
}

int main(){
    cin >> num_place >> num_spell;
    cin >> S;
    S = '_' + S + '_';
    std::vector<char> spells(num_spell, 0);
    std::vector<vector<char> > dirs(2, vector<char>(num_spell, 0));
    for (int i = 0; i < num_spell; ++i){
        cin >> spells[i] >> dirs[0][i];
        //cout << dirs[0][i];
        dirs[1][i] = (dirs[0][i] == 'R' ? 'L' : 'R');
    }
    int ub = S.size() - 1;
    int lb = 0;
    //左端からちょうど落ちなくなるところを探す lb: 落ちる側　ub: 落ちない側
    int m;
    while (ub - lb > 1){
        m = (ub + lb) / 2;
        (can_reach(0, m, S, spells, dirs[0]) ? lb : ub) = m;
    }
    int lower = lb;//引けば答えが出るようにしたい
    //cout << lb << endl;
    ub = S.size() - 1;
    lb = 0;
    reverse(S.begin(), S.end());
    
    while (ub - lb > 1){
        m = (ub + lb) / 2;
        (can_reach(0, m, S, spells, dirs[1]) ? lb : ub) = m;
    }
    int upper = lb;
    //cout << upper << endl;
    cout << S.size() - 2 - upper - lower << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<bool> sunuke(n+1,false);
    for(int i=0; i<k; i++) {
        int d;
        cin >> d;
        for(int i=0; i<d; i++) {
            int a;
            cin >> a;
            sunuke[a] = true;
        }
    }
    int sum = 0;
    cout << endl;
    for(int i=1; i<=n; i++){
        if(sunuke[i] == false) sum++;
    }
    cout << sum << endl;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

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

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    for(auto &x : A) cin >> x;

    vector<ll> s(N+1, 0);
    for(int i=0; i<N; i++) s[i+1]=(s[i]+A[i])%MOD;
    ll ans=0;
    for(int i=0; i<N; i++){
        ans=(ans+A[i]*(s[N]-s[i+1])%MOD)%MOD;
    }
    if(ans < 0) ans+=MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6424