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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;

vector<int> dijkstra(int i,int n, vector<vector<pair<int, int>>> graph) {
  vector<int> d(n, INF);
  d[i] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
  q.push(make_pair(0, i));
  while (!q.empty()) {
    pair<int, int> p = q.top();
    q.pop();
    int v = p.second;
    if (d[v] < p.first) {
      continue;
    }
    for (auto x : graph[v]) {
      if (d[x.first] > d[v] + x.second) {
        d[x.first] = d[v] + x.second;
        q.push(pair<int, int>(d[x.first], x.first));
      }
    }
  }
  return d;
}


signed main() {
  int N, A;
  cin >> N;

  vector<vector<pair<int, int>>> graph(N);
  REP(i, N) REP(j, N){
    cin >> A; 
    graph[i].push_back({j, A});
  }

  vector<vector<int>> dist(N);
  REP(i, N) dist[i] = dijkstra(i, N, graph);

  REP(i, N) REP(j, N){
    if(graph[i][j].second != dist[i][j]){
      cout << -1 << endl;
      return 0;
    }
  }

  int ans = 0;
  REP(i, N) FOR(j, i+1, N){
    int flag = 1;
    REP(k, N){
      if(k == i || k == j) continue;
      if(dist[i][j] == dist[i][k]+dist[k][j]) flag = 0;
    }
    if(flag) ans += dist[i][j];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4864
n,m = map(int, input().split())
mo = list(map(int,input().split()))
dp = [float("inf") for i in range(n+1)]
dp[0] = 0
for i in range(n+1):
    for j in mo:
        if i+j <= n:
            dp[i+j] = min(dp[i+j],dp[i]+1)
print(dp[n])


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

// a = bx + K以上
// K >= a - bx
// b > K

int main() {
  int N,K;
  cin >> N >> K;
  ll ans = 0;
  for ( int b=K+1;b<=N;b++ ) {
    ans += (N / b) * (b-K);
//    cout << b << " : " << ans << endl;
    if ( N%b != 0 && N%b >= K ) ans += N%b - (K- ((K==0) ? 0: 1));
//    cout << b << " : " << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  ll x2=0;  
  rep(i,n){
    if (i&1)x2-=a[i];
    else x2+=a[i];
  }    
  vector<int>ans(n);
  ans[0]=x2/2;
  rep(i,n-1){
    ans[i+1]=a[i]-ans[i];    
  }
  rep(i,n)ans[i]*=2;
  rep(i,n)printf("%d%c",ans[i],i==n-1?'\n':' ');  
  return 0;
}


Measured memory_bytes: 2048
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define abs(a) ((a) > 0 ? (a) : (-1 * (a)))
#define rep(i, n) for ((i) = 0; (i) < (n); (i)++)
#define rep2(i, s, e) for ((i) = (s); (i) < (e); (i)++)
#define LIM (1000000007)

////int g[220][220][220];

void sw(int *a, int *b)
{
    int c = a[0];
    a[0] = b[0];
    b[0] = c;
}

int gcd2(int a, int b)
{
    while (1)
    {
        b %= a;
        if (b == 0)
            return a;
        sw(&a, &b);
    }
}

int gcd(int i, int j, int k)
{
    if (i > j)
        sw(&i, &j);
    if (j > k)
        sw(&j, &k);
    if (i > j)
        sw(&i, &j);
    //   if (g[i][j][k] != 0)
    //       return g[i][j][k];

    //printf("%d %d %d\n", i, j, k);
    while (1)
    {
        if (i == 1 || j == 1 || k == 1)
        {
            //            g[i][j][k] = 1;
            return 1;
        }
        k %= i;
        if (k == 0)
        {
            //           g[i][j][k] = gcd2(i, j);
            //           return g[i][j][k];
            return gcd2(i, j);
        }
        sw(&j, &k);
        sw(&i, &k);
    }
}

int main(void)
{

    int n, i, j, k, cnt = 0;
    scanf("%d", &n);
    rep2(i, 1, n + 1)
    {
        rep2(j, 1, n + 1)
        {
            rep2(k, 1, n + 1)
            {
                //               printf("%d %d %d\n", i, j, k);
                cnt += gcd(i, j, k);
            }
        }
    }
    printf("%d", cnt);

    return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

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

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    vector<int> c(n - 1), s(n - 1), f(n - 1);
    for (int i = 0; i < n - 1; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }
    
    for (int i = 0; i < n; i++) {
        int pos = i;
        int t = 0;
        
        while (pos < n - 1) {
            if (t <= s[pos]) {
                t = s[pos] + c[pos];
                pos++;
            } else {
                t = f[pos] * ((t - 1 + f[pos]) / f[pos]) + c[pos];
                pos++;
            }
        }
        cout << t << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//atcoder 97
#include<stdio.h>
int main(void)
{

	int X,i,k,Y,a=1;
	scanf("%d",&X);
	for(i=2;i<=X/2;i++){
		k=X;
		Y=1;
		while(k/i>0){
			k=k/i;
			Y=Y*i;
		}
    if(Y>a){
		a=Y;
		}
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 128
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

int64_t GreatestCommonDivisor(const int64_t a, const int64_t b) {
  // GCD. O(log(min(a, b))). 最大公約数.
  int64_t result = -1LL;
  if (a < 0) {
    std::cerr << "ERROR: GreatestCommonDivisor(): a is out of range: " << a << std::endl;
    throw 1;
  } else if (b < 0LL) {
    std::cerr << "ERROR: GreatestCommonDivisor(): b is out of range: " << b << std::endl;
    throw 1;
  } else if (a == 0LL) {
    result = b;
  } else if (b == 0LL) {
    result = a;
  } else {
    const int64_t new_a = std::min(a, b);
    const int64_t new_b = std::max(a, b) % new_a;  // Euclidean Algorithm
    result = GreatestCommonDivisor(new_a, new_b);
  }
  return result;
}

int64_t LeastCommonMultiple(const int64_t a, const int64_t b) {
  // LCM. O(log(min(a, b))). 最小公倍数.
  int64_t result;
  if (a == 0 || b == 0) {
    return 0;
  } else if (a == 1) {
    return b;
  } else if (b == 1) {
    return a;
  } else if (a < 0 || b < 0) {
    std::cerr << "ERROR: LeastCommonMultiple(): Invalid arg. a=" << a << ", b=" << b << std::endl;
    throw 1;
  }
  try {
    result = (a / GreatestCommonDivisor(a, b) * b);
  } catch (...) {
    std::cerr << "ERROR: LeastCommonMultiple()" << std::endl;
  }
  return result;
}

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

  int64_t A, B, C, D;
  cin >> A >> B >> C >> D;
  const int64_t cd = LeastCommonMultiple(C, D);
  // const int64_t L = static_cast<int64_t>(T.length());
  const int64_t wareru = (B / C - (A - 1) / C) + (B / D - (A - 1) / D) - (B / cd - (A - 1) / cd);
  const int64_t result = B - (A - 1) - wareru;
  cout << result << endl;
  return 0;
}


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

struct Card {
	char suit, value;
};

void bubble(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		for (int j = N - 1; j >= i + 1; j--) {
			if (A[j].value < A[j - 1].value) {
				Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
			}
		}
	 }
}

void selection(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (A[j].value < A[minj].value) {
				minj = j;
			}
		}
		Card t = A[i]; A[i] = A[minj]; A[minj] = t;
	}
}

void print(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		if (i > 0) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
	for (int i = 0; i < N; i++) {
		if (C1[i].suit != C2[i].suit) return false;
	}
	return true;
}

int main() {
	Card C1[100], C2[100];
	int N;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> C1[i].suit >> C1[i].value;
	}
	for (int i = 0; i < N; i++) {
		C2[i] = C1[i];
	}

	bubble(C1, N);
	selection(C2, N);

	print(C1, N);
	cout << "Stable" << endl;
	print(C2, N);
	if (isStable(C1, C2, N) ) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}

	return 0;
}

Measured memory_bytes: 3100
chomp (my $n = <STDIN>);
chomp (my @a = split / /, <STDIN>);
my ($c1, $c2) = (0, 0);
for $_ (@a) {
  if ($_ % 4 == 0) {
    $c1++;
  } elsif ($_ % 2 == 0) {
    $c2++;
  }
}
print ($c1 + int($c2 / 2) >= int($n / 2) ? "Yes\n" : "No\n");

Measured memory_bytes: 17188
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 5e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

string s;
vector<int> has[30];
int que[MAXN], pre[MAXN], vs[30][MAXN];

void trace(int cur) {
	if (!~cur) return;
	trace(pre[cur]);
	cout << s[cur];
}

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	cin >> s;
	
	for (int i=0; i<sz(s); i++) {
		has[s[i] - 'a'].pb(i);
	}

	que[0] = -1;
	int qsize = 1;
	
	int gg = -1, ans = -1, find = 0;
	for (int i=0; i<qsize; i++) {
		int cur = que[i] + 1;
		
		for (int j=0; j<26; j++) {
			int nxt = lower_bound(has[j].begin(), has[j].end(), cur) - has[j].begin();
//			if (i == 28 && j == 0) cout << nxt << endl;
			if (nxt >= sz(has[j])) {
				gg = j;
				ans = que[i];
				find = 1;
//				cout << que[i] << endl;
				break;
			}
			else {
				if (!vs[j][nxt]) {
					vs[j][nxt] = 1;
					pre[has[j][nxt]] = que[i];
//					if (i == 1 && j == 2) cout << qsize << endl;
//					if (i == 0 && j == 0) cout << qsize << endl;
					que[qsize++] = has[j][nxt];
				}
			}
		}
		if (find) break;
	}
	
	assert(~gg);
	trace(ans);
	char c = gg + 'a';
	cout << c;
}


