akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

int const MAX = 100005;
long long p[MAX], x[MAX];
int order[MAX];

int main() {
	int n, s;
	cin >> n >> s;
	int t = 1; //sを挟んだ境界
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> p[i];
		if (x[i] < s) {
			t = i + 1;
		}
	}
	int left = 1; int right = n; int now = 1;
	while (left < t && right >= t) {
		if (p[left] >= p[right]) {
			order[now] = right;
			p[left] += p[right];
			right--;
			now++;
		}
		else {
			order[now] = left;
			p[right] += p[left];
			left++;
			now++;
		}
	}
	if (left == t) {
		order[now] = right;
	}
	else if (right < t) {
		order[now] = left;
	}
	for (int i = 1; i <= now; i++) {
	}
	long long ans = abs(s-x[order[now]]);
	while (now>1) {
		ans += abs(x[order[now]] - x[order[now-1]]);
		now--;
	}

	cout << ans << endl;
}

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

using namespace std;

int main() {
	long long N,A,B;
	cin >> N>>A>>B;
	long long ans = N / (A + B)*A;
	N %= A + B;
	if (N>A) {
		ans += A;
	}
	else {
		ans += N;
	}
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 3584
#include <cstdio>

int main(){
    int N,T;
    scanf("%d %d",&N, &T);
    int c[N], t[N];
    for(int i = 0; i < N; i++){
        scanf("%d %d",&c[i], &t[i]);
    }
    
    int a;
    int b;
    for(int i = 0; i < N; i++){
        a = t[i];
        for(int j = i + 1; j < N; j++){
            if(t[j] < a){
                a = t[j];
                b = c[j];
                t[j] = t[i];
                c[j] = c[i];
                t[i] = a;
                c[i] = b;
            }
        }
    }

    if(t[0] > T){
        printf("TLE\n");

        return 0;
    }
    
    int d = c[0];
    for(int i = 0; t[i] <= T; i++){
        if(c[i] < d){
            d = c[i];
        }
    }

    printf("%d\n",d);

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext())
		{
			int n=sc.nextInt();
			if(n==0)
				return;
			if(n==1)
			{
				System.out.println("deficient number");
				continue;
			}
			
			int sum=1;			
			for(int i=2;i*i<n;i++)
			{
				if(n%i==0)
				{
					sum+=i+n/i;
					if(i==n/i)
						sum-=i;
				}
				if(sum>n)
				{
					System.out.println("abundant number");
					break;
				}
			}
			if(n==sum)
				System.out.println("perfect number");
			else if(n>sum)
				System.out.println("deficient number");
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;
int main() {
    long long N;
    cin >> N;
    for(long long i = 1; i <= 3500; i++){
        for(long long j = 1; j < 3500; j++){
            long long c = i * j * N;
            long long m = 4 * i * j - (i + j) * N;
            if(m > 0){
                if(c % m == 0){
                    cout << i <<" " << j << " " << c / m << endl;
                    return 0;
                }
            }

        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s;
  cin >> s;
  int n = s.size(), g = 0, p = 0, points = 0;
  rep(i, 0, n) {
    if (g > p) {
      if (s[i] == 'g')
        points++;
      p++;
    } else {
      if (s[i] == 'p')
        points--;
      g++;
    }
  }
  cout << points << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
// scanf
#pragma warning(disable: 4996)
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値
#define _ceil(x) ceil(x)

int main()
{
	uint32_t n;
	cin >> n;

	printf("%d\n", (n / 3));
	return 0;
	//	std::cout << "Hello World!\n"; 
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication50
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (a[0] == 0 && a[1] == 0) break;
                int[] t = { 0, 0 };
                char[] s = new char[a[0] * a[1]];
                for (int b = 0; b < a[0]; b++)
                {
                    string c = Console.ReadLine();
                    for (int d = 0; d < a[1]; d++)
                    {
                        s[b * a[1] + d] = c[d];
                    }
                }
                int w = 0;
                while (true)
                {
                    if (w == a[0] * a[1]) { Console.WriteLine("LOOP"); break; }
                    if (t[1] >= a[1]) { t[1] = 0; t[0]++; }
                    switch (s[t[0] * a[1] + t[1]])
                    {
                        case '>': t[1]++; break;
                        case '<': t[1]--; break;
                        case '^': t[0]--; break;
                        case 'v': t[0]++; break;
                        default: Console.WriteLine(t[1] + " " + t[0]); goto o;
                    }

                    w++;
                }
            o:;
            }
        }
    }
}

Measured memory_bytes: 9636
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>

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

using namespace std;
typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        vector<string> v(n);
        rep(i,n) cin >> v[i];

        vector<int> res(n);
        rep(i,n) {
            if(v[i] == "x") res[i] = 0;
            else {
                stringstream ss;
                ss << v[i];
                ss >> res[i];
            }
        }

        bool flag = true;
        rep(i,n-1) {
            if(v[i] == "x" && v[i+1] == "x") flag = false;
        }

        if(!flag) {
            cout << "none" << endl;
        }
        else {
            bool zig = true;
            
            rep(i,n-1) {
                if(v[i] == "x" || v[i+1] == "x") continue;
            
                if(i%2 == 0) {
                    if(res[i] >= res[i+1]) zig = false;
                }
                else {
                    if(res[i] <= res[i+1]) zig = false;
                }
            }


            if(!zig) {
                cout << "none" << endl;
            }
            else {
                int M = 1000000000;
                int l = -M-5;
                int r = M+5;

                rep(i,n) {
                    if(v[i] != "x") continue;

                    if(i%2 == 0) {
                        if(i == 0) {
                            r = min(r,res[i+1]-1);
                        }
                        if(0 < i && i < n-1) {
                            r = min(r,res[i-1]-1);
                            r = min(r,res[i+1]-1);
                        }
                        if(i == n-1) {
                            r = min(r,res[i-1]-1);
                        }
                    }
                    else {
                        if(i == 0) {
                            l = max(l,res[i+1]+1);
                        }
                        if(0 < i && i < n-1) {
                            l = max(l,res[i-1]+1);
                            l = max(l,res[i+1]+1);
                        }
                        if(i == n-1) {
                            l = max(l,res[i-1]+1);
                        }
                    }
                }

                if(l == r) {
                    cout << l << endl;
                }
                else if(l > r) {
                    cout << "none" << endl;
                }
                else {
                    cout << "ambiguous" << endl;
                }
            }

        }


    }

    return 0;
}

