akhauriyash/Code-Regression huggingface dataset:
using System;

namespace AtCoder_Biggner168
{
    class Program
    {
        static void Main(string[] args)
        {
            // int num = int.Parse(Console.ReadLine());

            var num = Console.ReadLine().ToCharArray();

            if (num[num.Length - 1].Equals( '2') ||
                num[num.Length - 1].Equals('4') ||
                num[num.Length - 1].Equals('5') ||
                num[num.Length - 1].Equals('7') ||
                num[num.Length - 1].Equals('9')) Console.WriteLine("hon");
            else if (num[num.Length - 1].Equals('0') ||
                num[num.Length - 1].Equals('1') ||
                num[num.Length - 1].Equals('6') ||
                num[num.Length - 1].Equals('8')) Console.WriteLine("pon");
            else Console.WriteLine("bon");
        }
    }
}


Measured memory_bytes: 17472
N, A, B, C, D = map(lambda x: int(x)-1, input().split())
L = input()

reachable = not ("##" in L[A:C+1] or "##" in L[B:D+1])
interupt = "..." in L[B-1:D+2]
if reachable and (C < D or interupt):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K;
  cin>>K;
  if(K%2==0){
    cout<<(K/2)*(K/2)<<endl;
    return 0;
  }
  cout<<(K/2)*(K/2+1)<<endl;

  return 0;

}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	ll n,a,b;
	cin>>a>>b>>n;
	ll k=min(n,a);
	if(n>k){
		a=0;
		n-=k;
		b=max(ll(0),b-n);
	}
	else{
		a-=n;
	}
	cout << a<<" "<<b;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
vector<int> least_prime;
void leastPrimeFactor(int n) 
{ 
    // Create a vector to store least primes. 
    // Initialize all entries as 0. 
    least_prime.resize(n+1, 0); 
  
    // We need to print 1 for 1. 
    least_prime[1] = 1; 
  
    for (int i = 2; i <= n; i++) 
    { 
        // least_prime[i] == 0 
        // means it i is prime 
        if (least_prime[i] == 0) 
        { 
            // marking the prime number 
            // as its own lpf 
            least_prime[i] = i; 
  
            // mark it as a divisor for all its 
            // multiples if not already marked 
            for (int j = 2*i; j <= n; j += i) 
                if (least_prime[j] == 0) 
                   least_prime[j] = i; 
        } 
    } 
  
    // print least prime factor of 
    // of numbers till n 
//    for (int i = 1; i <= n; i++) 
//        cout << "Least Prime factor of "
//             << i << ": " << least_prime[i] << "\n"; 
} 
int main(){
	int n;
	cin>>n;
	vector<int> a(n),b(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	if(n==1){
		cout<<"pairwise coprime"<<endl;
		return 0;
	}
	map<int,int> m;
	leastPrimeFactor(*max_element(a.begin(),a.end())+2);
	for(int i=0;i<a.size();i++){
		unordered_map<int,int> ma;
		while(a[i]!=1){
			if(!ma[least_prime[a[i]]]){
				m[least_prime[a[i]]]++;
				ma[least_prime[a[i]]]++;
			}
			a[i]/=least_prime[a[i]];
		}
		ma.clear();
	}
	int flag=0;
	for(auto it:m){
		if(it.second>1){
			flag=1;
			break;
		}
	}
	if(!flag){
		cout<<"pairwise coprime"<<endl;
		return 0;
	}
	int g=__gcd(b[0],b[1]);
	for(int i=2;i<b.size();i++)
	g=__gcd(g,b[i]);
	if(g==1){
		cout<<"setwise coprime"<<endl;
	}
	else {
		cout<<"not coprime"<<endl;
	}
}

Measured memory_bytes: 18380
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int a, b, k;
    cin >> k >> a >> b;

    bool ans = false;
    for (int i = 0; i < 1000; i++) {
        if (a <= i * k && i * k <= b) {
            ans = true;
            break;
        }
    }

    if (ans) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }

    return 0;
}


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

vector<int> divisor(int n){
  vector<int> ret;
  for(int i = 0;i * i <= n;i++){
    if ( n % i != 0) continue;
    ret.push_back(i);
    if(i*i != n) ret.push_back(n/i);
  }
  sort(ret.begin(), ret.end());
  return ret;
}

