akhauriyash/Code-Regression huggingface dataset:
import sys
L=list(map(int,sys.stdin.readline().split()))
cnt=0
while True:
  if L[0]==L[1]==L[2]:
    break
  L.sort()
  if L[2]-L[0]>=2:
    L[0]+=2
  elif L[2]-L[1]>=2:
    L[1]+=2
  elif L[0] !=L[1] or L[1] !=L[2]:
    L[0]+=1
    L[1]+=1
  cnt+=1
  
print(cnt)  
    


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

int main(){
  ll n;
  cin>>n;
  ll a[n],b[n];
  for(int i=0;i<n;i++)cin>>a[i]>>b[i];
  ll cnt=0,ans=-1;
  for(int i=0;i<n;i++){
    if(a[i]==b[i])cnt++;
    else cnt=0;
    ans=max(ans,cnt);
  }
  cout<<(ans<3 ? "No" : "Yes")<<endl;
}


Measured memory_bytes: 3636
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())
def onem():
    return int(input())
def s(x):
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x):
    return " ".join(map(str,x))

n,k = m()

if k == 1:
    print(0)
else:
    print(n-k)

Measured memory_bytes: 38256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

#define MOD 1000000007

int main(void){
	int n; scanf("%d", &n);
	int a[n];
	rep(i, n) a[i] = 0;
	rep(i, n){
		int t; scanf("%d", &t);
		a[t]++;
	}
	if(n%2 == 1 && a[0] != 1){
		cout << 0 << endl;
		return 0;
	}
	for(int j = (n%2)+1 ; j <= n-1 ; j += 2) if(a[j] != 2){
		cout << 0 << endl;
		return 0;
	}
	
	lli ans = 1;
	rep(i, n/2){
		ans = (ans*2) % MOD;
	}

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

Measured memory_bytes: 640
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();

    if (a*b >= c*d) {
      System.out.println(a*b);
    } else {
      System.out.println(c*d);
    }

  }

}


Measured memory_bytes: 21844
n, y = gets.strip.split.map(&:to_i)
a, b, c = -1, -1, -1

(0..n).each do |i|
    k = (5000 * (n - i) - (y - 10000 * i)) / 4000
    j = n - i - k

    c1 = j >= 0 && k >= 0
    c2 = i + j + k == n
    c3 = 10000 * i + 5000 * j + 1000 * k == y

    if c1 && c2 && c3
        a, b, c = i, j, k
        break
    end
end

