akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque

N, M = map(int, input().split())
G = [[] for _ in range(N)]
goal = False

for _ in range(M):
    A, B = map(int, input().split())
    G[A - 1].append(B - 1)
    G[B - 1].append(A - 1)
    if A == 1 or B == 1:
        goal = True

if goal:
    print("Yes")
else:
    print("No")
    sys.exit()

d = deque([0])
ans = [-1] * N

while d:
     q = d.popleft()
     for g in G[q]:
         if ans[g] == -1:
             ans[g] = q + 1
             d.append(g)

for i in range(1, N):
    print(ans[i])

Measured memory_bytes: 94584
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	int H, W;
	cin >> H >> W;
	deque<pair<int, int>> path;
	vector<vector<int>> d(H, vector<int>(W));
	vector<string> A(H);
	rep(i, 0, H)cin >> A[i];
	rep(i, 0, H) {
		rep(i2, 0, W) {
			if (A[i][i2] == '#')path.push_back({ i, i2 });
		}
	}
	int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };
	int ans = 0;
	while (path.size()) {
		auto it = path.front();
		path.pop_front();
		rep(i, 0, 4) {
			int tx = it.second + dx[i], ty = it.first + dy[i];
			if (tx < 0 || tx >= W || ty < 0 || ty >= H)continue;
			if (A[ty][tx] == '.' && d[ty][tx] == 0) {
				d[ty][tx] = d[it.first][it.second] + 1;
				ans = max(ans, d[ty][tx]);
				path.push_back({ty, tx});
			}
		}
		/*rep(i, 0, H) {
			rep(i2, 0, W) {
				if (d[i][i2])printf("%d", d[i][i2]);
				else printf("%c", A[i][i2]);
			}
			puts("");
		}
		puts("");*/
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 17220
import numpy
N = int(input())
H = [i for i in map(int,input().split())]
H_slide = H[:-1]
diff = numpy.array([H[i+1] - H_slide[i] for i in range(N-1)])
diff = diff <= 0
count = 0
max_count = 0
for i in range(N-1):
  if diff[i]:
    count += 1
  else:
    if max_count < count:
      max_count = count
    count = 0
if max_count < count:
    max_count = count
print(max_count)

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n-1);
    for(int i = 0; i < n; i++)  cin >> a[i];
    for(int i = 0; i < n; i++)  cin >> b[i];
    for(int i = 0; i < n-1; i++)    cin >> c[i];
    int ans = accumulate(b.begin(), b.end(), 0);
    for(int i = 1; i < n; i++){
        if(a[i]-1 == a[i-1])    ans += c[a[i-1]-1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def solve():
    p0, p1, p2 = 0, 1, 2
    best = 1
    succ = True
    while p0 < N-1:
        if not succ:
            p0 += 1
            while d[p2]- d[p1] > d[p1]- d[p0]:
                p2 -= 1

        succ = False

        while p1 - p0 < N - 1 and d[p1] - d[p0] <= best:
            p1 += 1
        d0 = d[p1] - d[p0]
        if d0 <= best:
            continue

        while p2 - p0 < N and d[p2] - d[p1] < d0:
            p2 += 1
        if d[p2] - d[p1] < d0:
            continue

        if L - (d[p2] - d[p0]) >= d0:
            best = d0
            if best >= L//3:
                return best
            succ = True

    return best

N = int(input())
A = [int(input()) for i in range(N)]
L = sum(A)
d = [0] * (2 * N)
for i in range(1, 2 * N):
    d[i] = d[i-1] + A[(i-1)%N]

print(solve())

Measured memory_bytes: 20904
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean[][] trumps = new boolean[4][13];
		int n = sc.nextInt();
		String character;
		int number;
		int trumpsIndex = 0;
		for (int i = 0; i < n; i++) {
			character = sc.next();
			number = sc.nextInt() - 1;
			switch (character) {
			case "S":
				trumpsIndex = 0;
				break;
			case "H":
				trumpsIndex = 1;
				break;
			case "C":
				trumpsIndex = 2;
				break;
			case "D":
				trumpsIndex = 3;
				break;
			}
			trumps[trumpsIndex][number] = true;
		}
		character = "";
		for (int i = 0; i < trumps.length; i++) {
			for (int j = 0; j < trumps[i].length; j++) {
				if (trumps[i][j] == false) {
					switch (i) {
					case 0:
						character = "S";
						break;
					case 1:
						character = "H";
						break;
					case 2:
						character = "C";
						break;
					case 3:
						character = "D";
						break;
					}
					System.out.println(character + " " + (j + 1));
				}
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 26440
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){

  string S, T;
  cin >> S >> T;

  for (int i = 0; i < S.size(); i++) {
    if(S[i] != T[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3628
from _collections import deque


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
import scipy
from collections import deque
from math import sqrt
from math import floor
#https://atcoder.jp/contests/agc034/tasks/agc034_b
#B - ABC
"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()

ans = []

while (N != 0):  #
    r = N % 4
    #print(N, r)
    if (r == 0):  #
        ans.append(0)
        ans.append(0)  #
    elif r == 1:
        ans.append(1)
        ans.append(0)
    elif r == 2:
        ans.append(0)
        ans.append(1)
        N += 4
    else:
        ans.append(1)
        ans.append(1)
        N += 4
    N //= 4  #

if len(ans):
    ans.reverse()
    si = 0
    if (ans[si] == 0):  #
        si += 1

    for i in range(si, len(ans)):
        print(ans[i], end="")
else:
    print(0)  #


Measured memory_bytes: 12864
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, L;
  while (cin >> N >> L) {
    int mind = 1 << 25, res;
    int sum = 0;
    for (int i = 0; i < N; i++) sum += L + i;
    for (int i = 0; i < N; i++) {
      int b = 0;
      for (int j = 0; j < N; j++) {
        if (j == i) continue;
        b += L + j;
      }
      int d = abs(sum - b);
      if (d < mind) {
        mind = d;
        res = b;
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

struct list{
	char name[15];
	int time;
};

int main()
{
	int n,q,T=0;
	int i=0;
	scanf("%d%d",&n,&q);//要素数とターンアラウンドタイムの受け取り
	int coun=n;
	struct list node[n+1];
	while(coun--)//入力の受け取り
	{
		scanf("%s %d",&node[i].name,&node[i].time);
		i++;
	}
	for(int head=0,tail=n;head!=tail;head=(head+1)%(n+1))//すべての処理が完了する(tailに到達する)まで処理を続ける
	{
		i=head;
		if(node[i].time<=q)//処理が与えられたターンアラウンドタイムの時間内に終了するとき
		{
			T+=node[i].time;
			printf("%s %d\n",node[i].name,T);
			node[i].time=0;//残り処理必要時間をゼロにする
		}
		else//処理が与えられたターンアラウンドタイムの時間内に終了しないとき
		{
			T+=q;//ターンアラウンドタイムより長い処理時間が必要な時ターンアラウンドタイムを累計時間に付加する
			node[tail].time=node[i].time-q;//残り処理必要時間をターンアラウンドタイム分だけ減らす
			strcpy(node[tail].name,node[i].name);//一番後ろに処理しきれなかった命令を並ばせる
			tail=(tail+1)%(n+1);
		}
	}
	return 0;
}



Measured memory_bytes: 2680
def resolve():
    '''
    code here
    '''
    N = int(input())
    S = input()

    res = 0
    ans = 0
    for item in S:
        if item == 'I':
            res += 1
        else:
            res -= 1

        
        ans = max(ans, res)

    print(ans)


if __name__ == "__main__":
    resolve()


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

using namespace std;

#define fastio cin.tie(NULL);cout.tie(NULL);ios_base::sync_with_stdio(0);
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define MAXN 200005
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define pb push_back
#define endl '\n'
#define int long long

typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pii> vii;
typedef vector <vi> matriz;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// auto timer_start = chrono::steady_clock::now().time_since_epoch().count();

int a, b, c, n, m, k;
string s, t, u;
int q;
int v[MAXN];
int used[MAXN];

ll binExp(ll a, ll b){
    if(b == 0) return 1LL;
    ll p = binExp(a, b / 2);
    return (b & 1 ? (((p * p)) * a) : (p * p));
}

int32_t main(){
    fastio
    cin >> n >> m;
    priority_queue <pii> fila;
    int aux;
    for(int i = 1; i <= n; i++){
        cin >> v[i];
        fila.push({v[i], i});
    }
    pii atual;
    for(int i = 1; i <= m; i++){
        atual = fila.top();
        fila.pop();
        used[atual.second]++;
        if(atual.first == 0) break;
        int cc = round(v[atual.second] / binExp(2, used[atual.second]));
        // cout << v << " " << atual.first << endl;
        fila.push({cc, atual.second});
    }

    int res = 0;
    while(!fila.empty()){
        atual = fila.top();
        fila.pop();
        res += atual.first;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3568
# -*- coding: utf-8 -*-
N, X = map(int, input().split())
L = list(map(int,input().split()))

s = 0
count = 0
for i in range(N):
    if s <= X:
        s = s + L[i]
        count += 1

if s <= X:
    count += 1

print(count)

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

int a[110];

void solve(int a[],int n)
{
	for(int i=0;i<n;++i)
	{
		if(a[i]%2==0)
		{
			if(a[i]%3!=0 && a[i]%5!=0)
			{
				cout<<"DENIED"<<"\n";
				return;
			}
		}
	}
	cout<<"APPROVED"<<"\n";
	return ;
}
int main()
{
	int n; cin>>n;
	for(int i=0;i<n;++i)
	{
		cin>>a[i];
	}
	solve(a,n);
}

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

class Data{
public:
  void input_a(int i,int num);
   long double Sum_a(int n);
   long double Sum_b(int n);
  void eSum_input(int n);
   long double Pi(int n);
   long double Ans(int n);
   long double check(int i);
private:
   long double ma[200];
   long double mb[200];
};

void Data::input_a(int i,int num){
  ma[i] = num;
}

 long double Data::Sum_a(int n){
   long double ans=0;

  for(int i=0;i<n;i++){
    ans += ma[i];
  }

  return ans;
}

long double Data::Sum_b(int n){
  long double ans=0;

  for(int i=0;i<n;i++){
    ans += mb[i];
  }

  return ans;
}

void Data::eSum_input(int n){
  long double s,sa;
  sa = Pi(n);

  for(int i=0;i<n;i++){
    s = sa/ma[i];
    mb[i]=s;
  }
}

long double Data::Pi(int n){
  long double ans=1;

  for(int i=0;i<n;i++){
    ans *= ma[i];
  }
  return ans;
}

long double Data::check(int i){
  return ma[i];
}

long double Data::Ans(int n){
  if(n>1) return Pi(n)/Sum_b(n);
  if(n==1) return ma[0];
}

int main()
{
  int n,i;
  Data data;
  long double s,esum,pi;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>s;
    data.input_a(i,s);
  }

  data.eSum_input(n);

  /*for(i=0;i<n;i++){
    cout<<data.check(i)<<endl;
  }*/

  cout<<data.Ans(n)<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean[][] a=new boolean[2][sc.nextInt()];
        for(int i=0;i<2;i++) {
            for(int j=sc.nextInt();j>0;j--)
            a[i][sc.nextInt()-1]=true;
        }
        int count=0;
        for(int i=sc.nextInt();i>0;i--) {
            int t=sc.nextInt()-1;
            if(!a[0][t]||a[1][t]) {
                count++;
            }
        }
        System.out.println(count);
    }
}


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

int main() {
	int H, N;
  cin >> H >> N;
  
  vector<int> vec(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
  	cin >> vec.at(i);
    sum += vec.at(i);
  }
  if (sum >= H) {
  	cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  
}

Measured memory_bytes: 640
import java.util.Scanner;

class Problem {
    private String S;
    Problem() {
        Scanner sc = new Scanner(System.in);
        S = sc.next();
    }

    String solve() {
        if (S.compareTo("2019/04/30") <= 0) {
            return "Heisei";
        } else {
            return "TBD";
        }
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
}


Measured memory_bytes: 21588
using System;
class Program
{
    static void Main(string[] args)
    {
        //入力
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
		int Y = int.Parse(input[1]);
        bool flag = false;
 
        for (int i = 0; i <= N; i++)
        {
            for (int k = 0; k <=N-i; k++)
            {
                if (Y == 10000 * i + 5000 * k + 1000 * (N-i-k))
				{
					 Console.WriteLine(i+" "+k+" "+(N-i-k));
                     flag = true;
                     break;
				}
            }
            if (flag)
            {
                break;
            }
        }

        if (!flag)
        {
            Console.WriteLine("-1 -1 -1");
        }
     
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <unistd.h>

int	main(void)
{
	int	i = 0;
  	int j;
 	char str[27] = {0};
  	
  	read(0, str, 26);
  	while (str[i])
    {
      j = i + 1;
      while (str[j])
      {
        if (str[i] == str[j])
        {
          printf("no");
          return (0);
        }
        j++;
      }
      i++;
    }
  printf("yes");
  return (0);
}

  
  

Measured memory_bytes: 1576
// ================
// Himanshu Lal
// MNIT Jaipur
// ================
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define TEZ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define INF 1e18
#define vi vector<pair<ll,ll>>
#define ff first
#define ss second
#define mp map<ll,ll>
#define test ll t; cin>>t; while(t--)
#define srt(v) sort(v.begin(),v.end())
double pi=acos(-1);
void OJ(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
}
int main(){
    TEZ;
    ll n;
    cin>>n;
    ll p=n%10;
    if(p==3){
        cout<<"bon";
    }else if(p==0 or p==1 or p==6 or p==8){
        cout<<"pon";
    }else{
        cout<<"hon";
    }
}

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

if N == 0:
    print(0)
    exit()

# 1桁目から見ていって奇数なら1があるはずなので1桁目は1とやっていく
ans = []
i = 1
while N:
    if N % 2 == 0:
        ans.append('0')
    else:
        ans.append('1')
        if i % 2 == 0:
            N += 1
        else:
            N -= 1
    N //= 2
    i += 1

zero = True
for b in reversed(ans):
    if zero and b == 0:
        continue
    elif b == 1:
        zero = False
    print(b, sep='', end='')
print()

Measured memory_bytes: 38384
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
     
	static List<Integer> list=new ArrayList<Integer>();
    static boolean[] num=new boolean[150000];
     
    static void prime(int n) {
        for(int i=2; i*n<150000; i++) {
            num[n*i]=false;
        }
    }
     
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //while(sc.hasNext()) {
        for(int i=2; i<150000; i++) {
        	num[i]=true;
        }
        num[0]=false;
        num[1]=false;
        for(int i=2; i<150000; i++) {
        	if(num[i]) {
        		list.add(i);
        		prime(i);
        	}
        }
        while(sc.hasNext()) {
        	int N=sc.nextInt();
        	int P=sc.nextInt();
        	if(N==-1 && P==-1)	break;
        	List<Integer> res=new ArrayList<Integer>();
        	int k=0;
        	//System.out.println(list.get(1));
        	while(list.get(k)<=N) {
        		k++;
        	}
        	for(int i=k; i<k+P; i++) {
        		for(int j=i; j<k+P; j++) {
        			res.add(list.get(i)+list.get(j));
        		}
        	}
        	Collections.sort(res);
        	System.out.println(res.get(P-1));
        }
             
        
    }
}


Measured memory_bytes: 66824
import java.util.Scanner;
import static java.lang.Math.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];

		for(int i = 0; i < n; i++){
			x[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
			y[i] = sc.nextInt();
		}
		//マンハッタン距離
		{
			double manhattan = 0;
			for(int i = 0; i < n; i++){
				manhattan += abs(x[i] - y[i]);
			}
			System.out.println(manhattan);
		}
		//ユークリッド距離と3乗.ver
		{
			double yukurid = 0;
			double sum = 0;
			for(int i = 0; i < n; i++){
				sum += pow(abs(x[i] - y[i]), 2);
			}
			yukurid = sqrt(sum);
			System.out.println(yukurid);
			sum = 0;
			for(int i = 0; i < n; i++){
				sum += pow(abs(x[i] - y[i]), 3);
			}
			double p3ver = cbrt(sum);
			System.out.println(p3ver);
		}
		//チェビシェフ距離
		{
			double chebi = 0;
			double max = 0;
			for(int i = 0; i < n; i++){
				max = max(max, abs(x[i] - y[i]));
			}
			System.out.println(max);
		}
	}
}



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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

using mint = modint998244353;
mint pow10[200005];
mint sum10[200005];

struct S { mint x; int cnt; };
S op(S a, S b) { return S{a.x * pow10[b.cnt] + b.x, a.cnt + b.cnt}; }
S e() { return S{0, 0}; }

S mapping(int f, S s) {
    if (f == 0) return s;
    return S{sum10[s.cnt] * f, s.cnt};
}
int composition(int f, int g) { return f == 0 ? g : f; }
int id() { return 0; }

int main() {
    pow10[0] = 1;
    for_(i,1,200005) pow10[i] = pow10[i - 1] * 10;
    sum10[0] = 0;
    for_(i,1,200005) sum10[i] = pow10[i - 1] + sum10[i - 1];

    int N, Q;
    cin >> N >> Q;

    lazy_segtree<S, op, e, int, mapping, composition, id> seg(N);
    for_(i,0,N) seg.set(i, S{1, 1});

    for_(i,0,Q) {
        int L, R, D;
        cin >> L >> R >> D;
        seg.apply(L - 1, R, D);
        cout << seg.all_prod().x.val() << endl;
    }
}

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

int main(){
  const long int INF = 100000000;
  long int countwhite = 0;

  long int H, W;
  cin >> H >> W;

  typedef pair<long int, long int> P;

  char s[51][51];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> s[i][j];
      if (s[i][j] == '.') countwhite++;
    }
  }

  int d[51][51];

  int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

  queue<P> que;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) d[i][j] = INF;
  }
  que.push(P(0,0));
  d[0][0] = 0;

  while (que.size()) {
    P p = que.front(); que.pop();
    if (p.first == H-1 && p.second == W-1) break;

    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i], ny = p.second + dy[i];

      if (0 <= nx && nx < H && 0 <= ny && ny < W && s[nx][ny] != '#' && d[nx][ny] == INF) {
        que.push(P(nx,ny));
        d[nx][ny]  = d[p.first][p.second] + 1;
      }
    }
  }

  if (d[H-1][W-1] == INF) {
    cout << -1 << endl;
  }
  else{
    long int res = d[H-1][W-1] + 1;
    cout << countwhite - res << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
int n,i;
cin>>n;
string s;
cin>>s;
stack<char> st;
for(i=0;i<n;i++){
    while(st.size()&&st.top()==s[i])
        st.pop();
    st.push(s[i]);
}
cout<<st.size()<<endl;
}


Measured memory_bytes: 512
#include <stdio.h>
  
using namespace std;
  
int main(){
    int a,b;
    double a_d,b_d;
    scanf("%d %d",&a,&b);
    a_d = static_cast<double>(a);
    b_d = static_cast<double>(b);
    printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}


Measured memory_bytes: 2744
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
vector<int> divisor(int n)
{
	vector<int> ret;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n)	ret.push_back(n / i);
		}
	}
	return ret;
}
int main()
{
	// Tenka1 Programmer Contest-C, 1151, 15:40, First-AC
	/*ll n; cin >> n;
	rep(i, 3501) {
		if (i == 0) continue;
		rep(j, 3501) {
			if (j == 0) continue;
			int l = 0, r = 3500;
			while (l + 1 < r) {
				int m = (l + r) / 2;
				ll left = ll(m) * (ll(4) * ll(i) * ll(j) - n * ll(i) - n * ll(j));
				ll right = n * ll(i) * ll(j);
				if (left == right) {
					cout << i << " " << j << " " << m << endl;
					return 0;
				}
				else if (left < right) l = m;
				else r = m;
			}
		}
	}
	assert(false);
	*/

	// ABC106-B, 4:58, First AC
	/*int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i += 2) {
		vector<int> v = divisor(i);
		if (v.size() == 8) ans++;
	}
	cout << ans << endl;
	*/

	// ABC122-B,
	string s; cin >> s;
	int ans = 0, tmp = 0;
	bool ok = true;
	rep(i, s.size()) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') ok = true;
		else ok = false;
		if (ok) tmp++;
		else {
			ans = max(ans, tmp);
			tmp = 0;
		}
	}
	ans = max(ans, tmp);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define ceil(a, b) ((a+b-1)/b)
#define int ll
#define double ld
#define INF (1LL<<62)
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> arr(n);
    for (auto &x : arr) cin >> x;
    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 1; i < n; ++i)
    {
        for (int j = i-1; j >= max(i-k, 0LL); --j)
            dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]));
    }
    cout << dp[n-1] << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main()
{
        char a[19];
        int i = 0;
        for ( i = 0; i < 19; i ++)
        {
                scanf("%c",&a[i]);
        }
        a[5] = ' ';
        a[13] = ' ';
        for ( i = 0;i < 19 ;i ++)
        {
                printf("%c",a[i]);
        }
        return 0;
}


