akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

void dijkstra(){
  int i,v,minv;
  int d[MAX],color[MAX];

  for(i = 0; i< n ; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    int u = -1;
    for(i = 0; i < n; i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0; v<n ; v++){
      if(color[v] != BLACK && M[u][v] !=INFTY){
	if(d[v] > d[u] + M[u][v]){
	  d[v] = d[u]+M[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i = 0; i<n; i++){
    printf("%d %d\n",i,(d[i] == INFTY?-1:d[i]));
  }
}


int main(){
  int i,j;
  scanf("%d",&n);
  for(i = 0; i<n; i++){
    for(j = 0; j<n; j++){
      M[i][j] = INFTY;
    }
  }

  int k,c,u,v;
  for(i = 0; i<n; i++){
    scanf("%d%d",&u,&k);
    for(j = 0; j < k; j++){
      scanf("%d%d",&v,&c);
      M[u][v] = c;
    }
  }
  dijkstra();

  return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n; cin >> n;
	vector<ll> x(n), y(n);
	std::mt19937 mt(1333);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	auto dist = [](ll x, ll y) { return sqrt(x*x + y*y); };
	double ans = 0;
	for (int iter = 0; iter < 1000000; iter++) {
		ll rx = (mt() & 1 ? 1 : -1)*mt(), ry = (mt() & 1 ? 1 : -1)*mt();
		ll cx = 0, cy = 0;
		for (int i = 0; i < n; i++) {
			if (rx*x[i] + ry*y[i] > 0) {
				cx += x[i];
				cy += y[i];
			}
		}
		ans = max(ans, dist(cx, cy));
	}
	printf("%.20f\n", ans);
	return 0;
}

Measured memory_bytes: 256
n=int(input())
mod=10**9+7

dp=[0 for i in range(0,10**6+1)]
S=[0 for i in range(0,10**6+1)]

dp[1]=1
dp[2]=1
S[1]=1
S[2]=2
for i in range(3,10**6+1):
    dp[i]=(S[i-1]-dp[i-2]+1)%mod
    S[i]=(S[i-1]+dp[i])%mod

if n==1:
    print(1)
elif n==2:
    print(4)
else:
    ans=(S[n-2]*(n-1)**2+(n-1)**2+(n-1)*S[n-1]+n)%mod
    print(ans)

Measured memory_bytes: 115404
#include<stdio.h>

int main(){
    int x, y, tmp;
    
    //input data
    scanf("%d%d", &x, &y);

    //swao to x > y
    if(x < y){
        tmp = x;
        x = y;
        y = tmp;
    }

    //find a gcd
    while(y > 0){
        tmp = x % y;
        x = y;
        y = tmp;
    }

    //output data
    printf("%d\n", x);
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
int a,b,k[55],l[55];
bool ans[55][55],visited[55];

void dfs(int n){
  visited[n]=true;
  for(int i=0;i<a;++i){
    if(!ans[n][i]) continue;
    if(visited[i]) continue;
    dfs(i);
  }
}

int main(){
  cin>>a>>b;
  for(int i=0;i<b;++i){
     cin>>k[i]>>l[i];
    k[i]--;
    l[i]--;
    ans[k[i]][l[i]]=ans[l[i]][k[i]]=true;
  }
  
  int aa=0;
  for(int i=0;i<b;++i){
   ans[k[i]][l[i]]=ans[l[i]][k[i]]=false;
    for(int j=0;j<a;++j){
      visited[j]=false;
    }
    dfs(0);
    
    bool boo=false;
    for(int j=0;j<a;++j){
      if(!visited[j]) boo=true;
    }
    if(boo) aa++;
    ans[k[i]][l[i]]=ans[l[i]][k[i]]=true;
  }
  
  cout<<aa<<endl;
}

Measured memory_bytes: 256
import math

def binary_search(l, key):
    n = len(l)
    minindex = 0
    maxindex = n

    while minindex < maxindex:
        halfindex = math.floor(minindex + (maxindex - minindex) / 2)
        if key == l[halfindex]:
            return True
        elif key > l[halfindex]:
            minindex = halfindex + 1
        elif key < l[halfindex]:
            maxindex = halfindex

    return False


if __name__ == "__main__":
    import sys
    input = sys.stdin.readline # faster input

    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))

    c = 0
    for key in T:
        if binary_search(S, key):
            c += 1

    print(c)



Measured memory_bytes: 16764
N, M = map(int, input().split())
H = list(map(int, input().split()))

HH = [True]*N

for _ in range(M):
    A, B = map(int, input().split())
    if H[A-1] <= H[B-1]:
        HH[A-1] = False
    if H[A-1] >= H[B-1]:
        HH[B-1] = False

print(HH.count(True))

Measured memory_bytes: 20116
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!

int main(void){
    ll S, C;
    scanf("%lld %lld", &S, &C);
    ll ans = min(S, C/2);
    C -= 2*ans;
    if(C>0) ans += C/4;
    printf("%lld\n", ans); 
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int edge[200010];
int cycle[200010];

int main(){
	int n;
	long k;
	scanf("%d%ld", &n, &k);
	for(int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		edge[i] = a - 1;
	}
	int now = 0, cnt = 0;
	while(true) {
		if(cnt == k) {
			printf("%d\n", now + 1);
			return 0;
		}
		if(cycle[now] != 0) {
			k -= cnt;
			int j = k % (cnt - cycle[now] + 1);
			for(int i = 0; i < j; i++)
				now = edge[now];
			printf("%d\n", now + 1);
			return 0;
		}
		cycle[now] = ++cnt;
		now = edge[now];
	}
}


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

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

    string all="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for(int i=0;i<s.size();i++){
        for(int j=0;j<all.size();j++){
            if(all[j]==s[i]){
                
                cout << all[(j+n)%26];
            }
        }
    }

}

Measured memory_bytes: 256
#2019は3と673で割り切れることを考慮する必要がある(重要)
#入力。範囲指定
L, R = list(map(int,input().split()))
#解を仮に無限大と置いておく
ans = 150
#ans = float('inf')
"""
mod(x)とし、i = y1 * x + b, j = y2 * x + cなどと置くと i * j で xで括れない項は
b*c(余り同士の)掛け算のみ。
"""
#LとRの2019で割った時の余りは求めておく。
l = L % 2019
r = R % 2019
#余りの掛け算
lr = l * r
#(l*r) mod 2019  は次の式で表される。
modlr = lr - (lr//2019)
#2019未満で取りうる数値の中間地点
mid = (2019-1)//2
#LとRで挟まれる領域が十分に広い(673以上の)場合絶対に解は0(動ける範囲制限)
if R - L >= 673:
  ans = 0
  print(ans)
  exit(0)
#LとRで挟まれる範囲内に3で割り切れる要素と673で割り切れる要素が同時に存在したら解は0
#判定用変数
flag1 = 0 
flag2 = 0
#LとRで挟まれるリスト作製
list = [i for i in range(L,R+1)]
for i in range(len(list)):
  #3で割り切れるか判定
  if list[i] % 3 == 0:
    flag1 += 1
  #673で割り切れるか判定,3で割り切れていても判定するようにelifではなくifを使う
  if list[i] % 673 == 0:
    flag2 += 1
#両方満たしていたら解が0になる
if flag1 * flag2 != 0:
  ans = 0
  print(ans)
  exit(0)
#LとRの間に2019の倍数の壁がある=2019で割って余りが0になるタイミングがある
if l > r:
  ans = 0
  print(ans)
  exit(0)
#ここまで候補削ったらあとは全探索でもできる(と思われる)
#最小値をminと置く
ans = float('inf')
for i in range(l,r):
  for j in range(l+1,r+1):
    if ans > (i * j) % 2019:
      ans = (i * j) % 2019
print(ans)

Measured memory_bytes: 3192
n,x = map(int, input().split( ))
a = list(map(int, input().split( )))
a.append(0)
cnt = 0
for i in range(n):
    if a[i]>x:
        cnt += a[i]-x+a[i+1]
        a[i]=x #
        a[i+1]=0
    else:
        cnt += max(a[i]+a[i+1]-x,0)
        a[i+1] -= max(a[i]+a[i+1]-x,0)
print(cnt)


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
void dfs(vvi &v, vi &visited, int u) {
	visited[u] = 1;
	REP(i, v[u].size()) {
		if (!visited[v[u][i]])dfs(v, visited, v[u][i]);
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vvi v(n);
	vi a(m), b(m);
	REP(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		v[a[i]].push_back(b[i]);
		v[b[i]].push_back(a[i]);
	}
	int cnt = 0;
	REP(i, m) {
		vi visited(n, 0);
		REP(j, v[a[i]].size()) {
			if (v[a[i]][j] == b[i]) {
				v[a[i]].erase(v[a[i]].begin() + j);
			}
		}
		REP(j, v[b[i]].size()) {
			if (v[b[i]][j] == a[i]) {
				v[b[i]].erase(v[b[i]].begin() + j);
			}
		}
		dfs(v, visited, 0);
		if (*min_element(ALL(visited)) == 0)cnt++;
		v[a[i]].push_back(b[i]);
		v[b[i]].push_back(a[i]);

	}
	cout << cnt << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
using namespace std;

int Zeller(int month,int day){
	int year = 2004;
	if(month == 1 || month==2){
		year--;
		month += 12;
	}
	return (year + year/4 - year/100 + year/400 + (13*month+8)/5 + day)%7;
}

int main(){

	int month,day;
	while(true){
		scanf("%d %d",&month,&day);
		if(month == 0)break;

		switch(Zeller(month,day)){
		case 0:
			printf("Sunday\n");
			break;
		case 1:
			printf("Monday\n");
			break;
		case 2:
			printf("Tuesday\n");
			break;
		case 3:
			printf("Wednesday\n");
			break;
		case 4:
			printf("Thursday\n");
			break;
		case 5:
			printf("Friday\n");
			break;
		case 6:
			printf("Saturday\n");
			break;
		}

	}

    return 0;
}



Measured memory_bytes: 2504
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
string S;
  cin >>S;
  int count=0;
  rep(i,3) {
 if (S.at(i)=='1') {
count ++;
 }
  }
    cout << count << endl;
  }

Measured memory_bytes: 256
#include<cstdio>
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~(i)))
int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	if(x<=0&&y>=0)return printf("Zero"),0;
	if(x<0&&y<0)return printf("%s\n",(y-x+1)&1?"Negative":"Positive"),0;
	return printf("Positive"),0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	int n, k;
	cin >> n >> k;
	vector<ll> h(n);
	rep (i, n) cin >> h[i];

	sort(rng(h));

	ll ans = 10000000000;
	rep (i, n - k + 1) {
		chmin(ans, h[i+k-1] - h[i]);
	}

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

Measured memory_bytes: 1024
N,Z,W = map(int, input().split())
a = list(map(int, input().split()))

# どちらかが必ず山札の底のカードで勝負する
# Yに行動の選択肢を与えるとスコアを小さくされてしまうので、XはYに選択肢を与えないように行動する
# Xは山札の底のカードを自分で取るかYに取らせるかを選択する
# Xが自分で山札の底のカードを取る場合、初手で全取りしなければYに選択肢を与えてしまう
# Xが自分で山札の底のカードを取らない場合、底のカードだけ残してYに取らせなければYに選択肢を与えてしまう

if N == 1:
    print(abs(a[-1] - W))
else:
    print(max(abs(a[-1] - W), abs(a[-2] - a[-1])))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
/* {{{ */
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)

#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
#define PB push_back
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
//#define int long long

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1}; 

