akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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 n ;
  cin >>n ;
  string s ;
  cin >> s ;
  int cntr = 0 ;
  int cntb = 0 ;
  REP(i,n){
    if(s.at(i)=='B'){
      cntb++ ;
    }
    else{
      cntr++ ;
    }
  }
  
  if(cntr>cntb){
    cout <<"Yes"<<endl ;
  }
  else{
    cout <<"No"<<endl ;
  }


  return 0 ;
}




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

int main() {
  
  int a, b, c;
  cin >> a >> b >> c;
  
  if (a == b && b != c) {
    cout << "Yes" << endl;
  }
  else if (a == c && a != b) {
    cout << "Yes" << endl;
  }
  else if (b == c && a != b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
unittest
{
	assert( [ "3", "cbaa", "daacc", "acacac" ].parse.expand.solve == "aac" );
	assert( [ "3", "a", "aa", "b" ].parse.expand.solve == "" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto ss = new dchar[][ n ];
	foreach( ref s; ss )
	{
		input.popFront;
		s = input.front.to!( dchar[] );
	}
	return tuple( ss );
}

auto solve( dchar[][] ss )
{
	dchar[] ans;
	
	// 答えが辞書順指定なので並び替えておく
	ss.each!( sort );
	
	LOOP: while( true )
	{
		// 各文字列の先頭で一番大きい文字を検索
		auto cb = ss.map!( ( a ) => a[ 0 ] ).reduce!( max );
		
		// 全文字列の先頭が一番大きい文字か判定
		auto eq = ss.map!( ( a ) => a[ 0 ] == cb ).reduce!( ( a, b ) => a && b );
		if( eq )
		{
			// 一番大きかった文字を答えに追加
			ans ~= cb;
			
			// 各文字列から先頭文字を削除
			foreach( ref s; ss )
			{
				s.popFront;
				if( s.empty ) break LOOP;
			}
		}
		else
		{
			// 各文字列の先頭から一番大きかった文字の手前まで削除
			foreach( ref s; ss )
			{
				s = s.find!( ( c ) => cb <= c );
				if( s.empty ) break LOOP;
			}
		}
	}
	
	return ans;
}


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

constexpr double EPS = 1e-10;
typedef complex<double> Point;
typedef Point Vector;
typedef pair<Point, Point> Segment;
typedef Segment Line;
typedef pair<Point, double> Circle;
typedef vector<Point> Polygon;
double dot(Vector a, Vector b){
	return real(a) * real(b) + imag(a) * imag(b);
}
double cross(Vector a, Vector b){
	return real(a) * imag(b) - imag(a) * real(b);
}
Point project(Line l, Point p){
	Vector base = l.second - l.first;
	base /= abs(base);
	double r = dot(p - l.first, base);
	return l.first + r * base;
}
Point reflect(Line l, Point p){
	return p + (project(l, p) - p) * 2.0;
}
int ccw(Point p0, Point p1, Point p2){
	Vector v = p1 - p0, w = p2 - p0;
	if(cross(v, w) > EPS) return 1;
	if(cross(v, w) < -EPS) return -1;
	if(dot(v, w) < -EPS) return 2;
	if(norm(v) + EPS < norm(w)) return -2;
	return 0;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Point p0, p1;
	double x, y;
	cin >> x >> y;
	p0 = Point(x, y);
	cin >> x >> y;
	p1 = Point(x, y);
	int q;
	cin >> q;
	while(q--){
		cin >> x >> y;
		Point p2(x, y);
		cout << vector<string>{"ONLINE_FRONT", "CLOCKWISE", "ON_SEGMENT", "COUNTER_CLOCKWISE", "ONLINE_BACK"}[ccw(p0, p1, p2)+2] << "\n";
	}
}


Measured memory_bytes: 3364
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

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

char s[100001];
int main(void){
	scanf("%s", s);
	int n=strlen(s);
	if(s[0]==s[1]){
		printf("1 2\n");
	}else{
		for(int i=2; i<n; i++){
			if(s[i-2]==s[i]){
				printf("%d %d\n", i-1, i+1);
				return 0;
			}else if(s[i-1]==s[i]){
				printf("%d %d\n", i, i+1);
				return 0;
			}
		}
		printf("-1 -1\n");
	}
}


Measured memory_bytes: 256
N,K=map(int, input().split())

H=[]
for i in range(N):
    h=int(input())
    H.append(h)

H=sorted(H)
ans=10**10
for i in range(N-K+1):
    hmin=H[i]
    hmax=H[i+K-1]
    ans=min(ans, hmax-hmin)
print(ans)

Measured memory_bytes: 8280
/*B - Buffet*/

#include <bits/stdc++.h>

using namespace std;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int ans = 0;
	int dish;
	int ant;
	int pos;

	cin >> dish;

	vector <int> orden(dish);
	vector <int> value(dish);
	vector <int> extra(dish - 1);

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

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

	for (int i = 0; i < dish - 1; ++i){
		cin >> extra[i];
	}

	ant = orden[0] - 1;

	for (int i = 0; i < dish; ++i)
	{
		pos = orden[i] - 1;
		ans += value[pos];

		if(pos - ant == 1)
			ans += extra[ant];

		ant = pos;
	}

	cout << ans;


	return 0;
}

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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var nkq = Console.ReadLine().Split().Select(double.Parse).ToArray();

            double n = nkq[0];
            double k = nkq[1];
            double q = nkq[2];

            double[] a = new double[(int)q];
            double[] ans = new double[(int)n];

            for (int i = 0; i < q; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
                ans[(int)(a[i] - 1)] += 1;
            }

            for (int i = 0; i < n; i++)
            {
                ans[i] -= (q-k);
                Console.WriteLine(ans[i] <= 0 ? "No" : "Yes");
            }

        }
    }
}