Measured memory_bytes: 128
$swap = 0

def Swap(a, b)
	$swap += 1
	return b,a
end

gets
d = gets.chomp.split(" ").map &:to_i

d.length.times { |i|
	min = i
	(i...d.length).each_with_index { |j|
		min = j if d[min] > d[j]
	}
	d[i],d[min] = Swap(d[i],d[min]) if i != min
}

d.length.times { |i|
	print " " unless i == 0
	print "#{d[i]}"
}
print "\n#{$swap}\n"

Measured memory_bytes: 8672
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    ll m = n;
    int k = 0;
    while(m > 0){
        m/=10;
        k++;
    }

    ll sum = 0;
    rep(i, k-1){
        if((i+1)%2!=0){
            sum += 9*pow(10, i);
        }
    }

    if(k%2 != 0)sum += n - pow((ll)10, k-1) + 1;
    cout << sum;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("");
  
  var a = parseInt(input[0]);
  var b = parseInt(input[1]);
  var c = parseInt(input[2]);
  
  console.log(a + b + c);
  
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
<?php

$n = (int)fgets(STDIN);
$input = str_split(fgets(STDIN));
$count = 1;
$before = $input[0];

for ($i = 1; $i < $n; $i++) {
    $num = $input[$i];
    if ($before !== $num) {
        $count++;
    }
    $before = $num;
}

