akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

const int N=30;

int n,vis[N];
char a[N];

int main(){
	scanf("%s",a+1); n=strlen(a+1);
	if(n<26){
		for(int i=1;i<=n;i++) vis[a[i]-'a']=1;
		int nxt=0; while(vis[nxt]) nxt++;
		for(int i=1;i<=n;i++) putchar(a[i]); putchar(nxt+'a');
	}
	else{
		int nxt=0,p=-1;
		for(int i=1;i<=n;i++){
			int cur=a[i]-'a'+1;
			while(vis[cur]) cur++;
			if(cur<26) nxt=cur,p=i;
			vis[a[i]-'a']=1;
		}
		if(p==-1) return puts("-1"),0;
		for(int i=1;i<p;i++) putchar(a[i]); putchar(nxt+'a');
	}
}

Measured memory_bytes: 256
var rt,rtodd;

function aaa(n,dp1){

    var m = 0,a = 1,b = 1,c = 1;
    rt = [];
    rt.push(0);
    while(a <= n){
        m++;
        rt.push(a);
        c++;b+=c;a+=b;
    }

    dp1[0] = [];
    dp1[0][0] = 0;

    for(var i = 1;i < 5;i++)
        dp1[i] = [];
    for(var i = 1;i <= n;i++){
        dp1[0][i] = 1000000000;
    }
    for(var iii = 1;iii <= m;iii++){
        var i = iii % 5;
        var ii = i - 1;
        if(ii < 0)
            ii = 4;
        for(var j = 0;j <= n;j++){
            if(j < rt[iii])
                dp1[i][j] = dp1[ii][j];
            else
                dp1[i][j] = dp1[ii][j] < dp1[i][j - rt[iii]] + 1 ? dp1[ii][j] : dp1[i][j - rt[iii]] + 1;
        }
    }

    m %= 5;

    return m;
}



function bbb(n,dp2){

    var m = 0,a = 1,b = 1,c = 1;
    rtodd = [];
    rtodd.push(0);
    while(a <= n){
        if(a % 2){
            m++;
            rtodd.push(a);
        }
        c++;b+=c;a+=b;
    }

    dp2[0] = [];
    dp2[0][0] = 0;

    for(var i = 1;i < 5;i++)
        dp2[i] = [];
    for(var i = 1;i <= n;i++){
        dp2[0][i] = 1000000000;
    }
    for(var iii = 1;iii <= m;iii++){
        var i = iii % 5;
        var ii = i - 1;
        if(ii < 0)
            ii = 4;
        for(var j = 0;j <= n;j++){
            if(j < rtodd[iii])
                dp2[i][j] = dp2[ii][j];
            else
                dp2[i][j] = dp2[ii][j] < dp2[i][j - rtodd[iii]] + 1 ? dp2[ii][j] : dp2[i][j - rtodd[iii]] + 1;
        }
    }

    m %= 5;

    return m;
}
function Main(input){
    input = input.split("\n");
    var dp1 = [],dp2 = [];

    var m1 = aaa(1000000,dp1);var m2 = bbb(1000000,dp2);

    for(var i = 0;1;i++){
        var n = parseInt(input[i],10);
        if(n == 0)
            break;
        var a = dp1[m1][n];var b = dp2[m2][n];
        console.log(a,b);
    }
    
}


Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 151396
using System;
class main
{
    static void Main(string[] args)
    {
        for (int a = 1; a <= 9; ++a)
        {
            for (int b = 1; b <= 9; ++b)
            {
                Console.WriteLine(a+"x"+b+"="+(a * b));
            }
        }
    }
}

Measured memory_bytes: 5536
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int n;
ll ans[55][55],pro[55][55],a[55][55];

void sq(){
	int i,j,k;
	fill(pro[0],pro[55],0ll);
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			for(k=0; k<n; ++k){
				add_mod(pro[i][j],(a[i][k]*a[k][j])%MOD);
			}
		}
	}
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			a[i][j] = pro[i][j];
		}
	}
}

void mul(){
	int i,j,k;
	fill(pro[0],pro[55],0ll);
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			for(k=0; k<n; ++k){
				add_mod(pro[i][j],(ans[i][k]*a[k][j])%MOD);
			}
		}
	}
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			ans[i][j] = pro[i][j];
		}
	}
}

