akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define EVEN(x) (mu[x] == x || (mu[x] != x && phi[mu[x]] != mu[x]))
#define ODD(x)  (mu[x] != x && phi[mu[x]] == mu[x] && phi[x] != x)
#define OUTER(x) (mu[x] != x && phi[mu[x]] == mu[x] && phi[x] == x)
typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
int maximumMatching(const Graph &g) {
  int n = g.size();
  vector<int> mu(n), phi(n), rho(n), scanned(n);
  REP(v,n) mu[v] = phi[v] = rho[v] = v; // (1) initialize
  for (int x = -1; ; ) {
    if (x < 0) {                        // (2) select even
      for (x = 0; x < n && (scanned[x] || !EVEN(x)); ++x);
      if (x == n) break;
    }
    int y = -1;                         // (3) select incident
    FOR(e, g[x]) if (OUTER(e->dst) || (EVEN(e->dst) && rho[e->dst] != rho[x])) y = e->dst;
    if (y == -1) scanned[x] = true, x = -1;
    else if (OUTER(y)) phi[y] = x;      // (4) growth
    else {
      vector<int> dx(n, -2), dy(n, -2); // (5,6), !TRICK! x % 2 --> x >= 0
      for (int k = 0, w = x; dx[w] < 0; w = k % 2 ? mu[w] : phi[w]) dx[w] = k++;
      for (int k = 0, w = y; dy[w] < 0; w = k % 2 ? mu[w] : phi[w]) dy[w] = k++;
      bool vertex_disjoint = true;
      REP(v,n) if (dx[v] >= 0 && dy[v] > 0) vertex_disjoint = false;
      if (vertex_disjoint) {            // (5) augment
        REP(v,n) if (dx[v] % 2) mu[phi[v]] = v, mu[v] = phi[v];
        REP(v,n) if (dy[v] % 2) mu[phi[v]] = v, mu[v] = phi[v];
        mu[x] = y; mu[y] = x; x = -1;
        REP(v,n) phi[v] = rho[v] = v, scanned[v] = false;
      } else {                          // (6) shrink
        int r = x, d = n;
        REP(v,n) if (dx[v] >= 0 && dy[v] >= 0 && rho[v] == v && d > dx[v]) d = dx[v], r = v;
        REP(v,n) if (dx[v] <= d && dx[v] % 2 && rho[phi[v]] != r) phi[phi[v]] = v;
        REP(v,n) if (dy[v] <= d && dy[v] % 2 && rho[phi[v]] != r) phi[phi[v]] = v;
        if (rho[x] != r) phi[x] = y;
        if (rho[y] != r) phi[y] = x;
        REP(v,n) if (dx[rho[v]] >= 0 || dy[rho[v]] >= 0) rho[v] = r;
      }
    }
  }
  int ret = 0;
  REP(u,n) if (u < mu[u]) ret++;
  return ret;
}
int X, Y, E, x, y; Graph G;
int main() {
	scanf("%d%d%d", &X, &Y, &E); G.resize(X + Y);
	for(int i = 0; i < E; i++) {
		scanf("%d%d", &x, &y);
		G[x].push_back(Edge(x, X + y, 1));
		G[X + y].push_back(Edge(X + y, x, 1));
	}
	printf("%d\n", maximumMatching(G));
}

Measured memory_bytes: 3312
#include <iostream>
#include <queue>
#include <vector>

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

const int SIZE = 10000;
const int INF = 1 << 21;
std::vector<std::pair<int, int>> a[SIZE];
int d[SIZE];

void dijkstra(int s, int n) {
  std::priority_queue<std::pair<int, int>> q;

  rep(i, n) { d[i] = INF; }
  d[s] = 0;

  q.push(std::make_pair(0, s));

  while (!q.empty()) {
    auto p = q.top();
    q.pop();

    int u = p.second;
    if (d[u] < (-1) * p.first) continue;

    for (auto p : a[u]) {
      int v = p.first;
      if (d[v] > d[u] + p.second) {
        d[v] = d[u] + p.second;
        q.push(std::make_pair((-1) * d[v], v));
      }
    }
  }
}

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

  rep(i, n) {
    int u, k, v, c;
    std::cin >> u >> k;
    rep(j, k) {
      std::cin >> v >> c;
      a[u].push_back(std::make_pair(v, c));
    }
  }

  dijkstra(0, n);
  rep(i, n) { std::cout << i << ' ' << d[i] << '\n'; }

  return 0;
}



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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = 0;
    ll maxval = max(x, y);
    ll minval = min(x, y);
    ans += min(minval*c*2, minval*(a+b));
    if (x > y) ans += a * (x - minval);
    else ans += b * (y - minval);

    cout << min(ans, maxval*c*2) << endl;

    return 0;
}


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

