akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra
from scipy.spatial.distance import cdist

xs,ys,xt,yt = map(int,input().split())
N = int(input())
XYR = np.empty((N+2,3),dtype=np.int64)
XYR[:2,] = [[xs,ys,0], [xt,yt,0]]

XYR[2:] = np.array([input().split() for _ in range(N)], dtype=np.int64)

XY = XYR[:,:2]
dist = cdist(XY, XY)
R = XYR[:,2]
dist -= R[:,None] + R[None,:]
np.maximum(dist, 0, out = dist)
dist[np.arange(N+2), np.arange(N+2)] = np.inf

graph = csgraph_from_dense(dist, null_value = np.inf)

answer = dijkstra(graph, indices = 0)[1]

print(answer)


Measured memory_bytes: 52456
#include<cstdio>

int BinarySearch(int D, int N, int *list) {
	int kiri=0;
	int kanan=N-1;
	int hasil=-1;
	while ((kiri<=kanan)&&(hasil==-1)) {
		int tengah=(kiri+kanan)/2;
		if(D<list[tengah]) {
			kanan=tengah-1;
		}
		if(D>list[tengah]) {
			kiri=tengah+1;
		}
		if(D==list[tengah]) {
			hasil=tengah;
			return hasil;
		}
	}
	return hasil;
}