echo $count;

Measured memory_bytes: 21644
import math


import math

a,b,x = map(int,input().split())

y = (2*x - (a*a*b))/(a*a)
# print(y)

if(y <= 0):
	y = (2*x)/(a*b)
	c = y/math.sqrt(b*b + y*y)
	print((math.acos(c))*(180/math.pi))

else:
	c = a/math.sqrt(a*a + (b-y)*(b-y))
	print((math.acos(c))*(180/math.pi))




Measured memory_bytes: 38384
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())

def func(i):
    if i == 'r':
        return 'p'
    elif i == 's':
        return 'r'
    else:
        return 's'

tp = [0] * n
for i in range(k):
    tp[i] = func(t[i])
for i in range(k, n):
    if tp[i - k] == func(t[i]):
        tp[i] = '-'
    else:
        tp[i] = func(t[i])
ans = (tp.count('r') * r) + (tp.count('p') * p) + (tp.count('s') * s)

print(ans)

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

int main(){
  int n,a[1000000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int num=0;
  map<long long,int>mp;
  for(int i=0;i<n;i++){
      mp[a[i]]++;
  }
  for(auto i:mp){
      if(i.second%2!=0){
          num++;
      }
  }
  cout<<num<<endl;
}
      


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int a,b;
  cin >> a >> b;
  cout << max(0,a-2*b) << endl;
}


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