int main() {
	int n;
	cin >> n;
	
	int num[n];
	for(int i=0;i<n;i++){
		cin >> num[i];
	}
	
	cout<<num[n-1];
	for(int i=1; i<n; i++){
		cout<<" " << num[n-1-i];
	}
	cout<<endl;
	return 0;
}

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

int main() {
	int a,b,c,d,p;
	int xsum,ysum;
	
	cin>>a>>b>>c>>d>>p;
	
	xsum=a*p;
	
	if(p<c){
		ysum=b;
	}else{
		ysum=b+(p-c)*d;
	}
	
	if(xsum<ysum){
		cout<<xsum<<endl;
	}else{
		cout<<ysum<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define PII pair<ll,ll>
#define VI  vector<ll>
#define VB  vector<bool>
#define VVI vector<vector<ll>>
#define VS  vector<string>
#define VP  vector<PII>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
#define lr(i,a,b) for(ll i=a;i>=b;i--)
#define lfl(i,v) for(ll i=0;i<v.size();i++)
#define lrl(i,v) for(ll i=(ll)(v.size())-1;i>=0;i--)
#define chk2(a,b) cout<<"check :  "<<a<<" "<<b<<endl
#define chk3(a,b,c) cout<<"check :  "<<a<<" "<<b<<" "<<c<<endl
#define chk4(a,b,c,d) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define chk5(a,b,c,d,e) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
#define lb(v,k)  lower_bound(v.begin(),v.end(),k)-v.begin()
#define ub(v,k)  upper_bound(v.begin(),v.end(),k)-v.begin()
#define mod 1000000007
#define pb push_back
#define pf push_front
#define m_p make_pair
#define fi first
#define se second
#define sz size()
#define sort(v) sort(v.begin(),v.end())
ll n,m;
double dp[3000][3000];
vector<double> vpr;

double fun(ll ind,ll nh)
    {   if(ind>n)
        {   if(nh>(n-nh))
                return 1;
            else
                return 0;
        }
        if(dp[ind][nh]!=-1)
            return dp[ind][nh];
        
        return dp[ind][nh]=(1-vpr[ind])*fun(ind+1,nh)+(vpr[ind]*fun(ind+1,nh+1));
    }
int main()
{   cin>>n;
    vpr=vector<double>(n+1);
    lf(i,0,2999)
        lf(j,0,2999)
            dp[i][j]=-1;
    lf(i,1,n)
    {   cin>>vpr[i]; 
    }
    fun(1,0);
    printf("%0.10f",dp[1][0]);
}

Measured memory_bytes: 70784
n = int(input())
t = [1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100,
     125, 121, 128, 144, 169, 196, 216, 225, 243, 256,
     289, 324, 343, 361, 400, 441, 484, 512, 529, 576,
     625, 676, 729, 784, 841, 900, 961, 1000, 1024, 1296]

res = 0
for tt in t:
    res = tt if tt <= n else res
print(res)


Measured memory_bytes: 9048
import collections
X = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
ans = 1
for i in range(X):
  Y = X - i
  f = collections.Counter(prime_factorize(Y))
  if len(set(f.values())) == 1 and list(f.values())[0] > 1 :
    ans = Y
    break
print(ans)

Measured memory_bytes: 65248
#include<bits/stdc++.h>
#define int long long

using namespace std ;
char a[6][6] ;
signed main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL)  ;

    int h ,w , k ;
    cin >> h >>w >> k ;
    for(int i =0 ; i < h ; ++i)
    {
        for(int j = 0 ; j < w ; ++j)
        {
            cin >> a[i][j] ;
        }
    }
    int n = pow(2,h) ;
    int m = pow(2,w) ;
    int ans =  0;

    for(int maskr = 0 ; maskr  < n ;++maskr)
    {
        for(int maskc = 0 ; maskc < m ; ++maskc)
        {
            int black =  0 ;
            for(int i = 0 ; i < h ; ++i)
            {
                for(int j = 0 ; j < w ; ++j)
                {

                    if((((maskr) & (1<<i)) == 0) && (((maskc) & (1<<j)) == 0 ))
                    {

                        if(a[i][j] == '#')
                            black++ ;
                    }
                }
            }
            if (black == k )
                ans++ ;
        }
    }
    cout << ans << endl ;


}


Measured memory_bytes: 3996
#include <iostream>
typedef long long ll;
using namespace std;

int main() {
	ll a, b, x;
	cin >> a >> b >> x;
	ll right, left;
	right = b / x + 1;
	if (a == 0)
		left = 0;
	else
		left = (a - 1) / x + 1;
	cout << right - left << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	
	int i,N,k,a,b,flag,ans;
while(1){	
		scanf("%d",&N);
	ans=N+1;
	if(N==0){
		break;
	}
	flag=0;
	for(i=0;i<N;i++){
		scanf("%d",&k);
		if(k==0){
			ans--;
		}else if(k>=2){
			flag=1;
		}
	}
	if(flag==1){
		printf("%d\n",ans);
	}else if(flag==0){
		printf("NA\n");
	}
}		
return 0;
}

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