int main() {
    int N;
    cin >> N;
    int A[N + 1];
    for (int i = 0; i < N; i++) {
        cin >> A[i + 1];
    }
    int B[N + 1] = {0};
    vector<int> ans;
    for (int i = N; i > 0; i--) {
        if ( N / i == 1) {
            B[i] = A[i]; 
            if (A[i] == 1) {
                ans.push_back(i);
            }
        }
        else {
            int sum = 0;
            for (int j = 2; j <= N / i; j ++) {
                sum += B[j * i];
            }
            if ( sum % 2 == A[i]) {
                B[i] = 0;
            } else {
                B[i] = 1;
                ans.push_back(i);
            }
        }
    }
    cout << ans.size() << endl;
    for (int a : ans) {
        cout << a << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }

const int mx_n = 1100000;
int siz, dat[2*mx_n-1];

void init(int num){
  siz = 1;
  while(siz < num) siz *= 2;
  rep(i, 2*siz-1) dat[i] = 0;
}
//文字aを二進数に変換して返す
int ctoi(char a){
   int tmp = a - 'a';
   int res = pow(2, tmp);
   return res;
}

//k番目に出現する文字をaにする
void update(int k, char a){
  k += siz-1;
  dat[k] = ctoi(a);
  while(k>0){
    k = (k-1)/2;
    dat[k] = dat[k*2+1] | dat[k*2+2]; //論理和
  }
}

//区間[a, b)に出現する文字の種類を求める
//初期値: query(a, b, 0, 0, siz)
int query(int a, int b, int k, int l, int r){
  if(r <= a || b <= l) return 0;

  if(a <= l && r <= b) return dat[k];
  else{
    int vl = query(a, b, k*2+1, l, (l+r)/2);
    int vr = query(a, b, k*2+2, (l+r)/2, r);
    return vl | vr;
  }
}

int main() {
    int n, Q; string s; cin >> n >> s >> Q;
    
    init(n);
    rep(i, n){
        update(i, s[i]);
    }
    vector<int> res;
    rep(i, Q){
        int q; cin >> q;
        if(q==1){
            int a; char b; cin >> a >> b; a--;
            update(a, b);
        }else{
            int l, r; cin >> l >> r; l--;
            int cnt = query(l, r, 0, 0, siz);
            res.push_back(cnt);
        }
    }
    for(int num: res){
        int cnt = 0;
        rep(i, 26){
            if(num & (1<<i))cnt++;
        }
        cout << cnt << ln;
    }
}



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

struct Node
{
	std::list<int> edges, rev_edges;
	bool visited{};
	int num{-1};
};

std::vector<Node> graph;
std::vector<int> topology;
std::vector<std::vector<int>> sorted;

bool solve();
void back_track(int);
void sort(int, std::vector<int> &);
bool sc_success(std::vector<int> &, bool);

int main()
{
	if (solve())
		printf("POSSIBLE\n");
	else
		printf("IMPOSSIBLE\n");

	return 0;
}

bool solve()
{
	int n;
	scanf("%d", &n);
	graph.resize(n);
	for (int i{}; i < n; i++)
	{
		int p;
		scanf("%d", &p);
		p--;
		graph[p].edges.push_back(i);
		graph[i].rev_edges.push_back(p);
	}

	for (int i{}; i < n; i++)
		back_track(i);
	for (int i{}; i < n; i++)
		graph[i].visited = false;
	for (int i{n - 1}; i >= 0; i--)
	{
		if (graph[topology[i]].visited)
			continue;
		sorted.push_back({});
		sort(topology[i], sorted.back());
	}
	for (auto scv{sorted.rbegin()}; scv != sorted.rend(); scv++)
	{
		if (scv->size() == 1)
		{
			int &index{scv->front()};
			if (graph[index].edges.size() == 0)
				graph[index].num = 0;
			else
			{
				std::vector<int> to;
				for (auto &e : graph[index].edges)
					to.push_back(graph[e].num);
				std::sort(to.begin(), to.end());
				to.push_back(1 << 30);
				int num{};
				for (auto &e : to)
				{
					if (e > num)
						break;
					if (e == num)
						num++;
				}
				graph[index].num = num;
			}
		}
		else
		{
			if (sc_success(*scv, false))
				return true;
			for (auto &e : *scv)
				graph[e].num = -1;
			if (sc_success(*scv, true))
				return true;
			return false;
		}
	}
	return true;
}

void back_track(int index)
{
	if (graph[index].visited)
		return;
	graph[index].visited = true;
	for (auto &e : graph[index].edges)
		back_track(e);
	topology.push_back(index);
	return;
}

void sort(int index, std::vector<int> &scv)
{
	if (graph[index].visited)
		return;
	graph[index].visited = true;
	scv.push_back(index);
	for (auto &e : graph[index].rev_edges)
		sort(e, scv);
	return;
}

bool sc_success(std::vector<int> &scv, bool plus)
{
	std::vector<int> to;
	for (auto &e : graph[scv.front()].edges)
		to.push_back(graph[e].num);
	std::sort(to.begin(), to.end());
	int num{}, first{};
	unsigned i{};
	for (; i < to.size(); i++)
	{
		if (num < to[i])
			break;
		if (num == to[i])
			num++;
	}
	first = num;
	if (plus)
		num++;
	for (; i < to.size(); i++)
	{
		if (num < to[i]) break;
		if (num == to[i]) num++;
	}
	graph[scv.front()].num = num;
	for (unsigned int i{1}; i < scv.size(); i++)
	{
		to.clear();
		num = 0;
		for (auto &e : graph[scv[i]].edges)
			to.push_back(graph[e].num);
		std::sort(to.begin(), to.end());
		for (auto &e : to)
		{
			if (num < e)
				break;
			if (num == e)
				num++;
		}
		graph[scv[i]].num = num;
	}
	if (!plus && graph[scv.front()].num != graph[scv.back()].num)
		return true;
	if (plus && first == graph[scv.back()].num)
		return true;
	return false;
}

Measured memory_bytes: 31856
#include <bits/stdc++.h>
using namespace std;
char c;
int s;
int main()
{ cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin.get(c);
  while(isdigit(c))
    s+=(c-'0'),s%=9,cin.get(c);
  cout<<(s==0?"Yes\n":"No\n");
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;


int main(){
    int n;
    cin>>n;
    vector<int> x(n),y(n);
    vector<ll> h(n);
    for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>h[i];
    int cx,cy;
    ll hh;
    bool flag=false;
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            bool f=true;
            for(int m=0;m<n;m++){
                if(h[m]>0){
                    hh=h[m]+abs(x[m]-j)+abs(y[m]-i);
                    break;
                }
            }
            for(int m=0;m<n;m++){
                ll hsub=hh-abs(x[m]-j)-abs(y[m]-i);
                hsub=max(hsub,(ll)0);
                if(hsub==h[m]) continue;
                f=false;
                break;
            }
            if(f){
                cx=j;
                cy=i;
                flag=true;
                break;
            }
        }
        if(flag){
            break;
        }
    }
    cout<<cx<<" "<<cy<<" "<<hh<<endl;

}