puts "#{a} #{b} #{c}"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  ll a, b, c;
  cin >> a >> b >> c;

  // a + b + 2root(ab) < c
  // 4ab < (c- a - b)^2 and c-a-b >= 0

  if (4 * a * b < (c - a - b) * (c - a - b) && c - a - b >= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int N;
	string S;

	cin >> N;
	cin >> S;
	string ans = "No";

	if (S.substr(0, N / 2) == S.substr(N / 2))
		ans = "Yes";
	cout << ans << endl;
}



Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let d = read_vec::<usize>();
    if d[0] != 0 {
        println!("{}", 0);
        return;
    }
    for i in 1..n {
        if d[i] == 0 {
            println!("{}", 0);
            return;
        }
    }
    let big_int = 998244353i64;

    let mut levels = vec![0; n];
    for i in 0..n {
        levels[d[i]] += 1;
    }
    let mut max_level = 0;
    for i in 0..n {
        if levels[i] != 0 {
            max_level = i;
        }
    }

    let mut ans = 1;
    for i in 1..max_level + 1 {
        let mut temp = 1;
        for _ in 0..levels[i] {
            temp *= levels[i - 1] as i64;
            temp %= big_int;
        }
        ans *= temp;
        ans %= big_int;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 6396
import sys
input = sys.stdin.readline
X, Y, A, B, C = (int(i) for i in input().split())
p = [[int(x), "A"] for x in input().split()]
q = [[int(x), "B"] for x in input().split()]
r = [[int(x), "C"] for x in input().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]
apples = p+q+r


#apples.sort(reverse=True)
apples = sorted(apples, reverse=True)
#print(apples)
ans = 0
pend = 0


for hapi, col in apples:
    if col == "C":
        pend += 1
        ans += hapi
    elif col == "A":
        if X > 0:
            ans += hapi
            X -= 1

    elif col == "B":
        if Y>0:
            ans += hapi
            Y -= 1

    if (X < 1 and Y < 1) or X+Y == pend:
        break
    #print(ans)
    #print("XY", X, Y, pend)
#print("XY", X, Y, pend)
print(ans)


Measured memory_bytes: 119916
X,N=map(int,input().split())
A=[]
if N != 0:
  A=list(map(int,input().split()))

visited=[False]*102

for a in A:
  visited[a] = True
  
min = 200
ans=-1
for i in range(102):
  if (not visited[i]) and min > abs(i - X):
    min=abs(i-X)
    ans=i
    
print(ans)

Measured memory_bytes: 9200
# -*- coding: utf-8 -*-

import sys
import math
import itertools

debug = False

def log(text):
    if debug:
        print(text)


def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (a, b, h, m) = [int(e) for e in lines[0].split(' ')]
        
    return (a, b, h, m)


def solve(a, b, h, m):


    m_angle = m * 360 / 60
    h_angle = h * 360 / 12 + 30 * m_angle / 360
    
    
    a_b_angle = min([abs(h_angle - m_angle), 360 - abs(h_angle - m_angle)])

    cc = a**2 + b**2 - 2 * a * b * math.cos(2 * math.pi * a_b_angle / 360)
    
    result = math.sqrt(cc)

    return  result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Measured memory_bytes: 62956
#include<stdio.h>

int main(void){
  int i,j,n;

  scanf("%d",&n);
  for(i=3;i<=n;i++){
    j=i;
    if(i%3==0)
      printf(" %d",i);
    else
      while(j>0){
	if(j%10==3){
	  printf(" %d",i);
	  break;
      }
	j/=10;
     }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 1772
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var raw = ReadLine().Split().Select(int.Parse).ToArray();
            var A = raw[0];
            var B = raw[1];

            WriteLine(Math.Max(Math.Max(A + B, A - B), A * B));
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

const int mod = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, K, nmf = 0, nms = 0, ans = 0;
    cin >> N >> K;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    ll bmul = (K + 1) * K / 2ll % mod;
    ll amul = (K - 1) * K / 2ll % mod;
    
    rep(i, N) {
        rep(ii, N) {
            if (a[i] < a[ii]) {
                if (i > ii) {
                    ans = (ans + bmul) % mod;
                }
                else {
                    ans = (ans + amul) % mod;
                }
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
using namespace std;
typedef long long ll;
const int maxn=1e7+7;
string s1,s2;
int main (){
    int ans=0;
    cin>>s1>>s2;
    for(int i=0;i<s1.size();i++){
        if(s1[i]!=s2[i]) ans++;
    }
    printf ("%d\n",ans);


}







Measured memory_bytes: 3444
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
#include <algorithm>
#include<set>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
#define d9_7 1000000007
int main(void){
  ll n,k;
  cin >> n>>k;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }
  ll ten1=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      if(a[i]>a[j]){//繰り返しをいったん虫
        ten1++;
      }
    }
  }
  ll ten2=0;//繰り返しのところ
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(a[i]>a[j]){
        ten2++;
      }
    }
  }
  k%=d9_7;
  ll k2=(((k)*(k-1))/2)%d9_7;
  //cout << ten1 << " " << ten2 << endl;
  cout<< + ((ten2*(k2))%d9_7 + (ten1*k)%d9_7)%d9_7<<endl;
  return 0;
}

Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)


'''

'''

def gcd(a,b):
	if(b == 0):
		return a
	else:
		return gcd(b,a%b)

def solve(a,b):
	g = gcd(a,b)
	return a*b//g

a,b = list(map(int, stdin.readline().rstrip().split()))
ans = solve(a,b)
print(ans)


Measured memory_bytes: 5356
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

typedef struct{
  //石の数
  ll num;
  //同じ石の数の中で先頭の位置
  int lead;
  //同じ石の数の山の個数
  ll nums;
}T;

bool operator< (const T& l, const T& r){
  return l.num<r.num;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<ll> v(N,0);
  map<ll,PIL> mp;
  rep(i,N){
    ll x;cin >> x;
    if(mp.count(x)){
      ++mp[x].second;
    }else{
      mp[x] = PII(i,1ll);
    }
  }
  priority_queue<T> pque;
  for(const pair<ll, PII> p : mp){
    pque.push({p.first, p.second.first, p.second.second});
  }
  pque.push({0,-1,0});

  while(!pque.empty()){
    T t = pque.top(); pque.pop();
    T nt = pque.top(); pque.pop();
    v[t.lead] += (t.num - nt.num)*t.nums;
    nt.nums += t.nums;
    nt.lead = min(nt.lead,t.lead);
    if(nt.lead!=-1) pque.push(nt);
  }
  rep(i,N)cout << v[i] << endl;
  return 0;
}


Measured memory_bytes: 11892
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