Measured memory_bytes: 52868
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
using namespace std;


int main() {
    int n;
    long a[100010];

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

    long min = a[0];
    for (int i = 1; i < n; ++i) {
        min = __gcd(min, a[i]);
    }

    cout << min;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,i;
	cin >> N>> i;
	cout << N - i + 1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#ABC044D
def fun(b,n):
    if n<b:return n
    return (n%b)+fun(b,n//b)
n=int(input())
s=int(input())
n_root=n**0.5

def main(n,n_root,s):
    if s==n:return n+1
    if s>n:return -1
    if (n//2)+1<s:return -1
    for b in range(2,1+int(n_root)):
        if fun(b,n)==s:
            return b
    for i in range(int(n_root),0,-1):
        b=1+(n-s)//i
        if fun(b,n)==s:
            if b>1:return b
    return -1
print(main(n,n_root,s))


Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    cout << (1000 - n % 1000) % 1000 << endl;
}

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

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

int main(){
    int X, N, p[102], num;
    bool flag = 1;

    cin >> X >> N;
    for(int i = 0; i < N; i ++){
        cin >> p[i];
    }
    qsort(p, N, sizeof(int), comp);

    for(int j = 0; j < N; j ++){
        if(X == p[j]){
            flag = 0;
            num = j;
        }
    }
    if(flag){
        cout << X << endl;
        return 0;
    }
    for(int k = 1; k <= N; k ++){
        if(p[max(num - k, 0)] != (p[num] - k)){
            cout << p[num] - k << endl;
            break;
        }
        if(p[min(num + k, N - 1)] != (p[num] + k)){
            cout << p[num] + k << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3572
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int n = scan.nextInt();
		Tree t = new Tree(n);

		for (int i = 0; i < n; i++) {
			int id = scan.nextInt();
			int k = scan.nextInt();
			int pc = -1;
			for (int j = 0; j < k; j++) {
				int c = scan.nextInt();
				if (j == 0)
					t.setChild(id, c);
				else
					t.setRightSib(pc, c);
				t.setPar(c, id);
				pc = c;
			}
		}

		for (int i = 0; i < n; i++)
			t.printR(i);

		scan.close();
		System.exit(0);
	}
}

class Tree {
	private class Node {
		int Parent = -1;
		int LeftChild = -1;
		int RightSib = -1;

		public int getDepth() {
			if (Parent == -1)
				return 0;
			else
				return (node[Parent].getDepth() + 1);
		}

		public String getType() {
			if (Parent == -1)
				return "root";
			else if (LeftChild == -1)
				return "leaf";
			else
				return "internal node";
		}
	}

	private Node[] node;

	public Tree(int n) {
		node = new Node[n];
		for (int i = 0; i < n; i++) {
			node[i] = new Node();
		}
	}

	public void printR(int id) {
		System.out.print("node " + id + ": parent = " + node[id].Parent + ", depth = " + node[id].getDepth() + ", "
				+ node[id].getType() + ", [");
		if (node[id].LeftChild != -1) {
			System.out.print(node[id].LeftChild);
			for (int c = node[node[id].LeftChild].RightSib; c != -1; c = node[c].RightSib)
				System.out.print(", " + c);
		}
		System.out.println("]");
	}

	public void setChild(int id, int c) {
		node[id].LeftChild = c;
	}

	public void setRightSib(int id, int sib) {
		node[id].RightSib = sib;
	}

	public void setPar(int id, int par) {
		node[id].Parent = par;
	}

}

Measured memory_bytes: 131624
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

const LL mod = 998244353;

int n, x, a[105];
set<int> st;

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif

  scanf("%d%d", &x, &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    st.insert(a[i]);
  }

  for (int i = 0; ; i++) {
    if (st.find(x - i) == st.end()) {
      printf("%d\n", x - i);
      break;
    }
    if (st.find(x + i) == st.end()) {
      printf("%d\n", x + i);
      break;
    }
  }

#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 3772
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

const ll MOD = 1000000007;
//const ll MOD = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        return mint(*this) /= a;
    }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int n;
    cin >> n;

    vector<vi> g(n);
    REP(i, n - 1) {
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].pb(b);
        g[b].pb(a);
    }

    mint ans = 0;
    auto dfs = [&] (auto && f, int cur, int par = -1) -> ll {
        ll ret = 0;
        mint c = mint(2).pow(n-1);
        for(auto &e: g[cur]) {
            if (e == par) continue;
            ll tmp = f(f, e, cur);
            ret += tmp;
            c -= mint(2).pow(tmp) - 1;
        }

        c -= mint(2).pow(n - ret - 1);
        ans += c;

        return ret + 1;
    };

    dfs(dfs, 0);

    ans /= mint(2).pow(n);

    print(ans);
}


