akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
using ll = long long;
using ull = unsigned long long;

vector<int> v;

int main() {
    FAST;

    ll h, w;
    cin >> h >> w;

    ll ans = 0;
    if(h == 1 || w == 1){
        ans = 1;
    }else{
        ans = (h * w + 1) / 2;
    }
    
    println(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    double r, pai, area, circum;
    
    scanf("%lf", &r);
    
    pai = 3.1415926535897931;
    
    area = r * r * pai;
    
    circum = 2 * r * pai; 
    
    printf("%f %f\n", area, circum);
    
}

Measured memory_bytes: 3204
#include<stdio.h>
#include<math.h>
#define maxn 100005
#define inf 0x3f3f3f3f
using namespace std;
typedef long int ll;
ll a[maxn];
int main()
{
    int n, A, B;
    scanf("%d %d %d", &n, &A, &B);
    for (int i = 0; i < n; ++i) scanf("%lld", &a[i]);
    int C = A - B, l = 0, r = 1e9, ans;
    while (l <= r){
        int m = (l + r) / 2, cnt = 0;
        for (int i = 0; i < n; ++i){
            if ((a[i] - (ll)m * B) <= 0) continue;
            cnt += ceil((double)(a[i] - (ll)m * B) / C);
            if (cnt > m) break;
        }
        if (cnt > m) l = m + 1;
        else r = m - 1, ans = m;
    }
    printf("%d\n", ans);
    return 0;
}


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

int main(){
  long long x;
  cin>>x;
  long long y=1,z=0;
  for(int i=0;x>1;i++){
  z+=y;
  if(x%2==0){
  x=x/2;
  y=2*y;
  }
  else{
  x=(x-1)/2;
  y=2*y;
  }
  }
  cout<<y+z<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdint>
#include<cstdio>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(b); ++i)
#define rep(i,n) for(int i=0; i<n; ++i)
#define all(v) begin(v), end(v)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  auto w = v;
  sort(all(w));
  auto a = w[n/2];
  auto b = w[n/2-1];

  rep(i, n) {
          if (w[n/2] <= v[i]) {
                  cout << b << endl;
          } else {
                  cout << a << endl;
          }
  }
  return 0;
}


Measured memory_bytes: 3840
#include <iostream>

using namespace std;

const int MAX_N = 2005;

string s[MAX_N];
int cnt[MAX_N][MAX_N];

int main()
{
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; ++i){
        cin >> s[i];
        int prev_pos = -1;
        // left
        for(int j = 0; j < w; ++j){
            if(s[i][j] == '#'){
                prev_pos = j;
            }else{
                cnt[i][j] += j - prev_pos;
            }
        }
        prev_pos = w;
        for(int j = w-1; j >= 0; --j){
            if(s[i][j] == '#'){
                prev_pos = j;
            }else{
                cnt[i][j] += prev_pos - j - 1;
            }
        }
    }
    for(int j = 0; j < w; ++j){
        int prev_pos = -1;
        for(int i = 0; i < h; ++i){
            if(s[i][j] == '#'){
                prev_pos = i;
            }else{
                cnt[i][j] += i - prev_pos - 1;
            }
        }
        prev_pos = h;
        for(int i = h - 1; i >= 0; --i){
            if(s[i][j] == '#'){
                prev_pos = i;
            }else{
                cnt[i][j] += prev_pos - i - 1;
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            ans = max(ans, cnt[i][j]);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 20096
import java.util.Scanner;

class Tree {
	enum Order {
		PreOrder,
		InOrder,
		PostOrder
	}

	Node root;

	protected Node insert(Node node) {
		Node parent = null;
		Node child = root;

		while (child != null) {
			parent = child;
			if (node.key < child.key) child =child.left;
			else child = child.right;
		}
		node.parent = child;

		if (parent == null) {
			root = node;
		} else if (node.key < parent.key) {
			parent.left = node;
		} else {
			parent.right = node;
		}

		return node;
	}

	protected void print(Order order) {
		switch (order) {
			case PreOrder:
				walkPreOrder(root);
				break;
			case InOrder:
				walkInOrder(root);
				break;
			case PostOrder:
				walkPostOrder(root);
				break;
		}
		System.out.println();
	}

	private void walkPreOrder(Node node) {
		if (node == null) return;
		System.out.print(" " + node.key);
		walkPreOrder(node.left);
		walkPreOrder(node.right);
	}

	private void walkInOrder(Node node) {
		if (node == null) return;
		walkInOrder(node.left);
		System.out.print(" " + node.key);
		walkInOrder(node.right);
	}

	private void walkPostOrder(Node node) {
		if (node == null) return;
		walkPostOrder(node.left);
		walkPostOrder(node.right);
		System.out.print(" " + node.key);
	}
}

class Node {
	int key;
	Node parent, left, right;

	Node(int key) {
		this.key = key;
	}
}

/**
 * 二分探索木：挿入
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_8_A&lang=ja">ALDS1_8_A</a>
 */
public class Main {

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

		String command;
		Tree tree = new Tree();
		for (int i = 0; i < n; i++) {
			command = sc.next();
			if ("insert".equals(command)) {
				int key = sc.nextInt();
				tree.insert(new Node(key));
			} else if ("print".equals(command)) {
				tree.print(Tree.Order.InOrder);
				tree.print(Tree.Order.PreOrder);
			}
		}

		sc.close();
	}

}



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

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(), (x).end()

int main()
{
  int n, m, k;
  cin >> n >> m >> k;
  int a[n];
  int b[m];
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];

  ll t = 0;
  rep(i, m) t += b[i];

  int j = m;
  int ans = 0;
  rep(i, n + 1)
  {
    while (j > 0 && t > k)
    {
      --j;
      t -= b[j];
    }
    if (t > k)
      break;
    ans = max(ans, i + j);
    if (i == n)
      break;
    t += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5192
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

n,k = l_in()
P = l_in()
C = l_in()

s = min(k,n)

res = -(10**10)
for start in range(n):
    j = start
    current = 0
    tmp = -(10**10)
    for i in range(1, k+1):
        j = P[j]-1
        current += C[j]
        tmp = max(tmp, current)
        if j == start:
 #           print(i)
#            print(current)
            loop=current
            
            if current > 0:
                s = k%i
                add = current*(k//i)

                j = start
                current = 0

                for i2 in range(1, s+1):
                    j = P[j]-1
                    current += C[j]
                    tmp = max(tmp, current+add)


                if k//i >= 2:
                    add = loop*(k//i - 1) # (p-1)*i
                    j = start
                    current = 0

                    for _ in range(i): # i
                        j = P[j]-1
                        current += C[j]
                        tmp = max(tmp, current+add)
            break
                
    res = max(tmp, res)
    
print(res)


Measured memory_bytes: 68996
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
  int n,x=0,ans=0;
  string s;
  cin>>n>>s;
  for(auto i:s){
    if(i=='I'){
      x++;
    }else{
      x--;
    }
    ans=max(ans,x);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) FOR(i,0,n)
 

int main(){
	
	int a,b;cin>>a>>b;
	string s;cin >>s;
	rep(i,a)
	{
		int num = s[i] - '0';
		if(not(0<=num and num<=9))
		{
			cout << "No" << endl;
			return 0;
		}
	}
	
	if(s[a] != '-')
	{
		cout << "No" << endl;
		return 0;
	}
	
	FOR(i,a+1,a+1+b)
	{
		int num = s[i] - '0';
		if(not(0<=num and num<=9))
		{
			cout << "No" << endl;
			return 0;
		}
	}
		
	
	cout << "Yes"<< endl;
	
}

//cout << ans << endl;

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <string>
#include <string_view>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int64_t read_int() {
    int64_t ret = 0, sgn = 1;
    int ch = getchar_unlocked();
    while (isspace(ch)) { ch = getchar_unlocked(); }
    if (ch == '-') { sgn = -1; ch = getchar_unlocked(); }
    for (; isdigit(ch); ch = getchar_unlocked())
        ret = (ret * 10) + (ch - '0');
    ungetc(ch, stdin);
    return sgn * ret;
}

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()

template <typename T> inline void assign_min(T& x, const T& value) noexcept { x = min(x, value); }
template <typename T> inline void assign_max(T& x, const T& value) noexcept { x = max(x, value); }

constexpr char LF = '\n';

//-------------------------------------------------------------------------------------------------

int main() {
    int N = read_int();
    vector<int64_t> A(N);
    REP(i, N) A[i] = read_int();

    // i < j とすると
    //   j - i = A[j] + A[i]
    //   ∴ j - A[j] = A[i] + i

    map<int64_t, int64_t> B;
    REP(i, N) B[A[i] + i] += 1;

    int64_t ans = 0;
    REP(j, N) ans += B[j - A[j]];
    cout << ans << LF;
}


Measured memory_bytes: 27000
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


vector<int>list(200005, 0);

signed main() {
	int N;

	cin >> N;

	for (int i = 1; i < N; i++) {
		int num;
		cin >> num;
		list[num]++;
	}

	for (int i = 1; i <= N; i++) {
		cout << list[i] << endl;
	}



	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll zero=0;
    string n;   //xyz///
    ll k;
    cin>>n>>k;
    ll s=n.size();
    ll dp0[110][5],dp1[110][5];
    m0(dp0);
    m0(dp1);
    dp1[0][0]=1;
    for (int i = 0; i < s; i++)
    {
        int num=n[i]-'0';
        for (int j = 0; j <= k; j++)
        {
            dp0[i+1][j]+=dp0[i][j];
            dp0[i+1][j+1]+=dp0[i][j]*9;
            if(num>0)
            {
                dp0[i+1][j]+=dp1[i][j];

                dp0[i+1][j+1]+=dp1[i][j]*(num-1);
                dp1[i+1][j+1]+=dp1[i][j];
            }
            else //num=0
            {
                dp1[i+1][j]+=dp1[i][j];
            }
        }
    }
    
    cout<<dp0[s][k]+dp1[s][k]<<endl;

    return 0;
}

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

int h1,m1,h2,m2,k;

int main()
{
	cin>>h1>>m1>>h2>>m2>>k;
	int sum=h2*60-h1*60+m2-m1-k;
	if(sum<0)
	{
		cout<<0;
		return 0;
	}
		
	else{
		cout<<h2*60-h1*60+m2-m1-k<<endl;
	}
	
	return 0;
}

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

def main():
    N, W = map(int, input().split())
    inf = float('inf')
    dp = [inf] * (10**5+1)
    dp[0] = 0
    for n in range(1, N+1):
        w, v = map(int, input().split())
        for i in range(v, 10**5+1)[::-1]:
            if dp[i-v] + w <= W:
                dp[i] = min(dp[i], dp[i-v] + w)
    for i in range(10**5+1)[::-1]:
        if dp[i] < inf:
            print(i)
            break
if __name__ == '__main__':
    main()

Measured memory_bytes: 46540
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

int main()
{
  string s;
  while (getline(cin, s)) {
    if (s.find_first_of("\n") != string::npos)
      s.erase(s.end()-1);
    if (s.find_first_of("\r") != string::npos)
      s.erase(s.end()-1);

    if (s == "0")
      break;

    istringstream iss(s);
    int one = 0, sum = 0;
    while (!iss.eof()) {
      int num;
      iss >> num;

      if (num == 1)
	++one;
      else if (num >= 10)
	sum += 10;
      else
	sum += num;
    }

    int ans = 0;
    for (int i = 0; i <= one; ++i) {
      int p = i + (one-i)*11 + sum;
      if (p > 21)
	p = 0;
      ans = max(ans, p);
    }

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

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
double distance(double x1, double y1, double x2, double y2){
  return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main() {
  int n;cin>>n;
  double ans=0.0;
  vector<pair<int, int> > p(n);
  vector<int> idx(n);
  REP(i,n){
    int a,b;cin>>a>>b;
    p[i]=make_pair(a,b);
    idx[i]=i;
  }
  double sum=0.0;
  int pattern=0;
  do{
    REP(i,n-1){
      double dist=distance(p[idx[i]].first, p[idx[i]].second, p[idx[i+1]].first, p[idx[i+1]].second);
      sum+=dist;
    }
    pattern++;
  }while(next_permutation(ALL(idx)));
  ans=sum/(double)pattern;
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D,E;
  cin>>A>>B>>C>>E;
  D=C-A;
  if(D<0)D*=-1;
  if(D<=E)cout << "Yes" << endl;
  else{
    D=B-A;
    int F=C-B;
    if(D<0)D*=-1;
    if(F<0)F*=-1;
    if(D<=E&&F<=D)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int a, b, c;
	int d = 0;
	cin >> a >> b >> c;
	if (a > b) { d = a; a = b; b = d; }
	if (b > c) { d = b; b = c; c = d; }
	if (a > b) { d = a; a = b; b = d; }
	cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3108
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N = int(input())
B = list(map(int, input().split()))
ans = 0

ans += B[0]
for i in range(1, N - 1):
    ans += min(B[i - 1], B[i])
ans += B[N-2]

print(ans)


Measured memory_bytes: 9124
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF_L = 1e17+7;
const long long INF_I = 1e9+7;
const long long MOD = 1e9+7;
const double EPS = 1e-8;
const double PI=acos(-1);

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	int k;
	cin >> k;
	k--;
	for(int i=0;i<n;i++){
		if(s[i]==s[k])continue;
		s[i]='*';
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3600
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve(){
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return;
		map<pair<int, int>, pair<int, pair<int, int>>> vertexs;
		REP(i, n) {
			int a, b;
			string c;
			cin >> a >> b >> c;
			if (c == "x") {
				vertexs[mp(a, b)] = mp(-1, mp(a + 1, b));
				vertexs[mp(a + 1, b)] = mp(-1, mp(a, b));
			}
			else {
				vertexs[mp(a, b)] = mp(-1, mp(a, b + 1));
				vertexs[mp(a, b + 1)] = mp(-1, mp(a, b));
			}
		}
		int ok = 1;
		for (auto i = vertexs.begin(); i != vertexs.end(); ++i) {
			if (i->second.first != -1) continue;
			queue<pair<int, int>> next;
			next.push(i->first);
			next.push(i->second.second);
			vertexs[i->first].first = 0;
			vertexs[i->second.second].first = 1;
			while (next.empty() == false) {
				pair<int, int> now = next.front();
				next.pop();
				int dx[4] = { 1,-1,0,0 };
				REP(q, 4) {
					int next_x = now.first + dx[q];
					int next_y = now.second + dx[3 - q];
					if (vertexs.find(mp(next_x, next_y)) == vertexs.end()) continue;
					if (mp(next_x, next_y) == vertexs[now].second) continue;
					if (vertexs[mp(next_x, next_y)].first != -1) {
						//check
						
						if (vertexs[mp(next_x, next_y)].first != vertexs[now].first) {
							ok = 0;
							break;
						}
					}
					else {
						vertexs[mp(next_x, next_y)].first = vertexs[now].first;
						next.push(mp(next_x, next_y));
						pair<int, int> check = vertexs[mp(next_x, next_y)].second;
						vertexs[check].first = (vertexs[now].first + 1) % 2;
						next.push(check);
					}
				}
			}
		}
		if (ok == 1) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 6336
#include<bits/stdc++.h>
using namespace std;
#define int long long

int a,b,x;

double calc(double t){
  double rad = t * M_PI / 180.0;
  double c = b / tan(rad);
  double S;
  if(c < a) {
    S = (a * b * b) / (2.0 * tan(rad));
  }
  else {
    S = ((a*a) * (2.0*b - a * tan(rad))) / 2.0;
  }
  return S;
}

signed main() {
  cin >> a >> b >> x;

  if(a*a*b < x) {
    puts("0");
    return 0;
  }

#if 1
  int l=0, r=90*1000000;
  while(r-l>1) {
    int m = l + (r-l) / 2;
    double S = calc( m / (1000000.0) );
    if(S > x) {
      l = m;
    }
    else {
      r = m;
    }
  }

  //cerr << l << "\t" << fixed << calc(l/1000000.0) << "\t" << x << endl;
  //cerr << r << "\t" << fixed << calc(r/1000000.0) << "\t" << x << endl;

  double S = calc( r / (1000000.0) );
  if( S < x ) r = l;
  printf("%.7f\n", r / 1000000.0);
#else 
  for(int i = 1; i <= 90*1000000; i++) {
    double S = calc(i / (1000000.0));
    if(S < x) {
      printf("%.7f\n", (i-1) / 1000000.0);
      return 0;
    }
  }
#endif
}


Measured memory_bytes: 896
#include<iostream>

int main(){
    int n,m,l;
    int a[1000][1000]={};
    int b[1000][1000]={};
   long int c[1000][1000]={};
    std::cin>>n>>m>>l;
   int i,j,k;
   for(i=0;i<n;i++)
    for(j=0;j<m;j++)
        std::cin>>a[i][j];
    
   for(j=0;j<m;j++)
    for(k=0;k<l;k++){
        std::cin>>b[j][k];
        
    }
   for(i=0;i<n;i++)
    for(j=0;j<m;j++)
     for(k=0;k<l;k++){
         c[i][k]+= a[i][j] * b[j][k];
     }
    for(i=0;i<n;i++)
     for(k=0;k<l;k++){
         if(k==l-1)
          std::cout<<c[i][k]<<"\n";
         else
         std::cout<<c[i][k]<<" ";
     } 
}



Measured memory_bytes: 18728
n = int(input())
a = [int(input()) for _ in range(n)]
ans = a[0] - 1
max_before = 1
for i in range(1, n):
    if a[i] <= max_before:
        continue
    elif a[i] == max_before + 1:
        max_before += 1
    else:
        ans += (a[i] - 1) // (max_before + 1)
print(ans)


Measured memory_bytes: 80708
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
	int n;
	cin >> n;
	LL a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	LL ansnum = 0;

	vector<pair<LL,LL> > ans[n+1];
	vector<pair<LL,LL> > cur;


	for(int k = 17; k > 0; k--){
		LL r = 1;
		for(int c = 0; c < k; c++) r *= 10;
		LL p = r/10;
		for(int f = 1; f <= 9; f++){
			for(int i = 0; i <= n; i++) ans[i].clear();
			ans[0].push_back(make_pair(f*p,r-1));
			//cout << "case " << f*p << " " << r-1 << endl;
			int done = 0;
			for(int i = 0; i < n; i++){
				cur = ans[i];
				for(int l = 0; l < ans[i].size(); l++){
					if(a[i]%r >= ans[i][l].first && a[i]%r <= ans[i][l].second){
						done = 1;
						break;
					}
					LL s1 = (r+ans[i][l].first - a[i] % r)%r;
					LL e1 = (r+ans[i][l].second - a[i] % r)%r;
					cur.push_back(make_pair(s1,e1));
					//cout << s1 << " " << e1 << endl;
					if(done) break;
				}
				if(done) break;

				sort(cur.begin(), cur.end());
				/*for(int z = 0; z < cur.size(); z++){
					cout << cur[z].first << "," << cur[z].second << " ";
				}
				cout << endl;*/
				LL curs = 1e18;
				LL cure = -1;
				for(int z = 0; z < cur.size(); z++){
					if((!(cure < cur[z].first) && !(cur[z].second < curs)) || cure == -1){
						cure = max(cure,cur[z].second);
						curs = min(curs,cur[z].first);
					} else {
						ans[i+1].push_back(make_pair(curs,cure));
						curs = cur[z].first;
						cure = cur[z].second;
					}
				}
				if(cure != -1) ans[i+1].push_back(make_pair(curs,cure));

				/*for(int z = 0; z < ans[i+1].size(); z++){
					cout << ans[i+1][z].first << "," << ans[i+1][z].second << " ";
				}
				cout << endl;*/

				if(done) break;
			}
			if(done){
				ansnum ++;
				//cout << f*p << endl;
			}
		}
	}
	cout << ansnum << endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N, M, sum = 0;
    cin >> N >> M;
    vint A(N);
    rep(i, N)
    {
        cin >> A[i];
        sum += A[i];
    }
    sort(all(A));
    int ans = 0;
    rep(i, N)
    {
        if (A[i] * 4 * M >= sum)
            ans++;
    }
    cout << ((ans >= M) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

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

  int flag = 0;
  for(int i=1;i<=9;i++){
	if(n%i == 0 && n/i <= 9)flag = 1;
  }

  if(flag)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int k[N], p[N];

  for (int i = 0; i < N; i++) {
    cin >> k[i] >> p[i];
  }

  for (int ii = 0; ii<N; ii++) {
    if (k[ii]%p[ii] == 0) {
      cout << p[ii] << endl;
    } else {
      cout << k[ii]%p[ii] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const ll mod =1000000007;
int main(){
    ll n;
    cin>>n;
    vector<ll> a(n),ze(64,0), ei(64,0), ans(64,0);
    for(ll i=0; i<n; i++){
        cin>>a[i];
        bitset<64> ta =a[i];
        for(int j=0; j<64; j++){
            if(ta.test(j)) ei[j]++;
            else ze[j]++;
        }
    }
    for(ll i=0; i<n; i++){
        bitset<64> ta =a[i];
        for(int j=0; j<64 ; j++){
            if(ta.test(j)){
                ei[j] -=1;
                ans[j] =(ans[j] + ze[j] )%mod;
            }
            else{
                ze[j] -=1;
                ans[j] =(ans[j] + ei[j] ) %mod;
            }
        }
    }
    ll an=0;
    ll tmp=1;
    for(int i=0; i<64; i++){
        an += (ans[i] *tmp)%mod;
        an %= mod;
        tmp *=2;
        tmp %=mod;
    }
    cout<<an<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int m=0,n,aa[220000],a,b,cnt=0;
pair<int,int> p[220000];
string s,ss[110000];
char c;
signed main(){
    cin>>n;
    cnt+=n/500*1000;
    n-=n/500*500;
    cnt+=n/5*5;
    cout<<cnt;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s; cin >> s;
    bool is_res = false;
    if(s[0]==s[1] && s[2]==s[1])is_res = true;
    if(s[2]==s[1] && s[2]==s[3])is_res = true;
    cout << (is_res?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
//max_element

const int r = 1;
const int s = 2;
const int p = 3;

int N, K;
int R, S, P;
int T[100010];
int ans[100010];

int win(int a)
{
	switch (a)
	{
		case r: return p;
		case s: return r;
		case p: return s;
	}
}

signed main()
{
	cin >> N >> K;
	cin >> R >> S >> P;
	string t;
	cin >> t;
	int len = t.length();
	REP(i, len)
	{
		switch (t[i])
		{
			case 'r': T[i] = r; break;
			case 's': T[i] = s; break;
			case 'p': T[i] = p; break;
		}
	}

	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		if (i < K)
		{
			ans[i] = win(T[i]);
		}
		else
		{
			int w = win(T[i]);
			if (ans[i - K] == w)
			{
				ans[i] = 0;
			}
			else
			{
				ans[i] = w;
			}
		}

		switch (ans[i])
		{
			case r: sum += R; break;
			case s: sum += S; break;
			case p: sum += P; break;
		}
	}

	cout << sum << endl;
}



Measured memory_bytes: 5304
s = input().rstrip('\n');
can = 0;
n = len(s);
tsugi = n;
while tsugi >= 1 :
	if s[tsugi - 5 : tsugi] == 'dream' :
		can = 1;
		tsugi = tsugi -5;
	elif s[tsugi - 5 : tsugi] == 'erase' :
		can = 1;
		tsugi = tsugi -5;
	elif s[tsugi - 6 : tsugi] == 'eraser' :
		can = 1;
		tsugi = tsugi -6;
	elif s[tsugi - 7 : tsugi] == 'dreamer' :
		can = 1;
		tsugi = tsugi -7;
	else :
		can = 0;
		tsugi = -1;
if bool(can) :
	print('YES');
else :
	print('NO');

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	string S;
	cin>>S;
	
	if(S.substr(0,4)=="YAKI")cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
template <class X> void print(X x) { cout << x << endl; }
void print(vl x) {
    for(ll i : x) {
        cout << i << " ";
    }
    cout << endl;
}
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v, m;
ll codeforces = 1;
string S, T;
vl A, B;
long double eps = 10e-11, pp;
ll _25[100][100];
void input() {
  cin>>n;
  rep(i,n){
    cin >> S;
    a = 50;
    b = 50;
    c = 0;
    p=S.length()-1;
    rep(i, S.length()) {
        if(S[i] == '.')
            p = i;
        else
            c = c * 10 + (S[i] - '0');
    }
    a -= S.length() - p-1;
    b -= S.length() - p-1;
    while(c % 2 == 0) {
        c/= 2;
        a++;
    }
    while(c % 5 == 0) {
        c /= 5;
        b++;
    }
    _25[a][b]++;
  }
}
void solve() {
    rep(i, 100) {
        rep(j, 100) {
            rep(h, 100) {
                rep(k, 100) {
                    if(i + h > 99 && j + k > 99) {
                        ans+=_25[i][j]*_25[h][k];
                    }
                }
            }
            if(i > 49 && j > 49) {
                ans-=_25[i][j];
            }
        }
    }
    print(ans / 2);
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    while(codeforces--) {
        solve();
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  string s;
  cin >> s;
  bool HEISEI = true;
  if(s[5] > '0')
    HEISEI = false;
  else if(s[6] > '0' + 4)
    HEISEI = false;

  if(HEISEI)
    cout << "Heisei" << endl;
  else
    cout << "TBD" << endl;
  return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::io::stdin;
use std::cmp::min;

fn main() {
    let (n, k) = {
        let line = read_vec::<usize>();
        (line[0], line[1])
    };
    let mut vec = read_vec::<i64>();
    vec.sort();
    vec.reverse();
    for i in 0..min(n, k) {
        vec[i] = 0;
    }
    let sum = vec.iter().fold(0i64, |acc, &x| acc + x);
    println!("{}", sum);
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().split_whitespace().
        map(|x| x.parse().ok().unwrap()).collect()
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

template <class T>
class SegTree {
  int n;                       // 葉の数
  vector<T> data;              // データを格納するvector
  T def;                       // 初期値かつ単位元
  function<T(T, T)> operation; // 区間クエリで使う処理
  function<T(T, T)> update;    // 点更新で使う処理

  // 区間[a,b)の総和。ノードk=[l,r)に着目している。
  T _query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l)
      return def; // 交差しない
    if (a <= l && r <= b)
      return data[k]; // a,l,r,bの順で完全に含まれる
    else {
      T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
      T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
      return operation(c1, c2);
    }
  }

 public:
  // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
  // _update:更新関数
  SegTree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
    : def(_def), operation(_operation), update(_update) {
    n = 1;
    while (n < _n) {
      n *= 2;
    }
    data = vector<T>(2 * n - 1, def);
  }

  // 場所i(0-indexed)の値をxで更新
  void change(int i, T x) {
    i += n - 1;
    data[i] = update(data[i], x);
    while (i > 0) {
      i = (i - 1) / 2;
      data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  // [a, b)の区間クエリを実行
  T query(int a, int b) {
    return _query(a, b, 0, 0, n);
  }

  // 添字でアクセス
  T operator[](int i) {
    return data[i + n - 1];
  }
};

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

  ll n;
  cin >> n;

  // 要素数N・long long型・区間min・点更新
  SegTree<long long> st(
    n, 0, [](long long a, long long b) { return max(a, b); }, [](long long a, long long b) { return b; });

  vll a(n);
  rep(i, n) {
    cin >> a[i];
    st.change(i, a[i]);
  }

  rep(i, n) {
    cout << max(st.query(0, i), st.query(i + 1, n)) << endl;
  }

  return 0;
}


Measured memory_bytes: 7296
h,w=map(int,input().split())
pattern=[h//2+w//3+1,h//3+w//2+1,h,w]
if h%3==0 or w%3==0:
    pattern+=[0]
if h%2==0:
    pattern+=[h//2]
if w%2==0:
    pattern+=[w//2]
print(min(pattern))

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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;
const int N = 1e3 + 5;

int n, m, tx, ty;
string a[N];

int visited[N][N];
int lvl[N][N];

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

void bfs(int sx, int sy) {
    memset(lvl, -1, sizeof(lvl));

    deque<pair<int, int>> q;
    q.emplace_back(sx, sy);
    visited[sx][sy] = true;
    lvl[sx][sy] = 0;

    while (!q.empty()) {
        auto[x, y] = q.front();
        q.pop_front();

        for (int k = 0; k < 4; k++) {
            int new_x = x + dx[k], new_y = y + dy[k];
            if (new_x >= 0 and new_x < n and new_y >= 0 and new_y < m and a[new_x][new_y] != '#' and visited[new_x][new_y] <= 1) {
                lvl[new_x][new_y] = lvl[x][y];
                visited[new_x][new_y] = 2;
                q.emplace_front(new_x, new_y);
            }
        }

        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int new_x = x + i, new_y = y + j;
                if (new_x >= 0 and new_x < n and new_y >= 0 and new_y < m and a[new_x][new_y] != '#' and !visited[new_x][new_y]) {
                    lvl[new_x][new_y] = 1 + lvl[x][y];
                    visited[new_x][new_y] = 1;
                    q.emplace_back(new_x, new_y);
                }
            }
        }
    }
}

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

    int x1, y1;
    cin >> n >> m >> x1 >> y1 >> tx >> ty;

    for (int i = 0; i < n; i++) cin >> a[i];

    bfs(--x1, --y1);
    cout << lvl[--tx][--ty] << "\n";
    return 0;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 2e5+5;
const int M = 1e6+4;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int n, n_divisors[M], cnt[M], a[N];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
		cnt[a[i]]++;
	}

	for(int i=1; i<M; i++){
		for(int j=i; j<M; j+=i){
			n_divisors[j] += cnt[i];
		}
	}
	int ans = 0;
	for(int i=0; i<n; i++){
		ans += (n_divisors[a[i]] == 1);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 12204
def main():
    N = int(input())
    A = [0] + list(map(int, input().split()))

    for i in range(N):
        A[N - i] = sum(A[N - i :: N - i]) % 2

    print(sum(A))
    print(*(i for i, v in enumerate(A) if v))

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 11692
n = int(input())
p = []
for _ in range(n):
    x,y = map(int,input().split())
    p += [(x,y)]
p.sort()


def dist(p1, p2):
    return abs(p1[0]-p2[0]) + abs(p1[1]-p2[1])


ans = 0
q = set()
pmax = p[0]
pmin = p[0]
for i in range(1, n):
    for point in q:
        ans = max(ans, dist(point, p[i]))
    ans = max(ans, dist(p[i], pmax), dist(p[i], pmin))
    if pmax[1] < p[i][1]:
        q.add(pmax)
        pmax = p[i]
    if pmin[1] > p[i][1]:
        q.add(pmin)
        pmin = p[i]

    qrem = set()
    for point in q:
        if pmin[0]-point[0] <= point[1]-pmin[1] and pmax[0]-point[0] <= pmax[1]-point[1]:
            qrem.add(point)
    q -= qrem

print(ans)

Measured memory_bytes: 91952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
const ll L = 2e5 + 5;
ll arr[L];
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll n;
 	cin >> n;
 	vector <ll> vec(n);
 	for (ll i = 0; i < n; i++) {
 		cin >> vec[i];
 		arr[vec[i]]++;
 	}   
 	ll ans = 0;
 	for (ll i = 1; i <= n; i++) {
 		ans += ((arr[i] * (arr[i] - 1)) / 2);
 	}
 	for (ll i = 0; i < n; i++) {
 		ll temp = ans;
 		ll c = arr[vec[i]];
 		if (c >= 2) {
 			temp -= (c * (c - 1)) / 2;
 			temp += ((c - 1) * (c - 2)) / 2;
 		}
 		cout << temp << endl;
 	}
	return 0;
}

Measured memory_bytes: 4736
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
mod=10**9+7

def MatMul(A,B):
    C=[[0]*len(B[0]) for _ in range(len(A))]
    for i in range(len(A)):
        for j in range(len(B[0])):
            for k in range(len(B)):
                C[i][j]+=A[i][k]*B[k][j]
                C[i][j]%=mod
    return C
def MatPow(A,n):
    l=len(A)
    B=[[0]*l for _ in range(l)]
    for i in range(l):
        B[i][i]=1
    while n:
        if n&1:
            B=MatMul(B,A)
        A=MatMul(A,A)
        n//=2
    return B

n,k=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(n)]
P=MatPow(A,k)
ans=0
for p in P:
    ans+=sum(p)
    ans%=mod
print(ans)

Measured memory_bytes: 41452
n=int(input())
s=str(input())
ans=[]
li=["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"]  
for i in range(1,n):
    cnt=0
    for j in range(26):
        if li[j] in s[:i]:
            if li[j] in s[i:]:
                cnt+=1
    ans.append(cnt)   
print(max(ans))           

Measured memory_bytes: 3064
def main():
    N = int(input())
    P = list(map(int, input().split()))

    x = 0
    for i in range(1, N-1):
        a, b, c = P[i-1], P[i], P[i+1]
        if a < b and b < c or a > b and b > c:
            x += 1

    print(x)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
using namespace std;

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

int main(){
	const int dx[] = {-1,0};
	const int dy[] = {0,-1};
	const int mod = 100000;
	int h,w;
	int dp[2][2][128][128]; //[1=ok,0=no][nouth|west][][]
	
	while(scanf("%d %d",&w,&h),w|h){
		memset(dp,0,sizeof(dp));
		
		dp[1][0][1][2] = dp[1][1][2][1] = 1;
		REP(i,1,h+1){
			REP(j,1,w+1){
				rep(k,2){  // k=0 -> west
					int tx = j + dx[k];
					int ty = i + dy[k];
					dp[1][k][i][j] += (dp[0][k][ty][tx] + dp[1][k][ty][tx])%mod;
					dp[0][k][i][j] += dp[1][(k+1)%2][ty][tx];
					
					//printf("0 %d %d %d  , %d\n",k,i,j,dp[0][k][i][j]);
					//printf("1 %d %d %d  , %d\n",k,i,j,dp[1][k][i][j]);
				}
			}
		}
		int sum = dp[0][0][h][w] + dp[1][0][h][w] +
							dp[0][1][h][w] + dp[1][1][h][w];
		printf("%d\n",sum%mod);
	}
	return 0;
}

Measured memory_bytes: 0
fun main(args : Array<String>) {
        val list = (1..readLine()!!.split(" ")[0].toInt()).map { readLine()!! }
        (0 until list.size).forEach { i ->
            (0 until list[0].length).forEach { j ->
                if (list[i][j] == '#'
                        && (i == 0 || list[i - 1][j] == '.')
                        && (i == list.size - 1 || list[i + 1][j] == '.')
                        && (j == 0 || list[i][j - 1] == '.')
                        && (j == list[0].length - 1 || list[i][j + 1] == '.')) {
                    print("No")
                    return
                }
            }
        }
        print("Yes")
}

Measured memory_bytes: 37868
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;

#define EPS 1e-9
#define PI 3.14159265358979323846264338327950
const int N = 1e5 + 5;


int L[N], R[N];
template <class T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}


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

	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> L[i];
		R[i] = L[i];
	}

	for (int i = 1; i < n; ++i) {
		L[i] = gcd(L[i], L[i - 1]);
	}

	for (int i = n; i > 0; --i) {
		R[i] = gcd(R[i], R[i + 1]);
	}


	int ans = 0;

	for (int i = 1; i <= n; ++i) {
		ans = max(ans, gcd(L[i - 1], R[i + 1]));
	}
	cout << ans << '\n';
	
}


Measured memory_bytes: 4312
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  char suit;
  int rank;
  int card[4][13] = {};
  for (int i = 0; i < n; i++) {
    cin >> suit >> rank;

    if (suit == 'S') {
      card[0][rank - 1]++;
    } else if (suit == 'H') {
      card[1][rank - 1]++;
    } else if (suit == 'C') {
      card[2][rank - 1]++;
    } else if (suit == 'D') {
      card[3][rank - 1]++;
    }
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      if (card[i][j] == 0) {
        switch (i) {
        case 0:
          cout << "S " << j + 1 << endl;
          break;
        case 1:
          cout << "H " << j + 1 << endl;
          break;
        case 2:
          cout << "C " << j + 1 << endl;
          break;
        case 3:
          cout << "D " << j + 1 << endl;
          break;
        }
      }
    }
  }

  return 0;
}


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

int main(){
  
  string S, data;;
  cin >> S;
  int i;
  
  for(i=0; i<(int)S.size(); i++){
    if(data.size()!=0 && S[i]=='B'){
      data.pop_back();
    }else if(S[i]=='1'){
      data+='1';
    }else if(S[i]=='0'){
      data+='0';
    }
  }
  cout << data << endl;
  return 0;
}

Measured memory_bytes: 3632