akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int sum;
  while(1){
    cin>>sum;
    if(sum==0)break;
    int n,s=0;
    rep(i,9){
      cin>>n;
      s+=n;
    }
    cout<<sum-s<<endl;
  }
}

Measured memory_bytes: 2980
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
using namespace std;

const int N = 102;

int q = 0, n;
bool query(vector<int> v)
{
	q++;
	cout << "? ";
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
	cout << endl;
	string res;
	cin >> res;
	return (res[0] == 'R');
}

bool query(int x)
{
	vector<int> v;
	for (int i = 0; i < n; i++)
		v.PB(x + i);
	return query(v);
}

int pos, ans[N + N];
int val, l, r, m;

int solve(int l, int r)
{
	if (l + 1 == r)
		return r;
	int m = (l + r) / 2;
	if (query(m) == val)
		return solve(m, r);
	else
		return solve(l,m);

}

int main()
{
	cin >> n;
	val = query(1);

	pos = solve(1,n+1);

	ans[pos - 1] = val;
	ans[pos + n-1] = !ans[pos - 1];
	vector<int> x;
	for (int i = pos; i < pos + n - 1; i++)
		x.PB(i);

	for (int i = 1; i <= n + n; i++)
	{
		if (i < pos + n && i >= pos - 1)
			continue;
		x.PB(i);
		ans[i] = query(x);
		x.pop_back();
	}
	x.clear();

	for (int i = 1; i <= n + n; i++)
	{
		if (i < pos + n - 1 && i >= pos)
			continue;
		if (ans[i] == 0 && x.size() < (n - 1) / 2)
			x.PB(i);
	}
	for (int i = 1; i <= n + n; i++)
	{
		if (i < pos + n - 1 && i >= pos)
			continue;
		if (ans[i] == 1 && x.size() < (n - 1))
			x.PB(i);
	}

	for (int i = 1; i <= n + n; i++)
	{
		if (i < pos + n - 1 && i >= pos)
		{
			x.PB(i);
			ans[i] = query(x);
			x.pop_back();
		}
	}

	cout << "! ";

	for (int i = 1; i <= n + n; i++)
		if (ans[i])
			cout << "R";
		else
			cout << "B";
	cout << endl;

	return 0;
}

/*


123456
RRBBRB

12345678901234
BBBBBRRBRRBRRR


*/

Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
const ll maxn = 1e3+100,mod = 1e9+7,INF = 1ll<<62;
int n,m,a,b,l,r,k,ans,ind;
pair<pair<int,int>,int>lr[maxn];
vector<pair<int,int> >g[maxn];
bool mark[600];
void dfs(int v){
	mark[v]=true;
	for(int i=0;i<g[v].size();i++){
		if(g[v][i].S!=ind && mark[g[v][i].F]==0){
			dfs(g[v][i].F);
		}
	}
	return ;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>a>>b;
		g[a].push_back({b,i});
		g[b].push_back({a,i});
	}
	for(int i=1;i<=m;i++){
		ind=i;
		ll t=0;
		for(int j=1;j<=n;j++){
			if(mark[j]==0){
				t++;
				dfs(j);
			}
		}
		if(t>=2){
			ans++;
		}
		memset(mark,0,sizeof mark);
	}
	cout<<ans;
}

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

int main()
{
    int n,i;
    cin>>n;
    if(n<105)
    {
        cout<<"0";
        return 0;
    }
    if(n<135)
    {
        cout<<"1";
        return 0;
    }
    if(n<165)
    {
        cout<<"2";
        return 0;
    }
    if(n<189)
    {
        cout<<"3";
        return 0;
    }
    if(n<195)
    {
        cout<<"4";
        return 0;
    }
    if(n>=195)
        cout<<"5";
    return 0;
}



Measured memory_bytes: 256
object Main extends App {
  def findGcd(pregcd: Int, prev: Int, xlist: List[Int]): Int = {
    def gcd(a: Int, b: Int): Int = if(b == 0) a else gcd(b, a % b)
    if (xlist.isEmpty) pregcd
    else {
      val curgcd = gcd(xlist.head - prev, pregcd)
      findGcd(curgcd, xlist.head, xlist.tail)
    }
  }

  val temp: Array[Int] = io.StdIn.readLine().split(" ").map(_.toInt)
  val list: List[Int] = io.StdIn.readLine().split(" ").map(_.toInt).toList
  val N = temp(0)
  val X = temp(1)
  val xList = (X :: list).sorted
  val D = findGcd(0, xList.head, xList.tail)
  println(D)
}


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