Measured memory_bytes: 1300
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')
def Z(f):
    if f:
        print('Yay!')
    else:
        print(':(')
def ispow(n):
    if int(n**.5)**2==n:
        return True
    return False

l = [int(input()) for _ in range(5)]

res = 10 ** 100
for p in perm(list(range(5))):
    cur = 0
    for i in p:
        cur = (cur + 9) // 10 * 10
        cur += l[i]
    res = min(res, cur)
print(res)


Measured memory_bytes: 64364
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    println((1..n).map {
        val x = sc.nextDouble()
        when (sc.next()){
            "JPY" -> x
            else -> x * 380000
        }
    }.sum())
}

Measured memory_bytes: 31400
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define		int 			long long int
#define		pb				push_back
#define		fi(n)			for(int i=0;i<n;i++)
#define		fj(n)			for(int j=0;j<n;j++)
#define		fi1(n)			for(int i=1;i<n;i++)
#define		fj1(n)			for(int j=1;j<n;j++)
#define		firev(n)		for(int i=n-1;i>=0;i--)
#define		fjrev(n)		for(int j=n-1;j>=0;j--)
#define		rep(z,a,n)		for(z=a;z<n;z++)
#define		rep2(z,a,n)		for(z=a;z<n;z+=2)
#define		clr(x)			memset(x, 0, sizeof(x))
#define		print(x,n)		for(int i=0;i<n;i++) cout<<x[i]<<" ";  cout<<"\n"
#define		nl 				"\n"
#define		vi				vector<int>
#define		pairi			pair<int,int>
#define		mp				make_pair
#define		vpairi			vector<pair<int,int>>
#define		ff				first
#define		ss				second
#define		inf 			2e18
#define		setp(val,n)		cout<<fixed;cout<<setprecision(n)<<val<<nl;
#define 	input 			"C://Users//Piyush Aggarwal//Documents//Cpp files//input-output//input.txt"
#define 	output 			"C://Users//Piyush Aggarwal//Documents//Cpp files//input-output//output.txt"
#define 	error 			"C://Users//Piyush Aggarwal//Documents//Cpp files//input-output//error.txt"
int ctoi(char a){ int x=a-48;return x;}
string itos(int a){
	string out_string;
	stringstream ss;
	ss<<a;
	out_string=ss.str();
	return out_string;
}
char itoc(int a){ return itos(a)[0];}
int pow2(int e,int x){
	int ans=1;
	while(x>0){
		if(x&1) ans*=e;
		e*=e;
		x>>=1;
		if(ans>1000000000000) return -1;
	}return ans;
}
string bin(int x){
	bitset<sizeof(1)*CHAR_BIT> bits(x);
	// bitset<31> bits(x);
	string b=bits.to_string(); return b;
}
const int nax=1e5+5;
int indegree[nax];
vi adj[nax];
bool visited[nax];
int dis[nax];