int main() {
	int N;
	scanf("%d",&N);
	int list[N+1];
	for(int i=0;i<N;i++) {
		scanf("%d",&list[i]);
	}
	int Q;
	scanf("%d",&Q) ;
	int D[Q+1];
	for(int i=0;i<Q;i++) {
		scanf("%d",&D[i]);
	}
	int count=0;
	for (int i=0;i<Q;i++) {
		int y=BinarySearch(D[i],N,list);
		if(y!=-1) {
			count++;
		}
	}
	printf("%d\n",count);
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    vector <ll> as;
    vector <ll> bs;
    vector <ll> cs;
    REP(i, n){
        ll num; cin >> num;
        as.push_back(num);
    }
    REP(i, n){
        ll num; cin >> num;
        bs.push_back(num);
    }
    REP(i, n){
        ll num; cin >> num;
        cs.push_back(num);
    }
    ll ans = 0;
    ll last_dish = -2;
    REP(i, n){
        ll dish = as[i] - 1;
        if (dish - last_dish == 1){
            ans += cs[dish-1];
        }
        ans += bs[dish];
        last_dish = dish;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#3Nのうち前半部Nはどのような選択をしても前半部にしか所属できない
#3Nのうち後半部2N->3Nはどのような選択をしても後半部にしか所属できない。
#3Nのうち中盤部のN->2Nについて、前半に加えるか、後半に加えるか、加えないかの選択が発生する。
#中盤部をリストとする数列のどこまでをそれぞれに加えるかを考える。
#つまりそれぞれN~2NまでN通りの前後半部を作り、差分を調べる。
#それぞれについて最大最小部分をソート計算ではTLEだが、heapqを使えばO(N log N)？で実現できそう
#N->2Nまでを使った前半部の最大値リスト生成O(NlogN)
#N->2Nまでを使った後半部の最小値リスト生成O(NlogN)
#それぞれの差分を取って最大値となる答えを算O(N)なので、間に合いそう。

import heapq

N=int(input())
A=[int(x) for x in input().split()]

#前半部のheapqを生成
H=A[:N]
heapq.heapify(H)

#N->2Nを使った前半部の最大値計算
S=sum(A[:N])
F=[S]
for i in range(N,2*N):
  a=heapq.heappop(H)
  if a < A[i]:
    heapq.heappush(H, A[i])
    S+=(A[i]-a)
  else:
    heapq.heappush(H, a)
  F.append(S)

#後半部のheapqを生成
H=[int(x)*-1 for x in A[2*N:]]
heapq.heapify(H)

#同様にN->2Nを使った後半部の最小値計算
S=sum(A[2*N:])
F2=[S]
for i in range(2*N-1,N-1,-1):
  a=heapq.heappop(H)*(-1)
  if a > A[i]:
    heapq.heappush(H, A[i]*(-1))
    S+=(A[i]-a)
  else:
    heapq.heappush(H, -a)
  F2.append(S)
  
#差分計算
F2=F2[:][::-1]
ans=(10**14)*(-1)

for i in range(N+1):
  ans=max(ans,F[i]-F2[i])
print(ans)


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

namespace ABC147A
{
	class Program
	{
		static void Main(string[] args)
		{
			int A1, A2, A3;
			var word = Console.ReadLine().Split(' ');
			A1 = int.Parse(word[0]);
			A2 = int.Parse(word[1]);
			A3 = int.Parse(word[2]);

			if (A1 + A2 + A3 >= 22)
				Console.WriteLine("bust");
			else
				Console.WriteLine("win");

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 13140
import java.util.Scanner;



public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String str2 = sc.nextLine();
		String str3 = str2.substring(0, str2.length() - 1);
		if(str.equals(str3)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35684
#include <iostream>

using namespace std;

int main() {
    unsigned long long n;
    cin >> n;
    bool enable = true;
    long long x0 = 0;
    long long y0 = 0;
    long long t0 = 0;
    for (unsigned long long i = 0; i < n; ++i) {
        long long x, y, t;
        cin >> t >> x >> y;
        long long dist = abs(x - x0) + abs(y - y0);
        long long time = t - t0;
        if (dist > time) {
            enable = false;
            break;
        }

        if ((dist % 2 != 0 && time % 2 != 0) || (dist % 2 == 0 && time % 2 == 0)) {
            x0 = x;
            y0 = y;
            t0 = t;
        }
        else {
            enable = false;
            break;
        }
    }
    cout << (enable ? "Yes" : "No") << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/05/02.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC16８8
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

template<class T> inline bool chmin(T& a, T b){ if(a>b){a=b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b){ if(a<b){a=b; return 1;} return 0;}

 const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const int MOD = 1000000007;
//#define __DBG__



void solve(void){
  
  int K;
  string S;
  
  cin >> K >> S;
  
  if(S.size()<=K){
    cout << S << endl;
  }
  else
  {
    cout << S.substr(0,K) << "..." << endl;
  }
  
  return;
}



#define TESTCASES 1

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}




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

using namespace std;

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

  	const int NMMAX = 50;
    int A[NMMAX], B[NMMAX];
	for (int i = 0; i < M; ++i){
    cin >> A[i] >> B[i];
	}

  	int road[NMMAX];
	for (int i = 0;i < N; ++i){
	road[i] = 0;
    }

  	for (int i = 0;i < M;++i){
    	road[A[i] - 1] += 1;
    	road[B[i] - 1] += 1;
	}
	for (int i = 0; i < N;++i){ 
     cout << road[i] << endl;
	}
	return 0;
	}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	long gcd(long a,long b) {
		return a==0?b:gcd(b%a,a);
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		long X=sc.nextLong();//X*N=360Z
		System.out.println(360/gcd(X,360));
	}

	void tr(Object...o) {System.out.println(Arrays.deepToString(o));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
        	ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 32432
#include <bits/stdc++.h>
using namespace std;
vector<int> v[100005];
bool del[100005];
int deg[100005],dep[100005],ord[100005],par[100005];
void dfs(int node,int p)
{
	dep[node]=dep[p]+1;
	par[node]=p;
	for (int u:v[node])
	{
		if (u!=p)
		dfs(u,node);
	}
}
bool cmp(int a,int b)
{
	return dep[a]>dep[b];
}
int main()
{
	int n;
	scanf("%d",&n);
	if (n%2)
	{
		printf("First");
		return 0;
	}
	for (int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
		deg[a]++;
		deg[b]++;
	}
	dfs(1,0);
	for (int i=1;i<=n;i++)
	ord[i]=i;
	sort(ord+1,ord+n+1,cmp);
	for (int i=1;i<=n;i++)
	{
		if (del[ord[i]])
		continue;
		if (deg[par[ord[i]]]>2)
		{
			printf("First");
			return 0;
		}
		del[par[ord[i]]]=1;
		deg[par[par[ord[i]]]]--;
	}
	printf("Second");
}

Measured memory_bytes: 7808
from collections import deque
def main():
    H, W = map(int,input().split())
    s = [list(map(str,input())) for _ in range(H)]
    dist = [[-1]*W for _ in range(H)]
    
    q = deque([])
    for i in range(H):
        for j in range(W):
            if s[i][j] == "#":
                dist[i][j] = 0
                q.append((i, j))
    
    ans = 0
    while q:
        x, y = q.popleft()
        dx = [1, -1, 0, 0]
        dy = [0, 0, 1, -1]
        for i in range(4):
            nx = x+dx[i]
            ny = y+dy[i]
            if (0 <= nx < H and 0 <= ny < W and dist[nx][ny] == -1 and s[nx][ny] == '.'):
                dist[nx][ny] = dist[x][y] + 1
                q.append((nx, ny))
                ans = max(ans, dist[nx][ny])
                
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 155376
#define _CRT_SECURE_NO_WARNINGS
#include <math.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <iterator>
#include <vector>
#include <string>
#include <string.h>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <map>
#include <regex>
#include <sstream>
#include <utility>
#include <list>
#include <unordered_set>
#include <unordered_map>
#define endl	'\n'
#define MOD 1000000

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
int dx[] = { 0,1,0,-1 };
int dy[] = { -1,0,1,0 };
int dz[] = { 0,0,0,0,1,-1 };
const int INF = 1000000000;

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

	int n;
	cin >> n; 
	vector<int> v(n);

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

	for (int i = n - 1; i > 0; i--) {
		if(v[i] >= v[i - 1]) continue;
      	else if(v[i - 1] - 1 == v[i]) v[i - 1] -= 1; 
        else {
          cout << "No";
          return 0;
        }
        
      
	}

	cout << "Yes";
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    
    if( n*500 >= x )
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#ifdef LOCAL
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
#else
#define dmp(x) void(0)
#endif

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;
}
const int mod = 1000000007;

const int INF=1000000007;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;

using vi = vc<int>;
int gcd(int a, int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int lcm(int a, int b)
{
  return (a * b) / gcd(a, b);
}
int fact(int n)
{
  if (n == 0)
    return 1;
  return n * fact(n - 1);
}

int main()
{
  int n,m;
  cin >> n>>m;
  vc<P> a(n);
  rep(i,n)cin>>a[i].first>>a[i].second;
  vc<P> to(m+1);
  rep(i,m)cin>>to[i+1].first>>to[i+1].second;
 	
  	int dist=0;
  rep(i,n){
    int ans=0;
          int min=INF;
    for(int j=1;j<=m;j++){

    int x=abs(a[i].first-to[j].first);
    int y=abs(a[i].second-to[j].second);
      dist=x+y;
      if(min>dist){
        min=dist;
        ans=j;
      }
    }
    cout <<ans<<endl;
  }
  
}

Measured memory_bytes: 256
from sys import stdin

MAX = 10 ** 6
MOD = 10 ** 9 + 7
fac = [0] * MAX
finv = fac[:]
inv = fac[:]


def cmb_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD


def cmb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


def main():
    X, Y = [int(x) for x in stdin.readline().rstrip().split()]
    if (X + Y) % 3:
        print(0)
    else:
        m = (2 * X - Y) // 3
        n = X - 2 * m
        if n < 0 or m < 0:
            print(0)
        else:
            cmb_init()
            ans = cmb(n + m, min(n, m))
            print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 121716
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    rep(i,n){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    int ans = 0;
    rep(i,k){
        ans+=v[i];
    }
    cout<<ans<<endl;
    
return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long int
#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 all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    string s;
    cin >> s;
    rep(i, s.size()) cout << "x";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3560
import java.util.*;
public class Main{
	static String Vari(String s){
		char[] c = new char[s.length()];
		for(int i=0; i<s.length(); i++){
			c[i] = s.charAt(i);
		}
		for(int i=0; i<s.length()-1; i++){
			for(int j=i+1; j<s.length(); j++){
				if(c[i]==c[j])return "no";
			}
		}
		return "yes";
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		System.out.println(Vari(S));
	}
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	cout << (s == "ABC" ? "ARC" : "ABC");
}



Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
using namespace std;
int a[200020];
int b[200020];
char c[200020];
int n,k,c1;
int main()
{
    int p=0,q=0;
    int temp=99999999;
    cin>>n>>k>>c1;
    cin>>c;
    for(int i=0; i<n; i++)
    {
        if(p==k)
        {
            break;
        }
        if(c[i]=='o'&&temp>=c1)
        {
            a[p++]=i;
            temp=0;
        }
        else
        {
            temp++;
        }

    }
    temp=99999999;
    q=k-1;
    for(int i=n-1; i>=0; i--)
    {
        if(q<0)
        {
            break;
        }
        if(c[i]=='o'&&temp>=c1)
        {
            b[q--]=i;
            temp=0;
        }
        else
        {
            temp++;
        }
    }
    for(int i=0;i<k;i++)
    {
        if(a[i]==b[i])
        {
            cout<<a[i]+1<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5276
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <numeric>
#include <regex>
#include <locale>
#include <fstream>
#include <stdlib.h>
#include <cctype>

//#include <map>

using namespace std;

int main()
{
	string W, T;
	getline(cin, W);

	while (1)
	{
		string st;
		getline(cin, st);
		if (st == "END_OF_TEXT")break;

		T += st + '\n';
	}

	string temp;
	int count = 0;

	for (int i = 0; i < W.size(); i++)
	{
		T.at(i) = tolower(T.at(i));
	}

	for (int i = 0; i < T.size(); i++)
	{
	if (T.at(i) != ' ' && T.at(i) != '.' && T.at(i) != '\n')
		{
			temp += tolower(T.at(i));
		}
		else
		{
			if (temp == W)
			{
				count++;
			}
			temp = "";
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3164
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
typedef long long ll;
const int N=500005;

using namespace std;

int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	int a,b;
	cin>>a>>b;
	if (a+b==15){printf ("+");return 0;}
	if (a*b==15){printf ("*");return 0;}
	printf ("x");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll a, b, ans = 0;
int main() {
	cin >> a >> b;
	for (long long i = a; i < (a + 4) / 4 * 4; i++) {
		ans ^= i;
	}
	for (long long i = 4 * (b / 4); i <= b; i++) {
		ans ^= i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
	int H,W,h,w;
	cin >> H >> W >> h >> w;
	cout<<(H-h)*(W-w)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<list>
#include<set>
#include<map>
#include<stack>
using namespace std;

int main()
{
	int n,m;
	int node[110];
	cin>>n>>m;
	int sum = 0;
	int ans = 0;
	for(int i=0;i<n;i++)
	{
		cin>>node[i];
		sum+=node[i];
		ans = max(ans,node[i]); 
	}
	sort(node,node+n);
	int flag = m;
	for(int i=n-1;i>=0;i--)
	{
		if(node[i]>=1.0/(4*m)*sum)
		{
			flag--;
		}
		if(flag==0) break;
	}
	if(flag==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}	

Measured memory_bytes: 256
inf = float("inf")
N = int(input())
A = []
for _ in range(N):
    a = [int(s) for s in input().split()]
    A.append(a)
d = [a[:] for a in A]
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        dmin = min([inf] + [d[i][k] + d[k][j]
                            for k in range(N) if k not in (i, j)])
        if d[i][j] > dmin:
            print(-1)
            exit()
        if d[i][j] != dmin:
            ans += d[i][j]
print(ans)


Measured memory_bytes: 45660
// /**
// *    author:  Dooloper
// *    created: 30.05.2020 02:26:02
// **/

// #include <iostream>
// #include <vector>
// #include <map>
// #include <string>
// #include <utility>
// #include <algorithm>
// #include <queue>
// #include <deque>
// #include <stack>


// using namespace std;
// typedef unsigned long long ll;

// int main() {
//     cin.tie(0);
//     int N;cin>>N;
//     vector<int>A(N+1);
//     for(int i = 0; i < N+1; i++){
//         cin>>A[i];
//     }

//     int now_node = 1;
//     int node  = 1;
//     for(int i = 0; i < N; i++){
//         if(now_node <= 0){
//             node = -1;
//             break;
//         }

//         now_node = (now_node-A[i])*2;
//         node += now_node;
//         cout<<node<<endl;
//     }
//     if(now_node == A[A.size() -1])
//         cout<<node<<endl;
//     else{
//         cout<<-1<<endl;
//     }
// }

/**
*    author:  Dooloper
*    created: 30.05.2020 02:26:02
**/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>


using namespace std;
typedef unsigned long long ll;

int main() {
    cin.tie(0);
    string S;
    cin>> S;
    for(int i = 0; i < S.size() ; i++){
        if(S[i] == '?'){
            S[i] = 'D';
        }
    }

    cout<<S<<endl;
}


Measured memory_bytes: 3752
#include <iostream>

using namespace std;

int main()
{
	long n, d, ans = 0;
	cin >> n >> d;
	long x[200010], y[200010];
	for (long i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	for (long i = 0; i < n; i++) {
		if ((x[i] * x[i]) + (y[i] * y[i]) <= d*d) {
			ans++;
		}
	}
	cout << ans;
	return 0;
}



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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    string S, T;
    cin >> S >> T;

    int s = -1;
    for (int i = S.length() - 1; i >= 0; --i)
    {
        if (i + T.length() > S.length())
            continue;

        bool find = true;
        REP(j, T.length())
        {
            if (S[i + j] == '?' || S[i + j] == T[j])
                continue;
            find = false;
        }
        if (find)
        {
            s = i;
            break;
        }
    }
    if (s == -1)
    {
        cout << "UNRESTORABLE" << endl;
    }
    else
    {
        REP(i, S.length())
        {
            if (i < s || s + T.length() <= i)
            {
                if (S[i] == '?')
                    cout << 'a';
                else
                    cout << S[i];
            }
            else
            {
                cout << T[i - s];
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main (){
  string S;
  cin >> S;
  
  string T;
  
  string divide[4] = {"dream", "dreamer", "erase", "eraser"};
  
  reverse(S.begin(), S.end());
  for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());
  
  // 端から切っていく
  bool can = true;
  for (int i = 0; i < S.size();) {
    bool can2 = false; // 4 個の文字列たちどれかで divide できるか
    for (int j = 0; j < 4; ++j) {
      string d = divide[j];
      if (S.substr(i, d.size()) == d) { // d で divide できるか
        can2 = true;
        i += d.size(); // divide できたら i を進める
      }
    }
    if (!can2) { // divide できなかったら
      can = false;
      break;
    }
  }
  
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> h = new ArrayList<Integer>();
		ArrayList<Integer> w = new ArrayList<Integer>();

		int a, b;


		while ((a = sc.nextInt()) != 0 | (b = sc.nextInt()) != 0) {
			h.add(a);
			w.add(b);
		}

		for(int i = 0; i < h.size(); i++) {

			for(int j = 0; j < h.get(i); j++) {

				for(int k = 0; k < w.get(i); k++) {

					if(j % 2 == 0 && k % 2 == 0){
						System.out.print("#");
					} else if (j % 2 == 0 && k % 2 != 0){
						System.out.print(".");
					} else if (j % 2 != 0 && k % 2 == 0) {
						System.out.print(".");
					} else if (j % 2 != 0 && k % 2 != 0) {
						System.out.print("#");
					}

				}
				System.out.println();

			}
			System.out.println();

		}
	}

}





Measured memory_bytes: 34932
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<stdio.h>
using namespace std;

int main(){

	int ans = 0;
	int mymin = 100000;
	int H[100000];

	int N, T, A;
	int x; 

	cin >> N >> T >> A;

	x = (T - A) * 1000 / 6;

	for (int i = 1; i <= N; i++) {
		cin >> H[i];
		mymin = min(mymin, abs(x - H[i]));
		ans = (mymin == abs(x - H[i])) ? i : ans;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long ll;

ll gcd(ll a,ll b)
{
    return b ? gcd(b, a % b) : a;
}
ll lcm(ll a,ll b)
{
    return a / gcd(a, b) * b;
}

int main(){
    int a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    H = [int(number) for number in input().split()]

    ans = 0
    num = 0
    for i in range(N):
        if i != N-1:
            if H[i] >= H[i+1]:
                num += 1
            else:
                num = 0
        if num > ans:
            ans = num
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    int mn=inf;
    int mx=0;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        chmin(mn,a);
        chmax(mx,a);
    }
    cout << mx-mn << enld;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    ll n;
    cin >> n;
     ll ans  =modpow(10,n,mod)+modpow(8,n,mod);
     ans%=mod;
     ans=ans-modpow(9,n,mod)-modpow(9,n,mod);
     ans%=mod;
     if(ans<0){
         ans+=mod;
     }
     cout<<ans<<endl;
}
    



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 998244353;
ll n;
ll a[200005], b[200005];
int main () {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i] >> b[i];
        if (n % 2 == 0) a[i] *= 2, b[i] *= 2;
    }

    sort(a + 1, a + 1 + n);
    sort(b + 1, b + 1 + n);

    ll mn = (n % 2 == 0 ? (a[n/2] + a[n/2+1])/2 : a[(n+1)/2]);
    ll mx = (n % 2 == 0 ? (b[n/2] + b[n/2+1])/2 : b[(n+1)/2]);

    cout << mx - mn + 1 << endl;
}

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

const int INF = 1e9;
int a[50],b[50],c[50];
int dp[50][500][500];

signed main(){

  int n,Ma,Mb; cin >> n >> Ma >> Mb;
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i] >> c[i];
  }

  for(int i = 0; i < 50; i++){
    for(int j = 0; j < 500; j++){
      for(int k = 0; k < 500; k++){
        dp[i][j][k] = INF;
      }
    }
  }

  dp[0][0][0] = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 500; j++){
      for(int k = 0; k < 500; k++){
        dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
        dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
      }
    }
  }



  int ans = INF;
  for(int j = 1; j < 500; j++){
    for(int k = 1; k < 500; k++){
      if(j*Mb == k*Ma) ans = min(ans,dp[n][j][k]);
    }
  }
  if(ans == INF) ans = -1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 49024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    ll n;
    ll k;
    cin >> n>>k;
    vector<ll> loop(n);
    map<ll,pair<ll,ll>> data;
    rep(i,0,n){
        cin >> loop[i];
    }
    rep(i,0,n){
        rep(j,0,n){
            if(loop[i]<loop[j]&&i>j){
                data[i].first++;
                data[i].second++;

            }else if(loop[i]<loop[j]&&i<j){
                data[i].second++;
            }
        }
    }
    //cout<<data[1].first<<data[1].second<<endl;
    ll ans=0;
    rep(i,0,n){
        ans+=(data[i].first*k)%MOD;
        ans%=MOD;
        ans+=((k-1)*k/2%MOD)*data[i].second%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 3768
#include <stdio.h>

int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a % 3 == 0 ||b % 3 == 0||(a+b) % 3 == 0){
		printf("Possible");
	}
	else{printf("Impossible");}
	return 0;
}

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

int main(){
    int ansX, ansY, ansH;
    int hX, hY, hH;
    int i, N, hhH;
    int X[110], Y[110], H[110];
    bool sflag = false;
    bool can = true;

    cin >> N;
    for(i=0; i<N; i++) cin >> X[i] >> Y[i] >> H[i]; 

    for(hX=0; hX<=100; hX++){
        for(hY=0; hY<=100; hY++){

            for(i=0; i<N; i++){
                if(H[i] != 0){
                    hH = H[i] + abs(X[i]-hX) + abs(Y[i]-hY);
                    break;
                }
            }
            for(i=0; i<N; i++){
                if(H[i] != max(hH-abs(X[i]-hX)-abs(Y[i]-hY), 0)){
                    can = false;
                    break;
                }
            }

            if(can){
                ansX = hX;
                ansY = hY;
                ansH = hH;
                cout << ansX << " " << ansY << " " << ansH << endl;
                return 0;
            }else{
                can = true;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int num_divisors(int n)
{
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (n % i == 0) {
			++ans;
		}
	}
	return ans;
}

int main()
{
	int N;
	cin >> N;
	
	int ans = 0;
	for (int i = 1; i <= N; i += 2) {
		if (num_divisors(i) == 8) {
			++ans;
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a, i, x[100];
	scanf("%d", &a);
	for(i=0;i<a;i++){
		scanf("%d", &x[i]);
	}
	for(i=a-1;i>=0;i--){
		printf("%d", x[i]);
		if(i!=0){
			printf(" ");
		}
	}
	printf("\n");
}


Measured memory_bytes: 2104
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int N = sc.NextInt();
        int K = sc.NextInt() - 1;
        var c = sc.Next().ToCharArray();
        c[K] = (char) (c[K] + 'a' - 'A');
        Console.WriteLine(new string(c));
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer n = Integer.parseInt(scanner.next());
        char[] x = scanner.next().toCharArray();

        char tmp = (char) -1;
        int count = 0;
        for(int i = 0; i < n; i++) {
            if(x[i] != tmp) {
                tmp = x[i];
                count++;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 26980
N = int(input())

sList = {}

for i in range(N) :
    s = list(input())
    s.sort()
    s = ''.join(s)

    if s in sList :
        sList[s] += 1
    else :
        sList[s] = 1

ans = 0
for _, num in sList.items() :
    ans += num * (num - 1) // 2

print(ans)


Measured memory_bytes: 60376
N,M = map(int,input().split())
a = []
b = []
c = []
d = []
for i in range(N):
  x,y = map(int,input().split())
  a.append(x)
  b.append(y)
for i in range(M):
  x,y = map(int,input().split())
  c.append(x)
  d.append(y)
for i in range(N):
  tmp=10**9
  index=-1
  for j in range(M):
    if tmp>abs(a[i]-c[j])+abs(b[i]-d[j]):
      tmp = abs(a[i]-c[j])+abs(b[i]-d[j])
      index=j
  print(index+1)    
  
      
    

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

int main() {
  int A, B;
  cin >> A >> B;
  if (A >= 13) {
   cout << B << endl;
  } else if (A >= 6 && A <= 12) {
   cout << (B / 2) << endl;
  } else {
  	cout << 0 << endl;
  }
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n, w;
    while(cin >> n >> w, n || w) {
        int block[110] = {};
        int bars = 0, ma = 0;
        rep(i,0,n) {
            int inp; cin >> inp;
            int d = inp / w;
            block[d]++;
            bars = max(bars, d);
            ma = max(ma, block[d]);
        }

        double ans = 0.01;
        repq(i,0,bars) {
            // printf("debug: block[%lld] = %lld\n", i, block[i]);
            double darkness;
            if(bars == 0) darkness = 1.0;
            else darkness = (bars - i) / (double)bars;
            double pr = (double)block[i] / ma;
            ans += darkness * pr;
        }
        printf("%.12f\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3156
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

W, a, b = nl()

if (a <= b and b <= a+W) or (b <= a and a <= b+W):
    print(0)
else:
    print(min(abs(a+W - b), abs(a - b - W)))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(void){
    // Your code here!
    long long int n;
    cin >> n;
    
    long long int l[n];
    int i,j,k;
    
    for(i=0;i<n;i++){
        cin >> l[i];
    }
    long long int count=0;
    for(i=0;i<n-2;i++){
        for(j=i+1;j<n-1;j++){
            for(k=j+1;k<n;k++){
                if(l[i]<l[j]+l[k]&&l[j]<l[i]+l[k]&&l[k]<l[j]+l[i]&&l[i]!=l[j]&&l[k]!=l[j]&&l[i]!=l[k]){
                    //printf("%d %d %d\n",i+1,j+1,k+1);
                    count++;
                }
            }
        }
    }
    
    cout << count << endl;
    
}

Measured memory_bytes: 3632
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = myconv(next(),1);
  var list = myconv(next(),4);
  var s = new Array(N + 1);
  s[0] = 0;
  var set = {"0" : 0};
  var output = 0;
  for(var i = 0; i < N; i++){
    s[i + 1] = s[i] + list[i];
    if(set[s[i + 1]] == null){
       set[s[i + 1]] = 0;
    }else{
       set[s[i + 1]]++;
      output += set[s[i + 1]];
    }
  }
  
  myout(output);
}


Measured memory_bytes: 90060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <cstring>
#include <queue>
#include <sys/time.h>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rev(i,n) for(int i=(int)n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ( (a)/__gcd((a),(b))*(b) )

template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}

#define VAR(x) ((x) << 1)
#define NOT(x) ((x) ^ 1)

const int MAX_K = 3;
struct clause {
public:
  int k;
  int var[MAX_K];
};
bool satisfiability(int m, int n, clause cs[]) {
  int K = 100 * sqrt(m);
  for (int i = 0; i < m; ++i)
    K = K * 2 * (cs[i].k - 1) / cs[i].k;
  int x[m];
  while (--K) {
    for (int i = 0; i < m; ++i) // random assignment
      x[i] = rand() % 2;
    for (int i, j, t = 0; t < 3*m; ++t) { // local search
      for (i = 0; i < n; ++i) {
        for (j = 0; j < cs[i].k; ++j)
          if ((cs[i].var[j] & 1) != x[cs[i].var[j] >> 1]) break;
        if (j == cs[i].k) break;
      }
      if (i == n) return true;
      int k = cs[i].var[ rand() % cs[i].k ] >> 1;
      x[k] = 1-x[k];
    }
  }
  return false;
}

int encode(char c){
	static map<char,int> ok;
	if(ok.count(c)) return ok[c];
	else{
		int k = ok.size();
		ok[c] = k;
		return k;
	}
}
clause h[5000];
int main(){
	string s;
	while(cin >> s && s != "#"){
		rep(i,5000) h[i].k = 0;
		rep(i,s.size()) if(s[i]=='|' || s[i] == '(' || s[i] == ')' )s[i] = ' ';
		stringstream ss(s);
		vector<string> t;string tmp;
		while(ss >> tmp)t.push_back(tmp);
		set<int> items;
		rep(i,t.size()){
			rep(j,t[i].size())if(t[i][j]=='&')t[i][j] = ' ';
			stringstream s2(t[i]);
			while(s2 >> tmp){
				//cout << tmp << endl;
				if(tmp[0]=='~'){
					items.insert(encode(tmp[1]));
					h[i].var[h[i].k++] = NOT(VAR(encode(tmp[1])));
				}else{
					items.insert(encode(tmp[0]));
					h[i].var[h[i].k++] = VAR(encode(tmp[0]));
				}
			}
		}
		int m = items.size();
		int n = t.size();
		bool flag = false;
		rep(i,n){
			int K = h[i].k;
			bool bad = 0;
			rep(j,K){
				rep(k,K){
					if(h[i].var[k] == NOT(h[i].var[j])) bad = true;
				}
			}
			if(!bad){
				flag = true;
				break;
			}
		}
		cout << (flag?"yes":"no") << endl;
	}
}

Measured memory_bytes: 1000