int main(int argc, char const* argv[])
{
  int H, W;
  int h, w;
  cin >> H >> W;
  cin >>h >> w;
  int blk = h*W + w*H - h*w;
  int ans = H*W - blk;
  cout << ans << endl;

  return 0;
}


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

int main(void)
{
	int i, n, s[1000];
	double m, v, sd;
	
	while(1) {
		scanf("%d",&n);
		if(n==0) break;
		for (i=0; i<n; i++) {
			scanf("%d",&s[i]);
		}
		m = 0;
		for (i=0; i<n; i++) {
			m += s[i];
		}
		m /= n;
		v = 0;
		for (i=0; i<n; i++) {
			v += (s[i] - m)*(s[i] - m);
		}
		v /= n;
		sd = sqrt(v);
		printf("%f\n",sd);
	}
	return 0;
}

Measured memory_bytes: 636
from sys import exit, stdin
N, X = [int(_) for _ in stdin.readline().rstrip().split()]
A = [int(_) for _ in stdin.readline().rstrip().split()]
A.sort()
ans = 0
for i in range(N):
  if A[i] <= X:
    X -= A[i]
    if i == N-1 and X == 0:
      ans += 1
    elif i != N-1:
      ans += 1
  else:
    print(ans)
    exit()
print(ans)

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

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<#a<<':'<<a<<endl