void dfs(int a){
	visited[a]=true;
	for(auto x:adj[a]){
		dis[x]=max(dis[x],dis[a]+1);
		indegree[x]--;
		if(indegree[x]==0){
			dfs(x);
		}
	}
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	#ifndef ONLINE_JUDGE
	#endif
	int T=1;
	// cin>>T;
	while(T--){
		int n,m;
		cin>>n>>m;
		fi(m){
			int u,v;cin>>u>>v;
			u--;v--;
			adj[u].pb(v);
			indegree[v]++;
		}
		fi(n){
			if(!visited[i] && indegree[i]==0)
				dfs(i);
		}
		int ans=0;
		fi(n) ans=max(ans,dis[i]);
		cout<<ans<<nl;
	}
	return 0;
}

Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

vector<int> bef(100010,-1);

template<typename T>
void dijkstra(int s,vector<vector<pair<int, T> > > & G){  
  const T INF = numeric_limits<T>::max();    
  using P = pair<T, int>;
  int n=G.size();
  vector<T> d(n,INF);
  priority_queue<P,vector<P>,greater<P> > q;
  d[s]=0;
  q.emplace(d[s],s);
  while(!q.empty()){
    P p=q.top();q.pop();
    int v=p.second;
    if(d[v]<p.first) continue;
    for(auto& e:G[v]){
      int u=e.first;
      T c=e.second;
      if(d[u]>d[v]+c){
        d[u]=d[v]+c;
        bef[u]=v;
        q.emplace(d[u],u);
      }
    }
  }
  //return d;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,a,b;
    cin>>n>>m;
    vector<vector<P>>G(n);
    rep(i,0,m){
        cin>>a>>b;
        a--;b--;
        G[a].push_back({b,1});
        G[b].push_back({a,1});
    }
    dijkstra(0,G);
    rep(i,1,n){
        if(bef[i]==-1){cout<<"No"<<endl;return 0;}
    }
    cout<<"Yes"<<endl;
    rep(i,1,n){
        cout<<(bef[i]+1)<<endl;
    }
}

Measured memory_bytes: 19392
import java.util.*;
class Main {
  public static void main (String[] args) throws Exception {
    
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    
    int ans =0;
    
    int c75=0;
    int c25=0;
    int c15=0;
    int c5=0;
    int c3=0;
    
    
    int[] f= new int [n+1];
    
    for(int j=2;j<=n;j++){
      int l=j;
    for(int i=2; i<=l;i++){
         while (l%i==0){
           f[i]++;
           l=l/i;
       }
     }
   }
     
     for(int i=2;i<=n; i++){
       
        if(f[i] >= 74)c75++;
        if(f[i] >= 24)c25++;
        if(f[i] >= 14)c15++;
        if(f[i] >= 4)c5++;
        if(f[i] >= 2)c3++;
    }
    
    
    int ans1=0;
    int ans2=0;
    int ans3=0;
    int ans4=0;
    
    ans1=c75;
    ans2=c25*(c3-1);
    ans3=(c15)*(c5-1);
    if(c3>2)ans4=c5*(c5-1)/2*(c3-2);
    else ans4=0;
    ans= ans1+ans2+ans3+ans4;
   
     System.out.println(ans);
     
  }
  
}