Measured memory_bytes: 31972
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;
	cin>>h>>w;
	vector<string> s(h);
	REP(i,h) cin>>s[i];
	vector<vector<char>> ret(h,vector<char>(w,'#'));
	REP(i,h) {
		REP(j,w) {
			if(s[i][j]=='#') continue;
			int c=0;
			for(int dh=-1; dh<=1; dh++) {
				for(int dw=-1; dw<=1; dw++) {
					if(dh==0&&dw==0) continue;
					ll nh=i+dh;
					ll nw=j+dw;
					if(nh>=0&&nh<h&&nw>=0&&nw<w&&s[nh][nw]=='#') c++;
				}
			}
			ret[i][j]='0'+c;
		}
 	}
	REP(i,h) {
		REP(j,w) cout<<ret[i][j];
		cout<<endl;
	}
}


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

using namespace std;

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

    return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara,x) memset((ara),x,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	//char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n;

	f(i,0,n-1) cin>>ara[i];

	int s=0;
	for(i=0;i<n;i++){
        s+=ara[i];
	}

    cout<<s-n<<endl;


}


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

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

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

    for (int i = 0; i < N - 1; i++)
    {
        if (A[i] == A[i + 1])
        {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define MOD                 1000000007LL
#define EPS                 1e-9
#define io                  ios_base::sync_with_stdio(false);cin.tie(NULL);

const int MAXN = 1e5+5;

int main(){
	io;
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if(s < t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

string srt(string s){
    string alpha = "abcdefghijklmnopqrstuvwxyz";
    map<char,ll> mp;
    for(ll i = 0;i < alpha.length(); i++){
        mp[alpha[i]] = i;
    }
    for(ll i = 0; i < s.length(); i++){
        for(ll j = 0;j < i; j++){
            if(mp[s[i]] < mp[s[j]]){
                char tmp = s[j];
                s[j] = s[i];
                s[i] = tmp;
            }
        }
    }
    return s;
}

ll cmb(ll app){
    ll res = 1;
    for(ll i = app;i > app - 2 && i > 0; i--){
        res *= i;
    }
    return res / 2;
}

int main(void){
    ll n;
    cin >> n;
    map<string,ll> mp;
    vector<string> s(n);
    for(ll i = 0;i < n;i++){
        cin >> s[i];
        mp[srt(s[i])]++;
    }
    ll ans = 0;
    for (auto x : mp){
        if(x.second != 1){
            ans += cmb(x.second);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18176
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String A = sc.next();
    String B = sc.next();
    char[]a = A.toCharArray();
    char[]b = B.toCharArray();
    
    if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]){
    System.out.println("YES");
    }else{
    System.out.println("NO");    
    }
}
}

Measured memory_bytes: 35744
N = int(input())
a = list(map(int,input().split()))

odd = 0
double = 0
quatro = 0

for i in a:
  if i % 2 == 1:
    odd += 1
  else:
    if i % 4 == 0:
      quatro += 1
    else:
      double += 1

if double == N:
  print("Yes")
  exit()
plus = 0
if double != 0:
  plus = 1
if plus + odd - 1 <= quatro:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 62576
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define MOD 1000000007
#define DEBUG 0
#define REP(i,n) for(int i=0;i<n;i++)

int main(){

	lli n,min2=1e15+10;
	cin>>n;
	REP(i,5){
		lli tmp;
		cin>>tmp;
		min2 = min(min2,tmp);
	}

	lli ans = (lli)4 + (lli)n/min2;
	if(n%min2)ans++;
	cout<<ans<<endl;
	return 0;
}
 

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int a[2][1000];
	int n,ans;

	scanf("%d", &n);
	for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            scanf("%d",&a[i][j]);
        }
    }
    int max=0;
    int hako;
    int cnt1;
    int cnt2;
    int i,j,k;
    for(i = 0; i < n; i++){
        int sum=0;
        for(k=0;k<=i;k++){
            sum+=a[0][k];
        }
        for(j=i;j<n;j++){
            sum+=a[1][j];
        }
        if(max<sum){
            max=sum;
        }
    }
    
	printf("%d\n", max);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cassert>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds; 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX

const int M=998244353;
const int MAXN=4e5+5;

 
void solve(){

	int n;
	sfi(n)

 	queue<string> q;

 	for(int i=1;i<10;i++){
 		string s;
 		s.push_back('0'+i);
 		q.push(s);
 	}

 	int k=0;

 	while(true){
 		string s=q.front();
 		q.pop();

 		k++;

 		//cout<<k<<" "<<s<<endl;

 		if(k==n){
 			cout<<s;
 			return;
 		}

 		char ch=s.back();

 		int num=ch-'0';

 		if(num-1>=0){
 			s.push_back('0'+(num-1));
 			q.push(s);
 			//cout<<num<<" "<<s<<endl;
 			s.pop_back();

 		}
 		s.push_back('0'+(num));
 		q.push(s);
 		//cout<<num<<" "<<s<<endl;
 		s.pop_back();
 		if(num+1<=9){
 			s.push_back('0'+(num+1));
 			q.push(s);
 			//cout<<num<<" "<<s<<endl;
 			s.pop_back();
 		}
 		
 			
 		
 	}

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

Measured memory_bytes: 13568
import java.io.*;
class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(bu.readLine());
        String ans="";
        if(n>=30) ans="Yes";
        else ans="No";
        System.out.print(ans);
    }
}