typedef long long ll;
const ll mod=1e9+7;
const ll N=5e5+1;
const ll INF=1e10;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int h,w,k,ans=0;
	cin>>h>>w>>k;
	vector<string> mat(h);
	for(string &s:mat) cin>>s;
	int H=1<<h,W=1<<w;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			int cnt=0;
			bitset<6> rows(i),col(j);
			for(int r=0;r<h;r++){
				if(rows[r]) continue;
				for(int c=0;c<w;c++) cnt+=(!col[c] and mat[r][c]=='#');
			}
			ans+=(cnt==k);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int n,m;
int s[100001];
int c[100001];
int a[100001];

signed main()
{
	scanf("%d%d",&n,&m);
	memset(a,-1,sizeof(a));
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&s[i],&c[i]);
		if(a[s[i]]!=-1&&a[s[i]]!=c[i])
		{
			printf("-1");
			return 0;
		}
		a[s[i]]=c[i];
	}
	if(n==1&&(a[1]==-1||a[1]==0))
	{
		printf("0");
		return 0;
	}
	if(a[1]==0)
	{
		printf("-1");
		return 0;
	}
	else if(a[1]==-1)
		a[1]=1;
	for(int i=1;i<=n;i++)
		if(a[i]==-1)
			a[i]=0;
	for(int i=1;i<=n;i++)
		printf("%d",a[i]);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;






int main()
{
	int n;
	int m;
	cin >> n;
	m = 100000;
	for (int i = 0; i < n; i++) {
		m *=1.05;
		if (m % 1000 != 0) {
			m = m / 1000;
			m = m * 1000 + 1000;
		}
	}
	cout << m << endl;


}

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

int main(){
  int k[4][24]={0},a,b;
  string s;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>s>>b;
    if(s=="S")k[0][b]=1;
    else  if(s=="H")k[1][b]=1;
    else  if(s=="C")k[2][b]=1;
    else  if(s=="D")k[3][b]=1;
  }
  for(int i=0;i<4;i++){
    for(int j=1;j<=13;j++){
      if(k[i][j]==0){
	if(i==0)cout<<"S "<<j<<endl;
	if(i==1)cout<<"H "<<j<<endl;
	if(i==2)cout<<"C "<<j<<endl;
	if(i==3)cout<<"D "<<j<<endl;
	
      }
    }
  }
  return 0;
}



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

int main() {
	int N, a, C[8] = { 0 }, color = 0, tourist = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		for (int j = 0; j < 8; j++) {
			if (400 * j <= a && a < 400 * (j + 1) && C[j] == 0) {
				C[j] = 1;
				color++;
			}
		}
		if (3200 <= a) tourist++;
	}
	cout << max(1, color) << " " << color + tourist;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b;
	int q, w;
	double e;

	scanf("%d %d", &a, &b);

	q = a / b;
	w = a % b;
	e = (double)a / (double)b;

	printf("%d %d %f\n", q, w, e);

	return (0);
}

Measured memory_bytes: 632
#include "bits/stdc++.h"
using namespace std;
#define maxn 100001
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define pb push_back
#define mp make_pair

vector<pair<int,long long>> e[maxn];
int n, k, x;

int gcd(int a, int b){
	if (b == 0) return a;
	return gcd(b, a%b);
}
void solve(){
	cin >> n >> k;
	int tmp = 0;
	bool has_big = 0;
	rep(i, n){
		cin >> x;
		tmp = gcd(x, tmp);
		has_big |= (x >= k);
	}
	puts(has_big && k%tmp == 0 ? "POSSIBLE" : "IMPOSSIBLE");
}

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(0);
    solve();
}

Measured memory_bytes: 2560
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long ua = a - 1;
    long b = sc.nextLong();
    long c = sc.nextLong();
    long d = sc.nextLong();
    long lcm = lcm(c, d);

    long count = 0;
    
    long cCMsCount = b / c - ua / c;
    long dCMsCount = b / d - ua / d;
    long lcmCMsCount = b / lcm - ua / lcm;
    
    long wholeCMsCount = cCMsCount + dCMsCount - lcmCMsCount;
    count = b - a + 1 - wholeCMsCount;
    
//    System.out.println(cCMsCount);
//    System.out.println(dCMsCount);
//    System.out.println(lcmCMsCount);
//    System.out.println(wholeCMsCount);
    System.out.println(count);
  }
  
  private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
  }

  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
  }  
  
}