Measured memory_bytes: 21844
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> hoge(n);
    vector<int> fuga=hoge;
    int ans=0;
    
    for(int i=0;i<n;i++){
        cin>>hoge.at(i);
    }
    for(int i=0;i<n;i++){
        cin>>fuga.at(i);
        if(hoge.at(i)>fuga.at(i)) ans+=hoge.at(i)-fuga.at(i);
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	ll L, R;
	cin >> L >> R;

	if (R - L > 2019 * 3) {
		cout << 0 << endl;
		return 0;
	}

	ll ans = INF;
	FOR(i, L, R + 1) {
		FOR(j, i + 1, R + 1) {
			ans = min(i * j % 2019, ans);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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 Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll W, H;
    cin >> H >> W;
    REP(i, W+2){
        cout << '#';
    }
    cout << el;
    REP(i, H){
        cout << '#';
        string s;
        cin >> s;
        cout << s;
        cout << '#' << el;
    }
    REP(i, W+2){
        cout << '#';
    }
    cout << el;
}



Measured memory_bytes: 256
lst1=[]
lst2=[]
lst3=[]
answer_lst=[]
n,m,l=(int(x) for x in input().split())
for a in range(n):
    child_lst1=[]
    for b in input().split():
        child_lst1.append(int(b))
    lst1.append(child_lst1)
for c in range(m):
    child_lst2=[]
    for d in input().split():
        child_lst2.append(int(d))
    lst2.append(child_lst2)
for e in range(l):
    child_lst3=[]
    for f in lst2:
        child_lst3.append(f[e])
    lst3.append(child_lst3)
for g in range(1,n+1):
    child_lst4=[]
    need_lst1=lst1[g-1]
    for h in range(1,l+1):
        value=0
        need_lst2=lst3[h-1]
        for i in range(1,m+1):
            value+=need_lst1[i-1]*need_lst2[i-1]
        child_lst4.append(value)
    answer_lst.append(child_lst4)
for ans in answer_lst:
    print(*ans)


Measured memory_bytes: 7152
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <utility>
#include <queue>
#include <cassert>
#include <set>

using namespace std;
typedef long long ll;
typedef set <int> :: iterator Ite;
int n;
multiset <int> s;
int main(){
  scanf("%d",&n);
  for(int i = 1;i <= n;i++){
    int a;
    scanf("%d",&a);
    s.insert(a);
  }
  for(int i = 30;i >= 1;i--){
    int cnt = s.count(1 << (i - 1));
    for(int j = 1;j <= (cnt >> 1);j++){
      s.erase(s.find(1 << (i - 1)));
      s.erase(s.find(1 << (i - 1)));
    }
    vector <Ite> lis;
    lis.clear();
    for(Ite it = s.begin();it != s.end();it++){
      if(*it >= (1 << (i - 1))) break;
      if(s.find((1 << i) - *it) != s.end()){
        lis.push_back(it);
        s.erase(s.find((1 << i) - *it));
      }
    }
    for(int i = 0;i < (int)lis.size();i++) s.erase(lis[i]);
  }
  printf("%d\n",(n - s.size()) >> 1);
  return 0;
}

Measured memory_bytes: 10240
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int lowestNum;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		
		for (int i = 0; i < n; i++)
			arr[i] = sc.nextInt();
		
		int[] frog = new int[n];
		Arrays.fill(frog,  Integer.MAX_VALUE);
		
		frog[0] = 0;
		for (int i = 0; i < n; i++) {
			if (frog[i] == Integer.MAX_VALUE)
				continue;
			if (i+1 < n) {
				frog[i+1] = Math.min(frog[i+1], frog[i] + Math.abs(arr[i+1]-arr[i]));
			}
			if (i+2 < n) {
				frog[i+2] = Math.min(frog[i+2], frog[i] + Math.abs(arr[i+2] - arr[i]));
			}
		}
		System.out.println(frog[n-1]);
		/*
		lowestNum = Integer.MAX_VALUE;
		int[] memo = new int[n];
		for (int i = 0; i < n; i++)
			memo[i] = -1;
		
		System.out.println(frog(arr, arr.length - 1, 0, memo));
		*/
	}
	
	
	
	public static int frog(int[] arr, int pos, int totalCost, int[] memo) { // pos 0 - indexed
		if (pos == 0)
			return totalCost;
		if (pos == 1)
			return totalCost + Math.abs(arr[1] - arr[0]);
		if (memo[pos] != -1)
			return memo[pos];
		
		int cost1 = frog(arr, pos - 1, totalCost + Math.abs(arr[pos] - arr[pos-1]), memo);
		int cost2 = frog(arr, pos - 2, totalCost + Math.abs(arr[pos] - arr[pos-2]), memo);
		
		memo[pos] = Math.min(cost1, cost2);
		return Math.min(cost1, cost2);
	}
}


Measured memory_bytes: 49044
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,K = list(map(int, input().split()))
xy = [tuple(map(int, input().split())) for _ in range(n)]
xs = list(set([item[0] for item in xy]))
ys = list(set([item[1] for item in xy]))
xs.sort()
ys.sort()
dx = {x:i for i,x in enumerate(xs)}
dy = {y:i for i,y in enumerate(ys)}
lx = len(xs)
ly = len(ys)
c = [[0]*ly for _ in range(lx)]
for x,y in xy:
    c[dx[x]][dy[y]] += 1
from itertools import combinations, combinations_with_replacement
def cumsum2(v):
    # v: h*wの2次元リスト
    h,w = len(v), len(v[0])
    v.insert(0, [0]*w)
    for l in v:
        l.insert(0, 0)
    for i in range(1,h+1):
        for j in range(1,w+1):
            v[i][j] = v[i-1][j] + v[i][j-1] - v[i-1][j-1] + v[i][j]
    return v
cumsum2(c)
ans = float("inf")
for i,j,k,l in combinations_with_replacement(range(n),4):
#     for k,l in combinations(range(n),2):
    mx = min(xy[i][0], xy[j][0], xy[k][0], xy[l][0])
    my = min(xy[i][1], xy[j][1], xy[k][1], xy[l][1])
    Mx = max(xy[i][0], xy[j][0], xy[k][0], xy[l][0])
    My = max(xy[i][1], xy[j][1], xy[k][1], xy[l][1])
    ix,iy = dx[mx], dy[my]
    Ix,Iy = dx[Mx], dy[My]
    count = c[Ix+1][Iy+1] - c[Ix+1][iy] - c[ix][Iy+1] + c[ix][iy]
    if count>=K:
        ans = min(ans, (Mx-mx)*(My-my))