inline int in(){int x;std::cin>>x;return x;}

struct FAST {FAST(){cin.tie(0);ios::sync_with_stdio(false);}} Fast;

template <class X> void print(X hoge){ cout << hoge << '\n'; }
/*-------------------------------*/
/* }}} */ 

signed main(void)
{
  int h, w;
  string c;

  cin >> h >> w;
  
  rep(i, h) {
    cin >> c;
    cout << c << '\n' << c << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int>>;
int n;
vector<int> x;
vector<int> y;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    x = vector<int>(n);
    y = vector<int>(n);
    rep(i, n)
    {
        cin >> x[i] >> y[i];
    }

    long double dist=0;
    rep(i,n){
        rep(j,n){
            dist+=sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]))/n;
        }
    }
 
    cout << setprecision(10)<<dist << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var str string
	fmt.Scan(&str)

	// create map without overlapping alphabets
	m := make(map[string]int, len(str))
	for _, s := range str {
		m[string(s)] = 1
	}

	// logic
	for _, s := range "abcdefghijklmnopqrstuvwxyz" {
		_, ok := m[string(s)]
		if !ok {
			fmt.Println(string(s))
			return
		}
	}
	fmt.Println("None")

	return
}


Measured memory_bytes: 3584
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Scanner;

class Solve{
	Scanner in = new Scanner(System.in);
	