int main(void){
	int i,j;
	ll d,ret=0ll;
	cin >> n >> d;
	fill(ans[0],ans[55],0ll);
	for(i=0; i<n; ++i){
		ans[i][i] = 1ll;
	}
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			cin >> a[i][j];
		}
	}
	while(d){
		if(d%2){
			mul();
		}
		sq();
		d /= 2;
	}
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			add_mod(ret,ans[i][j]);
		}
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())
    R, S, P = map(int, readline().split())
    T = readline().strip()

    T = [int(c) for c in T.translate(str.maketrans('rsp', '012'))]

    point = [R, S, P]
    hand = [0] * N

    ans = 0
    for i, com in enumerate(T):
        win = (com - 1) % 3
        if i >= K and win == hand[i - K]:
            hand[i] = -1
        else:
            hand[i] = win
            ans += point[win]

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 79388
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if(c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o') cout << "vowel"<< endl;
  else cout << "consonant"<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
const ll MOD=1e9+7;
using namespace std;

int main(){
  ll N;
  cin >> N;
  ll even = 0, odd = 0;
  rep(i,N){
    ll a;
    cin >> a;
    if(a%2 ==0) even++;
    else odd++;
  }
  if(odd%2 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
n,t=list(map(int,input().split()))
a=list(map(int,input().split()))

dp={}
mina=a[0]
maxdiff=0

for i in range(1,n):
    if a[i]>mina:
        diff=a[i]-mina
        maxdiff=max(maxdiff,diff)

        if diff in dp:
            dp[diff]+=1
        else:
            dp[diff]=1
        
    mina=min(mina,a[i])

print(dp[maxdiff])

Measured memory_bytes: 67712
N = input().strip()
n = len(N)
dp = [[[[[[0 for _ in range(2)] for _ in range(2)] for _ in range(2)] for _ in range(2)] for _ in range(2)] for _ in range(n+1)]
dp[0][0][0][0][0][0] = 1
for i in range(1,n+1):
    for lead in range(2):
        for small in range(2):
            for a in range(2):
                for b in range(2):
                    for c in range(2):
                        if lead ==0:
                            dp[i][0][small or (0<int(N[i-1]))][a][b][c] += dp[i-1][0][small][a][b][c]
                        for j in range(3,min(int(N[i-1]),7)+1 if small==0 else 8, 2):
                            dp[i][1][small or (j<int(N[i-1]))][a or (j==3)][b or (j==5)][c or (j==7)] += dp[i-1][lead][small][a][b][c]
print(dp[n][1][0][1][1][1]+dp[n][1][1][1][1][1])

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#define mod 1000000007
using namespace std;

int main()
{
    int m,n,o,i,j,k,odd=0,even=0;
    //long long int m,n,o,i,j,k,len=0;
    //vector <int> v;
    //float f,g,h;
    //char c,d;
    string a;
    cin>>n;
    //cin>>m>>c>>n>>d>>i;
    //cin>>f>>g;
    //cin>>c;
    for(i=0;i<n;i++)
    {
        cin>>m;
        if(m%2==0) even++;
        else odd++;
    }
    if(odd%2==0) cout<<"YES";
    else cout<<"NO";
    return 0;
}



Measured memory_bytes: 888
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,popcnt")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<19, mod = 1e9 + 7;
int n, m, k, g[23][2], dp[2][maxn][22], go[maxn][22];//[msk][cur_layer][cur_bit]
void pre() {
	for(int i = 0; i < maxn; i++) {
		go[i][19] = -1;
		for(int j = 19; j--;) {
			if(~i >> j & 1) go[i][j] = -1;
			else {
				if(i >> (j+1) & 1) go[i][j] = go[i][j+1];
				else go[i][j] = i;
				if(go[i][j] != -1)
					go[i][j] ^= 3<<j;
			}
                        if(go[i][j] != -1 && go[i][j] >= maxn) go[i][j] = -1;
		}
	}
}
void add(int &a, int b) {
	a += b;
	if(a >= mod) a -= mod;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	pre();
	cin >> n >> m >> k;--n;
	for(int a, b, c, i = 0; i < k; i++) {
		cin >> a >> b >> c;--a, --b;
		g[a][c] |= 1<<(n-b-1);
	}
	for(int i = 0; i <= n; i++) {
		dp[0][(1<<i)-1][0] = 1;
	}
	for(int i = 0; i < m; i++) {
		int I = i&1;
		int J = I^1;
		memset(dp[J], 0, sizeof dp[J]);
		for(int j = 0; j < 1<<n; j++) {
			for(int k = 0; k < n; k++) {
				//if(dp[i][j][k]) {
				//	cout << i << " " << j << " " << k << " " << dp[i][j][k] << '\n';
				//}
				add(dp[I][j][k+1], dp[I][j][k]);
				if(go[j][k] != -1) {
					add(dp[I][go[j][k]][k+1], dp[I][j][k]);
				}
			}
			if((j&g[i][1]) != g[i][1] || (j&g[i][0])) continue; 
			add(dp[J][j][0], dp[I][j][n]);
			//cout << i << " - " << j << " -> " << j << "\n";
			for(int k = 0; k < n; k++) if(~j >> k & 1) {
				int t = j|((1<<(k+1))-1);
			//cout << i << " - " << j << " -> " << t << "\n";
				add(dp[J][t][0], dp[I][j][n]);
			}
		}
	}
	cout << dp[m&1][(1<<n)-1][0];
	return 0;
}


Measured memory_bytes: 135424
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

namespace CF317
{
	internal class Program
	{
		private static void Main(string[] args)
		{
			var sr = new InputReader(Console.In);
			//var sr = new InputReader(new StreamReader("input.txt"));
			var task = new Task();
			using (var sw = Console.Out)
				//using (var sw = new StreamWriter("output.txt"))
			{
				task.Solve(sr, sw);
				//Console.ReadKey();
			}
		}
	}

	internal class Task
	{
		public void Solve(InputReader sr, TextWriter sw)
		{
			var input = sr.ReadArray(Int64.Parse);
			var n = input[0];
			var x = input[1];
			sw.WriteLine(Count(x, n - x, true, x));
		}

		private long Count(long curr, long step, bool isEven, long currCount)
		{
			if (isEven) {
				if (curr % step == 0)
					return currCount + (2 * (curr / step)) * step;
				currCount += (2L * (curr / step) + 1L) * step;

				return Count(step, curr - (curr / step) * step, false, currCount);
			}
			if (curr % step == 0)
				return currCount + (2 * (curr / step) - 1L) * step;

			currCount += (2L * (curr / step)) * step;
			return Count(step, curr - (curr / step) * step, false, currCount);
		}
	}
}

internal class InputReader : IDisposable
{
	private bool isDispose;
	private readonly TextReader sr;

	public InputReader(TextReader stream)
	{
		sr = stream;
	}

	public void Dispose()
	{
		Dispose(true);
		GC.SuppressFinalize(this);
	}

	public string NextString()
	{
		var result = sr.ReadLine();
		return result;
	}

	public int NextInt32()
	{
		return Int32.Parse(NextString());
	}

	public long NextInt64()
	{
		return Int64.Parse(NextString());
	}

	public string[] NextSplitStrings()
	{
		return NextString()
			.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
	}

	public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
	{
		return NextSplitStrings()
			.Select(s => func(s, CultureInfo.InvariantCulture))
			.ToArray();
	}

	public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
	{
		return
			str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
				.Select(s => func(s, CultureInfo.InvariantCulture))
				.ToArray();
	}

	protected void Dispose(bool dispose)
	{
		if (!isDispose) {
			if (dispose)
				sr.Close();
			isDispose = true;
		}
	}

	~InputReader()
	{
		Dispose(false);
	}
}

Measured memory_bytes: 2776
#include <iostream>
using namespace std;
class list 
{
    public:
        struct Node
        {
            int val;
            Node *next, *pre;
        };
        Node *origin;
        list()
        {
            origin = new Node;
            origin->next = origin;
            origin->pre = origin;
        }
        Node *find(int num)
        {
            Node *n = origin->next;
            while(n != origin && n->val != num) n = n->next;
            return n;
        }
        void push_front(int num)
        {
            Node *n = new Node;
            n->val = num;
            n->next = origin->next;
            origin->next->pre = n;
            origin->next = n;
            n->pre = origin;
        }
        void erase(Node *n)
        {
            if(n == origin) return;
            n->pre->next = n->next;
            n->next->pre = n->pre;
            delete n;
        }
        void erase_num(int num)
        {
            erase(find(num));
        }
        void pop_front()
        {
            erase(origin->next);
        }
        void pop_back()
        {
            erase(origin->pre);
        }
        void print()
        {
            Node *n = origin->next;
            bool flag = false;
            while(n != origin)
            {
                if(flag) cout << " " << n->val;
                else cout << n->val, flag = true;
                n = n->next;
            }
            cout << "\n";
        }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    list L;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if(s == "insert")
        {
            int x; cin >> x;
            L.push_front(x);
        }
        else if(s == "delete")
        {
            int x; cin >> x;
            L.erase_num(x);
        }
        else if(s == "deleteFirst")
        {
            L.pop_front();
        }
        else if(s == "deleteLast")
        {
            L.pop_back();
        }
    }
    L.print();
    return 0;
}


Measured memory_bytes: 34296
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N; cin >> N;
	vector<pair<int, int>>ps;
	for (size_t i = 0; i < N; i++)
	{
		int h, m; cin >> h >> m;
		ps.emplace_back(h, m);
	}
	int M; cin >> M;
	for (size_t i = 0; i < M; i++)
	{
		int h, m; cin >> h >> m;
		ps.emplace_back(h, m);
	}
	sort(ps.begin(), ps.end());
	ps.erase(unique(ps.begin(), ps.end()), ps.end());
	for (int i = 0; i < ps.size();++i){
		auto p(ps[i]);
		string st = to_string(p.second);
		if (st.size() == 1)st = '0' + st;
		cout << p.first << ":" <<st;
		if (i != ps.size() - 1)cout << " ";
		else cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    ll N, P;
    string S;
    cin >> N >> P;
    cin >> S;

    if (P == 2 || P == 5) {
        ll ans = 0;
        for (int i = 0; i < N; i++) {
            if ((int)(S[i] - '0') % P == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    vector<ll> sum(N + 1, 0), ten(N + 1, 1);
    for (int i = N - 1; i >= 0; i--) {
        ten[i] = ten[i + 1] * 10 % P;
    }
    for (int i = N - 1; i >= 0; i--) {
        sum[i] = ((ll)(S[i] - '0') * ten[i + 1] % P + sum[i + 1]) % P;
    }

    map<ll, ll> m;
    for (auto i : sum) {
        m[i]++;
    }
    ll ans = 0;
    for (auto i : m) {
        ans += i.second * (i.second - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4100
class BinaryHeap
  def initialize
    @array = []
  end

  def add(obj)
    @array << obj
    sift_up(size - 1)
  end

  def swap(i, j)
    u = @array[i]
    v = @array[j]
    @array[i], @array[j] = v, u
  end

  def sift_up(i)
    return if i == 0
    j = (i - 1) / 2
    if @array[i] > @array[j]
      swap(i, j)
      sift_up(j)
    end
  end

  def shift
    min = @array[0]
    swap(0, size-1) if size > 1
    @array.pop
    sift_down(0) if size > 0
    min
  end

  def sift_down(i)
    j = 2 * i + 1
    k = j + 1
    return if j >= size
    if k >= size
      if @array[j] > @array[i]
        swap(i, j)
        sift_down(j)
      end
    else
      l = (@array[j] > @array[k] ? j : k)
      if @array[l] > @array[i]
        swap(i, l)
        sift_down(l)
      end
    end
  end

  def size
    @array.size
  end
end

queue = BinaryHeap.new
loop do
  command, value = gets.chomp.split
  case command
  when "end"
    break
  when "insert"
    queue.add(value.to_i)
  when "extract"
    p queue.shift
  end
end



Measured memory_bytes: 14776
class WeightenedUnionFind:
    def __init__(self, size: int):
        self.__size = size
        self.__root = [-1] * size
        self.__diff_weight = [0] * size

    def find(self, u: int)->int:
        if self.__root[u] < 0:
            return u
        r = self.find(self.__root[u])
        self.__diff_weight[u] += self.__diff_weight[self.__root[u]]
        self.__root[u] = r
        return self.__root[u]

    def same(self, u: int, v: int)->bool:
        return self.find(u) == self.find(v)

    def unite(self, u: int, v: int, w: int):
        w += self.weight(u)
        w -= self.weight(v)

        x, y = self.find(u), self.find(v)

        if x == y:
            return

        if self.__root[y] < self.__root[x]:
            x, y = y, x
            w = -w

        self.__root[x] += self.__root[y]
        self.__root[y] = x

        self.__diff_weight[y] = w

    def weight(self, u: int)->int:
        self.find(u)
        return self.__diff_weight[u]

    def diff_weight(self, u: int, v: int)->int:
        return self.weight(v) - self.weight(u)


def people_on_a_line(N: int, M: int, queries: list)->bool:
    uf = WeightenedUnionFind(N)
    for l, r, d in queries:
        if uf.same(l-1, r-1):
            if d != uf.diff_weight(l-1, r-1):
                return False
        else:
            uf.unite(l-1, r-1, d)

    return True


if __name__ == "__main__":
    M = 0
    N, M = map(int, input().split())
    queries = [tuple(int(s) for s in input().split()) for _ in range(M)]
    yes = people_on_a_line(N, M, queries)
    print('Yes' if yes else 'No')


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

long    PowL(long N, long L) {
        long    S=1;
        while(0 < L) {
                if(0==(L%2)) {
                        N *= N;
                        L /=2;
                } else {
                        S *= N;
                        L--;
                }
        }
        return S;
}

//long  N753Full(long L) {
//      if (L<3) return 0;
//      // 3C3x3^L - 3C2x2^L + 3C1x1^L + N753Full(L-1);
//      return PowL(3, L)-3*PowL(2, L)+3 + N753Full(L-1);;
//}

long    N753Sub(long N, long L, bool C3, bool C5, bool C7, vector<long> &v) {
        long S=0;
        if (L==0) {
                if (C7 && C5 && C3) {
                        return 1;
                } else return 0;
        }
        // L>0
        for (long i: v) {
                if (N-i*PowL(10, L-1)>=0) {
                        if (i==3) S += N753Sub(N-i*PowL(10, L-1), L-1, true, C5, C7, v);
                        else if (i==5) S += N753Sub(N-i*PowL(10, L-1), L-1, C3, true, C7, v);
                        else if (i==7) S += N753Sub(N-i*PowL(10, L-1), L-1, C3, C5, true, v);
                }
        }
        return S;
}

long    N753(long N, long L) {
        vector<long> v{3, 5, 7};
        long S=0;
        for (long i: v) {
                if (N-i*PowL(10, L-1)>=0) {
                        if (i==3) S += N753Sub(N-i*PowL(10, L-1), L-1, true, false, false, v);
                        else if (i==5) S += N753Sub(N-i*PowL(10, L-1), L-1, false, true, false, v);
                        else if (i==7) S += N753Sub(N-i*PowL(10, L-1), L-1, false, false, true, v);
                }
        }
        return S;
}

int     main() {
        long N;
        cin >> N;
        long SS=0;
        // for each length of digits
        for (long i=3; i<=9; i++){
                SS += N753(N, i);
        }

        cout << SS << endl;
        return 0;
}

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

int main(){
    int H ,W;
    cin >> H >> W;
    while(H!=0){
        for(int i=0;i<H;i++){
            if(i%2==0){
                for(int j=0;j<W;j++){
                    if(j%2==0){
                        cout << "#";
                    }
                    else{
                        cout << ".";
                    }
                }
            }
            else{
                for(int j=0;j<W;j++){
                    if(j%2==0){
                        cout << ".";
                    }
                    else{
                        cout << "#";
                    }
                
                }   
            }
            cout << endl;
            
        }
        cin >> H >> W;
        cout << endl;
    }
}


Measured memory_bytes: 3072
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<deque>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<map>
#include<stack>
#include<set>
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn =1000100;
typedef pair<ll,ll>p1;
typedef pair<pair<ll,ll>,ll>p2;
map<pair<pair<ll,ll>,ll>,ll>m1;
map<pair<ll,ll>,ll>m2;
const int MOD = 1e9;
const int N=351;
const int inf = 0x3f3f3f3f;
typedef pair<char, int> PAIR;
map<string,int>mm;
ll a[maxn],b[maxn],c[maxn];
ll dp[maxn][4];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    scanf("%d%d%d",&a[i],&b[i],&c[i]);
    dp[1][1] = a[1];dp[1][2] = b[1];dp[1][3] = c[1];
    for(int i=2;i<=n;i++)
    {
        dp[i][1] = max(dp[i-1][2]+a[i],dp[i-1][3]+a[i]);
        dp[i][2] = max(dp[i-1][1]+b[i],dp[i-1][3]+b[i]);
        dp[i][3] = max(dp[i-1][2]+c[i],dp[i-1][1]+c[i]);
    }
    printf("%lld",max(dp[n][1],max(dp[n][2],dp[n][3])));
}

Measured memory_bytes: 9192
import Control.Monad

type Pic = [String]

subList :: Int -> Int -> [a] -> [a]
subList idx len = take len . (drop idx)

stripFromPic :: Pic -> Int -> Int -> Int -> Pic
stripFromPic pic len x y = map (subList x len) $ subList y len pic

main :: IO ()
main = do
    [n, m] <- map (read :: String -> Int) <$> words <$> getLine
    pic <- replicateM n getLine
    tmpl <- replicateM m getLine
    let strip = stripFromPic pic m
    let a = strip <$> [0..n-m] <*> [0..n-m]
    putStrLn $ if any (==tmpl) a then "Yes" else "No"


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll H,W;
	cin>>H>>W;
	ll m=max(H,W);
	ll N;
	cin>>N;
	ll ans=ceil(1.0*N/m);
	cout<<ans<<"\n";
	return 0;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s = '1' + s + '1';

  vector<int> indexes, lengths;

  int count = 0;
  rep(i, 0, sz(s)) {
    if (s[i] == '1') {
      if (!count) indexes.pb(i);
      count++;
      continue;
    }
    if (count > 0) lengths.pb(count);
    count = 0;
  }
  lengths.pb(count);

  if (sz(indexes) - 1 <= k) {
    put(sz(s) - 2);
    return 0;
  }

  int ans = 0;
  rep(i, 0, sz(indexes) - k) {
    int first = indexes[i];
    int last = indexes[i + k] + lengths[i + k];
    if (!first) first++;
    if (last == sz(s)) last--;

    chmax(ans, last - first);
  }

  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


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

int main() {
    int n; cin >> n;
    switch (n%10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;
    }
}

Measured memory_bytes: 3520
// defines
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define casti static_cast<int>
#define cast static_cast
#define ll long long int
#define vi vector<int>
#define vpi vector<pair<int,int >>

// includes
#include <bits/stdc++.h>

using namespace std;

ll modF=1e9+7;

// topcoder


//codechef and codeforces

void solve1(){
    int x,n;
    cin>>x>>n;
    int inp;
    set<int> a;
    for(int i=0;i<n;i++){
        cin>>inp;
        a.insert(inp);
    }
    int ans=x;
    int h=-1;
    while(a.find(ans)!=a.end()){
        ans=x+h;
        if(h>0){
            h=-1*h-1;
        }
        else{
            h=-1*h;
        }
    }
    cout<<ans<<"\n";
}

int main(){
    boost_io;
    solve1();
    return 0;
}


Measured memory_bytes: 3648
import sys
input = sys.stdin.readline

n,m = map(int, input().split())

ma = 1<<n
DP = [float("inf")]*ma
DP[0] = 0
for i in range(m):
    nxt = DP[::]
    a,b = map(int, input().split())
    mask = 0
    for c in map(int, input().split()):
        mask += 1<<(c-1)
    for j in range(ma):
        if nxt[j|mask] > DP[j] + a:
            nxt[j|mask] = DP[j] + a
    DP = nxt

ans = DP[-1]
if ans == float("inf"):
    ans = -1
print(ans)

Measured memory_bytes: 43372
#include <cstdio>
#include <cstring>
int main () {
    char str[1001];
    while(true) {
        scanf("%s", str);
        if (str[0] == '0') break;
        int sum = 0;
        for (int i=0; i < strlen(str); i++) {
            sum += str[i] - '0';
        }
        printf("%d\n", sum);
    }
    return 0;
}

Measured memory_bytes: 964
// 6/14 リアルタイム参加
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll Q;
    cin >> Q;
    
    ll ans = 0;
    map<ll, ll> mp;

    rep(i, N) {
        ans += A[i];
        mp[A[i]]++;
    }

    while (Q--) {
        int b, c;  // 値がbの要素をcに変える
        cin >> b >> c;
        // b--;
        // ans = ans - A[b] + c;
        // A[b] = c;
        // cout << ans << endl;

        ans -= mp[b] * b;
        ans += mp[b] * c;
        mp[c] += mp[b];
        mp[b] = 0;

        cout << ans << endl;
    }
}

Measured memory_bytes: 10116
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>

using namespace std;

template <class T>
map<int, int> prime_factorization(T N) {
  map<int, int> m;
  int s = sqrt(N) + 1;
  vector<bool> sieve(s + 1, true);
  for (int i = 2; i <= s; ++i) {
    if (!sieve[i]) {
      continue;
    }
    while (N % i == 0) {
      ++m[i];
      N /= i;
    }
    if (N == 1) break;
    for (int j = 2 * i; j < s; j += i) sieve[j] = false;
  }
  if (N != 1) ++m[N];
  return m;
}

int main() {
  long long A, B;
  cin >> A >> B;
  cout << prime_factorization(gcd(A, B)).size() + 1 << endl;
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int po(int a, int b) {
  int res = 1;
  for(int i=0;i<b;++i) {
    res *= a;
  }
  return res;
}

int div(int k) {
  while(k > 0) {
    if(k == 1) {
      return true;
    }
    k /= 2;
  }
  return false;

}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int m, k; cin >> m >> k;
  int n = po(2, m);
  vector<int> ans(2 * n);
  for(int i=0;i<2 * n;++i) {
    ans[i] = i / 2;
  }

  if(k >= n || (m == 1 && k == 1)) {
    cout << -1 << endl;
    return 0;
  }

  if(k == 0) {
  for(int i=0;i<2 * n;++i) {
    ans[i] = i / 2;
  }
    printv(ans);
  } else {
    ans[0] = 0;
    ans[1] = k;
    ans[2] = 0;
    int pos = 3;
    for(int i=1;i<n;++i) {
      if(i != k) {
        ans[pos] = i;
        pos++;
      }
    }
    ans[pos] = k;
    pos++;
    for(int i=n-1;i>=1;--i) {
      if(i != k) {
        ans[pos] = i;
        pos++;
      }
    }
    printv(ans);
  }
}


Measured memory_bytes: 2816
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(input()) for _ in range(N)]

    max_num = max(As)
    max_index = As.index(max_num)

    for i in range(N):
        if i == max_index:
            As.remove(max_num)
            print(max(As))
        else:
            print(max_num)
if __name__ == "__main__":
    resolve()


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMarks solver = new CMarks();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMarks {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] a = in.readIntArray(n);
            for (int i = k; i < n; i++) {
                boolean answer = a[i] > a[i - k];
                out.println(answer ? "Yes" : "No");
            }
        }

    }

    static class InputReader {
        public final BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}



Measured memory_bytes: 55308
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<26;

typedef pair<int,int> pii;

int main() {
  int n;
  while(cin >> n, n) {
    pii b[n+1];
    b[0] = pii(0,0);
    REP(i, n) {
      int p, t;
      cin >> p >> t;
      b[i+1] = pii(t,p);
    }
    sort(b, b+n);
    int dp[n+1][4];
    REP(i,n+1)REP(j,4) dp[i][j] = INF;
    dp[0][0] = 0;

    for (int i=0; i<n;++i) {
      REP(k, 4) {               // houseツづ可姪淞づゥ
        if (k>0)
          if (b[i].first + b[i].second*(k+1) + b[i+1].second <= b[i+1].first)
            dp[i+1][1] = min(dp[i+1][1], dp[i][k]+b[i].second + b[i+1].second);
        if (k<3) {
          int dis = abs(b[i].second-b[i+1].second);
          if (b[i].first + dis*(k+1) <= b[i+1].first) {
            dp[i+1][k+1] = min(dp[i+1][k+1], dp[i][k]+dis);
          }
        }
      }
    }
    // for (int i=0; i<=n; ++i) {
    //   for (int j=0; j<4; ++j) {
    //     cout << dp[i][j] << " ";
    //   }
    //   cout << endl;
    // }
    int ans = INF;
    REP(k, 4) {
      ans = min(ans, dp[n][k]+b[n].second);
    }
    if (ans == INF) {
      int ma = 0;
      REP(i, n+1) {
        REP(k, 4) {
          if (dp[i][k] != INF) ma = max(ma, i);
        }
      }
      cout << "NG " <<  ma+1 << endl;
    } else {
      cout << "OK " << ans << endl;
    }
  }
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
	int n;
	long k;
	cin >> n >> k;
	long a[n];
	int d=0;
	long kk=k;
	while(kk){
		d++;
		kk>>=1;
	}
	int mask[d]={};
	for(int i=0;i<n;i++){
		cin >> a[i];
		for(int j=0;j<d;j++){
			if((a[i]>>j)&1){
				mask[j]++;
			}
		}
	}
	long m=0;
	for(int i=d-1;i>=0;i--){
		if(2*mask[i]<n && (m|(1L<<i))<=k) m|=(1L<<i);
	}
	
	long ans=0;
	for(int i=0;i<n;i++){
		ans+=m^a[i];
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int A,B,C,D; // 1 <= A,B,C,D <= 10, ABCDは全て整数
  			   // A,B = Left C,D = Right
  
  cin >> A >> B >> C >> D;

  if((A + B) == (C + D)){
    cout << "Balanced" << endl;
  }else if((A + B) > (C + D)){
    cout << "Left" << endl;
  }else if((A + B ) < (C + D)){
    cout << "Right" << endl;
  }
  
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int a,n;
    bool ans=false;
    cin>>n;
    for (int i=1;i<=n;i++) {
        cin>>a;
        ans |= (a&1);
    }
    if (ans) cout<<"first";
    else cout<<"second";
}


Measured memory_bytes: 256
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int T = sc.nextInt();

		int[] time=new int[N];

		for (int i = 0; i < N; i++) {
			time[i]=sc.nextInt();
		}

		int ans=0;
		for (int i = 0; i < N-1; i++) {

			ans+=Math.min(T,time[i+1]-time[i]);

		}

		ans+=T;

		System.out.println(ans);
	}

		//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

	static int lcm(int a, int b) {
		return a * b / gcd(a, b);
	}

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 66124
#include<bits/stdc++.h> 
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
int n,a[N];
LL ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int l=0,r=0,x=0;
	while(l<=r){
		x-=a[l++];
		while(r<n&&x+a[r+1]==(x^a[r+1])) x+=a[++r];
//		cout<<l<<' '<<r<<endl;
		ans+=r-l+1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b = list(map(int, input().split()))
# 

s = input()
if "A" in s and "B" in s:
    print("Yes")
else:
    print("No")





Measured memory_bytes: 2940
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

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

	a = s[5];
	b = s[6];
	c = s[8];
	d = s[9];

	cout << "2018/" << a << b << "/" << c << d;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int a,b;
  cin >>a;
  cin >>b;
 
 if(a<b)
 cout <<"a < b";
 
 else if(a>b)
 cout<<"a > b";
 else if (a==b)
 cout<<"a == b";
 cout <<endl;
 
}


Measured memory_bytes: 3072
while True:
    n,x = [int(i) for i in input().split()]
    if n == x == 0:
        break
    count = 0
    for s in range(1, n-1):
        for m in range(s+1, n):
            for e in range(m+1,n+1):
                if x == sum([s,m,e]):
                    count += 1
 
    print(count)

Measured memory_bytes: 7668
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    long long a,b;
    char c;
    cin>>a>>c>>b;
    if(c=='+'){cout<<a+b;}
    else{cout<<a-b;}
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long K = sc.nextLong();
		if (K%2==0) {
			System.out.println(A-B);
		} else {
			System.out.println(B-A);
		}
	}
}

Measured memory_bytes: 35668
import math

a,b,C=map(float,input().split())
C=math.radians(C)

S=a*b*(math.sin(C))/2
L=a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(C))
h=b*math.sin(C)