#define int long long
const int MAXN = 1e6 + 100 ;
bool vis[MAXN] ;
int par[MAXN] , b = -1 ;
vector<int> ver[MAXN] ;
void dfs(int v,  int p){
  int deg = 0 ;
  par[v] = p ; vis[v] = true ;
  for(auto u : ver[v]){
    if(vis[u])continue ;
    deg ++ ;
    dfs(u , v) ;
  }
  if(deg == 0)b = v ;
}
int32_t main() {
  ios_base::sync_with_stdio(0) ;
  cin . tie(0) ; cout . tie(0) ;

  int n ; cin >> n ;
  int m ; cin >> m ;
  for(int i= 0 ; i < m ; i ++){
    int x , y ; cin >> x >> y ;
    x-- , y-- ;
    ver[x] . push_back(y) ;
    ver[y] . push_back(x) ;
  }
  dfs(0 , -1) ;
  memset(vis , 0 , sizeof vis) ;
  vector<int> ans1 ;
  while(b != -1){
    ans1 . push_back(b) ;
    vis[b] = true ;
    b = par[b] ;
  }
  dfs(0 , -1) ;
  vector<int> ans2 ;
  while(b){
    ans2 . push_back(b) ;
    vis[b] = true ;
    b = par[b] ;
  }
  cout<< ans1 . size() + ans2 . size() << '\n' ;
  for(auto u : ans1)cout << u + 1 << ' ' ;
  while(ans2 . size()){
    cout << ans2 . back() + 1<< ' '  ;
    ans2 . pop_back() ;
  }
}


Measured memory_bytes: 34676
import sys
sys.setrecursionlimit(1000000)
from operator import itemgetter

S1 = input()
T = input()

idx = 100

for i in range(len(S1)-len(T)+1):
    for j in range(len(T)):
        if S1[i+j] == T[j] or S1[i+j] == '?':
            if j == len(T)-1:
                idx = i
            continue
        else:
            break

if idx == 100:
    print("UNRESTORABLE")
    exit()
    
S1 = S1[:idx] + T + S1[idx+len(T):]
S1 = S1.replace('?', 'a')
print(S1)

Measured memory_bytes: 3192
import java.util.*;

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

    int N = in.nextInt();
    int K = in.nextInt();
    char[] s = in.next().toCharArray();

    List<Integer> nums = new ArrayList<Integer>();

    char prev = s[0];
    int count = 1;

    for (int i = 1; i < N; i++) {
      if (prev == s[i]) {
        count++;
      } else {
        nums.add(count);
        count = 1;
        prev = s[i];
      }
    }
    nums.add(count);

    // Make nums start with '0' count
    if (s[0] == '1') {
      nums.add(0, 0);
    }
    // Make num ends with '0' count
    if (s[N - 1] == '1') {
      nums.add(0);
    }

    int numflip = 0;
    int ans = 0;
    int curr = 0;

    for (int i = 0; i < nums.size(); i++) {
      // We are looking at '0' count
      if (i % 2 == 0) {
        if (numflip < K) {
          numflip++;
        } else {
          int kickedOut0Index = i - K * 2;
          curr -= nums.get(kickedOut0Index);
          if (0 < kickedOut0Index) {
            curr -= nums.get(kickedOut0Index - 1);
          }
        }
        curr += nums.get(i);
      }
      // We are looking at '1' count
      else {
        curr += nums.get(i);
      }
      ans = Math.max(ans, curr);
    }

    ans = Math.max(ans, curr);

    System.out.println(ans);

  }
}

Measured memory_bytes: 26132
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　RedcoderになるためAtCoderを巡る旅をしてます。

　　　 　＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　   ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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;
}

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

    int N, R;
    cin >> N >> R;
    if(N >= 10)
        COUT(R);
    else
        COUT(R + 100 * (10 - N));
}


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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
vector<int> adj[maxn];
int n , dp[maxn][2];
void DFS(int u , int par)
{
    dp[u][0] = dp[u][1] = 1;
    for(int c : adj[u])
    {
        if(c == par)continue;
        DFS(c,u);
        dp[u][0] = (ll)dp[u][0] * (dp[c][0] + dp[c][1]) % mod;
//        cout << dp[c][0] << " " << dp[c][1] << " " << dp[u][0] << endl;
        dp[u][1] = (ll)dp[u][1] * dp[c][0] % mod;
    }
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n;
    for(int i = 1 ; i < n ; ++i)
    {
        int u , v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    DFS(1 , 0);
    cout << (dp[1][1] + dp[1][0]) % mod;
}


Measured memory_bytes: 13440
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(ll i = (ll)(n)-1;i >= 0;--i)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n,x;
  cin >> n >> x;
  vi a(n);
  REP(i,n) cin >> a.at(i);
  sort(ALL(a));
  int ans = 0;
  REP(i,n-1){
    if(x>=a.at(i)){
      ans++;
      x -= a.at(i);
    }else break;
  }
  if(x==a.at(n-1)) ans++;
  cout << ans << endl;
}



