akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int a = 0, b = 0, c = 0;
    for (int i = 0; i < S.length(); i++) {
      char x = S.charAt(i);
      if (x == 'a') a++;
      if (x == 'b') b++;
      if (x == 'c') c++;
    }
    if (Math.max(Math.max(a,b),c)-Math.min(Math.min(a,b),c) <= 1) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    } 
  }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){
  
  int k,a,b;
  cin >> k >> a >> b;
  bool is = false;
  for(int i = a;i <= b;i++)  {
    if((i%k) == 0)is = true;
  }
  if(is)cout << "OK" << endl;
  else cout << "NG" << endl;

  
  


  

  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int s = 2e9;
    rep(i,n){
        int c = 0;
        int b = a[i];
        while(b%2 == 0){
            b /= 2;
            c++;
        }
        s = min(s,c);
    } 
    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100010
int main(){
  int n,m,h[N],ma[N];
  //入力
  cin>>n>>m;
  //展望台1から入力
  for(int i=1;i<=n;i++) {
    cin>>h[i];
    ma[i]=0;//0に初期化
  }
  
  for(int i=0;i<m;i++) {
    int a,b;
    cin>>a>>b;
    ma[a]=max(ma[a],h[b]);//aと繋がっている展望台の標高の最大値
    ma[b]=max(ma[b],h[a]);//bと繋がっている展望台の標高の最大値
  }
  
  int ans=0;
  for(int i=1;i<=n;i++) {
    if(h[i]>ma[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4416
data = input().split()
N = int(data[0])
K = int(data[1])
 
TL = list(input())
TLlist = []
TLLlist = []
now = TL[0]
nowlist = now
anslist = []
 
for lop in range(1,len(TL)):
    if not (now == TL[lop]):
        TLlist.append(nowlist)
        TLLlist.append(len(nowlist))
        nowlist = TL[lop]
        now = TL[lop]
    else:
        nowlist += now
TLlist.append(nowlist)
TLLlist.append(len(nowlist))
 
 
if TLlist[0][:1] == "0" :
    anslist.append( sum(TLLlist[:2*K]) )
    anslist.append( sum(TLLlist[1:2*K + 2]) )
    for lop in range(3,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
elif TLlist[0][:1] == "1" :
    anslist.append( sum(TLLlist[:2*K + 1 ]) )
    for lop in range(2,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
 
print(max(anslist))

Measured memory_bytes: 6908
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
//#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200000];
vll v;
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            v.push(p);
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[60];
void power()
{
    powe[0]=1;
    REP(i,1,15)
    {
        powe[i]=2*powe[i-1];
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll fact[100005];
void factorial()
{
    fact[0]=1;
    REP(i,1,100002)
    {
        fact[i]=mymod(i*fact[i-1], num);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    if(n<m)
    {
        REP(i,0,m)
        {
            cout<<n;
        }
    }
    else
    {
        REP(i,0,n)
        {
            cout<<m;
        }
    }
	return 0;
}

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

int main(){
    int h1, m1, h2, m2, k;
    cin >>  h1 >> m1 >> h2 >>  m2 >> k;
    int hm1 = h1*60 + m1;
    int hm2 = h2*60 + m2;

    cout << hm2 -hm1-k  << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <math.h>
#define mod 1000000007
typedef long long ll;
ll pow_mod(int a,int n){
	if(n==0) return 1;
	int x = pow_mod(a,n/2);
	ll ans = (ll)x*x%mod;
	if(n%2==1) ans =ans*a%mod;
	return ans;
}
int main(){
	int m,n,i;
	long long sum;
	scanf("%d %d",&m,&n);
	sum = pow_mod(m,n);
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 
int N;
vector<string> W(101);
map<string, int> mp;

int main(void){
	
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) cin >> W[i];
	
	char last = W[0][0];
	for(int i = 0; i < N; ++i){
	    auto itr = mp.find(W[i]);
	    if(itr != mp.end()){
	        printf("No\n");
	        return 0;
	    }
	    else ++mp[W[i]];
	    
	    if(last != W[i][0]){
	        printf("No\n");
	        return 0;
	    }
	    else last = W[i].back();
	}
	printf("Yes\n");
	
    return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] str = Console.ReadLine().Split(' ');

            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);

            Console.WriteLine(a * b+" "+(a + b) * 2);



        }
    }
}


Measured memory_bytes: 13836
#include<iostream>
#include<vector>
#include<algorithm>

#define all(c) (c).begin(),(c).end()

using namespace std;

vector<int>w;

bool fg[2000000];

void sieve(void){
  w.clear();
  w.push_back(-1);

  fill(fg,fg+2000000,false);
  for(int i=2;i*i<2000000;i++){
    if(!fg[i]){
      w.push_back(i);
      for(int j=i*2;j<2000000;j+=i){
        fg[j]=true;
      }
    }
  }
}

int dp[20][300][1130];

int main(void){

  int K,n;

  sieve();

  while(cin >> n >> K,n|K){
    fill(*dp[0],*dp[20],0);
    dp[0][0][0]=1;

    int ans=0;
    int sz=(int)(upper_bound(all(w),n)-w.begin());
    for(int i=0;i<K;i++){
      for(int j=0;j<sz;j++){
        for(int k=0;k<=n;k++){
          for(int l=j+1;l<sz;l++){
            if(k+w[l]<=n){
              dp[i+1][l][k+w[l]]+=dp[i][j][k];
            }
          }
        }
      }
    }

    for(int i=0;i<sz;i++)ans+=dp[K][i][n];

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 29652
package main

import "fmt"

func main() {
	var n, tmp, last int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)
		if tmp == last+1 {
			last += 1
		}
	}
	if last == 0 {
		fmt.Printf("%d", -1)
	} else {
		fmt.Printf("%d", n-last)
	}
}


Measured memory_bytes: 5504
#include <stdio.h>
#include <limits.h>

using namespace std;

int main(){
	int n,tmp,min=INT_MAX,max=INT_MIN;
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d",&tmp);
		if(max < tmp-min) max = tmp - min;
		if(min > tmp) min = tmp;
	}
	printf("%d\n",max);
	return 0;
}



Measured memory_bytes: 2768
#include<stdio.h>

#define N 101

static int MAX = 500;
static int INFTY = (1<<21);

main(){
  int n, i, j, e, v,c=0,k=0;
  int u = 0, mincost = 0;
  int cost[N];
  int d[N];
  int p[N], M[N][N];
  
  //input
  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }
  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;
    }
  }
  
  //calc
  for(i = 0; i < n; i++){
    d[i] = INFTY;
    p[i] = -1;
    cost[i] = 0;
  }
  
  d[0] = 0;
  
  while(1){
    u = -1;
    mincost = INFTY;
    
    for(i = 0; i < n; i++){
      if(d[i] < mincost && cost[i] == 0){
	mincost = d[i];
	u = i;
      }
    }
    
    if(u == -1){
      break;
    }
    cost[u] = 1;
    
    for(v = 0; v < n; v++){

      if(d[v] > d[u]+M[u][v]){
	p[v] = u;
	d[v] = d[u]+M[u][v];
      }

    }
  }//end ehile
  
  //out
  for (i = 0; i < n; i++){
    printf("%d %d\n", i, (d[i] == INFTY ? -1 : d[i]));
  }
  
  return 0;
}

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

int main(){
  int n, k;
  int _min;
  cin >> n >> k;
  vector<int> h(n);
  vector<int> dp(n);

  for (int i = 0; i<n; i++) {
    cin >> h.at(i);
  };
  if(n<=k+1){
    cout<<abs(h.at(n-1)-h.at(0))<<endl;
  }else{
    for(int i=0;i<=k;i++){
      dp.at(i)=abs(h.at(i)-h.at(0));
    };
    for(int g=k+1;g<n;g++){
      _min=999999999;
      for(int l=g-k;l<g;l++){
        _min=min(_min, dp.at(l)+abs(h.at(g)-h.at(l)));
      }
      dp.at(g)=_min;
    };
    cout<<dp.at(n-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <queue>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

#if __has_include("debugger.cpp")
  #include "debugger.cpp"
#else
void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) > 0) cout << " ";
  print(std::forward<Tail>(tail)...);
}
# endif

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  ll input(v, e, r);
  struct Node {
    ll to, cost;
  };
  vector<vector<Node>> graph(v);
  REP(i, e) {
    ll input(s, t, d);
    graph[s].push_back({t, d});
  }

  auto comp = [](Node& v1, Node& v2) {
    return v1.cost > v2.cost;
  };
  priority_queue<Node, vector<Node>, decltype(comp)> que{comp};
  vector<ll> visited(v, -1);
  que.push({r, 0});
  while (!que.empty()) {
    Node node = que.top();
    que.pop();
    if (visited[node.to] != -1) continue;
    visited[node.to] = node.cost;

    for (auto v: graph[node.to]) {
      que.push({v.to, node.cost + v.cost});
    }
  }

  for (auto v: visited) {
    if (v == -1) print("INF");
    else print(v);
  }
}



Measured memory_bytes: 21520
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long
int inf = (1LL <<  62);
using namespace std;

signed main(){
    int n, m;
    cin >> n >> m;
    int a[m];
    int b[m];
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
    }
    sort(a, a+m);
    sort(b, b+m);
    if(b[0] - a[m - 1] < 0){
        cout << 0;
        exit(0);
    }else{
        cout << b[0] - a[m - 1] + 1;
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream&o,const pair<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
mt19937 rnd(random_device{}());

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
V<ll>fac,rfac; void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}

ll randInt(ll l,ll r){return uniform_int_distribution<ll>(l,r)(rnd);}
double randDouble(double l,double r){return uniform_real_distribution<double>(l,r)(rnd);}
void dout(double d){printf("%.12f\n",d);}

const double PI = acos(-1);
const double EPS = 1e-10;
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;

const int N = 1e5;
int n;
map<int, int> c;
map<int, int>::iterator i1, i2, i3;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int a;
    cin >> a;
    c[a]++;
  }
  switch(sz(c)){
    case 1:
      cout << (c[0] ? "Yes" : "No");
      break;
    case 2:
      cout << (c[0]*2==c.rbegin()->se ? "Yes" : "No");
      break;
    case 3:
      i1=c.begin(), i2=c.begin(), i3=c.begin();
      i2++;
      i3++; i3++;
      cout << ((i1->fi^i2->fi)==i3->fi && i1->se==i2->se && i2->se==i3->se ? "Yes" : "No");
      break;
    default:
      cout << "No";
      break;
  }
  cout << endl;
}