	int[][] cap;
	int m, n;
	boolean solve(){
		m = in.nextInt();
		n = in.nextInt();
		if(n == 0) return false;
		Node[] b = new Node[m];
		Node[] r = new Node[n];
		cap = new int[m+n+2][m+n+2];
		Node s = new Node(n+m, 0);
		Node t = new Node(n+m+1, 0);
		for(int i=0; i<m; i++){
			b[i] = new Node(i, in.nextInt());
			s.createEdge(b[i]);
			b[i].createEdge(s);
			cap[s.id][b[i].id] = 1;
		}
		for(int i=0; i<n; i++){
			r[i] = new Node(i+m, in.nextInt());
			r[i].createEdge(t);
			t.createEdge(r[i]);
			cap[r[i].id][t.id] = 1;
		}
		for(int i=0; i<m; i++){
			for(int j=0; j<n; j++){
				if(gcd(b[i].val, r[j].val) == 1) continue;
				b[i].createEdge(r[j]);
				r[j].createEdge(b[i]);
				cap[i][r[j].id] = 1;
			}
		}
		int res = 0;
		while(true){
			used.clear();
			int flow = flow(s, 1);
			if(flow == 0) break;
			res += flow;
		}
		System.out.println(res);
		return true;
	}
	
	BitSet used = new BitSet();
	int flow(Node from, int flow){
		if(from.id == m+n+1) return flow;
		if(used.get(from.id)) return 0;
		used.set(from.id);
		for(Node v: from.edge){
			if(cap[from.id][v.id]==0) continue;
			int f = flow(v, Math.min(flow, cap[from.id][v.id]));
			if(f == 0) continue;
			cap[from.id][v.id] -= f;
			cap[v.id][from.id] += f;
			return f;
		}
		return 0;
	}
	
	int gcd(int a, int b){
		return b==0 ? a : gcd(b, a%b);
	}
}

class Node{
	int id;
	int val;
	ArrayList<Node> edge = new ArrayList<Node>();
	Node(int id, int val){
		this.id = id;
		this.val = val;
	}
	
	void createEdge(Node nd){
		edge.add(nd);
	}
}

public class Main{
	public static void main(String[] args){
		Solve slv = new Solve();
		while(slv.solve());
	}
}

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

using namespace std;