Measured memory_bytes: 256
n=int(input())
a=[]
for _ in range(n):
  b=list(map(int,input().split()))
  a.append(b)
  
a.sort(key=lambda x: x[1])

ans=0
ch=0

for c in range(n):
  x=a[c][0]
  y=a[c][1]
  
  ans+=x
  if ans>y:
    ch+=1
  
if ch==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 47076
#include <iostream>

int main() {
  int n, a, amount;
  
  std::cin >> n >> a;

  if (n >= 500) {
    n %= 500;
  }

  if (a >= n) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}


Measured memory_bytes: 256
N = gets.to_i
A = N.times.map{ gets.split.map(&:to_i) }.unshift([])
ans = 0
completed = [true] + Array.new(N, false)
current_idx = (1..N).to_a
while completed.any?{|val| !val }
    ans += 1
    matched = Array.new(N+1, false)
    next_idx = []
    current_idx.each do |idx|
        next if completed[idx] || completed[A[idx][0]]
        if (!matched[idx] && !matched[A[idx][0]] && A[A[idx][0]][0] == idx)
            idx2 = A[idx].shift
            A[idx2].shift
            next_idx << idx
            next_idx << idx2
            matched[idx] = true
            matched[idx2] = true
            completed[idx] = true if A[idx].empty?
            completed[idx2] = true if A[idx2].empty?
        end
    end
    if next_idx.empty?
        p -1
        exit
    end
    current_idx = next_idx
end
p ans