Measured memory_bytes: 3200
S=[]
n = int(input())
for i in range(n):
    s=''.join(sorted(input()))
    S.append(s)
import collections
from scipy.special import comb
a=0
Sd=list(set(S))
c = collections.Counter(S)
for p in  range(len(Sd)):
    if c[Sd[p]] >=2:
        a  += comb(c[Sd[p]], 2, exact=True)
print(a)

Measured memory_bytes: 59892
long long l,i;main(r,x){for(;scanf("%lld",&l),l;printf("%d\n",(l>1?3:1)*r/2+1))for(r=1,i=2;i*i<=l;r*=2*x+1,i++)for(x=0;!(l%i);l/=i)x++;exit(0);}

Measured memory_bytes: 600
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

ll wazu = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (wazu - inv(wazu % x) * (wazu / x)) % wazu;
        if (a >= 0) { return a; }
        else { return wazu + a; }
    }
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    string s, t="";
    cin >> s;
    int k = s.size();

    rep(i, k) {
        if (s[i] == '0') {
            t.push_back('0');
        }
        else if (s[i] == '1') {
            t.push_back('1');
        }
        else if (s[i]=='B') {
            if (t == "") {}
            else { t.pop_back(); }
        }
    }

    cout << t << endl;

}

Measured memory_bytes: 256
#coding: utf-8

money = 100000

num = STDIN.gets.to_i

while num > 0 do
  money = money + (money * 0.05)
  up = money % 1000
  if up > 0 then
    money = money - up + 1000
  end
  num = num - 1
end

puts money.to_i
	

Measured memory_bytes: 8612
#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() {
  string S;
  cin >> S;
  int len = S.size();
  len = (len-1) /2;
  bool flg = true;
  rep(i, len){
   if(S.at(i) != S.at(i+len+1)){
    flg = false;
    break;
   }
  }
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}




Measured memory_bytes: 3632
#include<bits/stdc++.h>
        
        using namespace std;
        
        int main(){
        
            long long l,r;
            cin>>l;
            cin>>r;
            int minimum=1000000000;
            
            int MOD=2019;
            int a=l%MOD;
            int b=r%MOD;
            
            if(r-l+1>=2019){
                cout<<0<<endl;
                return 0;
            }
            //cout<<a<<endl;
            //cout<<b<<endl;
            //if(r)
            for(int i=a;i<=b;i++){
                
                for(int j=i+1;j<=b;j++){
                    int modulus=(i*j)%MOD;
                         minimum=min(modulus,minimum);
                    }
                }
               // break;
                cout<<minimum<<"\n";
            }
           
            

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

namespace ABC095C_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABCXY = ReadInt();
            int A = ABCXY[0];
            int B = ABCXY[1];
            int C = ABCXY[2];
            int X = ABCXY[3];
            int Y = ABCXY[4];

            int max = Math.Max(X, Y);
            long ans = long.MaxValue;
            for (int i = 0; i <= max; i++)
            {
                int cost = 0;
                cost += i * 2 * C;

                int remainX = X - i;
                int remainY = Y - i;
                if (remainX > 0) cost += remainX * A;
                if (remainY > 0) cost += remainY * B;

                if (ans > cost) ans = cost;
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 13268
N = int(input())
h = list(map(int, input().split()))
dp = [0]*len(h)
for i in range(1, N):
    if i<=1:
        dp[i] = dp[i-1]+abs(h[i]-h[i-1])
    else:
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 13980
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val a, b = sc.nextInt()
    val s = sc.next()

    var flag = true

    for (i <- s.indices) {
      if (i == a) {
        flag = flag && s(i) == '-'
      } else {
        flag = flag && "0123456789".contains(s(i))
      }
    }

    println(if (flag) {
      "Yes"
    } else {
      "No"
    })
  }
}


Measured memory_bytes: 27188
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int row[2005][2005];
int col[2005][2005];
int main() {
	int H,W;
	cin>>H>>W;
	vs S(H);
	rep(i,H){
		cin>>S[i];
	}
	//row
	rep(i,H){
		if(S[i][0] == '.'){
			row[i][0] = 1;
		}
	}
	rep(i,H){
		rep1(j,W){
			if(S[i][j]=='#'){
				row[i][j] = 0;
			}
			else{
				row[i][j] = row[i][j-1]+1;
			}
		}
	}

	rep(j,W){
		if(S[0][j] == '.'){
			col[0][j] = 1;
		}
	}
	rep1(i,H){
		rep(j,W){
			if(S[i][j] == '#'){
				col[i][j] = 0;
			}
			else{
				col[i][j] = col[i-1][j] + 1;
			}
		}
	}
/*
	rep(i,H){
		rep(j,W){
			cerr<<col[i][j]<<" ";
		}
		cerr<<endl;
	}
	cerr<<endl;
	rep(i,H){
		rep(j,W){
			cerr<<row[i][j]<<" ";
		}
		cerr<<endl;
	}
	cerr<<endl;
*/	for (int i = H-2; i > -1; --i){
		rep(j,W){
			if(col[i+1][j]>0&&col[i][j]>0)col[i][j] = col[i+1][j];
		}
	}
	rep(i,H){
		for (int j = W-2; j>-1; --j){
			if(row[i][j+1]>0&&row[i][j]>0)row[i][j] = row[i][j+1];
		}
	}/*
	rep(i,H){
		rep(j,W){
			cerr<<col[i][j]<<" ";
		}
		cerr<<endl;
	}
	cerr<<endl;
	rep(i,H){
		rep(j,W){
			cerr<<row[i][j]<<" ";
		}
		cerr<<endl;
	}*/
	int ans = 0;
	rep(i,H)rep(j,W){
		ans = max(ans, row[i][j] + col[i][j] -1);
	}
	cout<<ans<<endl;
}

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