Measured memory_bytes: 21716
from fractions import gcd
from functools import reduce
import sys
sys.setrecursionlimit(10 ** 7)

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    a = list(map(int, input().split(" ")))
    a = list(set(a))

    # for j in a:
    #     if j % 2 != 0:
    #         print("0")

    # a = [i/2 for i in a]
    l = lcm_list(a)

    # if l == 0:
    #     print(0)
    #     exit()

    if (2 * m) < l:
        print("0")
        exit()

    i = l / 2

    for j in a:
        if i // (j // 2) % 2 == 0:
            print(0)
            exit()

    # if m < i:
    #     print("0")
    else:
        # print("1")
        print(int(((m - i) // l) + 1))
        # print(int((m // i + 1) // 2))

Measured memory_bytes: 16348
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<list>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

string s;
ll n, k, q,c;

int main() {
   cin >> n >> k >> q;
   VLL a(n,k-q);
   rep(i, q) {
	  cin >> c;
	  a[c-1]++;
   }
   for (int i = 0; i < n; i++)
   {
	  if (a[i] > 0)cout << "Yes" << endl;
	  else cout << "No" << endl;
   }
}

Measured memory_bytes: 1408
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

  a1 -= b1;
  a2 -= b2;
  if (a1 * t1 + a2 * t2 == 0) {
    puts("infinity");
    return 0;
  }
  if (a1/abs(a1) * a2/abs(a2) > 0) {
    puts("0");
    return 0;
  }
  if (abs(a1 * t1) > abs(a2 * t2)) {
    puts("0");
    return 0;
  }
  ll x = abs(a1 * t1);
  ll y = (abs(a2 * t2) - abs(a1 * t1));
  ll ans = (x + y - 1) / y;
  ans = 2 * ans - 1;
  if (x % y == 0) ans++;

  cout << ans << endl;

  return 0;
}


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

int main() {
	// your code goes here
	string s,t;
	cin >> s >> t;
	int count=0;
	int n=s.length();
	for(int i=0;i<n;i++){
	    if(s[i]!=t[i])
	        count++;
	}
	cout << count;
	return 0;
}


Measured memory_bytes: 3828
from math import gcd
n = int(input())
s = list(map(int, input().split()))
s.sort()
dp = [0] * ((10 ** 6) + 100)

res = s[0]
for ss in s:
    dp[ss] += 1
    res = gcd(res, ss)

A = max(s)
pairwise = True
setwise = (res == 1)

primes = set(range(2, A+1))
for i in range(2, int(A**0.5+1)):
    if i not in primes:
        i += 1
    else:
        ran = range(i*2, A+1,i)
        primes.difference_update(ran)
primes = list(primes)

for i in primes:
    cnt = 0
    for j in range(i, A + 1, i):
        cnt += dp[j]
    if cnt > 1:
        pairwise = False
        break

if pairwise:
    print("pairwise coprime")
elif setwise:
    print("setwise coprime")
else:
    print("not coprime")


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

namespace AtCoder.DP
{
    public class SegmentTree<T>
    {
        private readonly T ex;

        private readonly int n;

        private readonly int offset;

        private readonly T[] node;

        private readonly Func<T, T, T> func;

        public T this[int index] => node[offset + index];

        public SegmentTree(int m, Func<T, T, T> func, T ex)
        {
            this.func = func;
            this.ex = ex;

            n = 1;
            while (n < m)
                n *= 2;
            offset = n - 1;
            node = new T[n * 2 - 1];
            for (int i = 0; i < node.Length; i++)
                node[i] = ex;
        }

        public SegmentTree(int n, Func<T, T, T> operation, T init, T ex) : this(n, operation, ex)
        {
            for (int i = offset; i < offset + n; i++)
                node[i] = init;
        }

        public SegmentTree(T[] values, Func<T, T, T> operation, T ex) : this(values.Length, operation, ex)
        {
            Array.Copy(values, 0, node, offset, values.Length);
            UpdateTree();
        }

        public void Assign(int i, T value)
            => node[offset + i] = value;

        public void AssignAndUpdate(int i, T value)
        {
            i += offset;
            node[i] = value;

            while (i > 0)
            {
                i = (i - 1) / 2;
                node[i] = func(node[2 * i + 1], node[2 * i + 2]);
            }
        }

        public void UpdateTree()
        {
            for (int i = offset - 1; i >= 0; i--)
                node[i] = func(node[2 * i + 1], node[2 * i + 2]);
        }

        public T Query(int head, int foot)
        {
            T leftValue = ex;
            T rightValue = ex;
            head += offset;
            foot += offset;

            while (head < foot)
            {
                if ((head & 1) == 0)
                    leftValue = func(leftValue, node[head++]);
                if ((foot & 1) == 1)
                    rightValue = func(node[foot--], rightValue);
                head >>= 1;
                foot = (foot - 1) >> 1;
            }
            return func(func(leftValue, node[head]), rightValue);
        }
    }

    class EDPC_Q
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var a = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var dp = new long[n + 1];
            var segmentTree = new SegmentTree<long>(n, (long x, long y) => Math.Max(x, y), 0, 0);

            for (int i = 0; i < n; i++)
            {
                var max = segmentTree.Query(0, h[i] - 1);
                segmentTree.AssignAndUpdate(h[i] - 1, max + a[i]);
            }
            Console.WriteLine(segmentTree.Query(0, n - 1));
        }
    }
}