#         print(count, i,j,k,l, (Mx-mx)*(My-my))
print(ans)

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	lnt N, M; cin >> N >> M;
	vector<vlnt> G(N); vector<map<lnt, lnt>> dp(N);
	REP(i, N-1){
		lnt x, y; cin >> x >> y; x--; y--;
		G[x].eb(y); G[y].eb(x);
	}

	auto solve = [&](auto&& solve, lnt v, lnt par, bool flag) -> lnt {
		if(dp[v].count(par)) return dp[v][par];
		lnt res = 1;
		if(par == -1 or flag){
			vlnt ret;
			for(lnt to: G[v]){
				if(to == par) continue;
				ret.eb(solve(solve, to, v, flag));
			}
			vlnt R(ret.size()+1, 1);
			for(lnt i = R.size()-1; i > 0; i--) R[i-1] = R[i]*(ret[i-1]+1)%M;
			if(par == -1){
				lnt L = 1;
				for(lnt i = 0; i < G[v].size(); i++){
					lnt to = G[v][i];
					dp[v][to] = L*R[i+1]%M;
					L = L*(ret[i]+1)%M;
				}
			}
			res = R[0];
		} else {
			solve(solve, v, -1, flag);
			res = solve(solve, v, par, flag);
		}
		return dp[v][par] = res;
	};

	solve(solve, 0, -1, 1);
	REP(i, N) cout << solve(solve, i, -1, 0) << ln;
}


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

int main() {
    while (true) {
        int n, m;
        cin >> n >> m;
        if ((n | m) == 0) {
            break;
        }
        int* places = new int [m];
        for (int i = 0; i < m; i++) {
            places[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                int input;
                cin >> input;
                places[j] += input;
            }
        }
        bool spaceFlag = false;
        for (int i = 1000; i >= 0; i--) {
            for (int j = 0; j < m; j++) {
                if (places[j] == i) {
                    if (spaceFlag) {
                        cout << " ";
                    } else {
                        spaceFlag = true;
                    }
                    cout << j + 1;
                }
            }
        }
        cout << endl;
        delete[] places;
    }
}

Measured memory_bytes: 908
n = gets.to_i
x = gets.split.map {|s| s.to_f}
y = gets.split.map {|s| s.to_f}
d1 = 0
d2 = 0
d3 = 0
dc = 0
for i in 1..n
  d = (x[i-1] - y[i-1]).abs
  d1 += d
  d2 += d**2
  d3 += d**3
  dc = d if dc < d
end
d2 = d2**(1.0/2.0)
d3 = d3**(1.0/3.0)
printf("%.8f\n", d1)
printf("%.8f\n", d2)
printf("%.8f\n", d3)
printf("%.8f\n", dc)

Measured memory_bytes: 6212
#include <stdio.h>
#define N 100

int main(void)
{
	int i,j,n,a[N],temp;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){
		temp = a[i];
		for(j=i-1;j>=0 && a[j]>temp;j--)
			a[j+1] = a[j];
		a[j+1] = temp;
		printf("%d",a[0]);
		for(j=1;j<n;j++)
			printf(" %d",a[j]);
		printf("\n");
	}
	return 0;
}



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