Measured memory_bytes: 32648
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=1000000007LL;
const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};




int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n,k;cin>>n>>k;
  vl a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  ll ans=0;
  rep(i,k)ans+=a[i];
  cout<<ans<<endl;
}

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

int main()
{
    int w, a, b, m;
    cin >> w >> a >> b;
    if (a > b)
        m = a - b - w;
    else
        m = b - a - w;
    if (m < 0)
        cout << 0 << endl;
    else
        cout << m << endl;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i, Xi in enumerate(X):
    for j, Xj in enumerate(X):
        if i == j:
            continue
        dist = 0
        for y, z in zip(Xi, Xj):
            dist += (y - z) ** 2
        dist **= .5
        if dist == int(dist):
            ans += 1
print(ans // 2)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] top = sc.next().toCharArray();
        char[] bottom = sc.next().toCharArray();

        boolean ans = true;
        for (int i = 0, j = top.length - 1; i < top.length && j >= 0; i++, j--) {
            if (top[i] != bottom[j]) {
                ans = false;
                break;
            }
        }


        if (ans)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


Measured memory_bytes: 23124
#include <stdio.h>
#include <string.h>

int main(){
 int i;
 scanf("%d", &i);
 
 char str[i+1];
 scanf("%s", &str);
 
 if (i%2!=0){
  printf("No\n");
 }
 else {
  int index=1;
  for (int n=0; n<i/2; n++){
   if (str[n]!=str[n+i/2]){
    index=0;
   }
  }
   if(index){
    printf("Yes\n");
   }
   else{
    printf("No\n");
   }
 }

 return 0;
}

Measured memory_bytes: 1640
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
using namespace std;

int main() {
	int l, r;
	cin >> l >> r;
	int ans = 2019;
	if (r - l >= 2019)
		ans = 0;
	else {
		for (int i = l; i < r; ++i) {
			int rmod = i % 2019;
			for (int j = i + 1; j <= r; ++j) {
				int lmod = j % 2019;
				int mod = (rmod * lmod) % 2019;
				if (mod < ans)
					ans = mod;
			}
			if (ans == 0)
				break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<numeric>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
int abc[300000];
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int X = 0, Y = 0, A = 0, B = 0, C = 0;
	while ((ct = getchar_unlocked()) >= '0') X = X * 10 + ct - '0';
	while ((ct = getchar_unlocked()) >= '0') Y = Y * 10 + ct - '0';
	while ((ct = getchar_unlocked()) >= '0') A = A * 10 + ct - '0';
	while ((ct = getchar_unlocked()) >= '0') B = B * 10 + ct - '0';
	while ((ct = getchar_unlocked()) >= '0') C = C * 10 + ct - '0';

	auto a = abc;
	auto b = abc + A;
	auto c = abc + A + B;

	int k = 0;
	int M = A + B + C;
	while (k < M) {
		int yoyuu = (cm - (ci - cn)) / 11;
		chmin(yoyuu, M - k);
		if (yoyuu > 10) {
			rep(i, yoyuu) {
				while ((ct = *ci++) >= '0') abc[k] = abc[k] * 10 + ct - '0';
				k++;
			}
		}
		else {
			auto tmp = ci;
			while (k < M) {
				abc[k++] = getint();
				if (tmp - ci < 0) break;
				tmp = ci;
			}
		}
	}

	nth_element(a, b - X, b);
	nth_element(b, c - Y, c);
	if (X + Y > B) memcpy(b, b - X, (B - Y) * sizeof(int));
	else memcpy(c - X - Y, b - X, X * sizeof(int));
	nth_element(c - X - Y, c + C - X - Y, c + C);

	ll kotae = accumulate(c + C - X - Y, c + C, 0ll);
	//for (auto kari = c + C - X - Y; kari < c + C; kari++) kotae += *kari;
	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1408
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
length = len(S)
if S[0] == S[-1]:
    length += 1
bl = length & 1
print('First' if bl else 'Second')
# 39

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

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

        int n=scan.nextInt();
        int []a=new int[n];
        for(int i=0;i<n;i++){
            a[i]=scan.nextInt();
        }

        int ans=0;
        int min=0;
        for(int j=-100;j<=100;j++) {
            ans=0;
            for (int i = 0; i < n; i++) {
                ans += (a[i] - j) * (a[i] - j);
            }
            if(j==-100)
                min=ans;
            if(min>ans)
                min=ans;
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 9552
#include<iostream>
#include<vector>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  int64_t N, K; std::cin >> N >> K;
  std::vector<int> A(N);
  for(int i = 0; i < N; ++i) { std::cin >> A[i]; --A[i]; }
  std::vector<int> n(N, -1);
  int s = 0, i;
  for(int i = 0;;++i) {
    if(n[s] >= 0) {
       int64_t p = i-n[s];
       K %= p;
       if(K == 0) fin(s+1);
       break;
    }
    n[s] = i;
    s = A[s];
    if(--K == 0) fin(s+1);
  }
  for(;;) {
    s = A[s];
    if(--K == 0) fin(s+1);
  }
  return 0;
}


Measured memory_bytes: 5172
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
const int Mod=1000000007;
int n,pa[100010],pb[100010],fx[100010],fy[100010];
long long a,b,s[100010],px,py,xi,yi;
int main()
{
	scanf("%d%lld%lld",&n,&a,&b);
	if (a<=b)
	{
		swap(a,b);
	}
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&s[i]);
	}
	fx[0]=fy[0]=1;
	int sa,sb;
	sa=sb=1;
	for (int i=1;i<=n;i++)
	{
		while (s[sa]+a<=s[i])
		{
			sa++;
		}
		while (s[sb]+b<=s[i])
		{
			sb++;
		}
		pa[i]=sa-1;
		pb[i]=sb-1;
	}
	for (int i=2;i<=n;i++)
	{
		xi=fy[min(i-2,pa[i])];
		yi=fx[min(i-2,pb[i])];
		if (pa[i]<i-1)
		{
			memset(fx+px,0,i-px-1<<2);
			px=i-1;
		}
		if (pb[i]<i-1)
		{
			memset(fy+py,0,i-py-1<<2);
			py=i-1;
		}
		fx[i-1]=(fx[i-1]+fx[i-2]+xi)%Mod;
		fy[i-1]=(fy[i-1]+fy[i-2]+yi)%Mod;
	}
	printf("%d\n",(fx[n-1]+fy[n-1])%Mod);
    return 0;
}

Measured memory_bytes: 2560
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();

            if (s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2)) {
                out.println("Yes");
            } else if (s.charAt(1) == s.charAt(2) && s.charAt(2) == s.charAt(3)) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }
}