Measured memory_bytes: 48560
#include <algorithm>
#include   <cstring>
#include    <cstdio>
#include    <vector>
using namespace std;

const int MAXN = 200000+9;
int n;
int num[MAXN];
int ans;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&num[i]);
		ans+=abs(num[i]-num[i-1]);
	}
	ans+=abs(num[n]);
	for(int i=1;i<=n;i++){
		int tmp=-abs(num[i]-num[i-1])-abs(num[i]-num[i+1])+abs(num[i+1]-num[i-1]);
		printf("%d\n",ans+tmp);
	}
	return 0;
}

Measured memory_bytes: 1536
n = int(input())
sp = []
for i in range(n):
        sp.append(input().split())
for i in range(n):
        sp[i][1] = int(sp[i][1])
for i in range(n):
        sp[i].append(i+1)
sp.sort()
start = 0
sp2=[]
for i in range(n-1):
        if sp[i][0] != sp[i+1][0]:
                sp2 = sp2+sorted(sp[start:i+1],key = lambda x:x[1],reverse = True)
                start = i+1
sp2 = sp2+sorted(sp[start:],key = lambda x:x[1],reverse = True)
for i in range(n):
        print(sp2[i][2])

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))

MAX = [1] * (N+1)
ans = [0] * (N+1)
INF = 10**15

if N == 0 and A[0] != 1:
    print(-1)
    exit()

for i in range(1, N+1):
    MAX[i] = min((MAX[i-1] - A[i-1]) * 2, INF)
    if MAX[i] < A[i]:
        print(-1)
        exit()

ans[N] = A[N]

for i in reversed(range(N)):
    ans[i] = min(ans[i+1]+A[i], MAX[i])

print(sum(ans))

Measured memory_bytes: 20152
while True:
    a, op, b = input().split(" ")
    a=int(a)
    b=int(b)

    if op =="?": break
    if op =="+": print("{}".format(a + b))
    if op =="-": print("{}".format(a - b))
    if op =="*": print("{}".format(a * b))
    if op =="/": print("{}".format(a // b))

Measured memory_bytes: 7680
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b;
	cin >> a >> b;
	int ans;
	if (a <= b)
		ans = a;
	else
		ans = a - 1;
	cout << ans << endl;
} 

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n, m;
char s[55][55];

int main() {
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++) scanf(" %c", &s[i][j]);
	bool flg = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			if(s[i][j] == '#') {
				if(s[i][j + 1] == '.' && s[i + 1][j] == '.' && s[i - 1][j] == '.' && s[i][j - 1] == '.') {
					flg = 0;
					break;
				}
			}
		}
	}
	if(flg) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
import fractions
n = int(input())
a = list(map(int,input().split()))
ans = 0
l = [0]*(n+1)
r = [0]*(n+1)
for i in range(n):
    l[i+1] =  fractions.gcd(l[i],a[i])
for i in range(n-1,0,-1):
    r[i] =  fractions.gcd(r[i+1],a[i])
for i in range(n):
    L = l[i]
    R = r[i+1]
    ans = max(ans,fractions.gcd(L,R))
print(ans)

Measured memory_bytes: 16136
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

const int M_N=200001;

struct UnionFind{
    int par[M_N];

    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
        }
    }

    void unite(int x,int y){
        if(x>y){
            par[x]=y;
        }
        else{
            if(par[y]==y) return;
            unite(x,par[y]);
        }
    }

};

map<int,int> mp;