const ll INF = 1e9+7;

template<typename T>inline T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  
  int tmp = 0;
  while(n > 0){
    ++tmp;
    n -= tmp;
  }
  print(tmp);
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<int> l(q),r(q);
    for(int i=0;i<q;i++) cin>>l[i]>>r[i];

    vector<int> table(n);
    table[0]=0;
    int cnt=0;
    for(int i=0;i<n-1;i++){
        //s[i]から始まる2文字をACと比較する
        //もし一致したら、tableにそこまでに含まれているACの数を追加する
        if(s.substr(i,2) == "AC") cnt++;
        table[i+1]=cnt;
    }
    /*
    for(int i=0;i<n;i++){
        cout<<table[i];
        if(i!=n-1)cout<<" ";
        else cout<<endl;
    }
    */
    for(int i=0;i<q;i++){
        int ans = table[r[i]-1] - table[l[i]-1];
        cout << ans << endl;
    }
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n;

int main() {
	cin >> n;
	if (n % 1000) {
		cout << 1000 - n % 1000 << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
# include"stdio.h"

int main(){
   int a,b,c;
   scanf("%d %d %d",&a,&b,&c);

   int c1=0,c2=0;

   if(a==5) c1++;
   else if(a==7) c2++;

   if(b==5) c1++;
   else if(b==7) c2++;

   if(c==5) c1++;
   else if(c==7) c2++;

   if(c1==2&&c2==1)
   printf("YES\n");
   else printf("NO\n");
}


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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


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


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

int main(){
  int N;
  cin >> N;
  
  vector<int> p(N);
  for(int i=0; i<N; i++) cin >> p[i];
  
  sort(p.begin(), p.end());
  p[N-1] = p[N-1]/2;

  cout << accumulate(p.begin(), p.end(), 0) << endl;

  return 0;
}

Measured memory_bytes: 256
# coding: utf-8

lst = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
        'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
C = input()
# print(C)

if C == 'z':
    print('a')
else:
    print(lst[lst.index(C) + 1])

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	ll x, y;
	cin >> x >> y;

	if (abs(x - y) > 1) { cout << "Alice"; }
	else { cout << "Brown"; }
	
	system("PAUSE");
}


Measured memory_bytes: 504
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S;
	cin >> S;
	cout << (S == "ABC" ? "ARC" : "ABC") << endl;

	return 0;
}