use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn dfs(sta:usize,n:usize,m:usize,retu:&mut Vec<i32>,abcd:&Vec<(i32,i32,i32,i64)>) -> i64 {
    let mut res = 0i64;
    if n  == retu.len() {
        for &(a,b,c,d) in abcd.iter(){
            if retu[(b - 1) as usize] - retu[(a - 1) as usize] == c {
                res += d;
            }
        }
        return res;
    }
    for i in sta..=m{
        retu[n] = i as i32;
        let curres = dfs(i,n + 1,m,retu,abcd);
        if res < curres {
            res = curres;
        }
    }
    res
}
fn main() {
/*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        n: usize,
        m: usize,
        q: usize,
        mut abcd: [(i32,i32,i32,i64); q],
    }

    let result = dfs(1,0,m,&mut vec![0;n],&abcd);
    println!("{}",result);
}


Measured memory_bytes: 2152
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

type Process struct {
	name string
	time int
}

type ProcessList struct {
	processList []Process
	qms         int
}

func (pl *ProcessList) enque(p Process) {
	pl.processList = append(pl.processList, p)
}

func (pl *ProcessList) deque() Process {
	p := pl.processList[0]
	pl.processList = pl.processList[1:]
	return p
}

func start(processList ProcessList) {
	time := 0
	for len(processList.processList) != 0 {
		process := processList.deque()
		if process.time > processList.qms {
			time += processList.qms
			process.time = process.time - processList.qms
			processList.enque(process)
		} else {
			time += process.time
			fmt.Println(process.name + " " + strconv.Itoa(time))
		}
	}

}

func main() {
	sc.Scan()
	firstLine := strings.Split(sc.Text(), " ")
	N, _ := strconv.Atoi(firstLine[0])
	qms, _ := strconv.Atoi(firstLine[1])
	var empty []Process
	processList := ProcessList{empty, qms}
	for i := 0; i < N; i++ {
		sc.Scan()
		line := strings.Split(sc.Text(), " ")
		time, _ := strconv.Atoi(line[1])
		process := Process{line[0], time}
		processList.processList = append(processList.processList, process)
	}
	start(processList)
}



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

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
}

class Solver {
  int n;
  long x;
  long[] as;
  
  private long[] createNextRangeMin(long[] rangeMin, int numShift) {
    long[] nextRangeMin = new long[n];
    for (int i = 0; i < n; i++) {
      nextRangeMin[i] = Math.min(rangeMin[i], as[(i - numShift + n) % n]);
    }
    return nextRangeMin;
  }
  
  public long solve(int n, long x, long[] as) {
    this.n = n;
    this.x = x;
    this.as = as;
    
    long[] previousRangeMin = as;
    long answer = Long.MAX_VALUE;
    for (int numShift = 0; numShift < n; numShift++) {
      long[] rangeMin = createNextRangeMin(previousRangeMin, numShift);
      long sumCreateCost = 0;
      for (long min : rangeMin) {
        sumCreateCost += min;
      }
      answer = Math.min(answer, sumCreateCost + x * numShift);
      previousRangeMin = rangeMin;
    }
    return answer;
  }
}

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    long x = reader.nextLong();
    long[] as = new long[n];
    for (int i = 0; i < n; i++) {
      as[i] = reader.nextLong();
    }
    out.println(new Solver().solve(n, x, as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}



Measured memory_bytes: 42964
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
#define MAXM 106
#define MAXN 100006
#define INF 2099999999
using namespace std;
int n,m,fa[MAXN],a,caozuo[MAXN],time[MAXN];
long long ans;
struct node
{
    char p;
    int a;
}work[MAXN];
int root(int x)
{
    if(fa[x]==x) return x;
    fa[x]=root(fa[x]);
    return fa[x];
};
int main()
{
    while(1)
    {
        scanf("%d%d",&n,&m);
        if(n==0&&m==0) return 0;
        ans=0;
        memset(time,0,sizeof(time));
        fa[1]=caozuo[1]=1;
        for(int i=2;i<=n;i++)
        {
            scanf("%d",&caozuo[i]);
            fa[i]=caozuo[i];
        }
        for(int i=1;i<=m;i++)
        {
            scanf("\n%c%d",&work[i].p,&work[i].a);
            if(work[i].p=='M')
            {
                time[work[i].a]++;
                fa[work[i].a]=work[i].a;
            }
        }
        for(int i=m;i>=1;i--)
        {
            if(work[i].p=='M')
            {
                if(work[i].a==1) continue ;
                time[work[i].a]--;
                if(!time[work[i].a]) fa[work[i].a]=caozuo[work[i].a];
            }
            else
                ans+=root(work[i].a);
        }
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 4712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e7;

int main(){
	int n;
	cin >> n;
	vector<int> l(n), la(n);
	for(int i=0;i<n;i++) {
		cin >> l[i];
		la[i] = -l[i];
	}
	sort(l.begin(), l.end());
	sort(la.begin(), la.end());
	ll ans = 0;
	for(int i=0;i<n;i++) {
		for(int j=i+1;j<n;j++) {
			int wa = l[i]+l[j];
			int sa = abs(l[i]-l[j]);
			auto witr = upper_bound(la.begin(), la.end(), -wa);
			int right = (int)(la.end()-witr);
			auto sitr = upper_bound(l.begin(), l.end(), sa);
			int left = (int)(sitr-l.begin());
			int plus = 0;
			if(right<=left) continue;
			if(left <= i and i < right) plus--;
			if(left <= j and j < right) plus--;
			plus += (right-left);
			if(plus>0) {
				// cout << abs(wa-sa)/2 << " " << (wa+sa)/2 << endl;
				ans += plus;
			}
		}
	}
	cout << ans/3 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, i, j, k, cnt = 0;
	int tmp = 0;
	int l[2000];
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &l[i]);

	for (i = 0; i < n - 1; i++) {
		for (j = i + 1; j < n; j++) {
			if (l[i] < l[j]) {
				tmp = l[i];
				l[i] = l[j];
				l[j] = tmp;
			}
		}
	}

	for (i = 0; i < n - 2; i++) {
		for (j = i + 1; j < n - 1; j++) {
			for (k = j + 1; k < n; k++) {
				if ((l[i] < (l[j] + l[k])) && (l[j] < (l[i] + l[k])) && (l[k] < (l[i] + l[j]))) {
					cnt++;
				}
				else
					break;
			}
		}
	}

	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll mod = 1000000007;

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 {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll N;
ll A[300010];
mint ans[70];

int main()
{
  std::cin >> N;

  rep( i, N )
    std::cin >> A[i];

  rep( b, 61 )
  {
    std::map<ll, ll> mp;

    rep( i, N )
    {
      ll bit = A[i]>>b&1;

      ans[b] += mp[bit^1];

      mp[bit] += 1;
    }
  }

  mint sum = 0;

  rep( b, 61 )
    sum += ans[b]*mint(2).pow(b);
  
  std::cout << sum.x << std::endl;

  return 0;
}

Measured memory_bytes: 2560
// Eating Symbols Easy

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;


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

    int res = 0;
    for (int i = 0; i < 4; i++) {
        if (s[i] == '+') {
            res++;
        } else {
            res--;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
#include <cstdint>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
#define mod 1000000007
typedef long long ll;

unsigned gcd(int a, int b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}


ll comb(int n, int r) {
	if (r * 2 > n) r = n - r;
	uintmax_t dividend = 1;
	uintmax_t divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}

int main(){

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	ll i, j, k, l, m, n, len, a, b, c;
	ll A, B, C, D, Ntemp, M, K,num_R,num_G,num_B;
	ll sum = 0, sum_B = 0, sum_C = 0, max, min, count, N, S, W;
	ll **dp;
	double ans;

	scanf("%lld %lld %lld %lld", &A ,&B, &C, &D);

	while (1){
		C -= B;
		if (C <= 0){
			printf("Yes\n");
			return 0;
		}
		A -= D;
		if (A <= 0){
			printf("No\n");
			return 0;
		}
	}
	return 0;

}
    

Measured memory_bytes: 3656
H,W = [int(i) for i in input().split()]
N = int(input())
a = [int(i) for i in input().split()]
seen = [[False] * W for _ in range(H)]
ans = [0 for _ in range(H*W)]
from numpy import cumsum
a_sum = list(cumsum(a))
colour = 0
for i in range(H*W):
    if i >= a_sum[colour]:
        colour +=1
    ans[i] = colour +1
for h in range(H):
    if h%2 == 0:
        print(" ".join(map(str, ans[h*W:(h+1)*W])))
    else:
        print(" ".join(map(str, reversed(ans[h*W:(h+1)*W]))))

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

int main(){
  string s;
  cin>>s;
  int count[26]={0};
  for(int i=0;i<s.length();i++){
    int index=s[i]-'a';
    count[index]++;
  }
  bool flag=true;
  for(int i=0;i<25;i++){
    if(count[i]%2!=0){
      flag=false;
    }
  }

  cout<<(flag?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var wr *bufio.Writer = bufio.NewWriter(os.Stdout)

func nextInt() int {
	sc.Scan()
	val, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return val
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

type edge struct {
	to  int
	col int
	idx int
}

type pair struct {
	f, s int
}

func main() {
	sc.Split(bufio.ScanWords)
	//
	N, H := nextInt(), nextInt()
	A := make([]int, N)
	B := make([]int, N)
	ma := 0
	for i := 0; i < N; i++ {
		A[i] = nextInt()
		B[i] = nextInt()
		ma = max(ma, A[i])
	}
	//sort.Slice(B, func(i, j int) bool { return B[i] > B[j] })
	sort.Sort(sort.Reverse(sort.IntSlice(B)))
	//fmt.Println(B)
	res := 0
	for _, b := range B {
		if b <= ma {
			break
		}
		res++
		H -= b
		if H <= 0 {
			break
		}
	}
	if H > 0 {
		if H%ma == 0 {
			res += H / ma
		} else {
			res += H/ma + 1
		}

	}
	fmt.Fprintln(wr, res)
	wr.Flush()
}


Measured memory_bytes: 4608
#include <iostream>/*{{{*/
#include <iomanip>
#include <string>
#include <map>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <exception>
#include <ctime>
#include <climits>
#include <list>
#include <bitset>
#include <cassert>
using namespace std;
#define rep_n(i, a, b) for (int i=(a); i<(b); i++)
#define rep(i, n) rep_n(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define sc1(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d %d", &a, &b)
#define sc3(a, b, c) scanf("%d %d %d", &a, &b, &c)/*}}}*/

int main() {
    char n[5];
    scanf("%s", n);

    int maxrep=0, cnt=0;
    rep(i, 4) {
        if (i>0) {
           if (n[i]!=n[i-1]) cnt=0; 
           else if (n[i]==n[i-1]) cnt++, maxrep=max(maxrep, cnt); 
        }
    }
    
    if (maxrep>=2) printf("Yes\n");
    else printf("No\n");

    //int ans=0;/*{{{*/
    //printf("%d", ans);/*}}}*/
}


Measured memory_bytes: 256
// In the name of Allah the Lord of the Worlds.

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
ll MOD = 1e9+7;
ll dp[100005][15];
string ar;

ll f(int i , int l)
{
    if(i==ar.size()){
        if(l==5)return 1;
        return 0;
    }
    if(dp[i][l]!=-1)return dp[i][l];
    ll value = 0;
    if(ar[i]=='?'){
        for(int j=0;j<10;j++){
            value+=f(i+1 , (l*10+j)%13);
        }
    }
    else{
        value+=f(i+1 , (l*10+ar[i]-'0')%13);
    }
    return dp[i][l] = value%MOD;
}
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    cin >> ar;
    memset(dp , -1 , sizeof(dp));
    cout << f(0 , 0) << endl;
    return 0;
}