print(S)
print(L)
print(h)


Measured memory_bytes: 5692
#include<stdio.h>
void quicksort(int a[],int s,int t){
  if(s<t){
    int i=s,j=t,p=a[(s+t)/2];
    while(1){
      while(a[i]>p)i++;
      while(p>a[j])j--;
      if(i>=j)break;
      a[i]^=a[j]^=a[i]^=a[j];
      i++;j--;
    }
    quicksort(a,s,i-1);quicksort(a,j+1,t);
  }
}
int main(){
  int n,h,a[100000],b[100000],i;
  scanf("%d%d",&n,&h);
  for(i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
  quicksort(a,0,n-1);quicksort(b,0,n-1);
  i=0;while(b[i]>a[0]&&h>0&&i<n){h-=b[i];i++;}
  if(h>0)i+=(h+a[0]-1)/a[0];
  printf("%d",i);
}


Measured memory_bytes: 2504
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007LL
#define all(x) x.begin() , x.end()
#define ld long double
void solve();
int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int t = 1; //cin >> t;
	while (t--)
		solve();
	return 0;
}
void solve()
{
	string s; cin >> s;
	ll ans = 0;
	if (s.find("R") != string::npos) ans = 1;
	if (s.find("RR") != string::npos) ans = 2;
	if (s.find("RRR") != string::npos) ans = 3;
	cout << ans;
	return ;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int cnt=0;
    char a[4];
    
    scanf("%s", a);
    
    rep(i, 3){
        if (a[i]==a[i+1]) {
            cnt++;
            if (cnt==2) {
                printf("Yes");
                return 0;
            }
        } else {
            cnt=0;
        }
    }
    
    printf("No");
    
    return 0;
}