Measured memory_bytes: 3580
#include <stdio.h>
int main(void){
    int n,m,x,i,a[100],cnt=0;
    scanf("%d%d%d",&n,&m,&x);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<x;i++){
        if(a[i]<x) cnt++;
        else break;
    }
    if(cnt<m-cnt) printf("%d\n",cnt);
    else printf("%d\n",m-cnt);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
double PI = acos(-1);
double l[8];

double f(double v,vector<double> L){
	double sum = 0;
	for(int i = 0 ; i < L.size() - 1 ; i++){
		double t = v / L[i] / L[i+1];
		sum += acos(t);	
	}
	return sum;
}
double calc(double v,vector<double> L){
	double sum = 0;
	for(int i = 0 ; i < L.size() - 1 ; i++){
		double t = v / L[i] / L[i+1];
		
		sum += sin(acos(t)) * L[i] * L[i+1] / 2.0;
	}
	return sum;
}
int main(){
	int N;
	cin >> N;
	for(int i = 0 ; i < N ; i++) cin >> l[i];
	
	double ans = 0;
	for(int i = 0 ; i < (1<<N) ; i++){
		vector<double> L;
		for(int j = 0 ; j < N ; j++)
			if( i >> j & 1 ) L.push_back(l[j]);
		if( L.size() < 3 ) continue;
		
		sort(L.begin(),L.end());
		do{
			L.push_back(L.front());
			double s = 1e18;
			for(int j = 0 ; j < L.size() - 1 ; j++)
				s = min(s,L[j] * L[j+1]);
			double le = -2*s , ri = 2*s;
			for(int k = 0 ; k < 64 ; k++){
				double mi = (le+ri) / 2.;
				if( f(mi,L) < 2 * PI ){
					ri = mi;
				}else{
					le = mi;
				}
			}
			//cout << f(le,L) << endl;
			ans = max(ans,calc(le,L));
			L.pop_back();
		}while(next_permutation(L.begin()+1,L.end()));
	}
	printf("%.15lf\n",ans);
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
typedef pair<ll,ll> 	pll;
#define br "\n"
#define ff first
#define ss second
#define MAXI 10000001

ll MAX = 1e10;

vll tree(MAXI),lazy(MAXI),arr;
vb vis;

void build(ll v,ll tl,ll tr){
    if(tl == tr){
        tree[v] = 0; 
        return;
    }
    ll tm = (tl + tr)/2;
    build(2*v,tl,tm);
    build(2*v + 1,tm + 1,tr);
    tree[v] = max(tree[2*v],tree[2*v + 1]);
}

ll sum(ll v,ll tl,ll tr,ll l, ll r){
    if(l > r) return 0;
    if(r == tr && l == tl) return tree[v];
    ll tm = (tl + tr)/2;
    return max(sum(2*v,tl,tm,l,min(tm,r)),sum(2*v + 1,tm + 1,tr,max(tm + 1,l),r));
}

void update(ll v,ll tl,ll tr,ll pos,ll val){
    if(tl == tr){
        tree[v] = val;
        return;
    }
    ll tm = (tl + tr)/2;
    if(pos <= tm) update(2*v,tl,tm,pos,val);
    else update(2*v + 1,tm + 1,tr,pos,val);
    tree[v] = max(tree[2*v],tree[2*v + 1]);
}

void solve(){
    ll n,k;
    cin >> n >> k;
    arr.resize(n);
    ll maxi = 0;
    rep(i,0,n){ 
        cin >> arr[i];
        maxi = max(maxi,arr[i]);
    }
    build(1,0,maxi);
    ll ans = 1;
    rep(i,0,n){
        ll l,r;
        l = max((ll)0,arr[i] - k);
        r = min(maxi,arr[i] + k);
        ll temp = sum(1,0,maxi,l,r);
        // cout << l << " " << r << " " << temp + 1 << br;
        ans = max(ans,temp + 1);
        update(1,0,maxi,arr[i],temp + 1);

    }
    cout << ans << br;
}
	
 
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
 
	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}
 
}	