Measured memory_bytes: 19164
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        long sum = 0;
        for (int i=0; i<n; i++) {
            a[i] = sc.nextInt();
            //arr[i] -= i+1;
        }
        //Arrays.sort(arr)
        // 11222;
        for (int i=1; i<a.length; i++) {
            if (a[i] == a[i-1]) {
                sum++;
                a[i] = a[i-1]+1;
                if (i<a.length-1 && a[i] == a[i+1]) a[i] = a[i+1]-1;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> a(n+1);
    for(int i = 1; i < n+1; i++){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.begin(), a.end());

    for(int i = 1; i < n+1 ; i++){
        cout << a[i].second << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    ll N; cin >> N;
    ll x; cin >> x;
    vel a(N); rep(i,N) cin >> a[i];

    sort(all(a));

    int ans = 0;
    rep(i,N) {
        if(x < a[i]){
            cout << ans << endl;
            return 0;
        }
        ans++;
        x -= a[i];
    }
    if(x != 0) ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)

int* binSearch(int *low, int *hi, int k)
{
   while(low < hi){
      int* const mid = low + (hi - low) / 2;
      if(*mid == k)return mid;
      if(*mid > k )hi = mid;
      else low = mid + 1;
   }
   return( NULL );
}

int main()
{
   int N, Q;
   int a[100005];

   scanf("%d", &N);
   rep(i, N)scanf("%d", a+i);

   int cnt = 0;
   scanf("%d", &Q);
   while(Q--){
      int n;
      scanf("%d", &n);
      if( binSearch(a, a+N, n) != NULL )
         ++cnt;
   }
   printf("%d\n", cnt);
}




Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>

using namespace std;

int main(){
    string input;
    cin >> input;
    string::iterator end = input.end();
    vector<string> search_str;
    search_str.resize(4);
    search_str[0] = "dream";
    search_str[1] = "dreamer";
    search_str[2] = "eraser";
    search_str[3] = "erase";

    while(end > input.begin()){
        for(vector<string>::iterator itr = search_str.begin(); itr < search_str.end(); itr++){
            string::iterator tmp = find_end(end - (int)(*itr).size(), end, (*itr).begin(), (*itr).end());
            if(end != tmp){
                end = tmp;
                break;
            }

            if(itr == search_str.end() - 1){
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

ll mod = 998244353;

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


	int N;
	cin >> N;
	int A[300];
	rep(i, N) cin >> A[i];

	int goukei = 0;
	rep(i, N) goukei += A[i];
	int goukei2 = 0;
	ll dp[45001][301] = {};
	dp[0][0] = 1;
	ll dp2[301] = {};
	rep(i, N) {
		for (int k = i; k >= 0; k--) if (dp2[k]) {
			dp2[k + 1] += dp2[k];
			dp2[k + 1] %= mod;
		}
		int x = max(0, goukei2 - goukei / 2);
		for (int j = min(goukei2, (goukei + 1) / 2 - 1); j >= x; j--) {
			for (int k = i; k >= 0; k--) {
				if (dp[j][k]) {
					if (j + A[i] >= (goukei + 1) / 2) dp2[k + 1] = (dp2[k + 1] + dp[j][k]) % mod;
					else dp[j + A[i]][k + 1] = (dp[j + A[i]][k + 1] + dp[j][k]) % mod;
				}
			}
		}
		goukei2 += A[i];
	}

	ll zenbu = 1;
	rep(i, N) {
		zenbu *= 3;
		zenbu %= mod;
	}
	ll bairitu[301];
	bairitu[0] = 1;
	rep(i, 300) {
		bairitu[i + 1] = 2 * bairitu[i] % mod;
	}

	ll dame = 0;
	rep1(k, N - 1) {
		if (dp2[k]) {
			int k2 = N - k;
			ll kari = dp2[k] * bairitu[k2] % mod;
			kari -= 2 * dp2[k];
			dame += kari + mod;
			dame %= mod;
		}
	}

	dame *= 3;
	dame %= mod;

	ll kari = 1;
	rep(i, N) {
		kari *= 2;
		kari %= mod;
	}
	dame += kari * 3;
	dame %= mod;

	co((zenbu - dame + mod + 3) % mod);

	Would you please return 0;
}

Measured memory_bytes: 106240
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sr = new Scanner(System.in);
		String str = sr.next();
		String str2 = sr.next();
		boolean flag =  true; 
		for(int i = 0; i < str.length(); i++) {
			char  ch = str.charAt(i);
			char ch2 = str2.charAt(i);
			if(ch != ch2) {
				flag  = false;
				break;
			}
		}
		if(flag)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 35696
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
using namespace std;
typedef long long int lld;
typedef long double llf;
typedef pair<lld, lld> pii;


int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  string s;
  int k;
  cin >> s;
  cin >> k;

  if (s.size() == 1) {
    cout << k / 2 << endl;
    return 0;
  }

  int cnt = 0;
  int lastChanged = -1;
  bool flag = true;
  int a = 1;

  for (int i = 1; i < s.size(); ++i) {
    if (s[i] != s[0]) flag = false;
    if (flag) {
      a++;
    }
    if (s[i] == s[i-1] && lastChanged != i-1) {
      lastChanged = i;
      cnt++;
    }
  }

  if (flag) {
    lld aux = (lld)s.size() * (lld)k;
    cout << aux / 2 << "\n";
    return 0;
  }

  lld ans = (lld)cnt * (lld)k;
  if (s.front() == s.back() && lastChanged != s.size()-1 && (a & 1)) {
    ans += k-1;
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
import collections
import itertools

n = int(input())
l = [input() for _ in range(n)]
counter = collections.Counter(l)

mode_v = counter.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, counter.most_common()
)

l2 = list((k for k, v in it))
l2.sort()
print(*l2)

Measured memory_bytes: 45220
#include <bits/stdc++.h>
using namespace std;
#define Endl endl
typedef long long ll;
const int MAXN = (int)2e5 + 5;
ll a,b;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> a>>b)
	{
		cout << max(max(a + b, a - b), a*b) << endl;
	}
}
/*
3
1 2 3
*/

Measured memory_bytes: 256
N = int(input())
A, B = list(map(int, input().split()))
P = list(map(int, input().split()))

first = []
second = []
third = []

for p in P:
    if p <= A:
        first.append(p)
    elif (A < p <= B):
        second.append(p)
    else:
        third.append(p)

ans = min(len(first), len(second), len(third))
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
typedef long long ll;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> x(N);
	for (int i = 0; i < N; i++)cin >> x.at(i);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		int M = min(x[i], abs(x[i] - K));
		sum += 2*M;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3644
lstr=[int(input()) for i in range(10)]
lsts=[int(input()) for j in range(10)]

mr=max(lstr)
mr2=sorted(lstr)[-2]
mr3=sorted(lstr)[-3]
ms=max(lsts)
ms2=sorted(lsts)[-2]
ms3=sorted(lsts)[-3]
print(mr+mr2+mr3,ms+ms2+ms3)


Measured memory_bytes: 5604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Computation of Salary
 * PCK2013 ??¬???2
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		line = br.readLine();

		int N, M;
		N = parseInt(line.substring(0, line.indexOf(' ')));
		M = parseInt(line.substring(line.indexOf(' ') + 1));

		Map<Integer, Map<Integer, Integer>> map = new HashMap<>();

		for (int i = 1; i <= N; i++) map.put(i, new HashMap<>());

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			if (line.equals("0 0 0")) break;
			StringTokenizer st = new StringTokenizer(line);
			int s, t, e;
			s = parseInt(st.nextToken());
			t = parseInt(st.nextToken());
			e = parseInt(st.nextToken());
			map.get(s).put(t, e);
		}

		int L = parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < L; i++) {
			int[] b = new int[M + 1];
			StringTokenizer st = new StringTokenizer(br.readLine());
			for (int j = 1; j <= M; j++) {
				b[j] = parseInt(st.nextToken());
			}

			List<String> list = new ArrayList<>();

			for (int j = 1; j <= N; j++) {
				int c = 0;
				for (int t : map.get(j).keySet()) {
					c += b[t] * map.get(j).get(t);
				}
				list.add(String.valueOf(c));
			}

			sb.append(String.join(" ", list)).append('\n');
		}

		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 195176
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    int n;
    cin >> n;
 
    int ans = 1;
    for (int i = 2; i * i <= n; ++i) {
        int t = i * i;
        while (t * i <= n) {
            t *= i;
        }
        ans = max(ans, t);
    }
 
    cout << ans << endl;
    return 0;
}

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