Measured memory_bytes: 23892
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;

const int maxn=(int) 3e5+20;

int n,m;
int T[maxn];
int ans[maxn];
struct Node
{
    int l,r,len,idx;
    bool operator < (const Node &t) const {return len<t.len;}
}node[maxn];

#define lowbit(x) ((x)&-(x))
int _N;
inline void init_T(int N)
{
    _N=N;
    memset(T,0,sizeof(int)*(_N+1));
}
inline void add(int pos,int v)
{
    for(int i=pos;i<=_N;i+=lowbit(i)) T[i]+=v;
}
inline int sum(int pos)
{
    int res=0;
    for(int i=pos;i;i-=lowbit(i)) res+=T[i];
    return res;
}

void work()
{
    while(~scanf("%d%d",&n,&m))
    {
        for(int i=0;i<n;i++) scanf("%d%d",&node[i].l,&node[i].r);
        for(int i=0;i<n;i++) node[i].len=node[i].r-node[i].l, node[i].idx=i;

        sort(node,node+n);
        init_T(m);

        for(int i=0;i<n;i++) add(node[i].l,1), add(node[i].r+1,-1);

        for(int i=m,j=n-1,tot=0;i;i--)
        {
            while(j>=0 && i<=node[j].len)
            {
                add(node[j].l,-1), add(node[j].r+1,1);
                j--; tot++;
            }
            ans[i]=tot;
            for(int k=i;k<=m;k+=i) ans[i]+=sum(k);
        }

        for(int i=1;i<=m;i++) printf("%d\n",ans[i]);
    }
}

