akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner; 
public class Main{ 
    public static void main(String[] args){ 
        Scanner scan = new Scanner(System.in); 
        int a =scan.nextInt(); 
        int b =scan.nextInt(); 
        int c =scan.nextInt(); 
        if(a>b && a>c){ 
            if(b>c){ 
                System.out.printf("%d %d %d\n",c,b,a); 
            }else{ 
                System.out.printf("%d %d %d\n",b,c,a); 
            }
        }else if(b>a && b>c){ 
            if(a>c){ 
                System.out.printf("%d %d %d\n",c,a,b); 
            }else{ 
                System.out.printf("%d %d %d\n",a,c,b); 
            } 
        }else if(c>a && c>b){ 
            if(a>b){ 
                System.out.printf("%d %d %d\n",b,a,c); 
            }else{ 
                System.out.printf("%d %d %d\n",a,b,c); 
            } 
        } 
    } 
} 


Measured memory_bytes: 26260
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# n = int(input())
# map(int, input().split())
# s = input().split()
n = input()
m = int(n[len(n) - 1])
if m == 3:
    print('bon')
elif m == 0 or m == 1 or m == 6 or m == 8:
    print('pon')
else:
    print('hon')

Measured memory_bytes: 10452
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){

    int N,M;
    scanf("%d %d",&N,&M);
    int P[M],Y[M],Index[M],Count[N+1]={0};
    for(int i=0;i<M;i++){
        scanf("%d %d",P+i,Y+i);
        Index[i] = i;
    }
    // 誕生年で市をソートする。
    sort(Index,Index+M,[&](int a, int b){
        return Y[a]<Y[b];
    });
    // Yに其の市が何番目に生まれたか代入. Index[1]は２番目に生まれた市の番号
    for(int i=0;i<M;i++){
        Y[Index[i]] = ++Count[P[Index[i]]];
    }
    for(int i=0;i<M;i++){
        printf("%06d%06d\n",P[i],Y[i]);
    }
}

Measured memory_bytes: 2944
import numpy as np
# + - - - - + even -> + + + + + + 全部プラス
# + - - - - - + odd -> どっか一個が -

N = int(input())
A = np.array(list(map(int, input().split())))

num_negative = np.count_nonzero(A < 0)
A = np.abs(A)
if num_negative % 2 == 0:
    print(A.sum())
else:
    print(A.sum() - A.min() * 2)


Measured memory_bytes: 23304
import sys
import math
L =[]
N,D = list(map(int,input().split()))
cnt = 0

for n in range(0,N):
    n = list(map(int,input().split()))
    L.append(n)

for l in L:
    d = math.sqrt(l[0]**2 + l[1]**2)
    if d <= D:
        cnt += 1

print(cnt)

Measured memory_bytes: 45456
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