int main(){
int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0; i<N; i++){
   cin>>A[i]; }
  
  int count=0;
  bool flag=true;
  while(true){
    for(int i=0; i<N; i++){  
     if(A[i]%2==0){A[i]/=2;}
     else{flag=false; break;}
    }
   if(!flag){cout<<count; return 0;}
   count++; 
  }
  
}

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

int main(){

    int a, b, c;
    string ans;

    cin >> a >> b >> c;
    
    int sum = a+b+c;
    if (sum >= 22){
        ans = "bust";
    }
    else{
        ans = "win";
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N,M = list(map(int,input().split(' ')))
s = []
c = []
for i in range(M):
    S,C = list(map(int,input().split(' ')))
    s.append(S)
    c.append(C)

number = [0,0,0]

f=True

for S,C in zip(s,c):
    if N!=1:
        if S==1 and C==0:
            #print('a')
            f=False

    if number[N-S]==0:
        number[N-S]=C
    elif number[N-S]==C:
        continue
    else:
        f = False
        break

if number[N-1]==0 and N!=1:
    number[N-1]=1

ans=0
for i in range(N):
    ans+=number[i]*(10**i)




if f:
    if N!=1 and ans==0:
        print(-1)
    else:
        print(ans)
else:
    print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {
	ll n;
	ll a[100001]={};
	ll total=0;
	ll o=0;

	cin>>n;
	a[0]=0;
	a[n+1]=0;
	for(ll i=1; i<n+1; i++){
		cin>>a[i];
		o+=abs(a[i]-a[i-1]);
	}
	o+=abs(a[n]-a[n+1]);
	total=o;
	ll x=0;
	for(ll i=1; i<n+1; i++){
		x=abs(a[i]-a[i+1])+abs(a[i-1]-a[i]);
		if(x<abs(a[i-1]-a[i+1])){
			total+=abs(a[i-1]-a[i+1])-x;
		}else if(x>abs(a[i-1]-a[i+1])){
			total-=x-abs(a[i-1]-a[i+1]);
		}
		cout<<total<<endl;
		total=o;
	}

	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    unordered_map<int, int> C;
    rep(i, n) C[a[i]] = 0;
    rep(i, n) C[a[i]]++;

    int res = 0;
    for (auto kv: C) {
        int ai = kv.first;
        int cnt = kv.second;
        int sum = cnt;
        sum += C.find(ai - 1) == C.end() ? 0 : C[ai - 1];
        sum += C.find(ai + 1) == C.end() ? 0 : C[ai + 1];
        res = max(res, sum);
    }

    put(res);


    return 0;
}

Measured memory_bytes: 7088
N = int(input())
H = []
H = list(map(int,input().split()))

Hi = 0
count = 0
Max = 0

while Hi < len(H)-1:
    if H[Hi] >= H[Hi+1]:
        count +=1
        #print(H[Hi], H[Hi+1] ,count)
    
    else:
        Max = max(Max, count)
        count = 0

    Hi += 1

Max = max(Max, count)

print(Max)

Measured memory_bytes: 63856
#include <stdio.h>

int main(void)
{
	int d1,d2,c,d;
	
	while(scanf("%d %d",&d1,&d2)!=EOF){
		c=0;
		d = (d1+d2)/10;
		while(d!=0){
			d/=10;
			c++;
		}
		printf("%d\n",c+1);
	}

	return 0;
}

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

//	LLONG_MAX 9.2*1e18	9223372036854775807LL = (2^63)-1
//	INT_MAX 2.1*1e9 2147483647 = (2^31)-1
//	O(1e8) 1.2sec

void Main()
{
	string S;
	cin>>S;
	int ans = 0;
	int cnt=0;
	for(auto&i:S){
		if(i=='R')cnt++;
		else cnt=0;
		ans = max(cnt,ans);
	}

	cout<<ans<<_n;
}


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


Measured memory_bytes: 3648
N, K = map(int, input().split())
mod = 10**9 + 7

l = (sum(range(K)), sum(range(N-K+1, N+1)))
a, b = l
ans = (1 + abs(a - b)) % mod
for k in range(K, N+1):
    a, b = l
    a, b = a + k, b + N - k
    l = (a, b)
    ans = (ans + (1 + abs(a - b)) % mod) % mod
        
print(ans)

Measured memory_bytes: 9208
def solve(P):
    N = len(P)
    s = N+1

    A = [s*i+1 for i in range(N)]
    B = [s*i+1 for i in reversed(range(N))]

    for i,p in enumerate(P):
        A[p-1] += i

    return A,B


if __name__ == '__main__':
    N = int(input())
    P = list(map(int,input().split()))

    a,b = solve(P)
    print(*a)
    print(*b)

Measured memory_bytes: 75804
//#include<bits/stdc++.h>
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<stdio.h>
#include <cstdio>
#include <cstring>
#include <string>


using namespace std;

#define ld long double
#define ll long long
#define ff first
#define ss second
#define sz(a) (int)a.size()
#define mem(a, b) memset((a), (b), sizeof(a))
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define pii pair<int ,int >
#define pll pair<ll ,ll >
#define mp make_pair
#define vi vector<int >
#define vii vector<pii>
#define vvi vector < vi >
#define vll vector < ll >
#define vllll vector < pll >
#define vvll vector < vll >
#define forn(i,n) for(int i=0;i<(n);i++)
#define fori(i,s,e) for(int i=s,i<n;i++)
#define qi  queue <int >
#define qll  queue <ll >
#define in_r(x,y,n,m) (x>=0 && x<n && y>=0 && y<m)
#define maxn 1000009


void fast(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}


const ll MOD = 1e9 + 9;
const double EPS = (1e-8);
const int OO = (int) 1e9 + 7;
const ll OOO = (ll) 1e18 + 7;
//double const PI = 3.1415926535897932384626433832795;
const int mxn = 200007;
char c1, c2, c3, c4;
string s, s1, s2, s3;
ll   n, m, k, t = 1, q, a, b, c, d, e, x, y, z; ll sol = 0;





void pre(){}
void solve(){
	
	cin >> a >> x;
	cin >> b >> y;
	cin >> n;
	
	if (x*n - abs(a - b) >= n * y) cout << "YES";
	else cout << "NO";

}


int main(){
	fast();
	

	pre();
	//cin >> t; 
	while (t--){

		solve();

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

Measured memory_bytes: 3656
n,a,b,c,d = map(int,input().split())
s = input()

def judge(start,goal):
    for i in range(start,goal-1):
        if s[i] == "#" and s[i+1] == "#":
            return 0
    return 1

def full_judge (start,obst,obfin,goal):
    if s[obst-2] == "." and s[obst] == "." :
        return 1
    for i in range(obst-1,obfin-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            return 1
    return 0


if c<b:
    if (judge(a,c) and judge(b,d)):
        print("Yes")
    else:
        print("No")
elif c<d:
    if (judge(a,c) and judge(b,d)):
        print("Yes")
    else:
        print("No")
else:
    if judge(b,d) and full_judge(a,b,d,c) and judge(a,c):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 40048
#define _GLIBCXX_DEBUG
#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);
  }
  int answer=0;
  for(int j=0;j<N;j++){
    int A = vec.at(j);
    int K=0;
    for(int i=0;i<j+1;i++){
      if(A == vec.at(i)){
        K++;
      }
    }
    if(K == 1){answer++;}
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
package main
 
import (
  "bufio"
  "fmt"
  "os"
  "strings"
   "strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func main() {
  if sc.Scan() {
    s := strings.Split(sc.Text(), " ")
    a, _ := strconv.Atoi(s[0])
    b, _ := strconv.Atoi(s[1])
    c, _ := strconv.Atoi(s[2])
    d := c - (a - b)
    if d < 0 {
      d = 0
    }
    fmt.Println(d)
  }
}

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

int main() {
  int x,n;
  cin>>x>>n;
  if(n==0)
    cout<<x<<endl;
  else if(n==100){
    if(x<=50) cout<<"0"<<endl;
    else cout<<"101"<<endl;
  }
  else{
    vector<int> p(n);
    vector<int> vec(100,1);
    for(int i=0;i<n;i++){
      cin>>p.at(i);
      vec.at(p.at(i)-1)=0;
    }
    //最もxに近いpの値を保持
    int ans=0;
    //xとpの差の最小値を保持
    int p_min=100;
    for(int i=0;i<100;i++){
      if(vec.at(i)==1){
        if(p_min > abs((i+1)-x)){
          p_min=abs((i+1)-x);
          ans=i+1;
        }
        if(p_min == abs((i+1)-x))
          ans=min(ans,i+1);
      }
    }
    if(p_min >= x)
      ans=0;
    else if(p_min>(101-x))
      ans=101;
    cout<<ans<<endl;
  }
  
}


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

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool era[10000001]={false};


void makeERA(){
    for(int i=2;i<1000001;i++){
        if(era[i]==true){
            int x=10000000/i;
            for(int j=2;j<=x;j++){
                    era[i*j]=false;
            }
        }
    }
    era[2]=true;
}




int main(){
    for(int i=0;i<10000001;i++)era[i]=true;
    era[0]=false;era[1]=false;
    makeERA();
    
    int n;
    while(cin>>n){
        if(n==0)break;
        
        if(n%2==0)n--;
        for(int i=n;i>=8;i-=2){
            if(era[i-8]){
                if(era[i-6]){
                    if(!era[i-4]){
                        if(era[i-2]){
                            if(era[i]){
                                cout<<i<<endl;
                                goto next;
                            }else i-=4;
                        }else i-=4;
                    }
                    else i-=4;
                }
            }else i-=2;
        }
        next:;
    }
    
    
    return 0;
}

Measured memory_bytes: 10924
//agc035_a.cpp
//Sat Aug  3 14:20:36 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll keta[40];
	fill(keta,keta+40,0);
	for (int i=0;i<n;i++){
		ll temp;
		cin >> temp;
		for (int j=0;j<40;j++){
			keta[j] += (temp>>j & 1);
		}
	}

	for (int i=0;i<40;i++){
		if (keta[i]==0 || (n-keta[i])*2 == keta[i]){
			continue;
		}
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
//	printf("%.4f\n",ans);
}

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

const double EPS  = 1e-8;
const double r = 6378.1;
const double PI = acos(-1);

int main(){
	double a, b, c, d;
	while( scanf("%lf %lf %lf %lf", &a, &b, &c, &d ) ){
		if( a == -1 && b == -1 && c == -1 && d == -1 ) break;
		
		a = (90.0 - a) * PI / 180.0;
		b = b * PI / 180.0;
		c = (90.0 - c) * PI / 180.0;
		d = d * PI / 180.0;
		
		double x1 = r * sin(a) * cos(b);
		double y1 = r * sin(a) * sin(b);
		double z1 = r * cos(a);
		
		double x2 = r * sin(c) * cos(d);
		double y2 = r * sin(c) * sin(d);
		double z2 = r * cos(c);
		
		double d = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2);
		int ans = r * acos( 1 - d / (2*r*r) ) + 0.5 + EPS;
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1108
#include<bits/stdc++.h>
using namespace std;
int MIN = 1e9 + 5;
int main(){
 	int n;
 	cin>>n;
  vector<int> a(n);
  	for(int &x: a){
    	cin>>x;
    }

  int c = 0;
  for(int i=0;i<n;i++){
  	if( i==0) {
		c++;
		MIN = a[i];
		continue;
	}
	if( a[i] <= MIN){
			c++;
			MIN = min( a[i], MIN);
	
	}
    
  }
  	
  	cout<<c<<endl;
  return 0;
}


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

int main(int argc, char* argv[]) {
    int n, cnt = 0;
    cin >> n;
    int array[n];
    for (int i = 0; i < n; i++) cin >> array[i];

    for (int i = 0; i < n; i++){
        int min = i;
        bool flag = false;
        for (int j = i; j < n; j++){
            if (array[j] < array[min]){
                min = j;
                flag = true;
            }
        }
        int tmp = array[min];
        array[min] = array[i];
        array[i] = tmp;
        if (flag) cnt++;
    }
    for (int i = 0; i < n-1; i++) cout << array[i] << " ";
    cout << array[n-1] << "\n";
    cout << cnt << "\n";

    return 0;
}



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


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


	int N, K;
	cin >> N >> K;

	int kotae = 0;
	while (N) {
		N /= K;
		kotae++;
	}
	co(kotae);


	Would you please return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#pragma warning(disable:4996)
//FILE *in = fopen("input.txt", "r"), *out = fopen("output.txt", "w");
FILE *in = stdin, *out = stdout;
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 0x7fffffff
#define NM 100005
#define MOD 1000000007
#define FOR(i,n,m) for (int i=(n);i<=(m);i++)
#define si(n) fscanf(in,"%d",&n)
#define sd(n) fscanf(in,"%lld",&n)
typedef long long int ll;

int n, a[NM * 2];
ll sum = 0;
void input() {
	si(n);
	FOR(i, 1, n) si(a[i]), sum += a[i];
}
void pro() {
	ll res = 1e18, t = 0;
	FOR(i, 1, n - 1) {
		t += a[i]; sum -= a[i];
		res = min(res, abs(t - sum));
	}
	fprintf(out, "%lld", res);
}
int main() {
	input();
	pro();
	return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main(){
    int N,K,Q;
    cin >> N >> K >> Q;
    int B[N];
    for(int i = 0; i < N; i++){
        B[i] = 0;
    }
    for(int i = 0; i < Q; i++){
        int A;
        cin >> A;
        B[A-1] += 1;
    }
    
    for(int i = 0; i < N; i++){
        if(Q - B[i] < K){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
    
    
    
    return 0;
}

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

int main(){
  int N, count = -1;
  bool b = true;
  cin >> N;
  vector<int>A_s(N);
  for(int i = 0; i < N; i++){
    cin >> A_s[i];
  }
  while (b){
    for(int &j : A_s){
      if(j % 2 == 0) j = j / 2;
      else {
        b = false;
        break;
      }
    }
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input().strip())
A = [int(x) - (i + 1) for i, x in enumerate(input().strip().split())]
B = sorted(A)
ans = 0
for i in B[len(B)//2-1:len(B)//2+3]:
    if ans == 0:
        ans = sum([abs(a - i) for a in A])
    else:
        ans = min(ans, sum([abs(a - i) for a in A]))

print(ans)

Measured memory_bytes: 25172
/**
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define ll long long int
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
#define nl cout<<"\n";
using namespace std;
const ll c=1e9+7;
int main()
{
IOS
char x;
cin>>x;
if(x>='a')
   cout<<"a";
    else
    cout<<"A";
return 0;
}



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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    cums(T& v){ T r; r.push_back(v[0]); for(int i=1; i<v.size(); i++) r.push_back(r[i-1] + v[i]); return r; }
TEMP_T void maxe(T& v, T m){ v = max(v, m); }
TEMP_T void mine(T& v, T m){ v = min(v, m); }

static inline int in(){ int x; scanf("%d", &x); return x; }

struct Edge {
  int f, t, c;
  Edge(int f, int t, int c) : f(f), t(t), c(c) {}
  bool operator<(const Edge& e) const { return c > e.c; }
};
typedef vector<Edge> Vertex;
typedef vector<Vertex> Graph;

struct Solver {
  Solver(int w, int h, int n) : w(w), h(h), G(w * h), pos(n + 1) {}
  int read_input(){
    for (int i = 0; i < h; i++){
      string s;
      cin >> s;
      field.push_back(s);
    }
    for (int y = 0; y < h; y++){
      for (int x = 0; x < w; x++){
        if (field[y][x] == 'X') continue;
        for (int d = 0; d < 4; d++){
          static const int dx[] = {1, -1, 0, 0};
          static const int dy[] = {0, 0, 1, -1};
          int ny = y + dy[d];
          int nx = x + dx[d];
          if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
          if (field[ny][nx] == 'X') continue;
          G[y * w + x].push_back(Edge(y * w + x, ny * w + nx, 1));
        }
        if (isdigit(field[y][x])){
          pos[field[y][x] - '0'] = y * w + x;
        }
        if (field[y][x] == 'S'){
          pos[0] = y * w + x;
        }
      }
    }
    return (0);
  }
  int solve(){
    int sum = 0;
    for (int i = 0; i < pos.size() - 1; i++){
      sum += get_path_len(pos[i], pos[i + 1]);
    }
    return sum;
  }
  int get_path_len(int f, int t){
    int n = G.size();
    priority_queue<Edge> pQ;
    set<int> v;
    pQ.push(Edge(-1, f, 0));
    while (!pQ.empty()){
      Edge e = pQ.top();
      pQ.pop();
      if (e.t == t) return e.c;
      if (v.find(e.t) != v.end()) continue;
      v.insert(e.t);
      for (int i = 0; i < G[e.t].size(); i++){
        pQ.push(Edge(e.t, G[e.t][i].t, e.c + G[e.t][i].c));
      }
    }
    return -1;
  }

  vector<string> field;
  vector<int> pos;
  int w, h;
  Graph G;
};

int main()
{
  int w, h, n;
  h = in();
  w = in();
  n = in();
  Solver solver(w, h, n);
  solver.read_input();
  printf("%d\n", solver.solve());

  return (0);
}

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

int main() {
	string s; cin >> s;
	int ans = s.size();
	sort(s.begin(), s.end());
	s.erase(unique(s.begin(), s.end()), s.end());
	cout << (ans - s.size() == 0 ? "yes" : "no") << endl;
	return 0;
}

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

vector<pair<ll,ll>> G[1001][1001],GW[1001][1001];
ll eh[4]={0,-1,0,1},ew[4]={1,0,-1,0};

int main(){
  ll h,w,ch,cw,dh,dw;
  cin>>h>>w>>ch>>cw>>dh>>dw;
  ch--;cw--;dh--;dw--;
  char M[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>M[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=0;k<4;k++){
        if(0<=i+eh[k] && i+eh[k]<h && 0<=j+ew[k] && j+ew[k]<w && M[i][j]!='#' && M[i+eh[k]][j+ew[k]]!='#')G[i][j].push_back({i+eh[k],j+ew[k]});
      }
      for(int k=-2;k<3;k++){
        for(int l=-2;l<3;l++){
          if(0<=i+k && i+k<h && 0<=j+l && j+l<w && M[i][j]!='#' && M[i+k][j+l]!='#')GW[i][j].push_back({i+k,j+l});
        }
      }
    }
  }
  ll dist[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      dist[i][j]=-1;
    }
  }
  queue<pair<ll,ll>> que,q2;
  dist[ch][cw]=0;que.push({ch,cw});q2.push({ch,cw});
  while(!que.empty()){
  while(!que.empty()){
    pair<ll,ll> v=que.front();
    que.pop();
    q2.push(v);
    for(auto nv : G[v.first][v.second]){
      if(dist[nv.first][nv.second]!=-1)continue;
      dist[nv.first][nv.second]=dist[v.first][v.second];
      que.push(nv);q2.push(nv);
    }
  }
  while(!q2.empty()){
    pair<ll,ll> v=q2.front();
    q2.pop();
    for(auto nv : GW[v.first][v.second]){
      if(dist[nv.first][nv.second]!=-1)continue;
      dist[nv.first][nv.second]=dist[v.first][v.second]+1;
      que.push(nv);
    }
  }
  }
  cout<<dist[dh][dw]<<endl;
}


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

using P = pair<int, char>;

array<array<int, 5003>, 5003> sum;

int main() {
    int N, M;
    cin >> N >> M;
    for(int i=0; i<M; ++i) {
        int A, B, X;
        cin >> A >> B >> X;
        sum[A][B] += 1;
        sum[A][B+1] += -1;
        sum[A+X+1][B] += -1;
        sum[A+X+2][B+1] += 1;
        sum[A+X+1][B+X+2] += 1;
        sum[A+X+2][B+X+2] += -1;
    }
    for(int i=0; i<N+3; ++i) {
        for(int j=0; j<=i; ++j) {
            sum[i][j+1] += sum[i][j];
        }
    }
    for(int i=0; i<N+2; ++i) {
        for(int j=0; j<=i; ++j) {
            sum[i+1][j] += sum[i][j];
        }
    }
    int res = 0;
    for(int i=0; i<N+2; ++i) {
        for(int j=0; j<=i; ++j) {
            sum[i+1][j+1] += sum[i][j];
            res += sum[i+1][j+1] > 0;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 69948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a;
  string s;
  cin>>a>>s;
  if(a>=3200)cout<<s<<endl;
  else cout<<"red"<<endl;
  return 0;
}


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

using namespace std;

vector<pair<pair<int, int>, int>> vec;

int main()
{
    int L;
    scanf("%d", &L);
    int cnt = 0;
    while (L >= (1 << (cnt + 1)))
        cnt++;
    int n = cnt + 1;
    for (int i = 1; i < n; i++)
    {
        vec.push_back(make_pair(make_pair(i, i + 1), 0));
        vec.push_back(make_pair(make_pair(i, i + 1), 1 << (i - 1)));
    }
    int acc = (1 << cnt);
    for (int i = 0; i < cnt; i++)
        if (L & (1 << i))
            vec.push_back(make_pair(make_pair(i + 1, n), acc)), acc += (1 << i);
    printf("%d %lld\n", n, 1LL * vec.size());
    for (auto x : vec)
        printf("%d %d %d\n", x.first.first, x.first.second, x.second);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
i64 X[202020], Y[202020];
pair<i64, int> small, large;
int sp, lp;

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		scanf("%lld%lld", X + i, Y + i);
		if (X[i] > Y[i]) swap(X[i], Y[i]);
	}

	small = make_pair(X[0], 0);
	large = make_pair(Y[0], 0);
	for (int i = 0; i < N; ++i) {
		small = min(small, { X[i], i });
		large = max(large, { Y[i], i });
	}
	sp = small.second;
	lp = large.second;

	i64 ret = 1LL << 62LL;
	if (sp != lp) {
		i64 rmax = Y[lp];
		i64 rmin = X[sp];
		i64 bmax = X[lp];
		i64 bmin = Y[sp];
		if (bmax < bmin) swap(bmax, bmin);

		vector<pair<i64, i64> > cov;
		for (int i = 0; i < N; ++i) if (i != lp && i != sp) {
			cov.push_back({ X[i], Y[i] });
		}
		sort(cov.begin(), cov.end());
		i64 w = 1001001001;
		multiset<i64> waf;
		for (auto a : cov) waf.insert(a.first);

		for (auto a : cov) {
			i64 x = a.first, y = a.second;
			w = min(w, max(bmax, *--waf.end()) - min(bmin, x));
			waf.erase(waf.find(x));
			bmax = max(bmax, y);
			bmin = min(bmin, y);
		}
		w = min(w, bmax - bmin);

		ret = min(ret, (rmax - rmin) * w);
	}
	{
		i64 rmax = X[lp];
		i64 rmin = X[sp];
		i64 bmax = Y[lp];
		i64 bmin = Y[sp];
		for (int i = 0; i < N; ++i) {
			rmax = max(rmax, X[i]);
			bmin = min(bmin, Y[i]);
		}
		ret = min(ret, (rmax - rmin) * (bmax - bmin));
	}
	printf("%lld\n", ret);
	return 0;
}


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


s = input()
ans = 0
n = len(s)
for i in range(n):
    c = int(s[i])
    for k in range(n):
        if n-i-1<k:
            break
        val = c * pow(2, i) * (1 if n-i-k-2 <=0 else pow(2,n-i-k-2)) * pow(10,k)
        ans += val
#         print(val)
print(ans)

Measured memory_bytes: 61972
A,B,C,D,E,F = map(int,input().split())
A *= 100
B *= 100
check = -1
for i in range(F//A+1):
    for j in range((F-(A*i))//B+1):
        if i + j == 0:continue
        for k in range(((F-(A*i))-B*j)//C+1):
            for l in range((((F-(A*i))-B*j)-C*k)//D+1):
                water = A*i+B*j
                sugar = C*k+D*l
                if water//100*E < sugar:continue
                if check < 100*sugar/(water+sugar):
                    check = 100*sugar/(water+sugar)
                    ans = [water+sugar,sugar]
print(*ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int s[10005];
void trip()
{
	for (int i=1;i<=10000;i++)
    {
    	int x,y,z,num=0;
    	for (x=1;x<=sqrt(i);x++)
		{
			if (x*x+3+2*x>i) break;
			for (y=1;y<=sqrt(i);y++)
			{
				if (x*x+y*y+x*y+1+x+y>i) break;
				for (z=1;z<=sqrt(i);z++)
				{
					if (x*x+y*y+z*z+x*y+y*z+x*z>i) break;
					if (x*x+y*y+z*z+x*y+y*z+x*z==i) num++;
				}
			}
		}
		s[i]=num;
	}
}

int main()
{
    int n;
    trip();
    while (~scanf("%d",&n))
    	for (int i=1;i<=n;i++) printf("%d\n",s[i]);
    return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    string s;
    cin >> s;
    string ans = "";
    rep(i,s.size()){
        if(s[i]=='0'){
            ans += '0';
        }else if(s[i]=='1'){
            ans += '1';
        }else if(ans.size()>0 && s[i]=='B'){
            ans = ans.substr(0,ans.size()-1);
        }
        //call(ans);
    }
    cout << ans << endl;
}

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

void bfs(vector<int> &S, int K) {
    deque<int> Q;
    Q.push_front(1);

    while(!Q.empty()) {
        int v = Q.front();
        Q.pop_front();
        
        int nv = v * 10 % K;
        if(S[nv] > S[v]) {
            S[nv] = S[v];
            Q.push_front(nv);
        }

        nv = (v + 1) % K;
        if(S[nv] > S[v] + 1) {
            S[nv] = S[v] + 1;
            Q.push_back(nv);
        }
    }
}

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

    vector<int> S(K, 100100101);
    S[1] = 1;

    bfs(S, K);
    cout << S[0] << endl;
}

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

int main(){
   int a,b; cin>>a>>b;
   int cnt=1;
   int ans=0;
   while(cnt<b){
      cnt+=(a-1);
      ans++;
   }
   cout<<ans<<endl;
   return 0;
}

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

#define INF 0x3f3f3f3f

int main()
{
	ios_base::sync_with_stdio(false);
 	cin.tie(NULL);
	
	int n, k;
	cin >> n >> k;
	vector < int > h(n+1);
	for(int i=1; i<=n; i++)
		cin >> h[i];
	vector < int > dp(n+1, INF);
	dp[1] = 0;
	for(int i=2; i<=n; ++i)
		for(int j=i-1; j>=i-k and j>=1; --j)
		dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]));
	cout << dp[n] << endl;
	
	return 0;
}

Measured memory_bytes: 1024