int main()
{
//    freopen("in.txt","r",stdin);
    work();
    return 0;
}


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

using namespace std;

int main()
{
    int num;
    cin>>num;
    if(num%10==9 || num/10==9)
    {
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}



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

using namespace std;

int main() {
    int n; 
    cin >> n;
    int r = n % 10;
    if (r == 3) cout << "bon";
    else if (r == 0 || r == 1 || r == 6 || r == 8) cout << "pon";
    else cout << "hon";
    cout << "\n";
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 100010
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    int n;
    scanf("%d", &n);
    printf("%d\n", n/2 + n%2);
    return 0;
}


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

int main() {
	int n,a,b,c;
	cin>>n;
	vector<vector<int>> v;
	for(int i=0;i<n;i++){
		vector<int> u;
		cin>>a>>b>>c;
		u.push_back(a);
		u.push_back(b);
		u.push_back(c);
		v.push_back(u);
	}
	vector<int> u(3,0);
	vector<vector<int>> dp(n,u);
	dp[0][0]=v[0][0];
	dp[0][1]=v[0][1];
	dp[0][2]=v[0][2];
	for(int i=0;i<n-1;i++){
		dp[i+1][0]=max(v[i+1][0]+dp[i][1],v[i+1][0]+dp[i][2]);
		dp[i+1][1]=max(v[i+1][1]+dp[i][2],v[i+1][1]+dp[i][0]);
		dp[i+1][2]=max(v[i+1][2]+dp[i][0],v[i+1][2]+dp[i][1]);
	}
//	cout<<dp[n-3][0]<<endl<<dp[n-3][1]<<endl<<dp[n-3][2]<<endl;
//	cout<<dp[n-2][0]<<endl<<dp[n-2][1]<<endl<<dp[n-2][2]<<endl;
//	cout<<dp[n-1][0]<<endl<<dp[n-1][1]<<endl<<dp[n-1][2];
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}

Measured memory_bytes: 11568
n = int(input())
ls_b = list(map(int, input().split()))

ls_a = [0] * n

ls_a[n - 1] = ls_b[n - 2]
ls_a[0] = ls_b[0]

for i in reversed(range(1, n - 1)):
    ls_a[i] = min(ls_b[i], ls_b[i - 1])

print(sum(ls_a))

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	static int N,count[1000009];
		count[1] = 1;
	for(int x=3;x<=1000000;x=x+2){
		int flag = 0;
		for(int y=3;y<=sqrt(x);y=y+2){
			if((x%y)==0)	flag = 1;
		}
		count[x] = count[x-2];
		count[x-1] = count[x-2];
		if(flag == 0)	count[x]++;
	}
	count[1] = 0;
	while(cin >> N){
		cout << count[N] << endl;
	}
	return 0;
}