int main(){
    int N;
    cin >> N;
    vector<LL> a;
    for(int i=0;i<N;i++){
        int s;
        cin >> s;
        a.push_back(s);
        mp[s]=i;
    }
    UnionFind uf,ruf;
    uf.init(N+1);
    ruf.init(N+1);
    for(int i=0;i<N-1;i++){
        uf.unite(a[i+1],a[i]);
    }
    for(int i=N-1;i>0;i--){
       ruf.unite(a[i-1],a[i]);
    }
    LL ans=0;
    for(int i=0;i<N;i++){
        LL l,r;
        l=i-mp[uf.par[a[i]]]-1;
        r=mp[ruf.par[a[i]]]-i-1;
        if(a[i]==uf.par[a[i]]){
            l=i;
        }
        if(a[i]==ruf.par[a[i]]){
            r=N-i-1;
        }
        ans+=a[i]*((r+l+1)*(r+l+2)/2-l*(l+1)/2-r*(r+1)/2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12784
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int a,b,c;
        a=scan.nextInt();
        b=scan.nextInt();
        c=scan.nextInt();
        int count=0;
        for(int i=a;i<=b;i++)if(c%i==0)count++;
        System.out.println(count);
   }
}


Measured memory_bytes: 26052
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
#define ref goto refrain
int main(){
	double a,b,c;
	cin>>a>>b>>c;
	c=c*M_PI/180;
	double S=a*b*sin(c)/2;
	printf("%lf\n",S);
	printf("%lf\n",a+b+sqrt(a*a+b*b-a*b*cos(c)*2));
	printf("%lf\n",S*2/a);
	return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	int n;
	while(cin >> n, n){
		double ww; // weight water
		cin >> ww;

		vector<double> vw(n), wf(n), vf(n), th(n);
		rep(i,n){
			cin >> vw[i] >> wf[i] >> vf[i] >> th[i];
		}

		auto C = [&](double w){
			double res = 0;
			rep(i,n){
				double a = (th[i] - w * vw[i]) / vf[i];
				if(a < 0) res += 0;
				else res += a * wf[i];
			}
			//cout << fixed << setprecision(8)<< w << ' ' << res + w * ww << endl;
			return res + w * ww;
		};


		double right = 1e15, left = 0;
		rep(i,200){
			double llr = (left * 2 + right) / 3;
			double rll = (left + right * 2) / 3;
			if(C(llr) > C(rll)){
				left = llr;
			}else{
				right = rll;
			}
		}

		cout << fixed << setprecision(8)  << C(left) << endl;

	}
}



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

const int MAXV = 6.1e5;
const int MAXN = 13;
int p3[MAXN];
int n;

struct node {
	int idx;
	node* c[3];
	bool lazy;
};

node* init(int cur, int pos) {
	node* v = new node();
	if (cur == n) {
		// leaf
		v->idx = pos;
	} else {
		for (int x = 0; x < 3; x++) {
			v->c[x] = init(cur+1, pos + p3[cur] * x);
		}
	}
	return v;
}

void apply(node* v) {
	assert(v);
	v->lazy = !v->lazy;
	swap(v->c[1], v->c[2]);
}

void propagate(node* v) {
	if (!v->lazy) return;
	v->lazy = false;
	for (int x = 0; x < 3; x++) apply(v->c[x]);
}

void upd(node* v, int cur) {
	if (cur == n) {
		// leaf
	} else {
		propagate(v);
		swap(v->c[1], v->c[2]);
		swap(v->c[0], v->c[1]);
		upd(v->c[0], cur+1);
	}
}

int ans[MAXV];

void dfs(node* v, int cur, int pos) {
	if (cur == n) {
		ans[v->idx] = pos;
	} else {
		propagate(v);
		for (int x = 0; x < 3; x++) dfs(v->c[x], cur+1, pos + x * p3[cur]);
	}
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	string t;
	cin >> n >> t;
	p3[0] = 1;
	for (int i = 1; i <= n; i++) p3[i] = p3[i-1] * 3;
	node* tr = init(0, 0);
	for (char op : t) {
		if (op == 'R') {
			upd(tr, 0);
		} else if (op == 'S') {
			apply(tr);
		} else assert(false);
	}
	dfs(tr, 0, 0);
	for (int i = 0; i < p3[n]; i++) {
		cout << ans[i] << " \n"[i+1==p3[n]];
	}
}


Measured memory_bytes: 43724
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n;
    R(n);
    VI an(n);
    REP(i,n){
        int x;
        R(x);
        an[x-1]=i+1;
    }
    W(an);
    return 0;
}