int main(void){
    long long l, r;
    cin >> l >> r;
    long long minj = 2020;
    for(l; l < r; l++){
        for(int j = r; l < j; j--){
            minj = min(minj, l*j%2019);
            if(minj == 0){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    cout << minj << endl;
    return 0;
}

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

int main()
{
    size_t N;
    cin >> N;

    vector<long long> A(N);
    for (long long &a : A)
    {
        cin >> a;
    }
    sort(A.rbegin(), A.rend());

    // 1 2 3 4 5
    // 5: 0
    // 5 4: 5
    // 5 3 4: 4
    // 5 3 4 2: 4
    // 5 3 1 4 2: 3

    // 0 1 2 3 4 5
    // 5: 0
    // 5 4: 5
    // 5 3 4: 4
    // 5 3 4 2: 4
    // 5 3 1 4 2: 3
    // 5 0 3 1 4 2: 3

    long long ans = 0;
    for (size_t i = 1; i < N; i++)
    {
        ans += A[i / 2];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4844
#include<stdio.h>
int mbk(long long a,int n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
int inv(int a,int m){return mbk((long long)a,m-2,m);}
long long M=1e9+7;
long long f(long long a,long long b,long long c){
  int i;
  long long s=1,ans=0;
  for(i=0;i<c-2;i++){
    s=s*(a*b-2-i)%M;
    s=s*inv(i+1,M)%M;
  }//printf("%lld\n",s);
  for(i=0;i<a;i++)ans=(ans+i*(a-i)%M*b%M*b%M*s%M)%M;
  return ans;
}
int main(){
  long long n,m,k;
  scanf("%lld %lld %lld",&n,&m,&k);
  printf("%lld\n",(f(n,m,k)+f(m,n,k))%M);
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
	int N, M;
	int k;
	int A[100];
	int S = 0;

	scanf("%d %d", &N, &M);

	for (int i = 0; i < N; ++i) {
		scanf("%d", &A[i]);
		S += A[i];
	};
	
	sort(A, A + N, [](const int& x, const int& y) { return x > y; });

	if (4 * M * A[M - 1] >= S) {
		printf("Yes");
	}
	else {
		printf("No");
	}
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
long long int N; 
cin >> N; 
long long int S[100], T[100]; 
T[0] = N, S[0] = abs(T[0]) % 2;
int count = 0;  
for(int i = 1; i <= 100; i++){
if(i % 2 == 0) {
T[i] = (S[i-1] + T[i-1]) / 2; 
S[i] = abs(T[i]) % 2; 
if(T[i] != 0) {count ++;} 
}
else if(i % 2 == 1) {
T[i] = (T[i-1] - S[i-1]) / 2; 
S[i] = abs(T[i]) % 2; 
if(T[i] != 0) {count ++;} 
}
}
for(int i = count; i >= 0; i--){
cout << S[i]; 
}
cout << endl; 
}

Measured memory_bytes: 256
import itertools
n, m, q = map(int, input().split())
lst = [0] * q
for i in range(q):
    a, b, c, d = map(int, input().split())
    lst[i] = (a, b, c, d)

up_lsts = list(itertools.combinations_with_replacement(range(1,m + 1), n))
ans = 0
for up_lst in up_lsts:
    tmp = 0
    for req in lst:
        if up_lst[req[1] - 1] - up_lst[req[0] - 1] == req[2]:
            tmp += req[3]
    ans = max(ans, tmp)

print(ans)

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

#define int long long 
#define EB emplace_back

using namespace std;

const string yy = "Yes";
const string nn = "No";


int32_t main()
{

	// #ifndef ONLINE_JUDGE
	// freopen("input","r",stdin);
	// freopen("output","w",stdout);
	// #endif

	int tt = 1;
	//cin>>tt;
	while(tt--)
	{
		int n,d; cin>>n>>d;
		cout<<d+100*(10-min(n,10LL));
		// int arr[n]; for(int i=0;i<n;i++) cin>>arr[i];
		// int brr[m]; for(int i=0;i<n;i++) cin>>brr[i];

	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define ll long long
#define fm_t  ll t;cin>>t;while(t--)
#define fr(i,a,b) for( ll i=a;i<b;i++)
#define fr1(i,n,a) for( ll i=n-1;i>=a;i--)
#define sz(x) (ll)(x).size()
#define all(v)  (v).begin(), (v).end()
#define Sort(x) sort(x.begin(),x.end())
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
const ll mod = 998244353;
#define Mod 1000000007

#define inf 1e18
#define ld long double
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define pi pair<ll, ll>
#define ppi pair<pair<ll, ll>, ll>
#define ump unordered_map<ll,ll>
#define pri priority_queue< pair<ll,ll> , vector< pair<ll,ll> >, greater< pair<ll,ll> > >
void ingraph(vl graph[], ll m){ll x, y;fr(i,0,m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)

//setprecision(10)
//greater<int>()
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll modinv(ll a){
    return modpower(a,mod-2);
}   
     
int main()
{
      
  fast;
  ll n;
  cin>>n;
  ll mx=0;
  ll ans=0;
  for(ll i=0;i<n;i++)
  {
    ll a;
    cin>>a;
    mx=max(a,mx);
    ans+=abs(mx-a);
  }
  cout<<ans<<endl;
    
//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LI long int
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(void){
    LLI n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    bool fl=false;
    FOR(i,0,n){
        LLI mx=d*i-c*(n-1-i),mn=c*i-d*(n-1-i);
        if(mx>=b-a&&b-a>=mn){
            fl=true;
        }
    }
    YES(fl);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;

// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;


int main ()
{
  prep();
  long long n;
  cin >> n;
  long long sum = (n/11)*2;
  if (n%11 == 0){
      cout << sum;
      return 0;
  }
  if (n%11 <= 6){
      cout << sum+1;
  }else{
      cout << sum+2;
  }
  return 0; 
}


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() {
  vector<vector<int>> bingo(3, vector<int>(3));
  rep(i, 3)rep(j, 3){
    cin >> bingo[i][j];
  }
  int n;
  cin >> n;
  vector<int> b(n);
  rep(i, n){
    cin >> b[i];
  }
  rep(k, n)rep(i, 3)rep(j, 3){
    if(bingo[i][j] == b[k]){
      bingo[i][j] = 0;
    }
  }
  int flag = 0;
  rep(i, 3){
    if(bingo[0][i] == bingo[1][i] && bingo[0][i] == bingo[2][i]){      
      flag = 1;
    }else if(bingo[i][0] == bingo[i][1] && bingo[i][0] == bingo[i][2]){      
     flag = 1;
    }else if(bingo[0][0] == bingo[1][1] && bingo[1][1] == bingo[2][2]){      
     flag = 1;
    }else if(bingo[0][2] == bingo[1][1] && bingo[1][1] == bingo[2][0]){      
      flag = 1; 
    }
  }
  if(flag == 1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int []a = new int[N];
    for(int i=0;i<N;i++){
      a[i]=sc.nextInt();
    }
    int max = 0;
    int sum = 0;
    for(int i = 0; i < N; i++){
        sum = sum + a[i];
        if(a[i]>max){
            max = a[i];
        }
    }
    if(2*max < sum){
        System.out.println("Yes");
    }
    else{
        System.out.println("No");
    }
  } 
}

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
  if (ch == 'A')
    return 1;
  else if (ch == 'C')
    return 2;
  else if (ch == 'G')
    return 3;
  else if (ch == 'T')
    return 4;
  else
    return 0;
}

long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++) {
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for (i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0)
      return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for (i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main() {
  int i, n, h;
  char str[L], com[9];
  for (i = 0; i < M; i++) H[i][0] = '\0';
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s %s", com, str);

    if (com[0] == 'i') {
      insert(str);
    } else {
      if (find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 17448
A,B,K = map(int,input().split())
ans = []
for i in range(A,min(A+K,B)):
    ans.append(i)
for j in range(max(A,B-K+1),B+1):
    ans.append(j)
ans = list(set(ans))
ans.sort()
for h in ans:
    print(h)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <climits> // int ???????????§????????????????????????
using namespace std;
const int MAX_V = 1000; // ???????????°????????§???
const int MAX_E = 2000; // ????????°????????§???
const int INF = INT_MAX; // ???????????§?????????(int ???????????§???)
struct E {
  int to, cost;
  E(int t, int c) : to(t), cost(c) {};
};
int v; // ????????°
vector<E> g[MAX_V]; // ??£??\?????????
int d[MAX_V]; // ??????s ????????????????????¢
// ?????????????????????????????????????????????????????????
// ??????????????????????????°true???????????°false ?????????
bool bellmanford(int s)
{
  // ??????
  fill(d, d + v, INF);
  d[s] = 0;
  // ??????s ??????????????¨???k+1 ???????????????????????????????????¢???
  for(int k = 0; k < v; ++k){
    // ??????1 ?????????????????¨???
    for(int j = 0; j < v; ++j){
      int from = j;
      // ??????????§??????¨????????¨???????????????????????????????????????
      for(int i = 0; i < g[from].size(); ++i){
	int to = g[from][i].to;
	int cost = g[from][i].cost;
	// ???????????¢??¨??????????????´???
	if(d[from] != INF && d[to] > d[from] + cost){
	  d[to] = d[from] + cost;
	  // ????????????????????¨??????????????°?????????????????????????????????????????????
	  // ???????????£??????v ???????????????????????¢????????????????????????????????°????????????????????¨
	  if(k == v - 1)return false;
	}
      }
    }
  }
  // ?????????????????????????????°????????????????????¨??????????????¨?????????
  return true;
}
int main()
{
  // ??\??????????????????gv ??????????????°???ge ???????????°???gr ????§????
  int gv, ge, gr;
  cin >> gv >> ge >> gr;
  v = gv;
  for(int i = 0; i < ge; ++i){
    // ??\??????????????????gs ??????????§???????gt ??????????????????gd ???????????????
    int gs, gt, gd;
    cin >> gs >> gt >> gd;
    g[gs].push_back(E(gt, gd)); // 2 ???????????????????????±????¨????
  }
  // ??????????????????gr ????????????????????????????????¢??????????????????????????????
  if(bellmanford(gr)) // ???????????????????????´???
    for(int i = 0; i < v; ++i){
      if(d[i] != INF)
	cout << d[i] << endl;
      else // ????????????i ?????????????????´???
	cout << "INF" << endl;
    }
  else // ???????????????????????´???
    cout << "NEGATIVE CYCLE" << endl;
}

Measured memory_bytes: 1260
a = []
n = 0
i = 0
j = 0
sum = 0

while True:
    a.append(list(input()))

    if int(a[n][0]) == 0:
        break
    n += 1

for i in range(n):
    sum = 0
    for j in range(len(a[i])):
        sum += int(a[i][j])
    
    print(sum)




Measured memory_bytes: 5624
#include<stdio.h>
#include<stdlib.h>
#define M 2000000
int heap_size;
void heapIncreaseKey(int *A,int i,int key){
  int tmp;
  if(key<A[i])
    exit(1);
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    tmp=A[i];
    A[i]=A[i/2];
    A[i/2]=tmp;
    i=i/2;
  }
}
void maxHeapInsert(int *A,int key){
  heap_size++;
  A[heap_size]=-20000000;
  heapIncreaseKey(A,heap_size,key);
}
void maxHeapify(int *A,int i){
  int l,r,largest,temp;
  l = 2*i;
  r = 2*i+1;
  if(l<=heap_size && A[l]>A[i])
    largest = l;
  else
    largest = i;
  if(r<=heap_size && A[r]>A[largest])
    largest = r;
  if(largest != i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapify(A,largest);
  }
}
int heapExtractMax(int *A){
  int max;
  if(heap_size<1)
    exit(2);
  max=A[1];
  A[1]=A[heap_size];
  heap_size--;
  maxHeapify(A,1);
  return max;
}
int main(void){
  int x,A[M];
  char com[8];
  while(1){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      maxHeapInsert(A,x);
    } 
    else{
      if(com[1]=='n')
	break;
      else
	printf("%d\n",heapExtractMax(A));
    }
  }
  return 0;
}

Measured memory_bytes: 4612
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n;
string s;
set<string> t;
char l = '!';

signed main() {
	cin >> n;
	rep(i,n) {
		cin >> s;
		if (t.count(s)) return cout << "No" << endl, 0;
		if (i!=0 && s[0]!=l) return cout << "No" << endl, 0;
		t.insert(s);
		l = s[s.size()-1];
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  while(true) {
    int n;
    cin >> n;
    int sum[86402] = {0};
    if(n == 0) break;
    rep(i, n) {
      string a, b;
      cin >> a >> b;
      int ah, am, as, bh, bm, bs;
      ah = atoi(a.substr(0,2).c_str());
      am = atoi(a.substr(3,2).c_str());
      as = atoi(a.substr(6,2).c_str());
      bh = atoi(b.substr(0,2).c_str());
      bm = atoi(b.substr(3,2).c_str());
      bs = atoi(b.substr(6,2).c_str());
      int at, bt;
      at = 60 * 60 * ah + 60 * am + as;
      bt = 60 * 60 * bh + 60 * bm + bs;
      // cout << at << " " << bt << endl;
      sum[at]++;sum[bt]--;
    }
    int ans;
    ans = sum[0];
    rep(i, 86400) {
      sum[i+1] += sum[i];
      ans = max(ans, sum[i+1]);
    }
    cout << ans << endl;
  }
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

void solve()
{
    ll n;
    cin>>n;
    VL arr(n);
    fr(i,0,n)
        cin>>arr[i];
    sort(ALL(arr));
    ll ct=0,sum=0;
    fr(i,0,n-1)
    {
        if(arr[i+1]<=2*(arr[i]+sum))
        {
            ct++;
            sum+=arr[i];
        }
        else
        {
            ct=0;
            sum+=arr[i];
        }
    }
    ct++;
    cout<<ct<<endl;
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }
	return 0;
}

Measured memory_bytes: 1152
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

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

func main() {
	a, b := readString(), readString()
	num, _ := strconv.ParseFloat(a+b, math.MaxInt64)
	sqrt := math.Sqrt(num)
	if math.Floor(sqrt) == sqrt {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main() {
    int input;

    for (int i = 1; i <= 10000; ++i) {
        cin >> input;
        if(input == 0){
            return 0;
        }
        cout << "Case "<< i << ": " << input << endl;
    }

    return 0;
}


Measured memory_bytes: 3000
#include<iostream>

using namespace std;

int f[200];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<=100;++i)
	  f[i]=0;
	for(int i=1;i<=k;++i)
	  {
	  	  int m;
	  	  cin>>m;
	  	  for(int j=1;j<=m;++j)
	  	    {
	  	    	int x;
	  	    	cin>>x;
	  	    	f[x]++;
	  	    }
	  }  
	int ans=0;
	for(int i=1;i<=n;++i)
	  if(f[i]==0) ans++;
	cout<<ans<<endl;    
}

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

const int DIM = 1e3 + 5;
const int MOD = 1e9 + 7;

int nr[DIM];

int main(void) {
    int n;
    cin >> n;
    
    for (int i = 2; i <= n; ++i) {
        int x = i;
        
        for (int j = 2; j <= x; ++j)
            while (x % j == 0)
                ++nr[j], x /= j;
    }
    
    int ans = 1;
    for (int i = 2; i <= n; ++i)
        ans = (1LL * ans * (nr[i] + 1)) % MOD;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

int main()
{
    char S[16];
    scanf("%s", S);
    int len = strlen(S);
    int count = 0;
    for(int i=0; i<len; i++){
        if(S[i] == 'o') count++;
    }
    if(count + 15 - len >= 8) printf("YES\n");
    else printf("NO\n");
}


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

using namespace std;

int main(){
	int a[10] = {0};
	string n;
	cin >> n;
	bool flag = false;
	if(n[0] == n[1] && n[1] == n[2] || n[1] == n[2] && n[2] == n[3]){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;


	return 0;
}



Measured memory_bytes: 256
N, B, R = map(int, input().split())
sum_B = (N // (B+R)) * B
n = N % (B+R)
if n == 0:
  print(sum_B)
elif n > B:
  sum_B += B
  print(sum_B)
else:
  sum_B += n
  print(sum_B)

Measured memory_bytes: 3060
import sys

file_input = sys.stdin

for line in file_input:
    M, T, P, R = map(int, line.split())
    if M == 0:
        break
    
    # [number of solved probrems, complement of elapsed time, team number] + [rejected times] * P
    # [rejected times] * P will be accessed in reverse order.
    result = [[0, M, i] + [0] * P for i in range(T+1)]
    
    for i in range(R):
        m, t, p, j = map(int, file_input.readline().split())
        team_data = result[t]
        if j:
            team_data[-p] += 1
        else:
            team_data[0] += 1
            team_data[1] -= (m + 20 * team_data[-p])

    result.sort(reverse=True)

    for td1, td2 in zip(result[:-2], result[1:]):
        if td1[0] == td2[0] and td1[1] == td2[1]:
            print(td1[2], end='=')
        else:
            print(td1[2], end=',')
    print(result[-2][2])

Measured memory_bytes: 7836
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"p=m=0\n"
"for c in input():p=-~p*(c in'ATGC');m=max(m,p)\n"
"print(m)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
#include <iostream>

using namespace std;

int main()
{
   int a[2][105];
   int n,maxx=-1,i,j,sum;
   cin>>n;
   for(int i=0;i<2;i++)
       for(int j=0;j<n;j++)
        cin>>a[i][j];
   for(i=0;i<n;i++)
   {   sum=0;
       for(j=0;j<=i;j++)//第一行的
           sum+=a[0][j];
       for(j--;j<n;j++)//第二行的
           sum+=a[1][j];
       if(sum>maxx) maxx=sum;
   }
   cout<<maxx<<endl;
    return 0;
}


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


class Program {

	static int testN=3;
	static long mod = 1000000007;
	//static long mod =998244353; 
	static System.IO.StringReader sr;
	static void Main(string[] args) {
		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res = "";
		long res = 0 ;
		int[] vals = parseAry(Console.ReadLine().Split(cs));
		long x = vals[1];
		long y = vals[0];

		res = ( x * y) / 2;
		if (( x % 2 == 1) && (y % 2 == 1) ) {
			res++;
		}

		if ( x == 1 || y==1) { res = 1; }

		Console.WriteLine(res);
		return;

	}



	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}



}

Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	long long a[n];
	long long b[n];
	for(int i=1;i<=n;i++)
	{
		cin >> a[i-1];
		b[i-1]=a[i-1]-i;
	}
	sort(b,b+n);

	long long bb;

	bb=b[(n+1)/2-1];

	long long ans=0;
	for(int i=1;i<=n;i++)
		ans+=abs(a[i-1]-(bb+i));

	cout << ans << endl;
}

Measured memory_bytes: 3328
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(){
    ll N;
    cin >> N;
    ll s = sqrt(N);
    while(N%s != 0){
        s--;
    }
    cout << s+N/s-2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(a%2==0&&(a%3!=0&&a%5!=0)){
      cout<<"DENIED"<<endl;
      return 0;
    }
  }
  cout<<"APPROVED"<<endl;
  return 0;
}

Measured memory_bytes: 256
x,y = map(int,input().split())
if (x+y) % 3 != 0:
  print(0)
elif x < 0 or y < 0:
  print(0)
elif x/y > 2 or y/x > 2:
  print(0)
else:
  n = (x+y) // 3
  m = x - n
  mod = 10**9 + 7
  def inv(x):
    y = 1
    while x != 1:
      y *= mod//x + 1
      y %= mod
      x -= mod%x
    return y
  #print(inv(5))
  ans = 1
  for i in range(m):
    ans *= (n-i)
    ans %= mod
    ans *= inv(m-i)
    ans %= mod
  #print(n,m)
  print(ans)

Measured memory_bytes: 3064
s = input()

s_wo_x = s.replace("x", "")
for i in range(len(s_wo_x)):
    if s_wo_x[i] != s_wo_x[len(s_wo_x)-i-1]:
        print("-1")
        break
else:
    i = 0
    j = len(s)-1
    ans = 0
    while(i < j):
        if s[i] == "x" and s[j] != "x":
            i += 1
            ans += 1
        elif s[i] != "x" and s[j] == "x":
            j -= 1
            ans += 1
        elif s[i] == s[j]:
            i += 1
            j -= 1
            
    print(ans)

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

struct node {
    int id;
    int parent = -1;
    int depth;
    string type;
    vector<int> children;
};

void search(vector<node> &tree, int idx, int dep) {
    if (tree.at(idx).parent != -1) {
        if (tree.at(idx).children.size() == 0) {
            tree.at(idx).depth = dep;
            tree.at(idx).type = "leaf";
            return;
        } else {
            tree.at(idx).depth = dep;
            tree.at(idx).type = "internal node";
        }
    }
    for (auto &x : tree.at(idx).children) {
        search(tree, x, dep + 1);
    }
    return;
}

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

    int n;
    cin >> n;
    vector<node> tree(n);
    for (int i = 0; i < n; ++i) {
        int ii;
        cin >> ii;
        tree.at(ii).id = ii;
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int c;
            cin >> c;
            tree.at(ii).children.push_back(c);
            tree.at(c).parent = ii;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (tree.at(i).parent == -1) {
            tree.at(i).depth = 0;
            tree.at(i).type = "root";
            search(tree, i, 0);
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << "node " << tree.at(i).id;
        cout << ": parent = " << tree.at(i).parent;
        cout << ", depth = " << tree.at(i).depth;
        cout << ", " << tree.at(i).type;
        cout << ", [";
        for (int j = 0; j < tree.at(i).children.size(); ++j) {
            if (j) cout << ", ";
            cout << tree.at(i).children.at(j);
        }
        cout << ']' << endl;
    }

    return 0;
}


Measured memory_bytes: 13036
import java.util.Scanner;

public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] v = new int[n];
        for(int i = 0; i < n; i++) {
            v[i] = scanner.nextInt();
        }
        int[] c = new int[n];
        for(int i = 0; i < n; i++) {
            c[i] = scanner.nextInt();
        }
        
        int[] value = new int[n];
        int max = 0;
        for(int i = 0; i < n; i++) {
            value[i] = v[i] - c[i];
            if(value[i] > 0) max += value[i];
        }

        System.out.println(max);

    }
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

void ufInit(int n);
int Root(int x);
bool Unite(int x, int y);

void dfs(int pos, vector<int>& v);

int root[SIZE];
int sz[SIZE];
int cost[SIZE];

vector<int> graph[SIZE];
bool isvisit[SIZE];

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

    int n, m;
    cin >> n >> m;
    ufInit(n);

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

    }

    while(m--) {
        int x, y;
        cin >> x >> y;
        Unite(x, y);
        graph[x].pb(y);
        graph[y].pb(x);

    }

    for(int i = 0; i < n; ++i) {
        Root(i);

    }

    int cnt = 0;
    vector<int> roots;
    LL res = 0;
    set<int> st;
    for(int i = 0; i < n; ++i) {
        roots.pb(root[i]);
        st.insert(root[i]);

    }
    
    if(st.size() == 1) {
        cout << 0 << endl;
        return 0;

    }

    LL unite_cnt = st.size() * 2 - 2;

    sort(all(roots));
    roots.erase(unique(all(roots)), roots.end());

    vector<int> unite_cost;
    for(int i = 0; i < roots.size(); ++i) {
        vector<int> tmp;
        dfs(roots[i], tmp);
        if(tmp.size() == 0) {
            continue;

        }
        --unite_cnt;
        sort(all(tmp));
        res += tmp[0];
        for(int j = 1; j < tmp.size(); ++j) {
            unite_cost.pb(tmp[j]);

        }

    }

    if(st.size() == 2) {
        cout << res << endl;
        return 0;

    }
    sort(all(unite_cost));

    if(unite_cost.size() < unite_cnt) {
        cout << "Impossible" << endl;
        return 0;

    }
    for(int i = 0; i < unite_cnt; ++i) {
        res += unite_cost[i];

    }
    cout << res << endl;

    return 0;
}

void ufInit(int n) {
    for(int i = 0; i <= n; ++i) {
        root[i] = i;
        sz[i] = 1;

    }

    return;
}

int Root(int x) {
    if(x == root[x]) {
        return x;

    }
    int rt = Root(root[x]);
    sz[x] = sz[rt];
    root[x] = rt;
    return rt;
}

bool Unite(int x, int y) {
    int rx, ry;
    rx = Root(x);
    ry = Root(y);

    if(rx == ry) {
        return false;

    }
    
    if(sz[rx] > sz[ry]) {
        root[ry] = rx;

    } else {
        root[rx] = ry;

    }
    sz[rx] += sz[ry];
    sz[ry] = sz[rx];

    return true;
}

void dfs(int pos, vector<int>& v) {
    if(isvisit[pos]) {
        return;

    }
    isvisit[pos] = true;
    v.pb(cost[pos]);

    for(int i = 0; i < graph[pos].size(); ++i) {
        dfs(graph[pos][i], v);

    }

    return;
}



Measured memory_bytes: 12024