Measured memory_bytes: 20048
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;
static const ll MAX_M = 100001;

ll x[100] = {};
ll y[100] = {};
ll h[100] = {};

int main() {
	ll n; cin >> n;
	ll I;
	rep(i, 0, n) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] > 0) I = i;
	}

	repe(py, 0, 100) repe(px, 0, 100) {
		ll H = h[I] + abs(y[I] - py) + abs(x[I] - px);
		bool same = true;
		rep(i, 0, n) {
			ll nH = h[i] + abs(y[i] - py) + abs(x[i] - px);
			if (h[i] > 0 && nH != H) {
				//if (h[i] > 0 && nH - h[i] != abs(px - x[i]) + abs(py - y[i])) {
				same = false;
			}
			if (h[i] == 0 && H > abs(y[i] - py) + abs(x[i] - px)) {
				same = false;
			}
		}

		if (same) {
			cout << px << " " << py << " " << H << endl;
			return 0;
		}
	}

	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int K=in();
	int N=in();
	auto A=vecin<ll>(N);
	ll minD=1<<30;
	REP(i,N){
		int left = i,right=(i+N-1)%N;
		ll lv=A[left];
		ll rv=(i==0? A[i+N-1] : A[(i+N-1)%N]+K);
		ll d = abs(rv-lv);
		minD = min(minD,d);
	}
	out(minD);
	return 0;
}