int main(void){
  int n,h[25],ans=1;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  int hma=h[0];
  for(int i=1;i<n;i++){
    if(hma<=h[i]){
      hma=h[i];
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
import sys

N,C = [int(x) for x in input().split()]
X=[]
V=[]
for _ in range(N):
    x,v = [int(x) for x in input().split()]
    X.append(x)
    V.append(v)

# 右回りの累積和
s = 0
r = [0]*N
for i in range(N):
    s += V[i]
    r[i] = s - X[i]

# 左回りの累積わ
s = 0
l = [0]*N
for i in range(N):
    s += V[N-1-i]
    l[N - 1 - i] = s - (C - X[N - 1 - i])

# 原点～iのMax(R)
MaxR = [0] * N
MaxR[0] = r[0]
for i in range(1,N):
    MaxR[i] = max(MaxR[i-1], r[i])

# 原点～iのMax(L)
MaxL = [0] * N
MaxL[N-1] = l[N-1]
for i in range(1,N):
    MaxL[N-1-i] = max(MaxL[N-i], l[N-1-i])

a = max(r)
b = max(l)
c, d = 0, 0
if N>1:
    c = max([r[i] - X[i] + MaxL[i + 1] for i in range(N - 1)])
    d = max([l[i] - (C-X[i]) + MaxR[i - 1] for i in range(N - 1,0,-1)])

print(max([a,b,c,d,0]))


Measured memory_bytes: 25232
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
vector<ll> a(55), p(55);
/* function */
ll f(ll n, ll x) {
    if (n == 0) {
        if (x <= 0) return 0;
        else return 1;
    }
    else if (x <= 1 + a[n - 1]) { return f(n - 1, x - 1); }
    else return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1]);
}
/* main */
int main(){
    ll N, X;
    cin >> N >> X;
    a[0] = 1, p[0] = 1;
    for (int i = 0; i < N; i++) {
        a[i + 1] = 2 * a[i] + 3;
        p[i + 1] = 2 * p[i] + 1;
    }
    cout << f(N, X) << '\n';
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector<vector<ll>> sidx(26, vector <ll> ());
	for (ll ii = 0; ii < s.size(); ++ii){
		ll ch = s[ii] - 'a';
		sidx[ch].push_back(ii);
		sidx[ch].push_back(ii + s.size());	//s.size()分だけオフセットを足したものも格納
	}

	for (ll ch = 0; ch < 26; ++ch){
		if (sidx[ch].size() > 0){
			sort(sidx[ch].begin(), sidx[ch].end());
		}
	}

	vector <ll> sitr(26, 0);
	ll now = -1;
	ll ans = 0;
	for (int ii = 0; ii < t.size(); ++ii){
		ll ch = t[ii] - 'a';

		if (sidx[ch].size() == 0){
			cout << -1 << endl;
			return 0;
		}

		//nowより大きい最小のsidx[ch]を求める
		auto itr = upper_bound(sidx[ch].begin(), sidx[ch].end(), now);
		ll idx = sidx[ch][itr - sidx[ch].begin()];

		//値を更新
		ans += idx - now;
		if (idx < s.size()){
			now = idx;
		} else {
			now = idx - s.size();
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3768
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		int n;
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		int[] BST = new int[n + 1];
		for(int i = 1; i <= n; i ++) {
			BST[i] = in.nextInt();
		}
		in.close();
		
		for (int i = 1; i <= n; i++) {
			System.out.print("node " + i + ": "
					+ "key = " + BST[i] + ", ");
			if (i != 1) {
				System.out.print("parent key = " + BST[i/2] + ", ");
			} 
			if ((2 * i) <= n) {
				System.out.print("left key = " + BST[2*i] + ", ");
			}
			if ((2 * i) + 1 <= n) {
				System.out.print("right key = " + BST[(2*i)+1] + ", ");
			}
			System.out.println("");
		}
		
	}
}


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

import sys

poker = ["0", "null", "one pair", "two pair", "three card", "straight", "full house", "four card"]
for line in sys.stdin:
    H = map(int, line.split(','))
    H.sort()
    if H[0] == H[1] == H[2] == H[3] or H[1] == H[2] == H[3] == H[4]:
        print poker[7]
    elif H[0] == H[1] or H[1] == H[2] or H[2] == H[3] or H[3] == H[4]:
        if H[0] == H[1] == H[2] or H[1] == H[2] == H[3] or H[2] == H[3] == H[4]:
            if H[0] == H[1] and H[2] == H[3] == H[4] or H[0] == H[1] == H[2] and H[3] == H[4]:
                print poker[6]
            else:
                print poker[4]
        else:
            if H[0] == H[1] and H[2] == H[3] or H[0] == H[1] and H[3] == H[4] or H[1] == H[2] and H[3] == H[4]:
                print poker[3]
            else:
                print poker[2]
    else:
        if H[0] == 1 and H[4] == 13:
            H[0] += 13
            H.sort()
        if H[0]+1 == H[1] and H[1]+1 == H[2] and H[2]+1 == H[3] and H[3]+1 == H[4]:
            print poker[5]
        else:
            print poker[1]

Measured memory_bytes: 6380
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define FOR(i, n) for(int i = 1; i<=n; i++)
#define F0R(i, n) for(int i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
int n, a[105], b[105];

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

	cin >> n;
	FOR(i, n)
		cin >> a[i] >> b[i];
	
	for(int i = 1; i+2 <= n; i++){
		if(a[i] != b[i]) continue;
		if(a[i+1] != b[i+1]) continue;
		if(a[i+2] != b[i+2]) continue;
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;

	cout.flush();
	return 0;
}

Measured memory_bytes: 3640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	int N;
	long A,B;
	int[] X;

	public void solve() {
		N = nextInt();
		A = nextInt();
		B = nextInt();

		X = new int[N];
		for(int i = 0;i < N;i++){
			X[i] = nextInt();
		}

		long[] memo = new long[N];
		Arrays.fill(memo,Long.MAX_VALUE);
		memo[0] = 0;

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

			if((X[i]-X[i-1])*A < B){
				memo[i] = Math.min(memo[i], (X[i]-X[i-1])*A+memo[i-1]);
			}else{
				memo[i] = Math.min(memo[i], B+memo[i-1]);
			}
		}
		out.println(memo[N-1]);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 38536
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix, lil_matrix

H, W = map(int, input().split())
# H, W = 2, 2
s = []
for _ in range(H):
    s.append(input())
# s = [func() for _ in range(H)]
# print('\n'.join(s))

def co_num(h, w):
    return h * W + w

row = []
col = []
dist = []
for h in range(H):
    for w in range(W):
#         if h != 0:
#             row.append(co_num(h, w))
#             col.append(co_num(h-1, w))
#             dist.append(0 if s[h-1][w] == s[h][w] else 1)
#         if w != 0:
#             row.append(co_num(h, w))
#             col.append(co_num(h, w-1))
#             dist.append(0 if s[h][w-1] == s[h][w] else 1)
        if h != H-1:
            row.append(co_num(h, w))
            col.append(co_num(h+1, w))
            dist.append(0 if s[h+1][w] == s[h][w] else 1)
        if w != W-1:
            row.append(co_num(h, w))
            col.append(co_num(h, w+1))
            dist.append(0 if s[h][w+1] == s[h][w] else 1)

d = int(dijkstra(csr_matrix((dist, (row, col)), shape=[H*W, H*W]), directed=True, indices=0)[H*W-1])

if s[0][0] == '.' and s[-1][-1] == '.':
    print(d // 2)
elif s[0][0] == '#' and s[-1][-1] == '#':
    print(d // 2 + 1)
else:
    print(d // 2 + 1)

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define sp << ' ' << 
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353

int main()
{
    boost;
    ll tt = 1, n, m, k = 0, i, j;
    ll q, l = 0, r = 0, x, y, z, h, a, b, c, d;

    bool poss = true;
    string s;
    ll ans = 0;

    // cin >> tt;
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> x;

        poss = false;
        for(a = 1; a <= 120; a++){
            for(b = -120; b <= 120; b++){
                if(a*a*a*a*a - b*b*b*b*b == x){
                    poss = true;
                    break;
                }
            }
            if(poss) break;
        }

        cout << a sp b << nl;
    }   
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <bits/stdc++.h>
#include <string>

using namespace std;

typedef long long int ll;
typedef unsigned long long  ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef deque <int> di;
typedef deque <char> dc;

#define f(i, a, b) for (int i = a; i < b; i++)
#define f2(i, a, b) for (int i = a; i <=b; i++)
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front;

int main()
{

int n;
cin >> n;

if (n >= 30) {
    cout << "Yes";
}
else {
    cout << "No";
}
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int cnt;
    if (a == b and b == c) {
        cout << 1 << endl;
    }
    else if (a == b or b == c or a == c) {
        cout << 2 << endl;
    }
    else {
        cout << 3 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define second sec
#define first fir
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if(u == s) cout << a-1 << " " << b << endl;
	else cout << a << " " << b-1 << endl;
	return 0;
}

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

using P = pair<int, int>;		//P.first, P.second

typedef long long ll;
typedef vector<string> vs;

int H,W;

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

//grid
//BFS
//幅優先探索

bool in(int x, int y){
	return 0<=x&&x<H&&0<=y&&y<W;
}

int main() {
	cin>>H>>W;
	vs A(H);
	rep(i,H)cin>>A[i];
	queue<P> Q;
	Q.push({0,0});
	int bcnt = 0;
	rep(i,H)rep(j,W){
		dist[i][j] = -1;
		if(A[i][j] == '#')bcnt++;
	}
	dist[0][0] = 1;
	while(!Q.empty()){
		P p = Q.front();
		Q.pop();
		int x = p.first, y = p.second;
		rep(i,4){
			int nx = x + dx[i], ny = y + dy[i];
			if(!in(nx,ny)||dist[nx][ny]!=-1||A[nx][ny] !='.')continue;
			dist[nx][ny] = dist[x][y]+1;
			Q.push({nx,ny});
		}
	}
	if(dist[H-1][W-1] == -1){
		cout<<-1<<endl;
		return 0;
	}
	int ans= H*W - bcnt - dist[H-1][W-1];
	cerr<<dist[H-1][W-1]<<endl;
	cout<<ans<<endl;
}						

Measured memory_bytes: 512
# B - 1 Dimensional World's Tale
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

for i in range(-100, 100):
    if X < i <= Y and max(x) < i <= min(y):
        print('No War')
        exit()
    else:
        pass
print('War')

Measured memory_bytes: 3060
num_list = list(map(int, input().split()))
if(num_list[0]+num_list[1]>num_list[2]+num_list[3]):
	print("Left")
elif(num_list[0]+num_list[1]==num_list[2]+num_list[3]):
	print("Balanced")
else:
	print("Right")

Measured memory_bytes: 3060
function main(){
  var i = 0;
  while(true){
    var fieldInfo = input[i].split(' ');
    var width = fieldInfo[0] - 0;//toInt
    var height = fieldInfo[1] - 0;//toInt
 
    // 0 0が入力された
    if(!width && !height){
      break;
    }
 
    var start;
    var goal;
    var elem = [[],[],[],[],[]];
    for(var ei = 0;ei < 5; ei++){
      elem[ei].length = 0;
    }
     
    for(var y = 0; y < height; y++){
      i++;//1行進める
      for(var x = 0; x < width; x++){
        var c = input[i][x];
 
        switch(c){
        case 'S':
          start = pos(x, y);
          break;
        case 'G':
          goal = pos(x, y);
          break;
        case '.':
          break;
        default : // 入力値が正しいので、絶対に属性
          elem[c - 1][elem[c - 1].length] = pos(x, y);
          break;
        }
      }
    }
 
     
    var bestElement = -1;
    var distance = Infinity;
     
    // 属性ごとにループ
    for (var startElem = 0; startElem < 5; startElem++) {
      // DPの初期化 DP[属性][同じ属性内の連番]
      var dp = [[],[],[],[],[]];
      for(var h = 0; h < 5; h++){
        var hLength = elem[h].length;
        dp[h].length = hLength;
        for(var hidx = 0; hidx < hLength; hidx++){
          dp[h][hidx] = Infinity;
        }
      }
       
      // 最初に選んだパチモンから次に捕まえられる属性番号
      var first = (startElem + 1) % 5;
 
      var firstLength = elem[first].length;
      for (var j = 0; j < firstLength; j++) {
        // s→e1を計算
        dp[first][j] = dist(start, elem[first][j]);
      }
       
      // s->1->2->3->4->g
      // なので、ループは間の-> * 3分まわす
      for (var e = 0; e < 3; e++) {
        // ex->e(x+1)
        var now = (first + e) % 5;
        var next = (now + 1) % 5;
        var nowLength = elem[now].length;
        var nextLength = elem[next].length;
        for (var j = 0; j < nowLength; j++) {
          for (var k = 0; k < nextLength; k++) {
            dp[next][k] = min(
              dp[next][k],
              dp[now][j] + 
                  dist(elem[now][j], elem[next][k]));
          }
        }
      }
       
      var last = (first + 3) % 5;
      var lastLength = elem[last].length;
      for (var j = 0; j < lastLength; j++) {
        // e4->g
        var d = dp[last][j] + 
                    dist(elem[last][j], goal);
         
        if (d < distance) {
          distance = d;
          bestElement = startElem + 1;
        }
         
      }
       
    }
     
    if (distance == Infinity) {
      console.log("NA");
    } else {
      console.log(bestElement + " " + distance);
    }
 
    i++;
  }
   
 
}
 
function dist(from, to){
  return Math.abs((from >> 11) - (to >> 11)) + Math.abs((from & 2047) - (to & 2047));
}
 
function min(a1, a2){
  return a1 < a2 ? a1 : a2;
}
 
function pos(a, b){
  return (a << 11) + b;
}
 
var
input = '';
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

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

typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mkmap;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<vi> vv;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const ll mod=1000000007;
const int sz=1000001;
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(i=a;i<b;++i)
#define rrep(i,a,b) for(i=a;i>=b;--i)
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db(x) cout << (#x) << " = " << x << endl;

inline ll mult(ll a, ll b) {return (((a % mod) * (b % mod)) % mod);}

int dp[100000][3];

int fun(vv &a,int i,int j){
    if(i==a.size()) return 0;
    if(j!=-1 && dp[i][j]!=-1) return dp[i][j];
    int mx=0,k;
    rep(k,0,3){
        if(k==j) continue;
        mx=max(mx,a[i][k]+fun(a,i+1,k));
    }
    return dp[i][j]=mx;
}

int main(){
    fast;
    int t,tt,tti,n,m,x,y,z,i,j,k,temp,count,o,e,f,ans,sum,l,r,mx,mn;
    ll lx,ly,lz,ltemp;
    double fx,fy,fz;
    string s;
   
    cin>>n;
    vv a(n,vi(3));
    rep(i,0,n) cin>>a[i][0]>>a[i][1]>>a[i][2];
    memset(dp,-1,sizeof(dp));
    cout<<fun(a,0,-1);
}

/*
    
*/

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

using namespace std;

const int maxn = 3010;

long long int dp[maxn][maxn];

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

    int n;

    cin >> n;

    vector<long long int> vet(n+1);

    for(int i=1; i<=n; i++) cin >> vet[i];

    for(int l=n; l>=1; l--){
        for(int r=l; r<=n; r++){
            if(l==r) dp[l][r] = vet[l];
            else dp[l][r] = max(vet[l] - dp[l+1][r], vet[r] - dp[l][r-1]);
        }
    }

    cout << dp[1][n] << endl;

    return 0;
}


Measured memory_bytes: 70016
a,b = map(int,input().split())

def xor_sum(x):
    ans = 0 
    if x % 2 == 1:
        if ((x + 1) // 2 )%2 ==0:
            ans = 0
        else:
            ans = 1
    else:
        if x%4 == 0:
            ans = x
        else:
            ans = 1^x
    return ans

print(xor_sum(a-1)^xor_sum(b))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
#define init(x) memset(x,0,sizeof(x))
int n,m;
int dis[15][15];
int a[205][205];
int ans=0;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	rep(i,10) rep(j,10) cin>>dis[i][j];
	rep(k,10) rep(i,10) rep(j,10) dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	rep(i,n) rep(j,m){
		cin>>a[i][j];
		if (a[i][j]!=-1) ans+=dis[a[i][j]][1];
	}
	cout<<ans;
}

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

using namespace std;
#define ll long long


string k;
const int N = 1e4 + 5, mod = 1e9 + 7;
int dp[N][2][105], d;

//complexity 1e4 * 1e2 * 2 * 10

int add(int a, int b, int Mod)
{
    return (a + b) % Mod;
}
int solve(int idx, bool smaller, int sum)
{
    if(idx == k.size())
        return sum == 0;
    int &ans = dp[idx][smaller][sum];
    if(ans != -1)
        return ans;
    ans = 0;
    for(int digit = 0; digit <= 9; digit++)
    {
        if(!smaller && digit > k[idx] - '0')
            continue;
        bool new_smaller;
        if(smaller)
            new_smaller = 1;
        else
            if(digit < k[idx] - '0')
                new_smaller = 1;
            else
                new_smaller = 0;
        ans = add(ans, solve(idx + 1, new_smaller, add(sum, digit, d)), mod);
    }
    return ans;
}

int table()
{
    dp[k.size()][0][0] = dp[k.size()][1][0] = 1;
    for(int idx = k.size() - 1; idx >= 0; idx--)
    {
        for(int smaller = 0; smaller <= 1; smaller++)
        {
            for(int sum = 0; sum < d; sum++)
            {
                //compute dp[idx][smaller][sum]
                for(int digit = 0; digit <= 9; digit++)
                {
                    if(!smaller && digit > k[idx] - '0')
                        continue;
                    int &ans = dp[idx][smaller][sum];
                    ans = add(ans, dp[idx + 1][smaller | (digit < k[idx] - '0')][add(sum, digit, d)], mod);
                }
            }
        }
    }
    return dp[0][0][0];
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> k >> d;
    cout << (table() - 1 + mod) % mod;
    return 0;
}


Measured memory_bytes: 8448
X = input()

cnt1 = 0
cnt2 = 0
cnt = 0
for i in range(len(X)):
    if X[i] == 'S':
        if cnt2:
            cnt += cnt2 * 2
            cnt2 = 0
        cnt1 += 1
    elif cnt1 and X[i] == 'T':
        cnt2 += 1
        cnt1 -= 1

if cnt2:
    cnt += cnt2 * 2

print(len(X) - cnt)

Measured memory_bytes: 3500
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8

using namespace std;
typedef pair<llong, llong> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

bool grid[100][100];

void solve(int A, int B) {
    for(int i = 0; i < 100; ++i)
        for(int j = 50; j < 100; ++j)
            grid[i][j] = true;
    
    A--, B--;

    //黒を追加
    for(int i = 0; i < 100; ++i)
        for(int j = 0; j < 50; ++j)
            if(i % 2 == 1 && j % 2 == 0) {
                if(B-- > 0)
                    grid[i][j] = true;
            }

    //白を追加
    for(int i = 0; i < 100; ++i)
        for(int j = 50; j < 100; ++j)
            if(i % 2 == 1 && j % 2 == 1) {
                if(A-- > 0)
                    grid[i][j] = false;
            }
}

int main(int argc, char **argv) {
    int A, B;
    cin >> A >> B;
    solve(A, B);

    cout << "100 100" << endl;
    for(int i = 0; i < 100; ++i) {
        for(int j = 0; j < 100; ++j)
            cout << (grid[i][j] ? '#' : '.');
        cout << endl;
    }

}

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

int main() {
  string a;
  int l=0;
  cin >> a;
  for(int i=0;i<a.size()/2;i++){
  if(a.at(i)!=a.at(a.size()-i-1)){
  l++;
  }
  }
  cout << l << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int D,N;
    cin >> D >> N;
    int cnt = 0;
    for(int i = 1; i <= 10000000; i++) {
        int res = 0;
        int X = i;
        while (X%100 == 0) {
            res++;
            X/=100;
        }
        if(res == D) {
            cnt++;
        }
        if(cnt == N) {
            cout << i << endl;
            return 0;
        }
    }
}


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

int main(){
  int N,M; cin >> N >> M;
  string A[50],B[50];
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<M; i++) cin >> B[i];
  
  bool exist=false;
  for(int i=0; i<N-M+1; i++){
    for(int j=0; j<N-M+1; j++){
      bool match=true;
      for(int k=0; k<M; k++){
        if(A[i+k].substr(j,M)!=B[k]){
          match=false;
          break;
        }
      }
      if(match==true){
        exist=true;
        break;
      }
    }
    if(exist==true) break;
  }
  cout << (exist==true?"Yes":"No") << endl;
}

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

int main() {
   int a,b;
   cin>>a>>b;
   
   if(a==1 and b==2 or b==1 and a==2){
       cout<<"3";
   }
   else if(a==2 and b==3 or b==2 and a==3){
       cout<<"1";
   }
   else{
       cout<<"2"<<endl;
   }
   
   return 0;
}



Measured memory_bytes: 256
function parse_numbers(s)
    pieces = split(s, ' ', keepempty=false)
    map(pieces) do piece
        parse(Int, piece)
    end
end

function main()
    s = readline();
    D, T, S = parse_numbers(s)
    if D / T > S
        println("No")
    else 
        println("Yes")
    end
end

main()


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

int main(void){
    int total = 0;
    vector<int> a(3);
    string ans;
    for(int i = 0; i < 3; i++) cin >> a[i];
    for(int i = 0; i < 3; i++) total += a[i];
    if(total <= 21) ans = "win";
    else ans = "bust";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
        int n;
        cin >> n;

        int x = 1000;
        for(int a = -x; a < x; a++) {
            for(int b = -x; b < x; b++) {
                if(pow(a, 5) - pow(b, 5) == n)
                    return cout << a << ' ' << b, 0;
            }
        }

        
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 3980
n=int(input())
a_l=list(map(int,input().split()))
a,b,c,d,e,f,g,h=0,0,0,0,0,0,0,0
cnt=0
for i in a_l:
    if i<400*1:
        a+=1
    elif 400*1<=i<400*2:
        b+=1
    elif 400*2<=i<400*3:
        c+=1
    elif 400*3<=i<400*4:
        d+=1
    elif 400*4<=i<400*5:
        e+=1
    elif 400*5<=i<400*6:
        f+=1
    elif 400*6<=i<400*7:
        g+=1
    elif 400*7<=i<400*8:
        h+=1
    else:
        cnt+=1
ans=0
for i in [a,b,c,d,e,f,g,h]:
    if i!=0:
        ans+=1
if ans!=0:
    print(ans, ans+cnt)
else:
    print(1,cnt)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

string solve(string a, string b) {
	if (a.size() > b.size()) {
		return "GREATER";
	} else if (a.size() < b.size()) {
		return "LESS";
	}

	for (int i = 0; i < a.size(); i++) {
		int numA = a[i] - '0';
		int numB = b[i] - '0';

		if (numA > numB) {
			return "GREATER";
		} else if (numA < numB) {
			return "LESS";
		}
	}

	return "EQUAL";
}

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

	string a, b;
	cin >> a >> b;

	cout << solve(a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
a,b,x=map(int,input().split())
ans=0
if (b-a+1)>=x:
    if a%x==0 and b%x==0:
        ans=((b-a)//x)+1
    elif not a%x==0 and not b%x==0:
        a=a+x-a%x
        b=b-b%x
        ans=((b-a)//x)+1
    elif not a%x==0 and b%x==0:
        a=a+x-a%x
        ans=((b-a)//x)+1
    elif a%x==0 and not b%x==0:
        b=b-b%x
        ans=((b-a)//x)+1
else:
    if a%x==0:
        ans=1
    else:
        if a+x-a%x<=b:
            ans=1
        else:
            ans=0
print(ans)


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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


void solve() {
    int a, b;
    cin >> a >> b;

    if (13 <= a) {
        cout << b << "\n";
    } else if (6 <= a) {
        cout << b / 2 << "\n";
    } else {
        cout << 0 << "\n";
    }
}


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

    solve();
    return 0;
}


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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 100100;
const long long Q = 10001;
const long long mod = 1e9 + 7;;
const long long block = sqrt(N);

using namespace std;

int t;
int a, b;

void solve()
{
        cin >> t;
        if(t == 1){
                cout << "Hello World" << endl;
        }
        else{
                cin >> a >> b;
                cout << a + b << endl;
        }
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("substr3.in");
        //fout("substr3.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define oo 4005
#define mod 1000000007
using namespace std;
int n, m, f[oo], fa[oo][12], dep[oo], p[oo][12];
long long x, w, ans;
struct edge {int x, y, w, et;} e[oo];
inline bool cmp (edge i, edge j) {return i.w < j.w;}
inline bool cnp (edge i, edge j) {return i.et < j.et;}
int find (int x) {return x == f[x] ? x : f[x] = find(f[x]);}
int ne[oo], to[oo], s[oo], cap[oo], cnt;
inline void add (int u, int v, int w)
{++ cnt; ne[cnt] = cap[u]; to[cnt] = v; s[cnt] = w; cap[u] = cnt;}
void dfs (int u)
{
    dep[u] = dep[fa[u][0]] + 1;
    for(int i = 1; (1 << i) < dep[u]; ++ i)
    {
        fa[u][i] = fa[fa[u][i - 1]][i - 1];
        p[u][i] = max(p[u][i - 1], p[fa[u][i - 1]][i - 1]);
    }
    for(int i = cap[u]; i; i = ne[i])
    {
        if(to[i] == fa[u][0]) continue;
        fa[to[i]][0] = u; p[to[i]][0] = s[i];
        dfs(to[i]);
    }
}
int query (int a, int b)
{
    int ret = 0;
    if(dep[a] < dep[b]) swap(a, b);
    for(int i = 10; i >= 0; -- i)
    if((1 << i) & dep[a] - dep[b])
    ret = max(p[a][i], ret), a = fa[a][i];
    if(a == b) return ret;
    for(int i = 10; i >= 0; -- i)
    if(fa[a][i] != fa[b][i])
    ret = max(p[a][i], ret), a = fa[a][i],
    ret = max(p[b][i], ret), b = fa[b][i];
    ret = max(p[a][0], ret);
    ret = max(p[b][0], ret);
    return ret;
}
inline long long qpow (int k)
{
    long long ret = 1, x = 2;
    while(k)
    {
        if(k & 1) ret = ret * x % mod;
        x = x * x % mod; k >>= 1;
    }
    return ret;
}
int main ()
{
    scanf("%d%d", &n, &m);
    scanf("%lld", &x);
    for(int i = 0; i < m; ++ i)
    scanf("%d%d%d", &e[i].x, &e[i].y, &e[i].w);
    sort(e, e + m, cmp);
    for(int i = 1; i <= n; ++ i) f[i] = i;
    for(int i = 0; i < m; ++ i)
    {
        int u = e[i].x, v = e[i].y;
        if(find(u) == find(v)) continue;
        add(u, v, e[i].w); add(v, u, e[i].w);
        f[f[u]] = f[v]; w += e[i].w;
    }
    dfs(1); int tmp = 0;
    for(int i = 0; i < m; ++ i)
    e[i].et = e[i].w - query(e[i].x, e[i].y);
    sort(e, e + m, cnp);
    for(int i = 1; i < m; ++ i)
    if(w + e[i].et == x) ++ tmp;
    for(int i = 1; i < m; ++ i)
    if(e[i].et + w == x)
    {ans = 2 * qpow(m - i - tmp) * (qpow(tmp) - 1) % mod; break;}
    printf("%lld", ans); return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <deque>

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

using namespace std;

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

	bool flag = true;

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

	rep(i, s.size() - 1)
		if (s[i] == s[i + 1]) {
			flag = false;
			break;
		}

	if (flag)
		cout << "yes" << endl;
	else
		cout << "no" << endl;

	return 0;
}

Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int N;

signed main(){

    in(N);
    out(N*(N+1)/2);

    return 0;
}


Measured memory_bytes: 256
import sys
from copy import deepcopy
def input(): return sys.stdin.readline().strip()

def main():
    H, W, K = map(int, input().split())
    cake = [input() for _ in range(H)]
    ans_cake = [[0]* W for _ in range(H)]

    row_num = [raw.count("#") for raw in cake]

    top_row = min([i for i, num in enumerate(row_num) if num != 0])
    
    cake_idx = 0
    for i, (cake_row, num) in enumerate(zip(cake[top_row:], row_num[top_row:])):
        i += top_row
        if num:
            cake_idx += 1
            for j in range(W):
                ans_cake[i][j] = cake_idx
                if cake_row[j] == "#":
                    num -= 1
                    if num:
                        cake_idx += 1
        else:
            ans_cake[i] = deepcopy(ans_cake[i-1])

    for i in range(top_row):
        ans_cake[i] = deepcopy(ans_cake[top_row])
    
    for ans_cake_row in ans_cake:
        print(*ans_cake_row, sep=" ")




if __name__ == "__main__":
    main()

Measured memory_bytes: 8016
#define _CRT_SECURE_NO_WARNINGS
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define sz(v)				((int)((v).size()))
#define clr(v, d)			memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define pb					push_back
#define MP					make_pair
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
typedef long long         ll;
typedef long double   	  ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;
typedef vector<ll>		  vll;


const ll OO = 1e16;

const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }


void fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}
string s;
int main(){
	fast();
	cin >> s;
	int cnt = 1; int mx = 0;
	for (int i = 0; i < s.size() - 1; i++){
		if (s[i] == s[i + 1])cnt++;
		else cnt = 1;
		mx = max(cnt, mx);
	}
	mx = max(cnt, mx);
	if (mx >= 3)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}
//mosta7il_

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

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		char []t = s.toCharArray();
		int max = 0;
		int count = 0;
		for(int i = 0; i <s.length(); i++) {
			boolean p = true;
			p = (t[i] == 'A'||t[i] =='T'||t[i]=='C'||t[i]=='G');
				if(p) {
					count++;
					max = Math.max(max, count);
				}
				else{
					count =0;
				}
			}
		System.out.println(max);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll          long long
#define dl          double
#define pb          push_back
#define mp          make_pair
#define pll         pair<long long,long long>
#define vll          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (long long)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main(){
	string t,s;cin>>t>>s;
	ll f[26]={0};
	vector<ll> v[26];
	for(ll i=0;i<t.size();i++){
		v[t[i]-'a'].push_back(i+1);
	}
	for(ll i=0;i<s.size();i++){
		if(v[s[i]-'a'].size()==0)return cout<<"-1",0;
	}
	ll inx=0;
	ll n=t.size();
	//cout<<n<<endl;
	ll c=0;
	for(ll i=0;i<s.size();i++){
		ll c=inx-f[s[i]-'a'];
		//cout<<"c "<<inx<<endl;
		ll x=lower_bound(all(v[s[i]-'a']),c)-v[s[i]-'a'].begin();
		//cout<<"x "<<x<<" "<<v[s[i]-'a'].size()<<endl;
		
		if(x==v[s[i]-'a'].size()){
			for(ll j=0;j<26;j++)f[j]+=n;		
			//cout<<"f[s[i]-'a'] "<<f[s[i]-'a']<<endl;
			inx=f[s[i]-'a']+v[s[i]-'a'][0]+1;
			//cout<<"inx1 "<<inx<<endl;
		}
		else{
			//cout<<"f[s[i]-'a'] "<<f[s[i]-'a']<<endl;						
			inx=f[s[i]-'a']+v[s[i]-'a'][x]+1;
			//cout<<"inx2 "<<inx<<endl;			
		}
	}
    cout<<inx-1<<endl;
}

Measured memory_bytes: 1724
a = int(input()) #500
b = int(input()) #100
c = int(input()) #50
x = int(input())
cnt = 0
for i in range(a+1):
    for j in range(b+1):
        if (x-500*i-100*j)%50==0 and  0<=(x-500*i-100*j)/50<=c:
            cnt += 1
print(cnt)      

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

// Euler-Tour
struct EulerTour {
  vector< vector<int> > graph;
  vector<int> tour, begins, ends;
  int idx, root;
  EulerTour(){}
  EulerTour(int n) : graph(n), begins(2*n), ends(2*n), idx(0), root(0){}
  void add_edge(int u, int v)
  {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  void dfs(int cur, int par)
  {
    begins[cur] = idx;
    tour.push_back(cur);
    idx++;
    for(int& to : graph[cur]) {
      if(to == par) continue;
      dfs(to, cur);
    }
    ends[cur] = idx;
  }
};

// Lazy-evaluated Segment Tree
struct SegmentTree
{
  vector<int> sum;
  vector<bool> lazy;
  int sz;
  SegmentTree(int n)
  {
    sz = 1; while(sz < n) sz *= 2;
    sum.resize(2*sz-1, 0);
    lazy.resize(2*sz-1, false);
  }
  inline void lazy_evaluate(int k, int l, int r)
  {
    if(lazy[k]) {
      sum[k] = (r - l) - sum[k];
      if(r - l > 1) {
	lazy[2*k+1] = !lazy[2*k+1];
	lazy[2*k+2] = !lazy[2*k+2];
      }
      lazy[k] = false;
    }
  }
  void update(int a, int b, int k, int l, int r)
  {
    lazy_evaluate(k, l, r);
    if(r <= a || b <= l) return;
    if(a <= l && r <= b) {
      lazy[k] = !lazy[k];
      lazy_evaluate(k, l, r);
      return;
    }
    update(a, b, 2*k+1, l, (l+r)/2);
    update(a, b, 2*k+2, (l+r)/2, r);
    sum[k] = sum[2*k+1] + sum[2*k+2];
  }
  void update(int a, int b)
  {
    update(a, b, 0, 0, sz);
  }
  int query(int a, int b, int k, int l, int r)
  {
    lazy_evaluate(k, l, r);
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) {
      return sum[k];
    }
    return query(a, b, 2*k+1, l, (l+r)/2) + query(a, b, 2*k+2, (l+r)/2, r);
  }
  int query(int a, int b)
  {
    return query(a, b, 0, 0, sz);
  }
};

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, q;
  cin >> n >> q;

  EulerTour et(n);
  rep(i, n-1) {
    int p;
    cin >> p; --p;
    et.add_edge(p, i+1);
  }
  vector<char> c(n);
  rep(i, n) cin >> c[i];
  et.dfs(0, -1);

  SegmentTree seg(n);
  rep(i, n) {
    if(c[i] == 'G') seg.update(et.begins[i], et.begins[i]+1);
  }
  while(q--) {
    int v;
    cin >> v; --v;
    seg.update(et.begins[v], et.ends[v]);
    int res = seg.query(0, n);
    //cout<<res<<endl;
    cout << (n-res < res ? "broccoli" : "cauliflower") << endl;
  }

  return 0;
}



Measured memory_bytes: 18064
import java.util.*

fun main( argv : Array<String> ) {
    
    val scan = Scanner(System.`in`)
    
    //
    val A = scan.nextInt()
    val B = scan.nextInt()
    
    //
    when {
        A/3*3==A -> println("Possible")
        B/3*3==B -> println("Possible")
        (A+B)/3*3==A+B -> println("Possible")
        else -> println("Impossible")
    }

}


Measured memory_bytes: 29348
#include <iostream>

using namespace std;

int main(){
	int d[6];
	while(true){
		int sum = 0;
		for(int i=0;i<6;i++){
			cin >> d[i];
			sum += d[i];
		}
		if(sum == 0) break;
		int res = 0;
		int val[3];
		int mx = 3;
		for(int i=0;i<3;i++){
			d[i] += d[i+3];
			val[i] = d[i]/3;
			mx = min(mx, d[i]);
		}
		for(int j=0;j<=mx;j++){
			int tmp = j;
			if(tmp < 0) continue;
			for(int i=0;i<3;i++)
				tmp += (d[i]-j)/3;
			res = max(res, tmp);
		}
		cout << res << endl;
	}
	return 0;
}

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

int main(){
	char** str;
	int** num;
	int i,j;
	int n;
	int min;

	scanf("%d",&n);
	str = (char**)calloc(n,sizeof(char*));
	num = (int**)calloc(n,sizeof(int*));

	for(i=0; i<n; i++){
		str[i] = (char*)calloc(51,sizeof(char));
		num[i] = (int*)calloc(26,sizeof(int));
		scanf("%s",str[i]);
	}

	for(i=0; i<n; i++){
		for(j=0; j<strlen(str[i]); j++){
			num[i][str[i][j]-97]++;
		}
	}

	for(i=0; i<26; i++){
		min = 51;
		for(j=0; j<n; j++){
			if( num[j][i] < min ) min = num[j][i];
		}

		for(j=0; j<min; j++){
			printf("%c",(char)(i+97));
		}
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 128
#include <cstring>
#include <cstdio>
using ll = long long;
const int M = 2e5 + 10, mod = 1e9 + 7;
ll arr[M], sum[M], n, ans = 0;
int main () {
    scanf ("%lld", &n);
    for (int i = 1; i <= n; i++) {
        scanf ("%lld", &arr[i]);
        sum[i] = sum[i - 1] + arr[i];
    }
    for (int i = 2; i <= n; i++) {
        ans = (ans + (sum[i - 1] % mod * arr[i] % mod)) % mod;
    }
    printf("%lld", ans);
    return 0;
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int n,a,b;
	int all,kaigai;
	all = kaigai = 0;
	string s;
	cin >> n >> a >> b;
	cin >> s;
	REP(i,s.size()){
		if(s[i] == 'a'){
			if(all < a+b){
				all++;
				cout << "Yes" << endl;
			}else{
				cout << "No" << endl;
			}
		}else if(s[i] == 'b'){
			if(kaigai < b && all < a+b){
				all++;
				kaigai++;
				cout << "Yes" << endl;
			}else{
				cout << "No" << endl;
			}
		}else{
			cout << "No" << endl;
		}
	}	
}

Measured memory_bytes: 896