Measured memory_bytes: 1152
#include "cstdio"
using namespace std;
int main()
{
	int a,b,c;
	float x;
	scanf("%d %d",&a,&b);
	x=(float)(a+b)/2.0;
	c=(int)x;
	if(x-(float)c>=0.5)
	{
		printf("%d\n",c+1);
	}
	else
	{
		printf("%d\n",c);
	}
	return 0;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int a; cin >> a;
    pair<pair<string, int>, int> p[a];
    int t;
    string s;
    for(int i=0; i<a; i++){
        cin >> s >> t;
        p[i]=make_pair(make_pair(s, -t), i);
    }
    sort(p, p+a);
    for(int i=0; i<a; i++) cout << p[i].second+1 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int[] count = new int[a.Max() + 1];
        int am = a.Max();
        for (int i = 0; i < n; i++)
        {
            int m = a[i];
            if (m > 0)
                count[m - 1]++;
            count[m]++;
            if (m < am)
                count[m + 1]++;
        }
        C.WriteLine(count.Max());
    }
}
//以下標準出力用のクラス
static class C
{
    [System.Runtime.InteropServices.DllImport("msvcrt.dll")]
    private static extern void printf(string s);
    public static void Write(string s) { printf(s); }
    public static void Write(char c) { printf(c.ToString()); }
    public static void Write(long n) { printf(n.ToString()); }
    public static void Write(int n) { printf(n.ToString()); }
    public static void Write(double d) { printf(d.ToString()); }
    public static void WriteLine() { printf("\n"); }
    public static void WriteLine(string s) { printf(s + "\n"); }
    public static void WriteLine(char c) { WriteLine(c.ToString()); }
    public static void WriteLine(long n) { WriteLine(n.ToString()); }
    public static void WriteLine(int n) { WriteLine(n.ToString()); }
    public static void WriteLine(double d) { WriteLine(d.ToString()); }
    public static void WriteLines(string[] s) { foreach (var i in s) WriteLine(i); }
    public static void WriteLines(char[] c) { foreach (var i in c) WriteLine(i); }
    public static void WriteLines(long[] c) { foreach (var i in c) WriteLine(i); }
    public static void WriteLines(int[] c) { foreach (var i in c) WriteLine(i); }
    public static void WriteLines(double[] d) { foreach (var i in d) WriteLine(i); }
}

Measured memory_bytes: 18528
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795L
#ifndef DEBUG
#define debug(args...)
#else
#include "debug.h"
#endif
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef DEBUG
  freopen("inp.txt", "r", stdin);
#endif
  int n;
  cin>>n;
  switch(n%10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
    cout<<"hon\n";
    break;
    case 0:
    case 1:
    case 6:
    case 8:
    cout<<"pon\n";
    break;
    case 3:
    cout<<"bon\n";
  }
  return 0;
}


Measured memory_bytes: 3612
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

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

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

// const ll MOD = 998244353;
const ll MOD = 1000000007;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll x, a, b;
  std::cin >> x >> a >> b;
  std::cout << (x - a) - ((x - a) / b) * b;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