Measured memory_bytes: 1792
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
	int N;
	cin >> N;
	set<string> S;
	string prev = "";
	REP( i, N )
	{
		string W;
		cin >> W;
		if( S.find( W ) != S.end() )
		{
			cout << "No" << endl;
			return 0;
		}

		S.insert( W );

		if( prev != "" && prev[ prev.size() - 1 ] != W[ 0 ] )
		{
			cout << "No" << endl;
			return 0;
		}

		prev = W;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NIL NULL
struct Node {
	int key;
	struct Node* right, * left, * parent;
};
typedef struct Node* Node;

Node root;

void inorder(Node);
void preordee(Node);
void insert(int);
Node find(Node, int);

Node find(Node u, int k) {
	while (u != NIL && k != u->key) {
		if (k < u->key)u = u->left;
		else u = u->right;
	}
	return u;
}

void insert(int k) {
	Node x, y, z;
	y = NIL;
	x = root;
	z = malloc(sizeof(struct Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}

void inorder(Node u) {
	if (u->left != NIL && u->right != NIL) {
		inorder(u->left);
		printf(" %d", u->key);
		inorder(u->right);
	}
	if (u->left != NIL && u->right == NIL) {
		inorder(u->left);
		printf(" %d", u->key);
	}
	if (u->right != NIL && u->left == NIL) {
		printf(" %d", u->key);
		inorder(u->right);
	}
	if (u->left == NIL && u->right == NIL)printf(" %d", u->key);
}

void preorder(struct Node* u) {
	printf(" %d", u->key);
	if (u->left != NIL) {
		preorder(u->left);
	}
	if (u->right != NIL) {
		preorder(u->right);
	}
}

int main(void) {
	int n, i, x;
	char com[7];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", com);
		if (com[0] == 'f') {
			scanf("%d", &x);
			Node t = find(root, x);
			if (t != NIL)printf("yes\n");
			else printf("no\n");
		}
		else if (strcmp(com, "print") == 0) {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (strcmp(com, "insert") == 0) {
			scanf("%d", &x);
			insert(x);
		}
	}
	return 0;
}


Measured memory_bytes: 20612