Measured memory_bytes: 3840
from fractions import gcd


def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x


N = int(input())
T = [int(input()) for _ in range(N)]

ans = lcm(T)

print(ans)

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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define pf push_front
#define pii pair <int ,int>
#define all(s) s.begin (), s.end ()
#define int long long

using namespace std;

const int N = 1e5 + 5;

int n, ar[N], pref[N];

main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        scanf("%lld", &ar[i]);

    sort(ar + 1, ar + n + 1);

    for (int i = 1; i <= n; i++)
        pref[i] = ar[i] + pref[i - 1];

    for (int i = n - 1; i >= 0; i--)
    {
        if (pref[i] * 2 < ar[i + 1])
        {
            cout << n - i;
            return 0;
        }
    }

}


Measured memory_bytes: 1920
f=lambda:map(int,input().split())
n,m=f()
p=[-1]*n
def root(x):
  while p[x]>=0: x=p[x]
  return x
def unite(x,y):
  x,y=root(x),root(y)
  if x==y: return
  if x>y: x,y=y,x
  p[x]+=p[y]
  p[y]=x
for i in range(m):
  a,b=f()
  unite(a-1,b-1)
print(-min(p))

Measured memory_bytes: 16788
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long inf = 1LL<<50;

int main() {
  int N, M; cin >> N >> M;
  long long dist[1010];
  vector<int> a(M), b(M);
  vector<long long> c(M);
  for(int i = 0; i < M; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    c[i] = -c[i];
  }

  for(int i = 0; i < N; ++i) dist[i] = inf;
  dist[0] = 0;

  for(int loop = 0; loop < N-1; ++loop) {
    for(int i = 0; i < M; ++i) {
      if(dist[a[i]] == inf) continue;
      if(dist[b[i]] > dist[a[i]] + c[i]) {
        dist[b[i]] = dist[a[i]]  + c[i];
      }
    }
  }
  long long ans = dist[N-1];
  bool navigate[1010];
  for(int i = 0; i < N; ++i) {
    navigate[i] = false;
  }

  for(int loop = 0; loop < N; ++loop) {
    for(int i = 0; i < M; ++i) {
      if(dist[a[i]] == inf) continue;

      if(dist[b[i]] > dist[a[i]] + c[i]) {
        dist[b[i]] = dist[a[i]] + c[i];
        navigate[b[i]] = true;
      }
      if(navigate[a[i]]) navigate[b[i]] = true;
    }
  }

  if(navigate[N-1]) cout << "inf" << endl;
  else cout << -ans << endl;
  return 0;
}


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

 int  main() {
     
      int n;
     cin>>n;
     int a[n];
     for(int i=0;i<n;i++){
         cin>>a[i];
     }
     sort(a,a+n);
     
     int min=INT_MAX;
     for(int i=a[0];i<=a[n-1];i++){
         int sum=0;
         for(int j=0;j<n;j++){
          sum=sum+((a[j]-i)*(a[j]-i));
         }
         if(sum<min){
             min=sum;
             
         }
     }
     cout<<min<<endl;
     
return 0;
}