x=int(input())
if x%11==0:
    print(x//11*2)
else:
    print(x//11*2+(x%11)//7+1)

Measured memory_bytes: 68964
#include<bits/stdc++.h>
#define LL long long
#define SZ(x) (int)x.size()-1
#define F(i,a,b) for (int i=a;i<=b;++i)
#define DF(i,a,b) for (int i=a;i>=b;--i)
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
LL read(){
    char ch=getchar(); LL w=1,c=0;
    for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
    for (;isdigit(ch);ch=getchar()) c=(c<<3)+(c<<1)+(ch^48);
    return w*c;
}
int main(){
	LL n=read(),A=read(),B=read();
	if (A>B) swap(A,B);
	if ((B-A)&1){
		cout<<min(A+(B-A)/2,(n-B+1+(B-A)/2))<<'\n';
	}
	else {
		cout<<(B-A)/2<<'\n';
	}
    return 0;
}



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

int out_print(vector<int> b, int N, int num) {
  cout << num << endl;
  if(num == 0) return 0;
  
  for(int i = 0; i < N; i++) {
    if(b[i] == 1) {
      cout << (i+1) << " "; 
    }
  }
  return 0;  
}

int is_odd(vector<int> b, int N, int k) {
  int sum = 0;
  for(int j = 1;;j++) {
    int index = k * j;
    if( index > N ) break;
    sum += b[index - 1];
  }
  return sum % 2;
}

int main(void) {
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  for(int i = 0; i < N; i++) {
    cin >> a[i]; 
    b[i] = 0;
  }
  
  if(N == 1) {
    b[N-1] = a[N-1];
    out_print(b, N, b[N-1]); return 0;
  }
  
  int num = 0;
  for(int i = N - 1; i >= 0; i--) {

    int sum = 0;
    for(int j = 1;;j++) {
      int index = (i+1) * j;
      if( index > N ) break;
      sum += b[index - 1];
    }
 
    b[i] = (sum % 2) ^ a[i];
    num += b[i];
  }
 
  out_print(b, N, num);
  return 0; 
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main(){
    while(true){
        int h,w;
        cin>>h>>w;
        if(h==0 && h==w){
            break;
        }
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                if((i+j) %2==0){
                    cout<<"#";
                }
                else{
                    cout<<".";
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
    
}


Measured memory_bytes: 3104
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 


int main(){

	int n;
	cin>>n;

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

	int b=1; // < = >
	int res=0;
	for(int i=1;i<n;i++){
		if( b==0 ){

			if( a[i-1] > a[i] ) res++,b=1;

		}else if(b==1){

			if( a[i-1] < a[i] ) b=0;
			else if( a[i-1] > a[i] ) b=2;

		}else if(b==2){
			if( a[i-1] < a[i] ) res++,b=1;
		}
	}

	res++;


	cout<<res<<endl;



}

Measured memory_bytes: 1024
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n = II()
    sumv = 0
    for i in range(1, n+1):
        if i%3==0 or i%5==0: continue
        else: sumv += i
    print(sumv)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include <iostream>
using namespace std;
int n,s[100],t[100],sum;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=0;i<n;i++){
        cin>>t[i];
        sum+=t[i];
    }
    int MAX=sum+s[0],M=MAX;
    for(int i=1;i<n;i++){
        M+=s[i]-t[i-1];
        MAX=max(MAX,M);
    }
    cout<<MAX<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

void solve() {
  int N;
  cin >> N;
  vvi lk(N),rk(N);
  ll ans = 0;
  int len=0;
  rep(i,N) {
    int k,l,r;
    cin >> k >> l >> r;
    k--;
    if(l>r) {
      l-=r;
      ans += r;
      lk[k].push_back(l);
      len++;
    } else {
      r-=l;
      ans += l;
      if(k<N-1) {
        rk[N-2-k].push_back(r);
      }
    }
  }
  {
    priority_queue<int> que;
    srep(i,len,N) {
      for(int p:lk[i]) {
        que.push(p);
      }
    }
    drep(i,len) {
      for(int p:lk[i]) {
        que.push(p);
      }
      if(que.empty()) continue;
      int p = que.top();
      que.pop();
      ans += p;
    }
  }
  {
    priority_queue<int> que;
    len=N-len;
    srep(i,len,N) {
      for(int p:rk[i]) {
        que.push(p);
      }
    }
    drep(i,len) {
      for(int p:rk[i]) {
        que.push(p);
      }
      if(que.empty()) continue;
      int p = que.top();
      que.pop();
      ans += p;
    }
  }
  cout << ans << endl;
}
  
int main() {
  int t;
  cin >> t;
  rep(ti,t) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 17796
import sys
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

minus = [b[i]-a[i] for i in range(n) if a[i]-b[i]<0]
c = [a[i]-b[i] for i in range(n) if a[i]-b[i]>0]

if sum(c)<sum(minus):
  print(-1)
  sys.exit()
elif sum(minus)==0:
  print(0)
  sys.exit()

c.sort()
cost = sum(minus)
x = 0
for i,y in enumerate(c[::-1]):
  if x>cost:
    print(len(minus)+i)
    sys.exit()
  else:
    x+=y
print(len(minus)+len(c))

Measured memory_bytes: 19060
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

int main() {
    int i, j, n, l;
    scanf("%d%d", &n, &l);
    vi x(n);
    for(i=0; i<n; i++) scanf("%d", &x[i]);
    for(i=0; i<n-1; i++) if(x[i]+x[i+1]>=l) break;
    if(i==n-1) {
        printf("Impossible\n");
        return 0;
    }
    printf("Possible\n");
    for(j=0; j<i; j++) printf("%d\n", j+1);
    for(j=n-2; j>i; j--) printf("%d\n", j+1);
    printf("%d\n", i+1);
    return 0;
}

Measured memory_bytes: 1152
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-19 07:21:34
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  vector<vector<int>> c(3, vector<int>(3)); cin >> c;

  if (c[0][0] + c[1][1] == c[0][1] + c[1][0] && 
      c[1][0] + c[2][1] == c[2][0] + c[1][1] && 
      c[0][1] + c[1][2] == c[1][1] + c[0][2] && 
      c[1][1] + c[2][2] == c[1][2] + c[2][1] && 
      c[0][0] + c[1][2] == c[1][0] + c[0][2] && 
      c[2][0] + c[1][2] == c[1][0] + c[2][2]) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }

  return 0;
}

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

int main() {
  int p = 1,ac = 1,bc = 0,cc = 0;
  string a,b,c;
  cin >> a >> b >> c;
  char x = a.at(0);
  if(a == "a"){
    cout << "A" << endl;
    return 0;
  }
  while(p = 1){
    if(x == 'a'){
      x = a.at(ac);
      ac++;
    }
    else if(x == 'b'){
      x = b.at(bc);
      bc++;
    }
    else if(x == 'c'){
      x = c.at(cc);
      cc++;
    }
    if(ac == a.size() && x == 'a'){
      cout << "A" << endl;
      return 0;
    }
    else if(bc == b.size() && x == 'b'){
      cout << "B" << endl;
      return 0;
    }
    else if(cc == c.size() && x == 'c'){
      cout << "C" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;

 int g[15][15];

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

    string s;
    int n;
    cin >> n >> s;
    rep(i,s.length()){
        if(int((s[i] + n)-'A') >= 26 ){
            s[i] = char((s[i]+n)-26);
        }
        else s[i] = char(s[i]+n);
    }
    cout << s << endl;



    cout << 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.PrintWriter;
   
public class Main {
    
    public static void main(String[] args) throws IOException {
//    	long l = System.currentTimeMillis();
        new Main().exec();
//    	long l2 = System.currentTimeMillis();
//    	System.out.println(l2 - l);
    }
      
    public void exec() throws IOException {
        InputUtil in = new InputUtil();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int[] S = in.nextInt(new int[n+1],n);
        int q = in.nextInt();
        int C = 0;
        for(int i=0; i<q; i++) {
            int j=0;
            int key=in.nextInt();
            for(S[n] = key; key!=S[j]; j++);
            if(j<n) C++;
        }
        out.println(C);
        out.flush();
    }
}

class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 50000;
	
	//Fields
	protected InputStream in;
	private char[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private BufferedReader br = null;
	
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {br = new BufferedReader(new InputStreamReader(this.in = in));}
	protected void initBuf(int bufsiz) {buf = new char[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && br.ready()) {
			max = br.read(buf);
			ptr = 0;
		}
	}
	//Number Input Reader/Parser
	private boolean isNum(char b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(char b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		char c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result, int num) throws IOException {
		readBuf();
		for(int i=0; i<num; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}

Measured memory_bytes: 25220
n, m = map(int, input().split())

p = set()
q = set()

for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        p.add(b)
    elif b == n:
        q.add(a)
else:
    print("POSSIBLE" if p & q else "IMPOSSIBLE")

Measured memory_bytes: 24208
// -*- coding:utf-8-unix -*-

use std::cmp::Ordering;
use std::collections::{HashMap, HashSet};

use itertools::Itertools;
use proconio::input;

#[allow(dead_code)]
fn map2d<InnerIt: IntoIterator, It: Iterator<Item = InnerIt>, B>(
    it: It,
    f: fn(InnerIt::Item) -> B,
) -> Vec<Vec<B>> {
    it.map(|row| row.into_iter().map(f).collect::<Vec<_>>())
        .collect::<Vec<_>>()
}

fn argmax_list<It: Iterator<Item = Item>, Item, F>(it: It, mut compare: F) -> Vec<It::Item>
where
    Item: Copy,
    F: FnMut(&It::Item, &It::Item) -> Ordering,
{
    let mut max: Option<Item> = None;
    let mut argmax = Vec::new();
    for item in it {
        let comp = match max {
            None => Ordering::Greater,
            Some(max) => compare(&item, &max),
        };
        match comp {
            Ordering::Equal => argmax.push(item),
            Ordering::Greater => {
                max = Some(item);
                argmax.clear();
                argmax.push(item);
            }
            Ordering::Less => {}
        }
    }
    return argmax;
}

#[allow(dead_code)]
fn compare_key<K, V>(t1: &(K, V), t2: &(K, V)) -> Ordering
where
    K: Ord,
{
    t1.0.cmp(&t2.0)
}

fn compare_val<K, V>(t1: &(K, V), t2: &(K, V)) -> Ordering
where
    V: Ord,
{
    t1.1.cmp(&t2.1)
}

#[allow(non_snake_case)]
fn main() {
    input! {
        _: i32,
        _: i32,
        M: i32,
        bombs: [(i32, i32); M],
    }
    // count_y[y] = #{ x | (x, y) is bomb }
    let mut count_y = HashMap::new();
    let mut count_x = HashMap::new();
    for bomb in &bombs {
        let (y, x) = *bomb;
        *count_y.entry(y).or_insert(0) += 1;
        *count_x.entry(x).or_insert(0) += 1;
    }
    let count_y = count_y;
    let count_x = count_x;
    let max_y = argmax_list(count_y.into_iter(), compare_val);
    let max_x = argmax_list(count_x.into_iter(), compare_val);
    let max = max_y[0].1 + max_x[0].1;
    let bomb_set = bombs.iter().map(|bomb| *bomb).collect::<HashSet<_>>();
    for ((y, _), (x, _)) in max_y.iter().cartesian_product(max_x.iter()) {
        let cand = (*y, *x);
        if !bomb_set.contains(&cand) {
            println!("{}", max);
            return;
        }
    }
    println!("{}", max - 1);
}


Measured memory_bytes: 21964
#include<bits/stdc++.h>
#define LIM 1+2+4+8+16+32+64+128
#define int long long 
using namespace std;
typedef struct{
  int per;
  int ko;
  int kyoda;
  int konoko;
}TRE;
int ace(int a,int b){
  int ss=0;
  for(int i=b;i<=a;i++){
    ss+=i;
  }
  return(ss);
}
typedef pair<int,int>P;
signed  main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int c,a,nb;
    cin>>c>>a>>nb;
    int ans=min(c,min(a,nb));
    c-=ans;
    a-=ans;
    nb-=ans;
    int ss=min(c/2,a);
    ans+=ss;
    c-=2*ss;
    a-=ss;
    ans+=c/3;
    cout<<ans<<endl;
  }
  return(0);
}



Measured memory_bytes: 3108
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            long a=scan.nextInt();
            long b=scan.nextInt();
            long c=scan.nextInt();
            long d=scan.nextInt();
            long ans=0;
            ans=b*d;
            ans=Math.max(ans,b*c);
            ans=Math.max(ans,a*c);
            ans=Math.max(ans,a*d);
            out.println(ans);
        }
        out.flush();
        out.close();
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


Measured memory_bytes: 32376
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string>
#include<map>

using namespace std;
const int INF = 1<<30;
typedef long long int ll;

int main(){
	int n, m, k;cin>>n>>m>>k;bool ans=false;
	for(int i=0;i<=n&&!ans;i++)
		for(int j=0;j<=m;j++){
			if(k==j*(n-i)+i*(m-j)){ans=true;break;}
		}
	cout << (ans?"Yes":"No") << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String s = scan.next();
        String t = scan.next();
        for(int i = 0; i < n; i++){
            System.out.print(s.charAt(i));
            System.out.print(t.charAt(i));
        }
        scan.close();
    }
}

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

void print_vec(vector<int> vec) {
  cout << "[";
  for (int i = 0; i < vec.size(); i++) {
    if (i) {
      cout << ", ";
    }
    cout << vec.at(i);
  }
  cout << "]...size: " << vec.size() << endl;
}

int main() {
  vector<double> v;

  while (1) {
    int n;
    cin >> n;

    if (n == 0) {
      break;
    }

    vector<int> ss(n);
    double sum = 0;

    rep(i, n) {
      int s;
      cin >> s;

      sum += s;
      ss[i] = s;
    }

    double ave = sum / n;
    double d = 0;

    rep(i, n) { d += pow(ss[i] - ave, 2); }

    double a = sqrt(d / n);
    v.push_back(a);
  }

  for (auto &&i : v) {
    printf("%f\n", i);
  }
}



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

long long int cnt[51];

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

	long long int a,b;

	cin >> a >> b;

	memset(cnt,0,sizeof(cnt));
	a-=1;
	long long int x = 2;
	for(long long int i=1;i<=40;i++)
	{
		cnt[i]+=(b/x)*(x/2);
		if(b%x>=(x/2))
		{
			cnt[i]+=(b%x)-(x/2)+1;
		}
		//cout << cnt[i] << ' ' << x << '\n';
		x*=2;
	}

	x = 2;
	for(long long int i=1;i<=40;i++)
	{
		cnt[i]-=(a/x)*(x/2);
		if(a%x>=(x/2))
		{
			cnt[i]-=((a%x)-(x/2)+1);
		}
		//cout << cnt[i] << ' ' << x << '\n';
		x*=2;
	}	

	long long int res = 0;
	x = 1;
	for(long long int i=1;i<=40;i++)
	{
		//cout << x << ' ' << cnt[i] << '\n';
		if(cnt[i]%2==1)
		{
			res+=x;
		}
		x*=2;
	}

	cout << res << '\n';
    return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n, k = nm()
    if k > 45:
        k = 45
    a = nl()
    b = [0]*n
    for _ in range(k):
        for i in range(n):
            b[max(0, i - a[i])] += 1
            if i + a[i] + 1 < n:
                b[i + a[i] + 1] -= 1
        for i in range(n-1):
            b[i+1] += b[i]
            a[i] = 0
        a[-1] = 0
        b, a = a, b
    print(*a)
    return

solve()


Measured memory_bytes: 91520
#include<bits/stdc++.h>
#include<vector>
#define REP(i,n) for(int i=0;i<n;i++)
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define M 1000000007

using namespace std;

int main(void){
    int N,K;
    cin>>N>>K;
    VI h(N);
    VI dp(N);
    REP(i,N)cin>>h[i];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);

    for(int i=2;i<N;i++){
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        for(int j=2;j<min(i+1,K+1);j++){
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

bool check(vector<int> A){

	REP(i,A.size()){
		if(A[i]%2 != 0) return false;
	}

	return true;
}


int main(void){

	int N; cin >> N;
	vector<int> A(N);
	REP(i,N) cin >> A[i];

	int ans = 0;
	while(1){
		if(check(A) == true){
			REP(i,N) A[i] /= 2;
			ans++;

		}else{
			break;
		}
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
using namespace std;
using ll = long long;
using pii = pair<int,int>;
template<typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a){
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os, vector<T> v){
    for(auto x:v)os << x << ' ';
    return os;
}
void debug(){cerr << '\n';}
template<typename H, typename... T>
void debug(H a, T... b){
    cerr << a;
    if(sizeof...(b))cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    vector<int>b(n);
    rep(i,n)cin >> b[i];
    vector<int>ans;
    rep(_,105)if(b.size())for(int i = (int)b.size()-1; i >= 0; i--){
        if(b[i] == i + 1){
            ans.push_back(i+1);
            b.erase(b.begin()+i);
            break;
        }
    }
    if(b.size()){
        cout << -1 << endl;
    }else{
        reverse(ans.begin(),ans.end());
        rep(i,n)cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define init(a) memset((a),0,sizeof(a))
using namespace std;
typedef double D;
typedef vector<D> P;
const D EPS = 1e-8;

int n,m,R;
P sp[2020],tp[20],ep;
D sr[2020],tb[20],p[20];
vector<int> rm[20];

inline P mul(P p, const D &d){
  rep(i,p.size())p[i] *= d;
  return p;
}

inline P add(P a, const P &b){
  rep(i,a.size())a[i] += b[i];
  return a;
}

inline D dis2(const P &a, const P &b){
  D x = a[0]-b[0], y = a[1]-b[1], z = a[2]-b[2];
  return x*x+y*y+z*z;
}

inline D score(const int &i){
  return tb[i]/dis2(ep,tp[i]);
}

inline int intersect(const int &p, const int &c){
  P l = ep, r = tp[p];
  D r2 = sr[c]*sr[c];
  bool f1 = (dis2(sp[c],l)<r2+EPS), f2 = (dis2(sp[c],r)<r2+EPS);
  if(f1&&f2)return 0;
  if(f1||f2)return 1;

  rep(i,30){
    P m1 = mul(add(mul(l,2),r),1.0/3), m2 = mul(add(l,mul(r,2)),1.0/3);
    D d1 = dis2(sp[c],m1), d2 = dis2(sp[c],m2);
    if(d1<d2)r = m2;
    else l = m1;
  }
  if(dis2(sp[c],l)<r2+EPS)return 1;
  return 0;
}


D rec(int d,int num, D sum, vector<int> &use){
  if(d==m)return sum;
  D res = rec(d+1,num,sum,use);
  vector<int> tmp = use;
  rep(i,rm[d].size()){
    if(!use[rm[d][i]]){
      num++;
      use[rm[d][i]] = 1;
    }
  }
  if(num<=R)res = max(res,rec(d+1,num,sum+p[d],use));
  use = tmp;
  return res;
}
		    
int main(){
  while(scanf("%d%d%d",&n,&m,&R),n){
    rep(i,n){
      sp[i].resize(3);
      rep(j,3)scanf("%lf",&sp[i][j]);
      scanf("%lf",&sr[i]);
    }
    rep(i,m){
      tp[i].resize(3);
      rep(j,3)scanf("%lf",&tp[i][j]);
      scanf("%lf",&tb[i]);
    }
    ep.resize(3);
    rep(i,3)scanf("%lf",&ep[i]);

    rep(i,m){
      rm[i].clear();
      rep(j,n){
	if(intersect(i,j))rm[i].push_back(j);
      }
    }

    rep(i,m)p[i] = score(i);
    vector<int> use(n,0);
    cout << fixed << setprecision(10) << rec(0,0,0,use) << endl;
  }
}

Measured memory_bytes: 1640
import sys
input=lambda: sys.stdin.readline().rstrip()
mod=10**9+7
n,a,b=map(int,input().split())
ans=pow(2,n,mod)-1

bb=1
for i in range(b):
  bb=(bb*(n-i)*pow(i+1,mod-2,mod))%mod
  if i==a-1:
    aa=bb
print((ans-aa-bb)%mod)


Measured memory_bytes: 40556
a = input()
if a[0] == a[1] and a[1] == a[2]:
  print("Yes")
elif a[1] == a[2] and a[2] == a[3]:
  print("Yes")
elif a[0] == a[1] and a[1] == a[2] and a[2] == a[3]:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
import java.util.Scanner;


public class Main {

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

		int n = sc.nextInt();
		int m = sc.nextInt();

		int l = 1;
		int r = n;
		for (int i=0;i<m;i++) {
			l = Math.max(l, sc.nextInt());
			r = Math.min(r, sc.nextInt());
		}

		System.out.println(Math.max(r-l+1, 0));

	}




}


Measured memory_bytes: 62708
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{
    public void Proc()
    {
        int itemCount = int.Parse(Reader.ReadLine());
        int[] list = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        Dictionary<int, int> lst1 = new Dictionary<int, int>();
        Dictionary<int, int> lst2 = new Dictionary<int, int>();
        for (int i = 0; i < list.Length; i++) {

            if(i%2 == 0) {
                if(lst1.ContainsKey(list[i])) {
                    lst1[list[i]]++;
                } else {
                    lst1[list[i]] = 1;
                }

            } else {
                if (lst2.ContainsKey(list[i]))
                {
                    lst2[list[i]]++;
                }
                else
                {
                    lst2[list[i]] = 1;
                }
            }
        }
        int ans = 0;
        List<KeyValuePair<int, int>> l1 = lst1.OrderByDescending(a => a.Value).ToList();
        List<KeyValuePair<int, int>> l2 = lst2.OrderByDescending(a => a.Value).ToList();
        int tmp1 = l1.First().Value;
        if(l1.First().Key == l2.First().Key) {
            if(l2.Count > 1) {
                tmp1 += l2[1].Value;
            }
        } else {
            tmp1 += l2.First().Value;
        }
        int tmp2 = l2.First().Value;
        if (l2.First().Key == l1.First().Key)
        {
            if (l1.Count > 1)
            {
                tmp2 += l1[1].Value;
            }
        }
        else
        {
            tmp2 += l1.First().Value;
        }

        ans = itemCount - Math.Max(tmp1, tmp2);
        Console.WriteLine(ans);
    }




    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"

6
105 119 105 119 105 119


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 29024
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ld a[3333];
ld res;
ld dp[3333][3333];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]; 
	}
	dp[0][0]=1.00;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=n;j++)
			dp[i][j]=dp[i-1][j]*(1.00-a[i])+dp[i-1][j-1]*a[i];
	res=0.00;
	for(int i=(n+1)/2;i<=n;i++)
		res+=dp[n][i];
	//for(int i=1;i<=n;i++)
	//	cout<<dp[n][i]<<endl;
	cout<<fixed<<setprecision(10)<<res<<endl;	
	return 0;
}



Measured memory_bytes: 157952
#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define SUM(v) accumulate(v.begin(),v.end(),lli(0))
#define rev(n,d) for(int i=n;i>=d;i--)
#define FOR0(n) for(int i=0;i<n;i++)
#define FOR(a,n) for(int i=a;i<n;i++)
#define FORQ(a,n) for(int i=a;i<=n;i++)
#define inf 1000000009
#define inff 0x3f3f3f3f
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define mem(ar,x) memset(ar,x,sizeof ar)
#define present(container, element) (container.find(element) != container.end())
#define max3(a,b,c) return (lli(a)>lli(b)?(lli(a)>lli(c)?a:c):(lli(b)>lli(c)?b:c))
#define max4(a,b,c,d) return (max3(a,b,c)>lli(d)?(max3(a,b,c)):d)
#define min3(a,b,c) return (lli(a)<lli(b)?(lli(a)<lli(c)?a:c):(lli(b)<lli(c)?b:c))
#define min4(a,b,c,d) return (max3(a,b,c)<lli(d)?(max3(a,b,c)):d)
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii>ppii;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<pii>vpii;
const int N=100005;
int dr8[]={0,0,1,-1,1,1,-1,-1};
int dc8[]={1,-1,0,0,-1,1,-1,1};
int dr4[]={0,1,-1,0};
int dc4[]={1,0,0,-1};
int main(){
	fast
	string s,t;
	cin>>s>>t;
	int ls=s.length();
	int lt=t.length();
	int dp[ls+1][lt+1];
	mem(dp,0);
	for(int i=1;i<=ls;i++){
		for(int j=1;j<=lt;j++){
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			if(s[i-1]==t[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
		}
	}
	int l=dp[ls][lt];
	string st="";
//	st[l]='\n';
	int in=l-1;
	int i=ls,j=lt;
	while(i>0&&j>0){
		if(s[i-1]==t[j-1]){
			st=s[i-1]+st;
			in--;i--;j--;
		}
		else if(dp[i-1][j]>dp[i][j-1]){
			i--;
		}
		else j--;
	}
//	cout<<l<<endl;
	cout<<st;
}



Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000;
const int MOD = (int)1e9 + 7;
template <class T>
inline T in()
{
    T x;
    cin >> x;
    return x;
}

int countBit(int x)
{
    int r = 0;
    while (x)
    {
        r += x % 2;
        x /= 2;
    }
    return r;
}

signed main()
{
    int n = in<int>();
    int m = in<int>();
    vector<int> v;
    vector<int> p;
    for (int i = 0; i < m; i++)
    {
        int k = in<int>();
        int num = 0;
        for (int i = 0; i < k; i++)
        {
            int s = in<int>();
            num += pow(2, s - 1);
        }
        v.push_back(num);
    }
    for (int i = 0; i < m; i++)
    {
        int x = in<int>();
        p.push_back(x);
    }
    int lim = pow(2, n);
    int sum = 0;
    for (int i = 0; i < lim; i++)
    {
        bool flag = true;
        for (int j = 0; j < m; j++)
        {
            int a = i & v[j];
            int cnt = countBit(a);
            if (cnt % 2 != p[j])
            {
                flag = false;
                break;
            }
        }
        if (flag)
            sum++;
    }
    cout << sum << "\n";
}

Measured memory_bytes: 512
#include<iostream>

int main(void){
    int x, y;
    std::cin >> x >> y; //x == a, y == b;
    
    if(x < y){
        std::cout << 'a' << " " << '<' << " " <<'b' << std::endl;
        return 0;
    }
    else if(x > y){
        std::cout << 'a' << " " << '>' << " " << 'b' << std::endl;
        return 0;
    }
    else{
        std::cout << 'a' << " " << "==" << " " <<  'b' << std::endl;
        return 0;
    }
}


Measured memory_bytes: 3096