Measured memory_bytes: 161880
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"



signed main()
{
    FAST;
    int t;
    t=1;
    
    while(t--)
    {
        int i=0,j=0,k=0,n=0,m=0,count=0,tempp=0;
        int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
        int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
        int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
        int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
        
        int a,b,v,w,ti;
        cin>>a>>v>>b>>w>>ti;
        
        int diff = v-w;
        if(diff<=0)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        
        double temp=0.0;
        temp = abs(a-b);
        //cout<<temp<<endl;
        temp = (double)temp/(double)diff;
        
        if(temp<=ti)
        {
            cout<<"YES"<<endl;
            return 0;
        }
        
        else
        {
            cout<<"NO"<<endl;
            return 0;
        }
        
        
    }
        
    
    
    
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int l, r;
  cin >> l >> r;
  r++;
  if(r - l >= 2019){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 2019;
  rep2(i, l, r-1){
    rep2(j, i+1, r){
      ll m = (ll)i*j%2019;
      ans = min(ans, m);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define int long long
#define N 100010
#define S str[pos]
#define Sp str[pos++]
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
int Max(int &a,int b){return a=max(a,b);}
int Min(int &a,int b){return a=min(a,b);}
typedef complex<double> P;
typedef pair<P,P> L;
string str;
int pos;

double dot(P a, P b){ return real(conj(a)*b); }
double cross(P a, P b){ return imag(conj(a)*b); }
P proj(P p, L l){return l.first + dot(p - l.first, l.second - l.first) / norm(l.second - l.first) * (l.second - l.first);}
P reflect(P p, L l){return p + (proj(p,l) - p) * 2.0;}

P crossPoint(L l, L m){
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
}

bool isPoint(L a){return a.first == a.second;}

double getNumber(){
  assert(S == '-' || isdigit(S));
  double res=0,f = 1;
  if(S == '-') pos++,f = -1;
  while(isdigit(S)) res = res * 10 + Sp - '0';
  return f * res;
}

P getPoint(){
  assert(Sp == '(' && (isdigit(S) || S=='-'));
  double real = getNumber();assert(Sp == ',');
  double imag = getNumber();assert(Sp == ')');
  return P(real,imag);
}

L expression();

L calc(){
  P a;
  L res;
  if(S == '(' && (isdigit(str[pos+1]) || str[pos+1] == '-'))a = getPoint(),res = L(a,a);
  else if(S == '(' && str[pos+1] == '(')pos++,res = expression(),pos++;
  else assert(!"calc error");
  return res;
}

L calc(L a,L b){
  if(isPoint(a) && isPoint(b)) return L(a.first,b.first);
  if(!isPoint(a) && !isPoint(b))return L(crossPoint(a,b),crossPoint(a,b));
  if(isPoint(a)) return L(reflect(a.first,b),reflect(a.first,b));
  if(isPoint(b)) return L(reflect(b.first,a),reflect(b.first,a));
  assert(!"@ calc error");
}

L expression(){
  L res = calc();
  while(pos < (int)str.size()){
    if(S == '@')pos++,res = calc(res,calc());
    else if(S == ')') break;
    else assert(!"expression error S");
  }
  return res;      
}


signed main(){
  while(1){
    cin>>str;
    if(str == "#") break;
    pos = 0;    
    L ans = expression();
    printf("%f %f\n",ans.first.real(),ans.first.imag());
  }
  return 0;
}

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

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define mod 1000000007
#define ull unsigned long long
#define mst(ss,b) memset(ss,b,sizeof(ss));
#define pl(x) cout << #x << "= " << x << endl;
const int inf = 0x3f3f3f3f;
const int N = 55;
typedef pair<int, int> P;


struct node{
    int x, y;
    int id;
    node(){}
    node(int xx, int yy, int dd):x(xx), y(yy), id(dd){}
    bool operator < (const node& rhs)const{
        return x<rhs.x || (x == rhs.x && y<rhs.y);
    }
}p[N], q[N];

int n, m, pos[N];

int  main(){
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=1; i<=n; i++){
        cin>>p[i].x>>p[i].y;
        p[i].id = i;
    }
    for(int i=1; i<=m; i++){
        cin>>q[i].x>>q[i].y;
        q[i].id = i;
    }
    sort(q+1, q+1+m);
    for(int i=1; i<=n; i++){
        int ans = inf;
        for(int j=1; j<=m; j++){
            int dis = abs(p[i].x-q[j].x)+abs(p[i].y-q[j].y);
            if(dis<ans){
                ans = dis;
                pos[i] = q[j].id;
            }
        }
    }
    for(int i=1; i<=n; i++)cout<<pos[i]<<endl;
    return 0;
}


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

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

using namespace std;

using pii = pair<int, int>;

int distance(pii p, pii q) {
    return abs(p.first - q.first) + abs(p.second - q.second);
}

int main() {
    while (true) {
        int h, w;
        cin >> h >> w;
        if (h == 0)
            break;
        map<char, pii> position;
        REP(i, h) {
            string r;
            cin >> r;
            REP(j, w) {
                position[r[j]] = pii(i, j);
            }
        }
        string s;
        cin >> s;
        int count_presses = 0;
        pii current_position = pii(0, 0);
        for (char c: s) {
            pii next_position = position[c];
            count_presses += distance(current_position, next_position) + 1;
            current_position = next_position;
        }
        cout << count_presses << endl;
    }
    return 0;
}


Measured memory_bytes: 3128