Measured memory_bytes: 256
import itertools
import math
def dist(i, j):
    return math.sqrt((coords[i][0] - coords[j][0]) ** 2 + (coords[i][1] - coords[j][1]) ** 2)

n = int(input())
coords = [tuple(map(int, input().split())) for _ in range(n)]

ans = []
for item in itertools.permutations(range(n)):
    length = 0
    for i in range(n-1):
        length += dist(item[i], item[i+1])
    ans.append(length)
print(sum(ans) / len(ans))


Measured memory_bytes: 43628
def main():
    from itertools import accumulate as ac
    n,c=map(int,input().split())
    xv=[list(map(int,input().split())) for _ in [0]*n]
    rmemo=[0]*n
    lmemo=[0]*n
    rmemo[0]=xv[0][1]-xv[0][0]
    lmemo[n-1]=xv[n-1][1]-(c-xv[n-1][0])
    for i in range(1,n):
        rmemo[i]=rmemo[i-1]+xv[i][1]-xv[i][0]+xv[i-1][0]
    for i in range(n-2,-1,-1):
        lmemo[i]=lmemo[i+1]+xv[i][1]+xv[i][0]-xv[i+1][0]
    temp=rmemo[0]
    rmemo2=[temp]*(n)
    temp=lmemo[-1]
    lmemo2=[temp]*(n+1)
    lmemo2[-1]=0
    for i in range(1,n):
        rmemo2[i]=max(rmemo[i],rmemo2[i-1])
    for i in range(n-2,-1,-1):
        lmemo2[i]=max(lmemo[i],lmemo2[i+1])
    rmemo2=[0]+rmemo2
    ans=max(rmemo+lmemo+[0])
    for i in range(n):
        ans=max(ans,rmemo[i]+lmemo2[i+1]-xv[i][0])
        ans=max(ans,lmemo[i]+rmemo2[i]+xv[i][0]-c)
    print(ans)