Measured memory_bytes: 1696
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
using namespace std;

int main(){
    int N, K;
    string S;
    cin >> N >> S >> K;
    string del = S.substr(K - 1, 1);
    string D;

    for (int i = 0; i < N; i++){
        if(S.substr(i, 1) != del){
            D += "*";
        }
        else D += S.substr(i, 1);
    }
    cout << D << endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let mut abc = input!(i32; 3);
    let mut cnt = 0;

    while !(abc[0] == abc[1] && abc[1] == abc[2]) {
        let mut min_i = vec![0];
        for i in 1..3 {
            if abc[min_i[0]] > abc[i] {
                min_i.pop();
                min_i.push(i);
            } else if abc[min_i[0]] == abc[i] {
                min_i.push(i);
            }
        }
        if min_i.len() == 1 {
            abc[min_i[0]] += 2;
        } else {
            abc[min_i[0]] += 1;
            abc[min_i[1]] += 1;
        }
        cnt += 1;
    }
    println!("{}", cnt);
}

Measured memory_bytes: 4352
// C - Attack Survival
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,K,Q; cin>>N>>K>>Q;
	vector<int> ans(N+1, K-Q);
	for(int i=0; i<Q; ++i){ int a; cin>>a; ans[a]++; }
	for(int i=1; i<=N; ++i) cout<< (ans[i]>0? "Yes":"No") <<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  long Max=INT_MIN, Min=INT_MAX, n, in;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> in;
    if(n==0){Max=in; Min=in;}
    else {Max = max(Max, in); Min = min(Min, in);}
    cerr << "[" << i << "]: " << Max << " " << Min << "(" << in << ")" << endl;
  }
  cout << Max - Min << endl;
  cerr << Max << endl << Min << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

cnt = 0
for i in range(N - 1, -1, -1):
    cnt += min(A[i + 1], B[i])
    B[i] = max(0, B[i] - A[i + 1])
    cnt += min(A[i], B[i])
    A[i] = max(0, A[i] - B[i])
print(cnt)


Measured memory_bytes: 24056
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
template <class T1, class T2>inline void gmax(T1 &a,T2 b){if (b>a) a=b;}
template <class T1, class T2>inline void gmin(T1 &a,T2 b){if (b<a) a=b;}
int a,b;
int main(){
    read(a),read(b);
    if ((a+b)%2==0) cout<<(a+b)/2<<endl;
    else cout<<(a+b+1)/2<<endl;
    return 0;
}


Measured memory_bytes: 256