Measured memory_bytes: 6908
N,T = map(int, input().split())
t = list(map(int,input().split()))
ans = 0
for i in range(N):
    if i == 0:
        continue

    if t[i] - t[i-1] < T:
        ans += t[i] - t[i-1]
    else:
        ans += T

ans += T
print (ans)


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

const int INF = 1000000000;
const int INI = 0;
int n, weight, w[200];
long long int v[200], dp[200][101010];

int main(){
  //入力
  cin >> n >> weight;
  rep(i, n) cin >> w[i] >> v[i];
  //dp配列の初期化
  rep(i, n + 1){
    rep(j, weight + 1){
      dp[i][j] = INI;
    }
  }
  
  //dp本体
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= weight; j++){
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
      if(j + w[i] <= weight){
        dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
      }
    }
  }
  
  //デバッグ（dp配列の出力
  /*
  rep(i, n + 1){
    rep(j, weight + 1){
      cerr << setw(3) << dp[i][j] <<" ";
    }
    cerr << endl;
  }*/
  
  //出力
  cout << dp[n][weight] << endl;
  return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repr(i,n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    double l;
    cin >> l;
    cout << fixed << setprecision(10) << pow(l/3, 3) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, l, r) for (__typeof(l) i = (l); i <= (r); ++i)
#define per(i, r, l) for (__typeof(r) i = (r); i >= (l); --i)
using namespace std;
typedef long long ll;
const int mod = 998244353;
int read() {
	int f = 1, x = 0; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return f * x;
}
int qpow(int a, int b) { int res = 1; while (b) { if (b & 1) res = (ll)res * a % mod; a = (ll)a * a % mod; b >>= 1; } return res; }

const int N = 200020;
int k, n, a[N]; 
int main() {
	scanf ("%d%d", &k, &n);
	for (int i = 1; i <= n; ++i) scanf ("%d", &a[i]);
	a[0] = 0, a[n + 1] = k;
	int ans = 0x3f3f3f3f;
	for (int i = 1; i <= n; ++i) {
		ans = min(ans, a[i] + k - a[i + 1]);
	}
	ans = min(ans, a[n] - a[1]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
//Ishita
using namespace std;
int a,b,c,x,d;
 
int main()
{
int wry =78;
    cin>>a>>b>>c>>x;
    for(int i = 0;i <= a;i ++)
    {
        for(int j = 0;j <= b;j ++)
        {
            for(int k = 0;k <= c;k ++)
                if(i * 500 + j * 100 + k * 50 == x)d ++;
        }
    }
    cout<<d<<endl;
}

Measured memory_bytes: 256