main()

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

int main()
{
    long long int n;
    cin>>n;
    vector<long long int> a(n);
    for (int i=0;i<n;i++){
        cin>>a.at(i);
    }
    priority_queue<long long int,vector<long long int>,less<long long int>> q;
    for (int i=0;i<n;++i){
        q.push(a.at(i));
    }
    long long int ans=q.top();
    q.pop();
    n-=2;
    while(n>1){
        int tmp=q.top();
        ans+=2*tmp;
        q.pop();
        n-=2;
    }
    if(n==1){
        ans+=q.top();
        q.pop();
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 6928
// Problem : A - Registration
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//look at my code
//my code is amazing
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007 //998244353
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define nl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<nl
#define cout2(a,b) cout<<a<<" "<<b<<nl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<nl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<nl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<nl
#define x first
#define y second
#define vc vector
#define pb push_back
#define ar array
#define all(a) (a).begin(), (a).end()
#define ms(v,n,x) fill(v,v+n,x);
#define init(c,a) memset(c,a,sizeof(c))
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define inf 9e18
#define cases ll T;cin>>T;while(T--)
#define BLOCK 500
//const double PI = 3.141592653589793238460;
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
// const int N=;

int32_t main()
{
    
	fast
	
	string s,t;
	cin>>s>>t;
	ll n=s.size();
	f(i,n){
		if(s[i]!=t[i]){
			puts("No");
			return 0;
		}
	}
	
	puts("Yes");
	

	



    

	return 0;
    
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = res * a;
      a = a * a;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("inn.txt","r",stdin);
  freopen("ouut.txt","w",stdout);
  #endif
}

int main()
{
  fast_io
  go();
  
    int n,k;cin>>n>>k;
    if(500*n>=k)
      cout << "Yes" <<"\n";
    else
      cout <<"No" <<"\n";

}



Measured memory_bytes: 3656
#include <iostream>
using namespace std;
typedef long long LL;

LL i, j, k;
LL a, b, c;

void solve(LL n) {
    for (i = 1; i <= 5000; i++) {
        for (j = 1; j <= 5000; j++) {
            LL tmp1 = i+j;
            LL tmp2 = i*j;
            k = 4*tmp2 - n*tmp1;
            if (k > 0 && n*tmp2%k==0) {
                k = n*tmp2/k;
                a = i;
                b = j;
                c = k;
            }
        }
    }
}

int main() {
//    freopen("test.txt", "r", stdin);
    int n;
    cin >> n;
    solve(n);
    cout << a << ' ' << b << ' ' << c << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
   int N;
   std::cin >> N;
   int A;
   std::vector<std::pair<int,int> > v;
   for(int i=0; i<N; ++i) {
      std::cin >> A;
      v.push_back(std::make_pair(A,i+1));
   }
   std::sort(v.begin(),v.end());

   for(int i=0; i<N; ++i){
      std::cout << v[i].second << std::endl;
   }
   return 0;
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
using namespace std;
using ll = unsigned long long;
using p = pair<int, int>;

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

    rep(i, 1, 11)
    {
        const int pay = 1000 * i;
        if (pay >= N)
        {
            cout << pay - N << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
int main(){
  string s;
  int r;
  cin>>s;
  bool resu = true;
  if(s.size()%2!=0){
    resu = false;
  }
  else{
    r = s.size()/2;
    int count = 0;
    for(int i = 0;count<r;i=i+2){
      string H = s.substr(i,1);
      string I = s.substr(i+1,1);
      if(H=="h"&&I=="i"){

      }
      else {
        resu=false;
      }
      count++;
    }
  }
  if(resu){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }

  
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n; cin >> n;
    int a=0,b=0,c=0;
    bool ok = false;
    rep(i,0,n){
        ll tmp; cin >> tmp;
        if(tmp%4==0) a++;
        else if(tmp%2==0) b++;
        else c++;
    }
    if(b>1){
        if(a>=c) ok = true;
    }else{
        if(a>=c+b-1) ok = true;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define int long long

#define ll long long
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int mod = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
struct Sieve {
	int n;
	vector<int> f, primes;
	// n以下の素数を列挙する
	Sieve(int n = 1) :n(n), f(n + 1) {
		f[0] = f[1] = -1;
		for (ll i = 2; i <= n; ++i) {
			if (f[i]) continue;
			primes.push_back(i);
			f[i] = i;
			for (ll j = i * i; j <= n; j += i) {
				if (!f[j]) f[j] = i;
			}
		}
	}
	// xが素数かどうか判定する
	bool isPrime(int x) { return f[x] == x; }
	// 素因数を全列挙
	vector<int> factorList(int x) {
		vector<int> res;
		while (x != 1) {
			res.push_back(f[x]);
			x /= f[x];
		}
		return res;
	}
	// ランレングス圧縮
	vector<P> factor(int x) {
		vector<int> fl = factorList(x);
		if (fl.size() == 0) return {};
		vector<P> res(1, P(fl[0], 0));
		for (int p : fl) {
			if (res.back().first == p) {
				res.back().second++;
			}
			else {
				res.emplace_back(p, 1);
			}
		}
		return res;
	}
};
bool tmp[1000010];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll n; cin >> n;
	Sieve s(1000010);
	vector<ll>a(n); rep(i, n)cin >> a[i];
	set<int>st; rep(i, n)st.insert(a[i]);
	rep(i, n)tmp[a[i]] = true;
	bool ok = true;
	if (st.size() == 1 && a[0] != 1)ok = false;
	for (auto i : s.primes) {
		ll cnt = 0;
		for (int j = i; j <= 1000010; j += i) {
			if (tmp[j]) {
				cnt++;
			}
		}
		if (cnt > 1) {
			ok = false; break;
		}
	}
	
	bool ok2 = true;
	
	ll now = 0;
	rep(i, n) {
		now = gcd(now, a[i]);
	}
	if (now != 1)ok2 = false;
	if (ok) {
		cout << "pairwise coprime" << endl;
	}
	else if (ok2) {
		cout << "setwise coprime" << endl;
	}
	else {
		cout << "not coprime" << endl;
	}
	return 0;
}

Measured memory_bytes: 67228
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back


int n;
vector<int> a;
void solve()
{
    cin>>n;
    a.resize(n);
    forn(i, n) cin>>a[i];
    int now = 0;
    int ans = 0;
    forn(i, n)
    {
        if (now <= a[i])
        {
            now = a[i];
            continue;
        }
        ans += now - a[i];
    }
    cout << ans << '\n';
}
signed main(void)
{
    int T = 1;
    // cout << fixed;
    // cout.precision(44);
    ios_base::sync_with_stdio(0); cin.tie(0);
    //cin >> T;
    while (T--) solve();
    return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	vector<vector<int>> T(N+1, vector<int> (3, 0));
	for (int i=1; i<=N; i++)
		for (int j=0; j<3; j++)
			cin >>T.at(i).at(j);
	for (int i=1; i<=N; i++) {
		int t=T.at(i).at(0)-T.at(i-1).at(0);
		int x=T.at(i).at(1)-T.at(i-1).at(1);
		int y=T.at(i).at(2)-T.at(i-1).at(2);
		int d=abs(x)+abs(y);
		if (d>t) {
			cout <<"No" <<endl;
			return 0;
		}
		if (0!=(t-d)%2) {
			cout <<"No" <<endl;
			return 0;
		}
	}
	cout <<"Yes" <<endl;
	return 0;
}



Measured memory_bytes: 5760
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define BUFSIZE 1000000

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

int main(void){
int N;
  scanf("%d",&N );
 for(int i = 1;;i++){
   if(1000*i  >= N){
     printf("%d",1000*(i) - N);
     exit(0);
   }
 }


/*
  qsort(a, n, sizeof(int), compare_int);
*/
}


Measured memory_bytes: 1732
import os,io
import sys
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
r,c,k=map(int,input().split())
dp = [0]*(r*c*4)
m=[]
for i in range(r):
  m.append([])
  for j in range(c):
    m[i].append(0)
for i in range(k):
  ri,ci,v=map(int,input().split())
  m[ri-1][ci-1]=v
dp[0*r*c+0*c+0]=0
dp[1*r*c+0*c+0]=m[0][0]
dp[2*r*c+0*c+0]=m[0][0]
dp[3*r*c+0*c+0]=m[0][0]
for i in range(r):
  for j in range(c):
    if j+1<c:
      dp[0*r*c+i*c+j+1]=max(dp[0*r*c+i*c+j+1],dp[0*r*c+i*c+j])
      dp[1*r*c+i*c+j+1]=max(dp[1*r*c+i*c+j],max(dp[1*r*c+i*c+j+1],dp[0*r*c+i*c+j]+m[i][j+1]))
      dp[2*r*c+i*c+j+1]=max(dp[2*r*c+i*c+j],max(dp[2*r*c+i*c+j+1],dp[1*r*c+i*c+j]+m[i][j+1]))
      dp[3*r*c+i*c+j+1]=max(dp[3*r*c+i*c+j],max(dp[3*r*c+i*c+j+1],dp[2*r*c+i*c+j]+m[i][j+1]))
    if i+1<r:
      dp[0*r*c+(i+1)*c+j]=dp[3*r*c+i*c+j]
      dp[1*r*c+(i+1)*c+j]=dp[3*r*c+i*c+j]+m[i+1][j]
      dp[2*r*c+(i+1)*c+j]=dp[3*r*c+i*c+j]+m[i+1][j]
      dp[3*r*c+(i+1)*c+j]=dp[3*r*c+i*c+j]+m[i+1][j]
print(dp[3*r*c+(r-1)*c+c-1])
    

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

int main(){
  int N;
  cin >> N;
  int ac=0,wa=0,tle=0,re=0;
  for(int i=0; i<N; i++){
    string s;
    cin >> s;
    if(s == "AC") ac++;
    if(s == "WA") wa++;
    if(s == "TLE") tle++;
    if(s == "RE") re++;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}

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

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

	int digit = log10(n)+1;
	int ans = 0;
	int num = 1;

	if (digit % 2 == 0) {
		for (int i = 0; i < digit; i+=2) {
			ans += 9*num;
			num *= 100;
		}
	} else {
		for (int i = 0; i < digit-1; i+=2) {
			ans += 9*num;
			num *= 100;
		}
		ans += n - num + 1;
	}


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

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

#define N 1299709

int main(void){
	vector<bool> isprime(N+1);
	for(int i=0;i<isprime.size();i++) isprime[i]=true;
	int upto = (int)sqrt(isprime.size());
	isprime[1]=false;
	for(int i=2;i<=upto;++i){
		if(isprime[i]){//消されてなければその倍数を消す
			for(int j=2;i*j<isprime.size();++j) isprime[i*j] = false;
		}
	}
	int n;
	while(cin>>n,n){
		int min=2,max=N;
		for(int i=0;n-i>1;++i) if(isprime[n-i]){min=n-i;break;}
		for(int i=0;n+i<=N;++i) if(isprime[n+i]){max=n+i;break;}
		cout<<max-min<<endl;
	}
	return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,g,ans=114514,tmp,cnt,cnt2,point;
  bool f=true;
  cin >> n >> g;
  long long a[n],b[n],bit[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i=0;i<pow(2,n);i++){
    tmp=i;cnt=0;cnt2=0;point=0;f=true;
    for(int j=0;j<n;j++){
      bit[j]=tmp%2;
      tmp/=2;
      if(bit[j]==1){
        cnt+=a[j];
        point+=a[j]*100*(j+1)+b[j];
      }
    }
    if(point<g){
      for(int j=n-1;j>=0;j--){
        if(bit[j]==0){
          if(a[j]*100*(j+1)+b[j]+point<g){
            f=false;
            break;
          }
          while(point<g){
            point+=100*(j+1);
            cnt2++;
            if(cnt2==a[j]){
              point+=b[j];
            }
          }
          cnt+=cnt2;
          break;
        }
      }
    }
    if(f)ans=min(ans,cnt);
  }
  cout << ans << endl;
  return 0;
}  

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n;
int t[3];
vector<int> ans;
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>t[i];
  if(n==2)t[2]=t[1];
  sort(t,t+3);
  for(int i=1;i*i<=t[0];i++){
    if(t[0]%i!=0)continue;
    if(t[1]%i==0&&t[2]%i==0)ans.push_back(i);
    if(i*i==t[0])continue;
    int a=t[0]/i;
    if(t[1]%a==0&&t[2]%a==0)ans.push_back(a);
  }
  sort(ans.begin(),ans.end());
  for(int i=0;i<(int)ans.size();i++)cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 1220
from fractions import gcd

N, M = map(int, input().split())
S = list(input())
T = list(input())

n = gcd(N, M)
#最小公倍数xを求める
x = N * M // n


flag = True
for i in range(n): #重なるのはgcdの個数分だけ
    # print (i)
    # print (i * x // M, i * x // N)
    if S[i * x // M] == T[i * x // N]:
        pass
    else:
        flag = False
        break

if flag:
    print (x)
else:
    print (-1)

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

int main() {
	int N;
	cin >> N;
	vector<int> vec(N);
	for (int i = 0; i < N; i++)
		cin >> vec.at(i);
	sort(vec.begin(), vec.end());
	int distance = 0;
	int tmp = 0;
	for (int i = vec.at(0); i <= vec.at(N - 1); i++) {
		tmp = 0;
		if (i == vec.at(0)) {
			for (int j = 0; j < N; j++)
				distance += pow(vec.at(j) - i, 2);
		}
		else {
			for (int j = 0; j < N; j++)
				tmp += pow(vec.at(j) - i, 2);
			distance = min(distance, tmp);
		}
	}
	cout << distance << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N, h[200001];
	long long C;
	scanf("%d %lld", &N, &C);
	for (i = 1; i <= N; i++) scanf("%d", &(h[i]));
	
	int j, k, l[2] = {1, 2}, r[2] = {1, 2}, L, R, M;
	long long dp[200001] = {0, 0, (long long)(h[2] - h[1]) * (h[2] - h[1]) + C}, tmp;
	for (i = 3; i <= N; i++) {
		if (r[0] - l[0] > 1000) {
			L = l[0];
			R = r[0];
			while (L < R) {
				M = (L + R) / 2;
				if (dp[M] + (long long)(h[i] - h[M]) * (h[i] - h[M]) > dp[M+1] + (long long)(h[i] - h[M+1]) * (h[i] - h[M+1])) L = M + 1;
				else R = M;
			}
			dp[i] = dp[L] + (long long)(h[i] - h[L]) * (h[i] - h[L]) + C;
		} else {
			for (j = l[0], dp[i] = (long long)1 << 60; j <= r[0]; j++) {
				tmp = dp[j] + (long long)(h[i] - h[j]) * (h[i] - h[j]) + C;
				if (tmp < dp[i]) dp[i] = tmp;
			}
		}
		
		L = l[1];
		R = r[1];
		while (L < R) {
			M = (L + R) / 2;
			if (dp[M] + (long long)(h[i] - h[M]) * (h[i] - h[M]) > dp[M+1] + (long long)(h[i] - h[M+1]) * (h[i] - h[M+1])) L = M + 1;
			else R = M;
		}
		if (dp[L] + (long long)(h[i] - h[L]) * (h[i] - h[L]) + C <= dp[i]) {
			dp[i] = dp[L] + (long long)(h[i] - h[L]) * (h[i] - h[L]) + C;
			l[0] = l[1];
			r[0] = r[1];
			l[1] = i;
			r[1] = i;
		} else r[1]++;
	}
	
	printf("%lld\n", dp[N]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 4072
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;

	string ret;
	if(a+b==c || a+c==b || b+c==a)
		ret = "Yes";
	else
		ret = "No";

	cout << ret << endl;

	return 0;
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<unsigned long long int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    for (int i = k; i < n; i++)
    {
        if (a[i - k] < a[i])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4840
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC061
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (a<=c && c<=b)
            {
                Console.WriteLine("Yes");
            }
        else 
            {
                Console.WriteLine("No");
            }

            Console.ReadKey(); 
            

        }

        }
    }


Measured memory_bytes: 11092
#include<bits/stdc++.h>
 #define ll long long
 #define ii pair<int,int>
 #define endl '\n'
using namespace std;
int inf = 1e9;
void q() { cout << -1 << endl; }

int pc(int n)
{
    int r=0;
    while(n)
    {
        r += n%2;
        n/=2;
    }
    return r;
}
void solve(){

    int dp[300001] = {0,};
    for(int i=1; i<=300000; i++)
        dp[i] = dp[i%pc(i)] + 1;

    int n;
    cin >> n;
    string s;
    cin >> s;

    int rem1 = 0;
    int rem2 = 0;
    int bits = 0;

    int ten1[n];
    int ten2[n];
    for(int i=0; i<s.size(); i++)
        if(s[i] == '1')
            bits++;
        
    int div1 = bits+1;
    int div2 = bits-1;

    for(int i=n-1, r=1; i>=0; i--)
    {
        ten1[i] = r;
        rem1 = (rem1+r*(s[i]=='1'))%div1;
        r = (r*2)%div1;
    }

    if(div2>0)
    {
        for(int i=n-1, r=1; i>=0; i--)
        {
            ten2[i] = r;
            rem2 = (rem2+r*(s[i]=='1'))%div2;
            r = (r*2)%div2;
        }
    }
    for(int i=0; i<n; i++)
    {
        if(s[i]=='1')
        {
            if(div2==0)
                cout << 0 << endl;
            else
            {
            ll t = (rem2 - ten2[i]+div2)%div2;
            cout << dp[t]+1 << endl;
            }
        }
        else
        {
            ll t = (rem1 + ten1[i]+div1)%div1;
            cout << dp[t]+1 << endl;
        }
    }
}
 
int main(){

/* 
    int t;
    cin >> t;
    for(int i=1; i<=t; i++) */
        solve();
}

Measured memory_bytes: 6492
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
using namespace std;

int main(){
  int n,k;
  string s;
  cin>>n>>k;
  cin>>s;
  for(int i=0;i<n;i++){
    if(i==k-1){
      if(s[i]=='A') s[i]='a';
      if(s[i]=='B') s[i]='b';
      if(s[i]=='C') s[i]='c';
    }
    cout<<s[i];
  }
  return 0;
}

Measured memory_bytes: 256
s1=int(input())
s2=int(input())
s3=int(input())
s4=int(input())
s5=int(input())
s6=int(input())
s7=int(input())
s8=int(input())
s9=int(input())
s10=int(input())

total=0
total+=s1
total+=s2
total+=s3
total+=s4
total+=s5
total+=s6
total+=s7
total+=s8
total+=s9
total+=s10

print(total)


Measured memory_bytes: 5588
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i, n) {
        cin >> p[i];
        q[i] = p[i];
    }
    sort(ALL(q));
    int ans = 0;
    rep(i, n) {
        if(p[i] != q[i]) ans++;
    }
    if(ans == 0 || ans == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
//ALL GLORY TO JESUS CHRIST 
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;

#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n-1); i>=0; --i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    int n;  cin >> n;
    string s; cin >> s;
    char lst = '.';
    int res = 0;
    forn(i, n) {
        if(s[i] == lst) continue;
        lst = s[i];
        ++res;
    }
    cout << res << "\n";
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

struct UnionFind{
    vector<int> r;

    UnionFind(int N){
        r = vector<int>(N,-1);
    }
    
    int root(int x) {
		if (r[x] < 0) return x;
		return r[x] = root(r[x]);
	}
 
	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (r[x] > r[y]) swap(x, y);
		r[x] += r[y];
		r[y] = x;
		return true;
	}
 
	int size(int x) {
		return -r[root(x)];
	}
};
 
 
int main() {
	int N, M;
	cin >> N >> M;
	
	//友達集合を作る
	UnionFind UF(N);//初期化
	for (int i = 0; i < M; i++)
	{
		int A, B;
		cin >> A >> B;
		A -= 1; B -= 1;//0インデックスにする
		UF.unite(A, B);
	}
 
	//最大の友達集合を求める
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans = max(ans, UF.size(i));
	}
 
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    ll n,m;cin>>n>>m;
    vll a(m), b(m);
    rep(i, m)cin>>a[i]>>b[i];
    vll ans(m);
    ll now = n*(n-1)/2;
    UnionFind uf = UnionFind(n);


    rep(i, m){
        ans[m-1-i] = now;
        if(uf.issame(a[m-1-i]-1, b[m-1-i]-1)){

        }else{
            now -= uf.size(a[m-1-i]-1)*uf.size(b[m-1-i]-1);
            uf.merge(a[m-1-i]-1, b[m-1-i]-1);
        }
    }
    rep(i, m){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

void func()
{
    ll n,m,sum=0;
    cin>>n>>m;
    ll a[n];
    loop(i,0,n)
    {
        cin>>a[i];
        sum+=a[i];
    }
    double r=sum/(4.0*m);
    sort(a,a+n,greater<ll>());
    loop(i,0,m)
    {
        if (a[i]<r)
        {
            cout<<"No"<<"\n";
            return;
        }

    }
    cout<<"Yes"<<"\n";
}

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

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


    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }

}

Measured memory_bytes: 256
w, h, n = map(int, input().split())
W = [1] * w
H = [1] * h

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        for j in range(x):
            W[j] = 0
    elif a == 2:
        for j in range(x, w):
            W[j] = 0
    elif a == 3:
        for j in range(y):
            H[j] = 0
    elif a == 4:
        for j in range(y, h):
            H[j] = 0
print(sum(W) * sum(H))

Measured memory_bytes: 9104