bool cmp(int a,int b)
{
    return a<b;
}
int main()
{
    int n,a[200],i;
    while(~scanf("%d",&n))
    {
        int acm=0;
        for(i=0;i<2*n;i++)
            scanf("%d",&a[i]);
        sort(a,a+2*n,cmp);
        for(i=0;i<2*n;i+=2)
            acm+=a[i];
        printf("%d\n",acm);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
//#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pi = pair<int, int>;
template <typename T>
using Pq = priority_queue<T>;
template <typename T>
using pQ = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> N >> K;
    if (K == 0) {
        REP(i, 1 << N) {
            cout << i << " " << i << endl;
        }
        return 0;
    }
    if (N == 1 && K == 1) {
        cout << -1 << endl;
        return 0;
    }
    pi mid = {-1, -1};
    REP(i, 1 << N) {
        ll x = K ^ i;
        if (x < (1 << N)) {
            mid = {i, x};
        }
    }
    if (mid == pi(-1, -1)) {
        cout << -1 << endl;
        return 0;
    }
    list<int> l;
    l.push_front(mid.first);
    l.push_back(mid.second);
    REP(i, 1 << N) {
        if (i == mid.first || i == mid.second) {
            continue;
        } else {
            l.push_front(i);
            l.push_back(i);
        }
    }
    l.push_front(mid.first);
    l.push_back(mid.second);
    for (auto x : l) {
        cout << x << " ";
    }
}

Measured memory_bytes: 11820
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <array>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	string a, b;
	cin >> a >> b;
	for(int i=0; i<n; i++){
		cout << a[i] << b[i];
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <numeric>

using namespace std;

vector<int> line_to_array(istream& is, const int cnt, const char sep);
vector<string> split(const string &str, const char sep);
string trim(const string& str, const char* trimCharacterList  = " \t\v\r\n");
bool chk_rcsv(int j, int k, char** t, bool** chk_t, string str, int pos);

int main(){
    //ifstream cin("inputAB55_3.txt");
    
    long N,M;
    long o;
    
    string str;
    vector<string> words;
    
    getline(cin, str);
    trim(str);
    words = split(str, ' ');
    N = atol(words[0].c_str());
    M = atol(words[1].c_str());
    
    if( M >= N*2 ){
        o = N + (M-N*2)/4;
    }else{
        o = M / 2;
    }
    
    cout << o << endl;
    
    return 0;
}

vector<int> line_to_array(istream& is, const int cnt, const char sep){
    vector<int> v;
    string str;
    getline(is, str);
    vector<string> words = split(str, sep);
    for (int i=0; i < cnt; i++) {
        v.push_back( atoi(words[i].c_str()) );
    }
    return v;
}

vector<string> split(const string &str, const char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ){
        v.push_back(buffer);
    }
    return v;
}

string trim(const string& str, const char* trimCharacterList)
{
    string result;
    string::size_type left = str.find_first_not_of(trimCharacterList);
    
    if (left != string::npos)
    {
        string::size_type right = str.find_last_not_of(trimCharacterList);
        result = str.substr(left, right - left + 1);
    }
    return result;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from heapq import heappush,heappop
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,X,Y=map(int,input().split())
    X-=1
    Y-=1
    
    def dijkstra(start,n,edges):
        d=[INF]*n
        used=[False]*n
        d[start]=0
        used[start]=True
        edgelist=[]
        for edge in edges[start]:
            heappush(edgelist,edge)
        while edgelist:
            minedge=heappop(edgelist)
            if used[minedge[1]]:
                continue
            v=minedge[1]
            d[v]=minedge[0]
            used[v]=True
            for edge in edges[v]:
                if not used[edge[1]]:
                    heappush(edgelist,(edge[0]+d[v],edge[1]))
        return d
    
    edges=[[] for _ in range(N)]
    for i in range(N-1):
        edges[i].append((1,i+1))
        edges[i+1].append((1,i))
    edges[X].append((1,Y))
    edges[Y].append((1,X))

    ans=[0]*N
    for i in range(N):
        d=dijkstra(i,N,edges)
        for x in d:
            ans[x]+=1
    for row in ans[1:]:
        print(row//2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 66012
#include <iostream>
#include <cmath>
#include <iomanip>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#define ll long long
         
using namespace std;
     
long long gcd(int x, int y){
     if ( x == 0 ) return y;
     
     return gcd(y%x, x);
}
     
long long lcm(int x, int y){
     if ( y == 0 ){
          return x;
     }
     
     return x*y/gcd(x, y);
}
     
int min(int a, int b){
     return a > b ? b : a;
}
     
double max(double a, double b){
     return a > b ? a : b;
}

int main()
{
     cin.sync_with_stdio( false );

     ll r,d, x;
     cin>>r>>d>>x;

     for (int i=0;i<10;i++){
          ll dd = r*x-d;
          cout<<dd<<endl;
          x=dd;
     }
}

Measured memory_bytes: 3620
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		long count = 0;
		int time = 0;
		for (int i = 1; ; i++) {
			count += i;
			if (count >= x) {
				time = i;
				break;
			}
		}
		System.out.println(time);
	}
}

Measured memory_bytes: 23764
num = int(input())
alist = input().split(" ")
alist = list(map(int,alist))

def max_number(l):
    sum = max(l)
    l.remove(sum)
    return sum

def alice_bob(n,m):
    q = 0
    a = 0
    b = 0
    while q <= n-1:
        temp = max_number(m)
        a += temp
        temp = 0
        q += 1
        if q <= n-1:
            temp = max_number(m)
            b += temp
            temp = 0
            q += 1
    sub = a-b
    return sub

ans = alice_bob(num,alist)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,a[1000000],b;
  cin>>n;
  for(int i=0;i<n;i++)scanf("%d",&a[i]);
  for(int i=n-1;i>=0;i-=2)printf("%d ",a[i]);
  if(n%2==1)b=1;
  else b=0;
  for(int i=b;i<n;i+=2){
    printf("%d",a[i]);
    if(!(i+2>=n))printf(" ");
    else printf("\n"); 
  }
  return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int f = 0 - a + b;

		if (b <= a) {
			System.out.println("delicious");;
		} else if (b - a <= x) {
			System.out.println("safe");
		} else {
			System.out.println("dangerous");
		}
	}
}

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