def main():
    N = int(input())

    a = []
    b = []
    for i in range(1, int(pow(N, 0.5))+1):
        if N%i == 0:
            a.append(i)
            b.append(N//i)
    ans = int(1e10)
    for i in range(len(a)):
        ans = min(ans, max(len(str(a[i])), len(str(b[i]))))
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import math

a,b,h,m = map(int, input().split())


h = h % 12

h = (h / 12.0 + m / 60.0 / 12.0) * math.pi * 2.0
m = m / 60.0 * math.pi * 2.0

ax = a * math.sin(h)
ay = a * math.cos(h)
bx = b * math.sin(m)
by = b * math.cos(m)

print(math.sqrt((ax-bx)**2 + (ay-by)**2))


Measured memory_bytes: 62524
#include <cstdio>
#include <bitset>
#include <cstring>
static_assert(sizeof(long) >= 8, "long too short");
using namespace std;
struct Node {
    Node *ch[2];
    Node(): ch() {}
};
void insert(Node *n, char *s) {
    if (!*s)
        return;
    auto &ch = n->ch[*s - '0'];
    if (!ch)
        ch = new Node();
    insert(ch, s + 1);
}
long solve(Node *n, long m) {
    if (!n)
        return m & -m;
    return solve(n->ch[0], m - 1) ^ solve(n->ch[1], m - 1);
}
char s[100001];
int main() {
    int n;
    long m;
    scanf("%d %ld", &n, &m);
    Node *root = new Node();
    for (int i = 0; i < n; i++) {
        scanf("%s", s);
        insert(root, s);
    }
    puts(solve(root, m + 1) ? "Alice" : "Bob");
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

template<class T>
class segment_tree {
  int N;
  vector<T> dat;
  T mempty;
  function<T(T, T)> mappend;

public:
  segment_tree(int n, T mempty_, function<T(T, T)> mappend_) : mempty(mempty_), mappend(mappend_) {
    N = 1;
    while (N < n) N *= 2;
    dat.resize(N * 2, mempty);
  }

  void update(int k, T v) {
    k += N;
    dat[k] = v;
    while (k > 1) {
      k >>= 1;
      dat[k] = mappend(dat[k * 2], dat[k * 2 + 1]);
    }
  }

  T query(int l, int r) {
    l += N;
    r += N - 1;
    T x = mempty, y = mempty;
    while (l <= r) {
      if ((l & 1) == 1) x = mappend(x, dat[l++]);
      if ((r & 1) == 0) y = mappend(dat[r--], y);
      l >>= 1;
      r >>= 1;
    }
    return mappend(x, y);
  }
};

template<class T>
ostream &operator<<(ostream &o, vector<T> a) {
  o << '[';
  rep(i, a.size()) {
    if (i > 0) o << ',';
    o << a[i];
  }
  return o << ']';
}


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> A(N); rep(i, N) cin >> A[i];
  segment_tree<int> mn(N, 1e9, [](int x, int y) { return min(x, y); });
  segment_tree<int> mx(N, -1e9, [](int x, int y) { return max(x, y); });
  rep(i, N) {
    mn.update(i, A[i]);
    mx.update(i, A[i]);
  }
  vector<int> cnt(N);
  for (int i = 0; i + 1 < N; i++) {
    cnt[i + 1] = cnt[i] + (A[i] > A[i + 1]);
  }
  int ans = 1;
  int s = cnt[K - 1] - cnt[0] > 0;
  for (int i = 0; i + K + 1 <= N; i++) {
    if ((s || cnt[i + K] - cnt[i + 1] > 0) && !(A[i] == mn.query(i, i + K + 1) && A[i + K] == mx.query(i, i + K + 1))) {
      if (cnt[i + K] - cnt[i + 1] == 0) {
        s = 0;
      }
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5952
def examA():
    A, B, T = LI()
    ans = (T//A)*B
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n+2);
  
  int sum = 0;
  int p;
  
  a[0] = 0;
  a[n+1] = 0;
  
  for (int i = 1; i <= n; i++) {
    cin >> p;
    a[i] = p;
  }
  
  vector<int> accum_1(n+2);
  vector<int> accum_2(n+2);
  
  accum_1[0] = 0;
  accum_2[n+1] = 0;
    
  for ( int i = 0; i <= n; i++) {
    accum_1[i+1] = accum_1[i] + abs(a[i+1]-a[i]);
    accum_2[n-i] = accum_2[n-i+1] + abs(a[n-i]-a[n-i+1]);
  }
  
  for ( int i = 0; i < n; i++) {
    cout << accum_1[i] + accum_2[i+2] + abs(a[i+2] - a[i]) << endl;
  }
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define rep(i, n, k) for(int i=k; i<n; ++i)
#define drep(i, n, k) for(int i=n; i>k; --i)
using namespace std;

int main(){
  long long int n;
  cin >> n;
  long long int ans;
  rep(i,n+1,1){
    if(i > 9 && i < 100) continue;
    if(i > 999 && i < 10000) continue;
    if(i > 99999 && i < 1000000) continue;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// AOJ 2191: A Book Shop With a Frequent Greetings
// 2017.12.10

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define QSIZE 500001
typedef struct { int n, t; } Q;
Q q[QSIZE]; int top, end;

int xp[1001], yp[1001];
int rel[1001][1001];
int len[1001];
int prev[1001];
char mk[1001];

char buf[30], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
	int cno, n, X, Y, x0, y0, i, j, k, t, ans;

	fgets(p=buf, 10, stdin), cno = getint();
	while (cno--) {
		fgets(p=buf, 30, stdin);
		n = getint(), X = getint(), Y = getint();
		fgets(p=buf, 30, stdin);
		x0 = getint(), y0 = getint();
		for (i = 0; i < n; i++) {
			fgets(p=buf, 30, stdin);
			xp[i] = getint(), yp[i] = getint();
		}

		ans = 0, top = end = 0;
		memset(prev, 0x81, sizeof(prev));
		memset(mk, 0, sizeof(mk));
		memset(len, 0, sizeof(len));
		for (i = 0; i < n; i++) {
			if (hypot(xp[i]-x0, yp[i]-y0) <= 10) q[end].n = i, q[end++].t = 0;
			for (j = i+1; j < n; j++) {
				if (hypot(xp[i]-xp[j], yp[i]-yp[j]) <= 50)
					rel[i][len[i]++] = j, rel[j][len[j]++] = i;
			}
		}

		while (top < end) {
			i = q[top].n, t = q[top++].t;
			if (X > Y) { if (t > X) { ans = -1; break; }}
			else {
				if (mk[i]) continue;
				mk[i] = 1;
			}
			if (prev[i] < t-Y) {
				t += X;
				prev[i] = t;
				if (t > ans) ans = t;
				for (j = 0; j < len[i]; j++) {
					k = rel[i][j];
					if (X <= Y && mk[k]) continue;
					q[end].n = k, q[end++].t = t;
				}
			}
		}
		if (ans < 0) puts("You're always welcome!");
		else printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 9528
#include<bits/stdc++.h>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc()
{
  static char buf[1000000],*p1=buf,*p2=buf;
  return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd()
{
  int x=0,f=1;char ch=gc();
  for(;ch<'0'||ch>'9';ch=gc())  if (ch=='-')  f=-1;
  for(;ch>='0'&&ch<='9';ch=gc())  x=(x<<1)+(x<<3)+ch-'0';
  return x*f;
}
inline int read()
{
  int x=0,f=1;char ch=getchar();
  for(;ch<'0'||ch>'9';ch=getchar())  if (ch=='-')  f=-1;
  for(;ch>='0'&&ch<='9';ch=getchar())  x=(x<<1)+(x<<3)+ch-'0';
  return x*f;
}
inline void print(int x)
{
  if(x<0)  putchar('-'),x=-x;
  if(x>9)  print(x/10);
  putchar(x%10+'0');
}
const int N=2e5;
int n,tot,rize,root;
int pre[(N<<1)+10],now[N+10],child[(N<<1)+10],val[(N<<1)+10],size[N+10],Msize[N+10];
ll Ans;
void join(int x,int y,int z){pre[++tot]=now[x],now[x]=tot,child[tot]=y,val[tot]=z;}
void insert(int x,int y,int z){join(x,y,z),join(y,x,z);}
void dfs(int x,int fa,int v)
{
  int Max=0;size[x]=1;
  for(int p=now[x],son=child[p];p;p=pre[p],son=child[p])
  {
    if(son==fa)  continue;
    dfs(son,x,val[p]),size[x]+=size[son];
    Max=max(Max,size[son]);
  }
  Ans+=1ll*min(size[x],n-size[x])*v*2;
  Max=max(Max,n-size[x]);Msize[x]=Max;
  if(Max<rize)  {rize=Max;root=x;}
}
int main()
{	
  n=read(),rize=inf;
  for(int i=1;i<n;i++)
  {
    int x=read(),y=read(),z=read();
    insert(x,y,z);
  }
  dfs(1,0,0);
  int tmp=inf;
  for(int p=now[root],son=child[p];p;p=pre[p],son=child[p])
  {
    tmp=min(tmp,val[p]);
    if(Msize[root]==Msize[son])
	{
      Ans-=val[p];
      printf("%lld\n",Ans);
      return 0;
    }
  }
  printf("%lld\n",Ans-tmp);
  return 0;
}

Measured memory_bytes: 12416
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        if(a.equals(a.toLowerCase())){
            System.out.println("a");
        } else {
            System.out.println("A");
        }

    }

}


Measured memory_bytes: 35632
parseInt(x) = parse(Int, x)
n = parseInt(readline())
x = parseInt.(split(readline()))

ans = 100000000000000000000

for i in 1:100
    tmp = 0
    for j in 1:n
        tmp += (x[j] - i)^2
    end
    if tmp < ans
        ans = tmp
    end
end
println(ans)


Measured memory_bytes: 121256
from math import factorial

def calc_permutation(n, r):
    return factorial(n) // factorial(n - r)


if __name__ == '__main__':
    n = int(input())

    mod_num = 10 ** 9 + 7

    if n == 1:
        print(0)
    else:
        ans = (10**n % mod_num - (9**n % mod_num)*2 + 8**n % mod_num) % mod_num
        if ans < 0:
            ans += mod_num
        print(ans)



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

typedef long long ll;

int main(void) {
	ll N, K;
	cin >> N >> K;

	if (N > K) {
		ll d = N / K;
		N -= d * K;
	}
	ll x1 = abs(K - N);
	ll x2 = abs(K - x1);
	ll ans = min(x1, x2);

	cout << ans << '\n';
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main(){
  int n,m;
  cin >> n >> m;
  vector<P> pairs(m);
  rep(i,m){
    int x,y;
    cin >> x >> y;
    pairs[i].first=y;
    pairs[i].second=x;
  }
  sort(pairs.begin(),pairs.end());
  /*rep(i,m){
    cout << pairs[i].first << "  " << pairs[i].second << endl;
  }*/
  int count =0;
  int left=0;
  int right=0;
  rep(i,m){
    if(pairs[i].second<=left && right<=pairs[i].first) continue;
    left = pairs[i].first-1;
    right = pairs[i].first;
    //cout << left << "   " << right << endl;
    count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int X[N], sx[N]; rep(i, N) { cin >> X[i]; sx[i]=X[i]; }
  sort(sx, sx+N);

  rep(i, N) {
    int result=0;
    if (X[i]<sx[N/2]) result = sx[N/2];
    else result = sx[N/2-1];
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 3712
#include <iostream>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl

int factor(int N, int p) {
    int a = p;
    int count = N/a;
    while (N >= a) {
      a *= p; count += N/a;
    }
    return count;
}
int main() {
  IN(N);

  const int n = 16;
  int prime[n] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
  int ans = 0;

  REP(i, n) {
    int a = factor(N, prime[i]);
    if (a >= 74)
      ++ans;
    FOR(j, i+1, n) {
      int b = factor(N, prime[j]);
      if (a >= 24 && b >= 2) ++ans;
      if (b >= 24 && a >= 2) ++ans;
      if (a >= 14 && b >= 4) ++ans;
      if (b >= 14 && a >= 4) ++ans;
      REP(k, n) {
        if (k == i || k == j)
          continue;
        int c = factor(N, prime[k]);
        if (a >= 4 && b >= 4 && c >= 2)
          ++ans;
      }
    }
  }
  OUT(ans);
  return 0;
}


Measured memory_bytes: 256
def solve():
    N, M = map(int, input().split())
    edges = [[] for _ in [0]*N]
    r_edges = [[] for _ in [0]*N]

    for _ in [0]*M:
        a, b = map(int, input().split())
        edges[a].append(b)
        r_edges[b].append(a)
        
    c = get_strongly_connected_components(edges, r_edges)
    group = [0]*N
    for i in range(len(c)):
        for v in c[i]:
            group[v] = i

    result = []
    append = result.append
    for _ in [0]*int(input()):
        a, b = map(int, input().split())
        append("1" if group[a] == group[b] else "0")

    print("\n".join(result))


def get_strongly_connected_components(edges, r_edges):
    import sys
    sys.setrecursionlimit(10**7)
    v_count = len(edges)
    order = [0]*v_count
    k = 1

    def get_order(v):
        order[v] = 1
        nonlocal k
        for dest in edges[v]:
            if order[dest] == 0:
                get_order(dest)
        order[v] = k
        k += 1

    def get_components(v):
        order[v] = 0
        return [v] + [_v for dest in r_edges[v] if order[dest] > 0 for _v in get_components(dest)]

    [None for v in range(v_count) if order[v] == 0 and get_order(v)]
    return [get_components(v) for v, _ in sorted(enumerate(order), key=lambda x: x[1], reverse=True) if order[v] > 0]

if __name__ == "__main__":
    solve()

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

int main()
{
 
 long long  int H;
  cin>>H;
  
  long long int N;
  cin>>N;
  
  int A[N];
  for(int i=0;i<N;i++)
  cin>>A[i];
  
  
  for(int i=0;i<N;i++)
  {
    H=H-A[i];
  }
  
  if(H<=0)
  cout<<"Yes";
  else
  cout<<"No";
  
  return 0;
}

Measured memory_bytes: 640
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a,b;
	cin>>a>>b;
	ll mn=a*2;
	ll mx=a*4;
	if(b%2==0)
	{
		if(mn<=b&&b<=mx)
			cout<<"Yes";
		else
			cout<<"No";
	}
	else
			cout<<"No"<<endl;
}

Measured memory_bytes: 3640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
    };

    println!("{}", if n % 2 == 0 {
        n
    } else {
        2*n
    });
}


Measured memory_bytes: 2156
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	vector<int> a(n + 1);
	rep(i, n + 1) cin >> a[i];
	reverse(all(a));
	set<int> ans;
	int g = 0;
	rep(i, n + 1) g = gcd(g, abs(a[i]));
	for (int i = 2; i*i <= g; i++) {
		if (g % i == 0) ans.insert(i);
		while (g % i == 0) g /= i;
	}
	if (g != 1) ans.insert(g);
	for (int p = 2; p < 10010; p++) {
		bool prime = true;
		for (int i = 2; i*i <= p; i++) if (p%i == 0) prime = false;
		if (prime) {
			if (a[0] % p != 0) continue;
			vector<ll> cnt(p - 1);
			rep(i, n + 1) cnt[i % (p - 1)] += a[i];
			bool flag = true;
			rep(i, p - 1) if (cnt[i] % p != 0) { flag = false; break; }
			if (flag) ans.insert(p);
		}
	}
	for (int i : ans) cout << i << '\n';
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
void solve()
{
	double d, t ,s, res;
	cin >> d >> t >> s;
	res=d/s;
	if(t>=res) cout << "Yes" << endl;
	else cout << "No" << endl;
	return;
}
int main()
{
	int t=1;
	//cin >> t;
	while(t--) solve();
	return 0; 
}

Measured memory_bytes: 3720
n = int(input())
dp = [0]

for i in range(1, n+1):
    q = []
    q.append(1+dp[i-1])

    a = 1
    while True:
        a *= 6
        if a > i:
            break
        q.append(1+dp[i-a])

    b = 1
    while True:
        b *= 9
        if b > i:
            break
        q.append(1+dp[i-b])

    dp.append(min(q))

print(dp[n])

Measured memory_bytes: 3860
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;

int string_to_int(const string& s){
  int n;
  istringstream iss(s);
  iss>>n;
  return n;
}

int main()
{
  string num;
  int work=0,a,b;


  cin>>num;
  a=string_to_int(num);
  work=a;
  while(1){
    cin>>num;
    if(num=="=") break;
    if(num=="+"){ 
      cin>>b;
      work+=b;
      a=0;
    }
    else if(num=="-"){
      cin>>b;
      work-=b;
      a=0;
    }
    else if(num=="*"){
      cin>>b;
      work*=b;
    }
    else if(num=="/"){
      cin>>b;
      work/=b;
    }
  }
  cout<<work<<endl;  
  return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int H, W;
    int h, w;
 
    while (1) {
        scanf("%d%d", &H, &W);
        if (H == 0 && W == 0) break;
        for (h = 0; h < H; h++) {
            for (w = 0; w < W; w++) {
                putchar(((h & 1) ^ (w & 1)) == 0 ? '#' : '.');      }
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}


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

typedef long long ll;

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

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

const int INF = 1e+10;

int main() {
    string S;
    cin >> S;
    
    int t = S.size();
    
    int ans = INF;
    
    REP(i,t-1){
        if ( S[i] != S[i+1] ) {
            int c;
            int pos = i + 1;
            c = max(pos,t-pos);
            ans = min(ans,c);
        }
    }
    
    if ( ans == INF ) ans = t;
    
    cout << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 3760
#include<stdio.h>
#define MAX 250

int Parent(int i){
  return i/2;
};
int Left(int i){
  return 2*i;
};
int Right(int i){
  return 2*i+1;
};
int main(){
  int i, n;
  int left, right, parent;
  int H[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&H[i]);
  }

  for(i=0;i<n;i++){
    left = Left(i+1);
    right = Right(i+1);
    parent = Parent(i+1);

    printf("node %d: key = %d, ",i+1,H[i]);
    if(i!=0){
      printf("parent key = %d, ",H[parent-1]);
    }
    if(left<=n){
      printf("left key = %d, ",H[left-1]);
    }
    if(right<=n){
      printf("right key = %d, ",H[right-1]);
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 600
require 'pp'

n, k, q = gets.chomp!.split(" ").map(&:to_i)
a_n = []
q.times do |i|
    a_n << gets.chomp!.to_i
end

ans = {}
1.upto(n) do |i|
    ans[i] = 0
end

a_n.each do |i|
    ans[i] += 1
end

ans.each do |i, j|
    if k + j > q
        puts "Yes"
    else
        puts "No"
    end
end


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

bool cango(int y, int x, int H, int W, vector<string>& Map, vector<vector<int>>& Visited) {
	if (y < 0 || x < 0 || y >= H || x >= W) return false;
	if (Visited[y][x]) return false;
	return Map[y][x] == '.';
}

void pushcheck(int y, int x, queue<pair<int, int>>& Q, vector<vector<int>>& Visited) {
	Q.push({ y, x });
	Visited[y][x] = 1;
}

int main() {
	int H, W, Ch, Cw, Dh, Dw;
	cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
	Ch--, Cw--, Dh--, Dw--;
	vector<string> Map(H);
	for (int i = 0; i < H; i++) cin >> Map[i];

	queue<pair<int, int>> Q, NextQ;
	vector<vector<int>> Visited(H, vector<int>(W, 0));
	vector<vector<int>> Warped(H, vector<int>(W, 0));

	int warp = 0;
	Q.push({ Ch, Cw });
	Visited[Ch][Cw] = 1;
	while (!Q.empty()) {
		while (!Q.empty()) {
			auto p = Q.front();
			int y = p.first, x = p.second;
			//cout << y << "," << x << endl;
			Q.pop();
			if (y == Dh && x == Dw) {
				cout << warp << endl;
				return 0;
			}

			if (cango(y + 1, x, H, W, Map, Visited)) pushcheck(y + 1, x, Q, Visited);
			if (cango(y - 1, x, H, W, Map, Visited)) pushcheck(y - 1, x, Q, Visited);
			if (cango(y, x - 1, H, W, Map, Visited)) pushcheck(y, x - 1, Q, Visited);
			if (cango(y, x + 1, H, W, Map, Visited)) pushcheck(y, x + 1, Q, Visited);

			for (int ny = y - 2; ny <= y + 2; ny++) {
				for (int nx = x - 2; nx <= x + 2; nx++) {
					if (!cango(ny, nx, H, W, Map, Visited)) continue;
					if (cango(ny, nx, H, W, Map, Warped)) pushcheck(ny, nx, NextQ, Warped);
				}
			}

		}
		//cout << "Warp!" << endl;
		warp++;
		while (!NextQ.empty()) {
			auto p = NextQ.front();
			NextQ.pop();
			int y = p.first, x = p.second;
			if (Visited[y][x]) continue;
			Q.push(p);
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 13448
# problem C
N = input()
n = int(N)
X = list(map(int,input().split()))

P = []

for i in range(1,101):
    sa = list(map(lambda x:x-i, X))
    nizyo = list(map(lambda x:x**2, sa))
    summ = sum(nizyo)
    P.append(summ)

print(min(P))

Measured memory_bytes: 3060
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

int main(){
	int n, m;
	cin >> n;
	int *t = new int[n];
	for (int i = 0; i < n; ++i){
		cin >> t[i];
	}
	cin >> m;
	int *x = new int[m];
	int *p = new int[m];
	for (int i = 0; i < m; ++i){
		cin >> p[i] >> x[i];
	}

	int totalTime = 0;
	for (int i = 0; i < n; ++i){
		totalTime += t[i];
	}

	for (int i = 0; i < m; ++i){
		cout << totalTime + x[i] - t[p[i]-1] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef long l;
typedef pair<int,int> p;
typedef vector<int> ve;
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(int i=a;i<b;i++)
ll val[100000]={};
ll wt[100000]={};
ll k[101][100001]={};
ll calc(ll n,ll w)
{
  for(ll i=0;i<=n;i++)
  {
    for(ll weight=0;weight<=w;weight++)
    {
      if(i==0||weight==0)
        k[i][weight]=0;
      else if(wt[i-1]<=weight)
        k[i][weight]=max(val[i-1]+k[i-1][weight-wt[i-1]],k[i-1][weight]);
      else
        k[i][weight]=k[i-1][weight];
    }
  }
  return k[n][w];
}
int main()
{
  ll n,w;
  cin>>n>>w;
  loop(i,0,n)
  {
    cin>>wt[i];
    cin>>val[i];
  }
  ll ans=calc(n,w);
  cout<<ans;
  return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll M = 1e18;
#define rep(i, ss, ee) for (int i = (ss); i < (ee); ++i)

void solve() {
  ll N, x, a = 1;
  double b = 1;
  cin >> N;
  rep(i, 0, N) {
    cin >> x;
    a *= x;
    b *= x;
  }
  cout << ((a > M) or (b > M) ? -1 : a) << endl;
}

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

Measured memory_bytes: 3596
#include <bits/stdc++.h>
     
    using namespace std;
     
    #define ll  long long
    #define mod 1000000007
    #define pb push_back
 
    
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
 
        
 
        ll i,n,n2,m,t,j,l,pos,mpos,f=0,k,p,n1,d,z,q,x,y,x1,y1,x2,y2;
      
        /*cin>>t;
        
      
       while(t--)
    {
 
        
    }*/
        ll a,b,c,s=0;
        cin>>a>>b>>c>>k;

        if(a<k){
            
            k-=a;
        }
        else
        {
            cout<<k;
            return 0;
        }
        if(b<k){
            
            k-=b;
        }
        else
        {
            cout<<a;
            return 0;
        }
        cout<<a-k;
      return 0;
   }

Measured memory_bytes: 3612
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A, B, Q = mapint()
Ss = [-10**18]+[int(input()) for _ in range(A)]+[10**18]
Ts = [-10**18]+[int(input()) for _ in range(B)]+[10**18]
from bisect import bisect_left

for q in range(Q):
    x = int(input())
    ls = Ss[bisect_left(Ss, x)-1]
    lt = Ts[bisect_left(Ts, x)-1]
    rs = Ss[bisect_left(Ss, x)]
    rt = Ts[bisect_left(Ts, x)]
    print(min((rs-lt)+min(rs-x, x-lt), (rt-ls)+min(rt-x, x-ls), max(x-ls, x-lt), max(rs-x, rt-x)))

Measured memory_bytes: 101872
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n,k;
    cin >> n >> k;
    set<int>st;
    for(int i = 1; i <= n; i+=2){
        st.insert(i);
    }
    if(st.size()>=k){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[100];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int sum=0;
	for(int i=0;i<n-1;i++){
		sum=sum+a[i];
	}
	sum=sum+a[n-1]/2;
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define _for(it, a) \
  for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

using namespace std;

int main() {
  int N;
  cin >> N;
  cout << (N * (N + 1)) / 2 << endl;
  return 0;
}

// Built using Sublime-CHelper plug-in (beta)


Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
using namespace std;
int a[105]={0};
int main() {
    int n,m;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>m;
        a[m]++;
    }
    int s=0;
    for(int i=1;i<=100;i++)
        if(a[i]!=0)
            s++;
    cout<<s<<endl;
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;


int main() {
	int n, k;
	long long int ans = 0, suma = 0;
	cin >> n >> k;
	vector<long long int> sum(n + 1);
	for (int i = 0; i <= n; i++) {
		suma += i;
		sum[i] = suma;
	}
	for (int i = k; i < n + 1; i++) {
		ans += (sum[n] - sum[n - i] - sum[i - 1] + 1);
	}
	ans++;
	cout << ans % 1000000007 << endl;


	return 0;
}


Measured memory_bytes: 4712
#include <iostream>

int main(){
        long long N,h[100];
        std::cin >> N;
        for(int i=0; i<N; i++) {
                std::cin >> h[i];
        }
        long long result=h[0];
        for(int i=1; i<N; i++) {
                if(h[i]-h[i-1]>0) result+=h[i]-h[i-1];
        }
        std::cout << result;
        return 0;
}


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

int main() {
	// your code goes here
	int n,d;
	cin>>n>>d;
	vector<int>v[n];
	for(int i=0;i<n;i++){
		int arr[d];
		for(int j=0;j<d;j++){
			cin>>arr[j];
			v[i].push_back(arr[j]);
		}
	}
	int count=0;
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			int dis=0;
			for(int k=0;k<d;k++){
				dis+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
			}
			int s=sqrt(dis);
			if(s*s==dis)
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N,K,i,j,*S,B,a;
	while(a=1,cin>>N>>K,N||K){
		S=new int[K];
		for(i=K;i--;)cin>>S[i];
		for(i=N;i--;)for(j=K;j--;)cin>>B,S[j]-=B,S[j]<0?a=0:0;
		cout<<(a?"Yes":"No")<<endl;
	}
}

Measured memory_bytes: 1200
x, y, r, g, c = map(int, input().split())
r_d = list(map(int, input().split()))
g_d = list(map(int, input().split()))
c_d = list(map(int, input().split()))
r_d.sort(reverse=True)
g_d.sort(reverse=True)
c_d.sort(reverse=True)
a = r_d[:x]+g_d[:y]+c_d
a.sort(reverse=True)
print(sum(a[:x+y]))

Measured memory_bytes: 23328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int A, B;

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

int main() {
  cin >> A >> B;
  cout << ll(A) * B / gcd(A, B) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a>>b;
  if(a>9||b>9)cout<<-1<<endl;
else
  cout<<a*b<<endl;
  return 0;
}


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

int main(){
  
  int n, a, ans = 0;
  
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a;
    ans += a - 1;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256