Measured memory_bytes: 47812
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 29 16:33:51 2018
ABC111C
@author: maezawa
"""

import collections

n = int(input())
v = list(map(int, input().split()))

v0 = [v[i] for i in range(0,n,2)]
v1 = [v[i] for i in range(1,n,2)]

v0cnt = collections.Counter(v0)
v1cnt = collections.Counter(v1)

v0most = v0cnt.most_common()[0]
v1most = v1cnt.most_common()[0]
if len(v0cnt) > 1:
    v0next = v0cnt.most_common()[1]
if len(v1cnt) > 1:
    v1next = v1cnt.most_common()[1]
if v0most[0] != v1most[0]:
    ans = n - v0most[1] -v1most[1]
else:
    if v0most[1] == v1most[1]:
        if v0most[1] == n//2:
            ans = n//2
        else:
            if v0next[1] > v1next[1]:
                ans = n - v1most[1] - v0next[1]
            else:
                ans = n - v0most[1] - v1next[1]            
    elif v0most[1] > v1most[1]:
        ans = n - v0most[1] - v1next[1]
    else:
        ans = n - v1most[1] - v0next[1]

print(ans)
    

Measured memory_bytes: 19040
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    string S, res;
    bool a, b, c;
    a = b = c = false;
    res = "No";
    cin >> S;
    for (int i = 0; i < 3; i++) {
        if (S[i] == 'a') {a = true;}
        else if (S[i] == 'b') {b = true;}
        else if (S[i] == 'c') {c = true;}
    }
    if (a && b && c) res = "Yes";
	cout << res << endl;
	return 0;
}

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

void solve(long long N, long long M, std::vector<long long> A)
{
    long long res = 0;
    for (int i = 0; i < M; i++)
    {
        res += A[i];
    }

    cout << max(-1LL, N - res) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> A(M);
    for (int i = 0; i < M; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

#define pi 3.141592653589
#define repeat(i,n) for(int i=0;i<n;i++)

int main(){
	double x[2], y[2];
	cin >> x[0] >> y[0] >> x[1] >> y[1];
	double d;
	d = sqrt((x[0] - x[1])*(x[0] - x[1]) + (y[0] - y[1])*(y[0] - y[1]));
	cout << fixed << setprecision(5) << d << endl;
	return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
int par[111111],siz[111111],n,m;
void init(int x){
	rep(i,x){
		par[i]=i;
		siz[i]=1;
	}
}
int find(int x){
	if (par[x]==x)return x;
	return par[x]=find(par[x]);
}
void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	if(siz[x]<siz[y]){
		par[x]=y;
		siz[y]+=siz[x];
	}
	else{
		par[y]=x;
		siz[x]+=siz[y];
	}
}
bool same(int x,int y) {
	return find(x)==find(y);
}
int Size(int f){
	return siz[find(f)];
}
set<int>st;
signed main(){
	cin>>n>>m;
	init(n);
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		unite(a-1,b-1);
	}
	rep(i,n){
		st.insert(find(i));
	}
	cout<<st.size()<<endl;
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  string s;cin >> s;
  for(auto it:s){
    if(it=='7'){
      cout << "Yes\n";
      return 0;
    }
  } 
  cout << "No\n";
  return 0;
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}


Measured memory_bytes: 3624
package main

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

var sc = bufio.NewScanner((os.Stdin))

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

func nextInt() int {
	l := nextLine()
	i, e := strconv.Atoi(l)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N, L := nextInt(), []int{}
	for i := 0; i < N; i++ {
		L = append(L, nextInt())
	}

	fmt.Printf("%s\n", ABC117B(L))
}

// ABC117B ...
func ABC117B(L []int) string {
	maxIndex, maxVal := 0, -1
	for i, l := range L {
		if maxVal < l {
			maxIndex, maxVal = i, l
		}
	}
	L[maxIndex] = 0

	sum := 0
	for _, l := range L {
		sum += l
	}

	if maxVal < sum {
		return "Yes"
	}

	return "No"
}


Measured memory_bytes: 1780
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

class Node{
	long value;
	long id;
	long groupid = -1;
	bool isGrouped;
	Node[] nodes;
	this(long id, long value){
		this.id = id;
		this.value = value;
	}
	void join(Node nd){
		if(this.value == nd.value) return;
		else{
			this.nodes ~= nd;
			nd.nodes ~= this;
		}
	}
	void groupify(long id){
		if(this.isGrouped) return;
		this.isGrouped = 1;
		this.groupid = id;
		foreach(nd; this.nodes){
			nd.groupify(id);
		}
	}
	override string toString(){
		return "\n" ~ this.id.to!string ~  " '" ~ this.value.to!char ~ "' " ~ this.groupid.to!string ~ " " ~ this.nodes.map!(x => x.id.to!string).join(",");
	}
}

void main(){
	auto h = read.to!long;
	auto w = read.to!long;
	
	string s;
	foreach(i; 0 .. h) s ~= readln.chomp;
	
	Node[] nodes;
	foreach(i; 0 .. h * w){
		nodes ~= new Node(i, s[i]);
		}
	
	foreach(i, nd; nodes){
		if(i >= w) nd.join(nodes[i - w]);
		if(i % w > 0) nd.join(nodes[i - 1]);
	}
	debug writeln("nodes:", nodes);
	
	foreach(nd; nodes){
		nd.groupify(nd.id);
	}
	debug writeln("nodes:", nodes);
	
	long[] bcount, wcount;
	foreach(i; 0 .. h * w){
		bcount ~= 0;
		wcount ~= 0;
	}
	foreach(nd; nodes){
		if(nd.value == '#') bcount[nd.groupid] += 1;
		else wcount[nd.groupid] += 1;
	}
	debug writeln("bcount:", bcount);
	debug writeln("wcount:", wcount);
	
	
	long ans = 0;
	foreach(i; 0 .. h * w){
		ans += bcount[i] * wcount[i];
	}
	
	ans.writeln;
}


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

using namespace std;

#define ff first
#define ss second
#define pb push_back

using ll = long long;
using ii = pair<int, int>;

const int oo = 1e9;
const int N = 1e5 + 5;

int main(){
	int n;
	scanf("%d", &n);
	ii v[N];
	for(int i = 0; i < n; i++){
		scanf("%d", &v[i].ff);
		v[i].ss = i+1;
	}
	sort(v, v + n);
	for(int i = 0; i < n; i++){
		printf("%d%c", v[i].ss, i == n-1 ? '\n' : ' ');
	}
	return 0;
}


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

long n, d, a, x[200020], cumsum[200020];
pair<long, long> ps[200020];

int main() {
  cin >> n >> d >> a;
  for(int i = 0; i < n; ++i) {
    cin >> ps[i].first >> ps[i].second;
    x[i] = ps[i].first;
  }
  sort(ps, ps + n);
  sort(x, x + n);
  
  long ans = 0;
  for(int i = 0; i < n; ++i) {
    if (i > 0) cumsum[i] += cumsum[i - 1];
    ps[i].second -= cumsum[i];
    if (ps[i].second > 0) {
    int idx = upper_bound(x, x + n, ps[i].first + d * 2) - x;
    long tmp = (ps[i].second + a - 1) / a;
    cumsum[i] += tmp * a;
    cumsum[idx] -= tmp * a;
    ans += tmp;
    }
  }
  cout << ans;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int H, W, K; cin >> H >> W >> K;
    vector<string> c(H);
    rep(i, H) {
        cin >> c[i];
    }
    int mx = 1;
    rep(i, H+W) {
        mx *= 2;
    }
    int ans = 0;
    int tmp;
    for (int i = 0; i < mx; i++) {
        tmp = 0;
        for (int j = 0; j < H; j++) {
            if (i & (1<<j)) {
                for (int k = H; k < H+W; k++) {
                    if ((i & (1<<k)) && c[j][k-H] == '#') {
                        tmp++;
                    }
                }
            }
        }
        if (tmp == K) ans++;
    }
    cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
using ll = long long;
using namespace std;


int strr(string s, int n) {
	string ss;
	rep(i, n)ss += s;
	int cnt=0;
	for (int i = 1; i < ss.size(); i++) {
		if (ss[i - 1] == ss[i]) {
			ss[i] = '_';
			cnt++;
		}
	}
	return cnt;
}
int main() {
	string s;
	map<char, int>mp;
	ll k, cnt = 0;
	cin >> s >> k;
	ll slen = s.size();
	for (char c : s)mp[c]++;
	//if (slen == 1) {
	//	cout << k / 2 << endl;
	//	return 0;
	//}
	if (mp[s[0]] == slen) {
		cout << (slen * k) / 2 << endl;
		return 0;
	}
	ll dist = strr(s, 2) - strr(s, 1);
	cout << strr(s,1) + dist * (k - 1) << endl;
	return 0;
}


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

int n, m;
vector<int> G[10];
vector<bool> seen(10, false);

int dfs(int from, int now){
    seen[now]=true;
    bool all_visit=true;
    for(int i=0; i<n; ++i) if(!seen[i]) all_visit=false;
    if(all_visit){
        seen[now]=false;
        return 1;
    }

    int ret=0;
    for(auto to:G[now]){
        if(!seen[to] && to!=from) ret+=dfs(now, to);
    }

    seen[now]=false;
    return ret;
}

int main(){
    cin >> n >> m;
    for(int i=0; i<m; ++i){
        int a, b; cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    cout << dfs(-1, 0) << '\n';
    return 0;
}

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

vector<vector<pair<int, int>>> v;
vector<int> r;

void dfs(int i, int j, int d) {
  r[j] = d;
  for (auto e : v[j]) {
    if (e.first == i) continue;
    dfs(j, e.first, (d + e.second) % 2);
  }
}

int main() {
  int n;
  cin >> n;
  v = vector<vector<pair<int, int>>>(n);
  for (int i = 0; i < n - 1; i++) {
    int p, q, w;
    cin >> p >> q >> w;
    p--;
    q--;
    v[p].push_back({q, w});
    v[q].push_back({p, w});
  }
  r = vector<int>(n);
  dfs(0, 0, 0);
  for (auto e : r) cout << e << endl;
}


Measured memory_bytes: 8192
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 998244353;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	cout << (k % 2 == 0 ? a - b : b - a) << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp
ans = 0
(1...n).each do |i|
  former = s[0...i]
  latter_max = n - i
  trim_size = ans + 1
  tmp = 0
  while trim_size <= latter_max
    if former.include?(s[i, trim_size])
      tmp = trim_size
      trim_size += 1
    else
      break
    end
  end
  ans = tmp if ans < tmp
end
puts ans


Measured memory_bytes: 9400
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k; cin >> k;
  string s; cin >> s;
  if(s.size()<=k)
    cout << s;
  else{
    for(int i = 0; i < k; i++)
      cout << s.at(i);
    cout << "...";
  }
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
 
int main() {
    int n, k; cin >> n >> k;
    int h[100000];
    rep(i, n) cin >> h[i];
    int ans = 0;
    rep(i, n) {
        if(h[i] >= k){
            ans++;
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;

int n;
string s;
set<string> st;
set<string> st1,st2;

int main() {
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++) {
        string k = "";
        k += s[i];
        for (auto p:st2) {
            string tmp = p + k;
            st.insert(tmp);
        }
        for (auto p:st1) {
            string tmp = p + k;
            st2.insert(tmp);
        }
        st1.insert(k);
    }
    cout << st.size() << endl;
    return 0;
}


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

int main() { 
    int M[5];
    int maxW = 0;
    int lastM = 0;
    for (int i=0; i<5; i++) {
        cin >> M[i];
        int mod = M[i]%10;
        if (mod != 0) {
            if (10-mod > maxW) {
                lastM = i;
                maxW = 10-mod;
            }
        }
    }


    int T = 0;
    for (int i=0; i<5; i++) {
        if (i==lastM || M[i] %10 == 0) {
            T += M[i];
        } else {
            T += 10 * (M[i] / 10) + 10;
        }
    }

    cout << T << endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());;
        var A = new int[N+2];
        var inp =ReadLine().Split();
        for (int i = 0; i < N; i++)
        {
            A[i+1]=int.Parse(inp[i]);
        }
        var c=0;
        for (int i = 0; i < N; i++)
        {
            c+=Math.Abs(A[i+1]-A[i]);
        }
        c+=Math.Abs(A[N]);
        for (int i = 1; i <= N; i++)
        {
            if(A[i-1]<=A[i]&&A[i]<=A[i+1])WriteLine(c);
            else
            {
                WriteLine(c-Math.Abs(A[i+1]-A[i])-Math.Abs(A[i]-A[i-1])+Math.Abs(A[i+1]-A[i-1]));
            }
        }
    }
}

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

long long find_lb(long long a[], long long n, long long v) {
	if (a[0] >= v) return 0;
	if (a[n-1] < v) return n;
	long long l = 0, u = n;
	while(l + 1 < u) {
		long long t = (l + u) / 2;
		if (a[t] >= v) {
			u = t;
		} else {
			l = t;
		}
	}
	return u;
}

long long count_larger(long long a[], long long n, long long b) {
	long long r = 0;
	for(long long i = 0; i < n; i++) {
		long long m = find_lb(a, n, b - a[i]);
		// if not found in the range, returns n
		r += n - m;
	}
	return r;
}

long long sum_larger(long long a[], long long n, long long b) {
	long long sum = 0;
	for(long long i = 0; i < n; i++) {
		long long m = find_lb(a, n, b - a[i]);
		// if not found in the range, returns n
		sum += a[i] * (n - m);
	}
	return sum * 2;
}


	

int main(void) {
	long long n, m, a[100000];
	
	cin >> n >> m;
	for(long long i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);

	long long lb = 0, ub = a[n-1] * 2 + 1;
	long long c = n * n;
	while(lb + 1 < ub) {
		long long nb = (lb + ub) / 2;
		long long t = count_larger(a, n, nb);
		if (t >= m) {
			c = t;
			lb = nb;
		} else {
			ub = nb;
		}
	}
	long long res = sum_larger(a, n, lb) - (c - m) * lb;
	cout << res;
	return 0;
}

Measured memory_bytes: 1024
from functools import reduce
H, W =  map(int,input().split())
list1 = [input() for i in range(H)]
row_index = []
column_index =[]
[row_index.append(i) for i, elem in  enumerate(list1) if elem.count(".") < W]
[column_index.append(i) for i,elem in enumerate(zip(*list1)) if elem.count(".")<H]
for i in  row_index:
  for j in column_index:
    print(list1[i][j],end="")
  print("")


Measured memory_bytes: 42344
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a;
    string s, t;
    cin >> s >> t;
    if (s.length() + 1 != t.length()) {
        cout << "No" << endl;
    } else {
        for (lli i = 0; i < s.length(); i++) {
            if (s[i] != t[i]) {
                cout << "No" << endl;
                return;
            }
        }
    }
    cout << "Yes" << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 3652
h,w=map(int,input().split())
s=[input() for _ in range(h)]
v=[[1]*w for _ in range(h)]
q=[(0,0)]
dxy=((-1,0),(0,-1),(1,0),(0,1))
while q:
  x,y=q.pop()
  v[x][y]=0
  cnt=0
  for dx,dy in dxy:
    nx=x+dx
    ny=y+dy
    if not(0<=nx<h and 0<=ny<w) or s[nx][ny]=='.':continue
    elif v[nx][ny] and ((dx==-1 or dy==-1)or cnt):
      print('Impossible')
      exit()
    elif v[nx][ny] :
      q+=[(nx,ny)]
      cnt=1
print(['Possible','Impossible'][v[h-1][w-1]])

Measured memory_bytes: 62000
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>


using namespace std;


int main()
{
    vector<pair<int, int>> red;
    vector<pair<int, int>> blue;

    int N;
    cin >> N;

    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        red.push_back(make_pair(x, y));
    }
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        blue.push_back(make_pair(x, y));
    }

    sort(red.begin(), red.end(),
            [](pair<int, int> l, pair<int, int> r) { return l.second < r.second; });
    sort(blue.begin(), blue.end(),
            [](pair<int, int> l, pair<int, int> r) { return l.first < r.first; });

    int cnt = 0;
    for (auto b : blue) {
        pair<int, int> p;
        for (auto it = red.rbegin(); it != red.rend(); ++it) {
            if (it->first < b.first && it->second < b.second) {
                cnt++;
                it->first = it->second = 300;
                break;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
ab=[0]*N
for _ in range(M):
  a,b=map(int,input().split())
  ab[a-1]+=1
  ab[b-1]+=1
  
for i in range(N):
  if ab[i]%2==1:
    print("NO")
    exit()
print("YES")

Measured memory_bytes: 3828
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
L = sorted(readInts())
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        if L[i] == L[j]:
            continue
        for k in range(j+1,n):
            if L[j] == L[k]:
                continue
            if abs(L[i]-L[j]) < L[k] < L[i] + L[j]:
                ans += 1
print(ans)


Measured memory_bytes: 73068
def resolve():
    n = int(input())
    luca = [2, 1] + [0] * (n - 1)
    for i in range(2, n + 1):
        luca[i] = luca[i - 1] + luca[i - 2]
    print(luca[n])


if __name__ == "__main__":
    resolve()


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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i, k , n) for(int i = k; i <= n; i++)
typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int a, b;
   cin >> a >> b;
   ll n = b -a;
   cout << n*(n-1)/2 - a<< nl;
   return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    string s;
    cin >> s;
    bool ans = s[1] == s[2] && (s[0] == s[1] || s[2] == s[3]);

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<vector<int>> f(n, vector<int>(10, 0));
    vector<vector<int>> p(n, vector<int>(11, 0));

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

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

    ll ans = -(ll)MOD*10;
    rep1(i, (1<<10)-1){
        //営業パターン
        ll tans = 0;
        vector<int> mise_cnt(n, 0);
        for (int j = 0; j < 10; j++)
        {
            if ((i>>j)&1){
                for (int mise = 0; mise < n; mise++)
                {
                    if (f[mise][j] == 1) mise_cnt[mise]++;
                }
            }
        }
        for (int mise = 0; mise < n; mise++)
        {
            tans += p[mise][mise_cnt[mise]];
        }
        //cout << mise_cnt[0] << endl;
        //cout << i << " " << tans << endl;
        ans = max(tans, ans);
    }

    cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int a,b,c; cin>>a>>b>>c;
	a%=b;
	reps(i,b){
		if(i*a%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef enum { left, right } bool;


int trace(int N, int Q, char *s, char *s_t, bool *b_d, int origin, int dest, int l, int r)
{
    static int i;
    static int static_origin = -1000;
    static int index;
    
    
    if(l > r)
    {
        if(static_origin == -1000)
        {
            if(dest == N)
                return N;
            else
                return -1;
        }
        else
        {
            origin = static_origin;
            static_origin = -1000;
            
            return origin;
        }
    }
    else
    {
        index = origin;
        
        
        for(i=0; i<Q && index >= 0 && index < N; i++)
        {
            if(s_t[i] == s[index])
            {
                if(b_d[i] == left)
                {
                    index--;
                }
                else
                {
                    index++;
                }
            }
        }
        
        if(index == dest)
        {
            static_origin = origin;
        }
        
        if((dest == N && index < N) || (dest == -1 && index < 0))
        {
            return trace(N, Q, s, s_t, b_d, origin+(r-origin+1)/2, dest, origin+1, r);
        }
        else
        {
            return trace(N, Q, s, s_t, b_d, l+(origin-l)/2, dest, l, origin-1);
        }
    }
}

int main(void)
{
    int N, Q;
    char *s, *s_t;
    bool *b_d;
    int i;
    char t, d, c;
    int sum;
    
    
    scanf("%d%c%d", &N, &c, &Q);
    
    s = (char*)malloc(sizeof(char)*(N+1));
    
    s_t = (char*)malloc(sizeof(char)*Q);
    b_d = (bool*)malloc(sizeof(bool)*Q);
    
    
    sum = N;
    
    
    scanf("%s\n", s);
    
    
    for(i=0; i<Q; i++)
    {
        scanf("%c%c%c%c", &t, &c, &d, &c);
        
        
        s_t[i] = t;
        
        if(d == 'L')
        {
            b_d[i] = left;
        }
        else
        {
            b_d[i] = right;
        }
    }
    
    
    sum -= N-trace(N, Q, s, s_t, b_d, N/2, N, 0, N-1);
    sum -= trace(N, Q, s, s_t, b_d, N/2, -1, 0, N-1)+1;
    
    printf("%d\n", sum);
    
    
    free(s);
    free(s_t);
    free(b_d);
    
    
    //system("pause");
    
    
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+7
#define MOD 1000000007
using namespace std;



int main(){
    ll ans=0;
    
    string S;
    cin >> S;

    ll n=0;
//    そこより左にあるBの数
    for(int i=0; i<S.length(); i++){
        if(S[i]=='B'){
            n++;
        }else{
            ans+=n;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream> 
#include <cassert> 
#include <vector> 
#include <cmath> 
#include <ctime> 
#include <cstdlib> 
#include <fstream> 
#include <string> 
#include <sstream> 
#include <iterator> 
#include <map> 
#include <algorithm> 
#include <memory> 
#include <iomanip> 
#include <limits> 
#include <typeinfo> 
#include <queue> 

//------------------------

#include <stdio.h> 
#include <string.h> 


using namespace std;

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

    if(s>t){
        cout << ">" << endl;
    }else if(s<t){
        cout << "<" << endl;
    }else{
        cout << "=" << endl; 
    }

}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, K; cin >> N >> K;
  ll A[N]; rep(i,N) cin >> A[i];
  ll l = 1, r = pow(10,9);
  while (l!=r) {
    ll mid = (l+r)/2;
    ll count = 0; rep(i,N) count += (A[i]-1)/mid;
    if (count>K) l = mid+1;
    else r = mid;
  }
  ll result = l;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 5136