using namespace std;
const int INF = 1e9 + 7;

int gcd(int a, int b) {
  if (a < b) swap(a, b);
  while (b != 0) {
    int tmp = b;
    b = a % b;
    a = tmp;
  }

  return a;
}

int main()
{
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];

  for (int i = 0; i < N - 1; ++i) {
    A[i+1] = gcd(A[i], A[i+1]);
  }

  cout << A[N-1] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
constexpr ll INF = 1e18;
constexpr double PI = 3.14159265358979;

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

  long long n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  for(int i = a; i < c-2; i++){
    if(s[i] == '#' and s[i+1] == '#'){
      cout << "No\n";
      return 0;
    }
  }
  for(int i = b; i < d-2; i++){
    if(s[i] == '#' and s[i+1] == '#'){
      cout << "No\n";
      return 0;
    }
  }
  if(c > d){
    bool judge = false;
    for(int i = b-1; i <= d-1; i++){
      if(s[i-1] == '.' and s[i] == '.' and s[i+1] == '.'){
        judge = true;
      }
    }
    if(!judge){
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 592
_ = input()
numbers = list(map(int,input().split(' ')))

count = 0
finished = False
while True:
    for index, value in enumerate(numbers):
        if value % 2 == 0:
            numbers[index] = value / 2
        else:
            finished = True
            break
    if finished:
        break
    else:
        count += 1
print(count)

Measured memory_bytes: 3060
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)

	ans := a[0]
	for i := 0; i < n; i++ {
		ans = gcd(ans, a[i])
	}

	fmt.Fprintln(wr, ans)
}

func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}


Measured memory_bytes: 3072
using System;
using System.Linq;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true){
                string[] data = Console.ReadLine().Split(' ');
                if (data[0] == "0" && data[1] == "0") { break; }

                int num1 = Convert.ToInt32(data[0]);
                int num2 = Convert.ToInt32(data[1]);

                if (num1 < num2)
                {
                    Console.WriteLine(data[0] + " " + data[1]);
                }
                else
                {
                    Console.WriteLine(data[1] + " " + data[0]);
                }
            }
        }
    }
}

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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll l = 2;
    ll r = 3;
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    if (a[n - 1] != 2) {
        cout << -1;
        return 0;
    }
    for (int i = n - 2; i >= 0; --i) {
        if (r < a[i]) {
            cout << -1;
            return 0;
        }
        r = r - r % a[i] + a[i] - 1;
        l += (a[i] - (l % a[i])) % a[i];
    }
    if (l <= r) {
        cout << l << ' ' << r;
    } else {
        cout << -1;
    }
    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
S = gets.chomp.split

if S.to_set.length == 4
  puts 'Four'
else
  puts 'Three'
end


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

using namespace std;
int main(void){
    // Your code here!
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<long long> vecx(x,0),vecy(y,0),vecz(z,0),vectemp(x*y,0),ans(min(x*y,3000)*z,0);
    for(int i=0;i<x;i++){
        cin >> vecx[i];
    }
    for(int i=0;i<y;i++){
        cin >> vecy[i];
    }
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            vectemp[i+x*j]=vecx[i]+vecy[j];
        }
    }
    sort(vectemp.rbegin(),vectemp.rend());
    
     for(int i=0;i<y;i++){
        cin >> vecz[i];
    }
    
    for(int i=0;i<min(x*y,3000);i++){
        for(int j=0;j<z;j++){
            ans[i+min(x*y,3000)*j]=vectemp[i]+vecz[j];
        }
    }
    
    sort(ans.rbegin(),ans.rend());
    
    for(int i=0;i<k;i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 31616
#include "bits/stdc++.h"
using namespace std;
using ll = long long;


int main() {
	int n;
	ll k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int> s;
	vector<int>ord(n+1, -1);
	int c = 1,l=0;
	{
		int v = 1;
		while (ord[v] == -1) {
			ord[v] = s.size();
			s.push_back(v);
			v = a[v - 1];
		}
		c = s.size() - ord[v];
		l = ord[v];
	}
	if (k < l) {
		cout << s[k] << endl;
	}
	else {
		k -= l;
		k %= c;
		cout << s[l + k] << endl;
	}
	return 0;
}

Measured memory_bytes: 5888