akhauriyash/Code-Regression huggingface dataset:
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<string> vec(n);
    rep(i,n){
        cin>>vec[i];
    }
    sort(all(vec));
    ll tempcnt=1;
    ll Max=0;
    vector<string> res;
    string prev=vec[0];
    rep3(i,1,n){
        if(prev==vec[i]){
            tempcnt++;
        }else{
            if(tempcnt>Max){
                vector<string> temp;
                temp.push_back(vec[i-1]);
                res=temp;
                Max=tempcnt;
            }else if(tempcnt==Max){
                res.push_back(vec[i-1]);
            }
            tempcnt=1;
            prev=vec[i];
        }
    }
    if(tempcnt>Max){
        vector<string> temp;
        temp.push_back(vec[n-1]);
        res=temp;
        Max=tempcnt;
    }else if(tempcnt==Max){
        res.push_back(vec[n-1]);
    }
    sort(all(res));
    for(auto i:res){
        cout<<i<<endl;
    }
}


Measured memory_bytes: 14576
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <list>

#define ll long long

using namespace std;
long long n;
ll ans = 20;
int m = 0;
int main() {
	cin >> n;

	for (ll i = 1; i <= 100000; i++)
	{
		if (n % i == 0) {
			int l = to_string(i).length();
			int L = to_string(n / i).length();
			m = max(l,L);
		}

		if (m < ans) {
			ans = m;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, k;
    cin >> n >> k;
    cout << n - k + 1;
    return 0;
}

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

int main(){
  double A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  A *= 100;
  B *= 100;
  int ans1=A,ans2=0;
  double tmp_dens = 0.0;
  for(int i=1; A*i<=F; i++){
    for(int j=0; A*i+B*j<=F; j++){
      double w = A*i+B*j;
      for(int k=0; w+C*k<=F && C*k<=E*w/100; k++){
        int l_1 = static_cast<int>((F-w-C*k)/D);
        int l_2 = static_cast<int>((E*w/100-C*k)/D);
        int l = max(0,min(l_1, l_2));
        double s = C*k+D*l;
        if(tmp_dens<s/(s+w) && s<=E*w/100){
          ans1 = s+w;
          ans2 = s;
          tmp_dens = s/(s+w);
        }
      }
    }
  }
  cout << ans1 << " " << ans2;
  return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) cin >> v[i];
	sort(v.begin(), v.end());
	double ans = v[0];
	for (int i = 1; i < n; i++) ans = (ans + v[i]) / 2;
	cout << ans << endl;
}


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

int main(){
    int d, n;
    cin >> d>>n ;
    if(d==0){
        if(n<100){
        cout << n << endl;
        }
        else{
            cout << 101 << endl;
        }
    }
    else if(d==1){
        if(n<100){
            cout << n*100 << endl;
        }
        else{
            cout << 10100 << endl;
        }
    }
    else{
        if(n<100){
            cout <<n*10000 << endl;
        }
        else{
            cout << 1010000 << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A[1010],pre[1010];
int main()
{
	int N;
	cin>>N;
	for(int i=0;i<N;i++)
		cin>>A[i];
	for(int i=0;i<N;i++)
		pre[i+1]=pre[i]+A[i];
	int mn=1000000;
	for(int i=1;i<N;i++)
		mn=min(mn,abs(pre[i]-(pre[N]-pre[i])));
	cout<<mn<<endl;
	return 0;
}

Measured memory_bytes: 256
# include <cstdio>
# include <queue>
# define N 100000
# define M 200000
# define R register
# define inf 1000000000
# define C const int
using namespace std;
inline int r()
{
	int f = 1,x = 0;
	char c = getchar();
	
	while(c < '0' || c > '9'){
		if(c == '-') f = -1;
		c = getchar();
	}
	
	while(c >= '0' && c <= '9'){
		x = x * 10 + c - '0';
		c = getchar();
	}
	
	return x *= f;
}
struct edge
{
	int from,to,wi;
} e[2 * M + 42];
long long dis[N + 42],head[N + 42],cnt;
bool vis[N + 42],flag;

inline void add(C u,C v,C wi)
{
	e[++cnt].from = head[u];
	e[cnt].to = v;
	e[cnt].wi = wi;
	head[u] = cnt;
}

queue <int> q;
int n,m;
inline bool SPFA(int s);
int main()
{	
	n = r();m = r();
	
	int a,b,c;
	while(m--){
		a = r();b = r();c = r();
		add(a,b,c);
		add(b,a,-c);
	}
	
	for(R int i = 1;i <= n;i++)
		if(!vis[i] && SPFA(i)) break;
	
	if(flag == false) puts("Yes");
	else puts("No");
}
inline bool SPFA(int s)
{
	if(flag) return true;
    vis[s] = true;
    int v;
    for(int i = head[s]; i ; i = e[i].from)
    {
    	v = e[i].to;
        if(!vis[v]) dis[v] = dis[s] + e[i].wi,SPFA(v);
        else if(dis[v] != dis[s] + e[i].wi) return flag = true;
    }
    return false;
}

Measured memory_bytes: 7680
S = input()
box = [0]*len(S)
cnt = 0
for i in range(len(S)):
    if S[i] == "R":
        cnt += 1
    elif S[i] == "L":
        even = cnt//2
        box[i] += even
        box[i-1] += cnt-even
        cnt = 0
cnt = 0
for i in range(1,len(S)+1):
    i = -i
    if S[i] == "L":
        cnt += 1
    elif S[i] == "R":
        even = cnt//2
        box[i] += even
        box[i+1] += cnt-even
        cnt = 0
print(*box)

Measured memory_bytes: 47676
def solve(N, A, S):
    bit = [0] * 64
    for i in range(N-1,-1,-1):
        Ai = A[i]
        Si = S[i]
        while Ai:
            n = Ai.bit_length() -1
            if bit[n] == 0 and Si == '1':
                return 1
            elif bit[n] == 0 and Si == '0':
                bit[n] = Ai
                break
            Ai ^= bit[n]
    return 0

T = int(input())
for _ in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    S = input()
    print(solve(N, A, S))

Measured memory_bytes: 68164
#include<iostream>
using namespace std;
int main(){
 
 double N;
  cin>>N;
  if((N-9)/10-1==0||(N-9)/10-2==0||(N-9)/10-3==0||
     (N-9)/10-4==0||(N-9)/10-5==0||(N-9)/10-6==0||
     (N-9)/10-7==0||(N-9)/10-8==0||(N-9)/10-9==0||N/9 >= 10){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const int64_t INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    cout << (x == 1 ? 0 : 1) << '\n';
    return 0;
}


Measured memory_bytes: 3632
<?php
while($l=fgets(STDIN)){
  if(!$l) break;
  list($a,$b)=explode(' ',$l);
  $c=$a+$b;
  $d=1;
  while(9<$c){++$d;$c=floor($c/10);}
  echo $d,PHP_EOL;
}

Measured memory_bytes: 15364
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		String t = scan.next();
		String p = scan.next();

		nFind(t, p);

		scan.close();
		System.exit(0);
	}

	private static void nFind(String t, String p) {
		for (int st = 0; st < t.length() - p.length() + 1; st++)
			if (isEqual(t, p, st))
				System.out.println(st);
	}

	private static boolean isEqual(String t, String p, int st) {
		for (int i = 0; i < p.length(); i++)
			if (t.charAt(i + st) != p.charAt(i))
				return false;
		return true;
	}

}

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

bool prime[100005]; 
void SieveOfEratosthenes() 
{ 
  memset(prime, true, sizeof(prime)); 
  for (int p=2; p*p<=100005; p++) 
  { 
    if (prime[p] == true) 
    { 
      for (int i=p*p; i<=100005; i += p) 
        prime[i] = false; 
    } 
  } 
} 

int main() 
{  
  int n;
  SieveOfEratosthenes();
  cin >> n;
  while(!prime[n]) {
    n++;
  }
  cout << n << '\n';
  return 0; 
} 

Measured memory_bytes: 384
a = gets.to_i
b = []
c = []
ans = 0
for num in 0..a-1 do
d = gets.chomp.split(" ")
  b << d[0]
  c << d[1].to_i
end
e = gets.chomp
f = b.index(e)
for num in f+1..a-1 do
  ans += c[num]
end
p ans

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

using namespace std;
using ll = long long;
const int N = 1e6 + 5 , MOD = 1e9 + 7;
long long fact[N] , fact_inv[N];

long long mul(long long a , long long b) {
    return a * b % MOD;
}

long long power(long long a , long long b) {
    if (!b) return 1;
    long long r = power(a , b / 2);
    r = mul(r , r);
    if (b&1) return mul(r , a);
    return r;
}

long long mod_inv(long long x) {
    return power(x , MOD - 2);
}

long long nCr(long long n , long long r){
    if (!n) return !r;
    if(r>n) return  0;
    return mul(fact[n] , mul(fact_inv[n - r] , fact_inv[r]));
}

void pre() {
    fact[0] = fact_inv[0] = 1;
    for(int i = 1 ; i < N ;i++) {
        fact[i] = mul(fact[i - 1] , i);
        fact_inv[i] = mod_inv(fact[i]);
    }
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif
    pre();
    ll x, y;
    scanf("%lld %lld", &x, &y);
    ll b = (x-2*y) / -3;
    if((x-2*y) % -3 != 0){
        puts("0");
        return 0;
    }

    ll a = y - 2*b;
    if(a < 0 || b < 0){
        puts("0");
        return 0;
    }
    printf("%lld\n", nCr(a + b, a)%MOD);
    return 0;
}

Measured memory_bytes: 15872
def f_b():
    n, d = map(int, input().split())
    x = []
    stack = []
    c = 0

    for _ in range(n):
        x.append(list(map(int, input().split())))

    for i in range(n):
        xi = x[i]
        for xj in stack:
            d = 0
            for y, z in zip(xi, xj):
                d += (y-z)**2
            if (d**0.5)%1==0:
                c += 1
        stack.append(xi)

    print(c)

if __name__ == "__main__":
    f_b()


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  int N,A[100],i,j,a,count;

  scanf("%d",&N);
  
  if((1<=N)&&(N<=100)){
    for(i=0;i<N;i++){
      scanf("%d",&A[i]);
    }
  }
  for(j=0;j<N;j++){
    for(i=N-1;i>j;i--){
      if (A[i] < A[i-1]){
	a=A[i];
	A[i]=A[i-1];
	A[i-1]=a;
	count++;
      }
    }
  }
  for(i=0;i<N-1;i++)
    printf("%d ",A[i]);

  printf("%d\n",A[i]);
  
  printf("%d\n",count);

  return 0;
}

    
  



Measured memory_bytes: 2112
mod = 998244353
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    # comb init
    nmax = 6 * 10 ** 3 + 10  # change here
    fac = [0] * nmax
    finv = [0] * nmax
    inv = [0] * nmax
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, nmax):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

    def comb(n, r):
        if n < r:
            return 0
        else:
            return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod

    K, N = map(int, input().split())
    for i in range(2, 2*K+1):
        if i & 1:
            A = 0
            B = 0
            for j in range(1, K+1):
                if 1 <= i - j <= K:
                    A += 1
                else:
                    B += 1
            A //= 2
            ans = 0
            for a in range(A+1):
                if B == 0 and a == A:
                    break
                ans = (ans + (-1)**(a&1) * ((comb(N + (A+B-a) - 1, N) * pow(2, A-a, mod))%mod * comb(A, a))%mod)%mod
            print(ans)
        else:
            A = 0
            B = 0
            for j in range(1, K + 1):
                if 1 <= i - j <= K:
                    A += 1
                else:
                    B += 1
            A = (A-1) // 2
            ans = 0
            for a in range(A + 1):
                if B == 0 and a == A:
                    break
                ans = (ans + (-1) ** (a & 1) * (
                            (comb(N + (A + B - a) - 1, N) * pow(2, A - a, mod)) % mod * comb(A, a)) % mod) % mod
            for a in range(A + 1):
                if B == 0 and a == A:
                    break
                ans = (ans + (-1) ** (a & 1) * (
                            (comb(N-1 + (A + B - a) - 1, N-1) * pow(2, A - a, mod)) % mod * comb(A, a)) % mod) % mod
            print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 50652
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define mp make_pair
#define sp ": "
#define cs "Case "
#define fi first
#define sn second 
#define po(x) x*x
/* STL */
#define vi vector<int>v
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxa(a) *max_element(a, a.size())
#define r(a) reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n)i=1;i<=(n);i++)
#define fa(i,a,n) for(__typeof(a)i=(a);i<=(b);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define db(something)   cerr<<#something<<" - "<<something<<"\n";         
int main()
{
  
   Ezio
   /*Variables*/
   /*Code*/
   ll n,m;
   cin>>n;
   
   m=n%10;
   if(m==2 or m==4 or m==5 or m==7 or m==9)
   cout<<"hon"<<endl;
   else if(m==0  or m==1 or m==6 or  m==8)
   cout<<"pon"<<endl;
   else
   cout<<"bon"<<endl;
   return 0;
}
    

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

using namespace std;

#define INF (1ll << 62)
#define eb emplace_back
#define ii pair<int,int>
#define OK (cerr <<"OK"<< endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'
const int MOD = 1e9 + 7;

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

  int n, a, b;

  cin >> n >> a >> b;

  int t = n / (a + b);
  int ans = 0;

  ans += t * a;

  n -= t*(a + b);

  ans += min(a, n);

  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define moder 1234567
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int n;
double a[105];
double ave;
signed main() {
	cin>>n;
	rep(i,n){
		cin>>a[i];
		ave+=a[i];
	}
	ave/=(double)(n);
	double ans,sa=(double)(moder);
	rep(i,n){
		if(sa>abs(a[i]-ave)){
			ans=i;
			sa=abs(a[i]-ave);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#! python3
import math

def main():
    N = int(input())
    alist = [int(num) for num in input().split()]
    ans1 = 0
    ans2 = 0
    m = sum(alist) / N

    if sum(alist) % N == 0:
        ans = 0
        for i in range(N):
            ans += (alist[i] - m)**2
    else:
        mu = math.floor(m)
        mo = math.ceil(m)
        for i in range(N):
            ans1 += (alist[i] - mu)**2
            ans2 += (alist[i] - mo)**2

        if ans1 <= ans2:
            ans = ans1
        else:
            ans = ans2

    print(int(ans))


main()

Measured memory_bytes: 3064
# -*- coding: UTF-8 -*-
a = list(map(int, input().split()))
count5 = 0
count7 = 0
for i in a:
    if i == 5:
        count5 += 1
    elif i == 7:
        count7 += 1
if count5 == 2 and count7 == 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
ll mypow(ll a, ll b)
{
  ll res = 1;
  a %= mo;
  while (b)
  {
    if (b & 1)
      res = res * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return res;
}
const ll MAX = 510000;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(ll n, ll k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<ll> factorial(ll n)
{
  vector<ll> fac;
  fac.push_back(1);
  for (ll i = 1; i < n + 10; i++)
  {
    fac.push_back((fac[i - 1] * i) % mo);
  }
  return fac;
}
int main()
{
/* 
https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/5
ボール      箱	      入れ方に制限なし 箱の中身は1つ以下 箱の中身は1つ以上
区別できる   区別できる  1            2             3
区別できない  区別できる  4            5             6
区別できる   区別できない 7            8             9
区別できない  区別できない 10          11            12
*/
ll n , k ;
cin >> n >> k ;
auto mod = [](ll modx) {modx%=mo;modx+=mo;modx%=mo;return modx; };
COMinit();
vector<ll> fac = factorial(100000);

//1
//cout << mypow(k,n) << endl;
//2
//cout << (COM(k,n)*fac[n])%mo << endl;
/* 
//3
ll t=0;
rep(i,k+1){
  t=mod(t+mypow(-1,k-i)*COM(k,i)*mypow(i,n));
}
cout << t << endl;
 */
//4
//cout << COM(n+k-1,n) << endl;
//5
cout << COM(k,n) << endl;

return 0;
}


Measured memory_bytes: 15864
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    LL w,h,x,y;
    cin>>w>>h>>x>>y;

    cout << w*h/2.0 << " ";
    if(w == x*2 && h == y*2){
        cout << 1;
    }
    else{
        cout << 0;
    }
    cout << endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
int N, M;
int par[100005]; //親
int tree_rank[100005]; //木の深さ

void init_union_find(int n){
  rep(i, n){
    par[i] = i;
    tree_rank[i] = 0;
  }
}

// 木の根を求める
int find(int x){
  if (par[x] == x) return x;
  else return par[x] = find(par[x]);
}

// xとyの属する集合を併合
void unite(int x, int y){
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (tree_rank[x] < tree_rank[y]) par[x] = y;
  else{
    par[y] = x;
    if (tree_rank[x] == tree_rank[y]) tree_rank[x]++;
  }
}


int main() {
  INCANT;
  cin >> N >> M;
  int x,y,z;
  init_union_find(N);
  rep(i, M) {
    cin >> x >> y >> z;
    x--;y--;
    unite(x,y);
  }
  set<int> S;
  rep(i, N) S.insert(find(i));
  cout << S.size() << "\n";
  return 0;
}

Measured memory_bytes: 5760
package main

import "fmt"

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	ar := make([]int, n)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	sum := 1
	sv := 0
	for _, v := range ar {
		sv += v
		if sv <= x {
			sum++
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
     Scanner sc=new Scanner(System.in);
         int a=sc.nextInt();int b=sc.nextInt();int c=sc.nextInt();
       int e=0;e=Math.abs(b-a);int f=0;f=Math.abs(c-a); int d=Math.min(e,f);
        if(d==e){System.out.println("A");}if(d==f){System.out.println("B");
}}}


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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    set<string> s;
    for(int i = 0; i < n; i++) {
        string t; cin >> t;
        s.insert(t);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 19148
#include <iostream>
#include <vector>
using namespace std;
//---------------------------------------
int gcd(int x, int y);  //?????§??¬?´???°???????????¢??°gcd
//---------------------------------------

int main(void)
{
	int x, y;
	
	cin >> x;
	cin >> y;
	
	cout << gcd(x, y) << endl;
	 
	return 0;
}

//------------------------------------------
int gcd(int x, int y)
{
	int max, min;
	
	if(x >= y){
		max = x;
		min = y;
	}else{
		max = y;
		min = x;
	}
	
	
	int amari = max % min;
	if(!amari){
		return min;
	}
	gcd(amari, min);
}
//--------------------------------------------

Measured memory_bytes: 3040
#include <stdio.h>
int main (){
char s[100005];
int a=0,b=0,i;
scanf ("%s",s);
  for (i=0;s[i]!=0;i++){
  if(i%2==0){
  if (s[i]=='0'){
  a++;
  }
  else {
  b++;
  }
  }
  else if(i%2==1){
  if (s[i]=='1'){
  a++;
  }
  else {
  b++;
  }
  }
  }
    if (a<b){
    printf ("%d",a);
    }
else {
printf ("%d",b);
}
    return 0;
  }

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

int main(int argc, char const *argv[])
{ 
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);

ll a,b;
cin>>a>>b;
cout<<(a*b)<<endl;
}
 
 

Measured memory_bytes: 3652
# -*- coding: utf-8 -*-

import io
import sys
import math

def solve(n, k, a_lst):
    # implement process
    a_set = set(a_lst)
    ak = len(a_set)
    diff = ak - k
    if diff < 1:
        return 0
    
    #ソート済み配列を検査することで、count処理を線形にする
    a_lst.sort()
    tmp = a_lst[0]
    cnt = 0
    cnt_lst = []
    for i in range(len(a_lst)):
        if tmp != a_lst[i]:
            tmp = a_lst[i]
            cnt_lst.append(cnt)
            cnt = 0
        cnt += 1
    cnt_lst.append(cnt)
    cnt_lst.sort()
    return sum(cnt_lst[0:diff])

def main():
    # input
    n, k = map(int,input().split())
    a_lst = list(map(int,input().split()))

    # process
    ans = str( solve(n, k, a_lst) )
    
    # output
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
5 2
1 1 2 2 5
"""
_EXPECTED = """\
0
"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Measured memory_bytes: 33500
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n;
	cin>>n;
	vector<string> vs;
	int v[3]={};
	LL ans=0;
	FOR(i,0,n){
		string s;
		cin>>s;
		int l=s.length();
		FOR(ii,1,l){
			if(s[ii-1]=='A'&&s[ii]=='B')ans++;
		}
		if(s[0]=='B'&&s[l-1]=='A')v[0]++;
		else if(s[0]=='B')v[1]++;
		else if(s[l-1]=='A')v[2]++;
	}
	if(v[2]>0){
		if(v[0]>0){
			v[2]--;
			ans+=v[0];
			if(v[1]>0){
				ans++;
				v[1]--;
				ans+=min(v[1],v[2]);
			}
		}else{
			ans+=min(v[1],v[2]);
		}
	}else{
		if(v[1]>0){
			ans+=v[0];
		}else{
			if(v[0]>0)ans+=v[0]-1;
		}
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  long long ans;
  vector<long long> a(n),r(n+1),l(n+1);
  r[0]=0;l[n]=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    r[i+1]=a[i]+r[i];
  }
  for(int i=n-1;i>=0;i--){
    l[i]=l[i+1]+a[i];
  }
  ans=abs(r[1]-l[1]);
  for(int i=1;i<n;i++){
    if(abs(r[i]-l[i])<ans){ans=abs(r[i]-l[i]);}
  }
  cout<<ans;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#include <cstdio>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    int k[n];
    vector<int> p(m, 0);
    REP(i, n){
        cin >> k[i];
        REP(j, k[i]){
          	int a[n][k[i]];
            cin >> a[i][j];
            a[i][j]--;
            p[a[i][j]]++;
        }
    }

    int ans = 0;
    REP(i, m){
        if(p[i] == n){
            ans++;
        }
    }

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

Measured memory_bytes: 256
//00
#include<iostream>
#include<iomanip>

using namespace std;

int main(){
  int mat[11][11];
  for(int n;cin>>n,n;){
    for(int y=0;y<n;y++){
      int s=0;
      for(int x=0;x<n;x++){
	cin>>mat[y][x];
	s+=mat[y][x];
      }
      mat[y][n]=s;
    }
    for(int x=0;x<=n;x++){
      int s=0;
      for(int y=0;y<n;y++){
	s+=mat[y][x];
      }
      mat[n][x]=s;
    }
    for(int y=0;y<=n;y++){
      for(int x=0;x<=n;x++){
	cout<<setw(5)<<right<<mat[y][x];
      }
      cout<<endl;
    }
  }
  return 0;
}

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

static const int N = 1000;

int lcs(string X, string Y){
    int c[N + 1][N + 1];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X;
    Y = ' ' + Y;
    for (int i = 0; i <= m; ++i){
        c[i][0] = 0;
    }
    for (int i = 0; i <= n; ++i)
    {
        c[0][i] = 0;
    }
    for (int i = 1; i <= m; ++i)
    {
        for (int j = 1; j <= n; ++j){
            if( X[i] == Y[j]){
                c[i][j] = c[i - 1][j - 1] + 1;
            }else{
                c[i][j] = max(c[i - 1][j], c[i][j - 1]);
            }
            maxl = max(maxl, c[i][j]);
        }
    }
    return maxl;
}

int main()
{
    string s1, s2;
    int n;
    cin >> n;

    for (int i = 0; i < n; i++){
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }

        return 0;
}


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

using namespace std;

typedef long long ll;

int main(){

    ll n, d;
    cin >> n >> d;
    if( abs(n-d) > 2019 )
        cout << 0 << endl;
    else{
        ll mn = min(n, d), mx = max(n, d);
        ll res = 1e10;
        for(int i = mn; i <= mx; i++)
            for(ll j = i+1; j <= mx; j++)
                res = min(res, (i*j)%2019);
        cout << res << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
	/*
	int n;
	cin >> n;
	int p[200][3];

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

	int _p;
	for(int k=0;k<3;k++)
	{
		for(int i=0;i<n;i++)
		{
			_p = p[i][k];
			for(int j=i+1;j<n;j++)
			{
				if(_p == p[j][k])
				{
					p[i][k] = 0;
					p[j][k] = 0;
				}
			}
		}
	}

	for(int i=0;i<n;i++)
	{
		cout << p[i][0] + p[i][1] + p[i][2] << endl;
	}
	*/

	int ai,am,as,ae,bi,bm,bs,be;
	cin >> ai >> am >> as >> ae >> bi >> bm >> bs >> be;
	int answer=ai+am+as+ae;
	if(answer < bi+bm+bs+be)
	{
		answer=bi+bm+bs+be;
	}
	cout << answer << endl;

	return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int cnt[26] = {};
    int H, W; cin >> H >> W;
    rep(i, H){
        string S; cin >> S;
        rep(j, W) cnt[S[j]-'a']++;
    }
    
    bool ok = true;
    if(H % 2 == 0 && W % 2 == 0){
        rep(i, 26) if(cnt[i] % 4) ok = false;
    }
    else if(H % 2 == 1 && W % 2 == 1){
        int val = H/2 + W/2;
        //val個は2の倍数でいい
        int acc1 = 0, acc2 = 0, acc4 = 0;
        rep(i, 26){
            if(cnt[i] > 0){
                while(cnt[i] >= 4){
                    acc4++;
                    cnt[i]-=4;
                }
                while(cnt[i] >= 2){
                    acc2++;
                    cnt[i]-=2;
                }
                while(cnt[i] >= 1){
                    acc1++;
                    cnt[i]--;
                }
            }
        }
        if(acc1 > 1 || acc2 > val || acc1*1 + acc2*2 + acc4*4 < H*W) ok = false;
        else ok = true;
    }
    else{
        int val;
        if(H % 2 == 0) val = H/2;
        else val = W/2;
        //val個は2の倍数でいい
        //(HW-2val)/4回4を取り出したい
        int acc2 = 0, acc4 = 0;
        rep(i, 26){
            if(cnt[i] > 0){
                while(cnt[i] >= 4){
                    acc4++;
                    cnt[i]-=4;
                }
                while(cnt[i] >= 2){
                    acc2++;
                    cnt[i]-=2;
                }
            }
        }
        if(acc2 > val || acc2*2 + acc4*4 < H*W) ok = false;
        else ok = true;
    }

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

Measured memory_bytes: 256
h , w = map(int, input().split())
a = [list(input()) for _ in range(h)]
good_r = [False for _ in range(h)]
good_c = [False for _ in range(w)]

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            good_r[i] = True
            good_c[j] = True

for i in range(h):
    if good_r[i]:
        string = ''
        for j in range(w):
            if good_c[j]:
                string += a[i][j]
        if len(string) > 0:
            print(string)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#define pb(x) push_back(x)
using namespace std;

const int N=200005;

int n,m;
struct tree{int mx,tag;}t[N*4];
vector<int> vec[N];

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

void pushdown(int d)
{
	int w=t[d].tag;t[d].tag=0;
	t[d*2].mx+=w;t[d*2].tag+=w;
	t[d*2+1].mx+=w;t[d*2+1].tag+=w;
}

void build(int d,int l,int r)
{
	if (l==r) {t[d].mx=-(m-l+1);return;}
	int mid=(l+r)/2;
	build(d*2,l,mid);build(d*2+1,mid+1,r);
	t[d].mx=max(t[d*2].mx,t[d*2+1].mx);
}

void ins(int d,int l,int r,int x,int y)
{
	if (l<r) pushdown(d);
	if (l==x&&r==y) {t[d].mx++;t[d].tag++;return;}
	int mid=(l+r)/2;
	if (y<=mid) ins(d*2,l,mid,x,y);
	else if (x>mid) ins(d*2+1,mid+1,r,x,y);
	else ins(d*2,l,mid,x,mid),ins(d*2+1,mid+1,r,mid+1,y);
	t[d].mx=max(t[d*2].mx,t[d*2+1].mx);
}

int query(int d,int l,int r,int x,int y)
{
	if (l<r) pushdown(d);
	if (l==x&&r==y) return t[d].mx;
	int mid=(l+r)/2;
	if (y<=mid) return query(d*2,l,mid,x,y);
	else if (x>mid) return query(d*2+1,mid+1,r,x,y);
	else return max(query(d*2,l,mid,x,mid),query(d*2+1,mid+1,r,mid+1,y));
}

int main()
{
	n=read();m=read();
	for (int i=1;i<=n;i++)
	{
		int x=read(),y=read();
		vec[x].pb(y);
	}
	build(1,0,m+1);
	int ans=n-m;
	for (int i=0;i<m;i++)
	{
		for (int j=0;j<vec[i].size();j++) ins(1,0,m+1,0,vec[i][j]);
		ans=max(ans,query(1,0,m+1,i+2,m+1)-i);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 14080
package main

import (
	"fmt"
	"math"
)

var N, ans int

func main() {
	fmt.Scan(&N)
	x := 800 * N
	y := (N / 15) * 200
	fmt.Println(x - y)
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }

type si struct {
	s int
	i int
}

type SortBy []si

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i].s < a[j].s }


Measured memory_bytes: 512
n, l = [int(i) for i in input().split()]
ans = (l-1)*n+n*(n+1)//2
if l<=0 and l-1+n>=0:
  print(ans)
elif l+n-1<0:
  print(ans-(l+n-1))
elif l >0:
  print(ans-l)

Measured memory_bytes: 3060
import numpy as np

N, D = map(int, input().split())

X = [0] * N

for i in range(N):
    X[i] = list(map(int, input().split()))

ok = 0

for i in range(N):
    for j in range(i+1,N):
        sum = 0
        for k in range(D):
            sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k])
        sum = np.sqrt(sum)
        if sum.is_integer() == True:
            ok += 1

print(ok)




Measured memory_bytes: 12396
{-# LANGUAGE LambdaCase #-}

import           Data.Either
import           Data.Maybe

import qualified Data.Array.IArray   as I
import qualified Data.Array.MArray   as M

import           Data.Array.IO       (IOArray)
import           Data.Array.ST       (STArray)

import qualified Data.List           as L

import           Data.Bifunctor
import           Data.Function
import           Data.Monoid

import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import           Data.Functor

main :: IO ()
main = do
    n <- read <$> getLine
    ls <- getSeq
    print $ solve ls n

getSeq :: Read a => IO [a]
getSeq = map read . words <$> getLine

solve :: [Int] -> Int -> Int
solve ls n = runST $ do
    sticks <- M.newArray (1, 100) (Right 0) :: ST s (STArray s Int (Either Int Int))
    forM_ ls $ \l -> M.readArray sticks l >>= M.writeArray sticks l . \case
      Right x -> Left    x
      Left  x -> Right $ x + l

    xs <- M.getAssocs sticks
    let f :: Either Int Int -> Sum Int
        f (Right x) = Sum x
        f (Left  x) = Sum x
        x = foldl (\x l -> case x of Right (y, m) -> Left (y + m); Left y -> Right (y, l))
          (Left $ getSum $ foldMap f $ map snd xs)
          $ map fst $ filter (isLeft . snd) xs
    return $ case x of
      Right (y, _) -> y
      Left   y     -> y


Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum ^= a[i];
  }
  for(int i = 0; i < n; i++){
    ll ans = sum ^ a[i];
    cout << ans << endl;
  }
  return 0;
}


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

int judgenum(int n){
  if(n == 1){
    n = 6000;
  }else if(n == 2){
    n = 4000;
  }else if(n == 3){
    n = 3000;
  }else if(n == 4){
    n = 2000;
  }
  return n;
}


int main(){

  int t1,n1,t2,n2,t3,n3,t4,n4;
  cin >> t1 >> n1;
  cin >> t2 >> n2;
  cin >> t3 >> n3;
  cin >> t4 >> n4;

  t1 = judgenum(t1);
  t2 = judgenum(t2);
  t3 = judgenum(t3);
  t4 = judgenum(t4);

  cout << t1*n1 << endl;
  cout << t2*n2 << endl;
  cout << t3*n3 << endl;
  cout << t4*n4 << endl;

  return 0;
}

Measured memory_bytes: 1164
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 1e9+7;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 2e6+5;
char arr[10][10];

int32_t main(){
   
   speed_cubing
   
   int h,w,k;
   cin>>h>>w>>k;
   
   for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
         cin>>arr[i][j];

   int ans = 0;      

   for(int i=0;i<(1<<h);i++){
      for(int j=0;j<(1<<w);j++){

         int cnt = 0;

         for(int l=0;l<h;l++){
            for(int r=0;r<w;r++){

               if(((i>>l)&1) || ((j>>r)&1))
                 continue;

               if(arr[l][r]=='#')
                 cnt++;

            }
         } 

         if(cnt==k)
           ans++;

      }
   } 

   cout<<ans;     
   

   return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

int a[3];

int main(){
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	if(a[0]%2==0||a[1]%2==0||a[2]%2==0)
		puts("0");
	else{
		sort(a,a+3);
		printf("%lld\n",(long long)a[0]*a[1]);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> X(N), Y(N);
  rep(i, N) cin >> X[i] >> Y[i];
  double sum = 0;
  vector<bool> vis(N);
  auto dfs = [&](auto dfs, int cur, double d, int cnt) -> void {
    if(cnt == N-1) {
      sum += d;
      return;
    }
    vis[cur] = true;
    rep(i, N) {
      if(!vis[i]) {
        ll dx = X[i]-X[cur];
        ll dy = Y[i]-Y[cur];
        dfs(dfs, i, d+sqrt(dx*dx+dy*dy), cnt+1);
      }
    }
    vis[cur] = false;
  };
  rep(i, N) dfs(dfs, i, 0, 0);
  for(int i=1; i<=N; i++) sum /= i;
  cout << fixed << setprecision(20) << sum << "\n";
  return 0;
}


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

using namespace std;

typedef long long  ll;
typedef vector<ll> VL;
typedef pair<ll,ll> PLL;
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define inf 1000*1000*1000+5
const ll mod=998244353;


void solve()
{
	ll k,n;
	cin>>k>>n;
	VL arr(n);
	fr(i,0,n)
		cin>>arr[i];
	ll ans=inf;
	fr(i,0,n)
	{
		ll x=0;
		if(arr[i]<arr[(i+1)%n])
		{
			x=k-abs(arr[i]-arr[(i+1)%n]);
		}
		else
		{
			x=k-abs((k-arr[i])+arr[(i+1)%n]);
		}
		ans=min(ans,x);
	}
	cout<<ans<<endl;
	return;
}
int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int n=s.length();
  int m=t.length();
  int i,j,c,ans=0;
  for(i=0;i<=n-m;i++)
  {
    c=0;
    for(j=i;j<i+m;j++)
    {
      if(s[j]==t[j-i])
         c++;
    }
    ans=max(ans,c);
  }
  cout<<m-ans;
  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
using namespace std;
long long int p[100005];
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

    long long int N;
    long long int result=0;
    cin >> N;
    for(long long int i=0;i<N;i++){
        cin >> p[i];
    }
    for(long long int i=0;i<N;i++){
        if(p[i]==i+1){
            result++;
            if(i<N-1){
                if(p[i+1]==i+2){
                    i++;
                }
            }
        }
    }
	cout << result << "\n";
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args){
		String in = s.next();
		int s=-1,g=-1;
		for(int i=0;s==-1;i++) {
			if(in.charAt(i)=='A') s=i;
		}
		for(int i=in.length()-1;g==-1;i--) {
			if(in.charAt(i)=='Z') g=i;
		}
		System.out.println(g-s+1);
	}
}


Measured memory_bytes: 14512
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}




int main() {

  long a, b;
  long n;
  cin >> n ;
  vector<long> h(n);

  cin >> h;


  long ans = 0;

  long tmp = -1;
  for(int i=0;i<n;i++){
    if (h[i]>=tmp){
      ans++;
      tmp=h[i];
    }
  }


  cout << ans << endl;

}




















Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n, m, ret;

void solve(ll i){
	if(m - i * (n - 1) > 0){
		if((m - i * (n - 1)) % i == 0) ret = max(ret, i);
	}
}

signed main(){
	cin >> n >> m;
	ret = 0;
	for(ll i=1; i*i<=m; i++){
		solve(i);
		solve(m/i);
	}
	cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
@d = gets.to_i
@c = gets.split.map &:to_i
@s = @d.times.map { gets.split.map &:to_i }

def score(schedule, range = 0...@d, last = [0] * 26)
  sat = 0
  range.each do |day|
    type = schedule[day]
    sat += @s[day][type]
    day += 1
    last[type] = day
    sat -= 26.times.sum { |i, day_last| @c[i] * (day + 13 - last[i]) }
  end
  sat
end

schedule = [0] * @d
last = [0] * 26
@d.times do |day|
  s_max, i_max = -10000000, 0
  26.times do |i|
    schedule[day] = i
    s = score(schedule, day..day, last.dup)
    s_max, i_max = s, i if s > s_max
  end
  schedule[day] = i_max
  last[i_max] = day + 1
end

schedule.each do |type|
  p type + 1
end


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

n, m, q = map(int, input().split())
si, res = [1] + [0 for i in range(55)], 0
a, b, c, d = [0 for i in range(55)], [0 for i in range(55)], [0 for i in range(55)], [0 for i in range(55)]
for i in range(1, q+1): a[i], b[i], c[i], d[i] = map(int, input().split())

def solve(x: int):
    global res
    if x == n + 1: res = max(res, sum([d[i] for i in range(1, q+1) if si[b[i]] - si[a[i]] == c[i]]))
    else:
        for i in range(si[x-1], m + 1): si[x] = i; solve(x+1)
solve(1); print(res)

Measured memory_bytes: 77852
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
signed main(){
	int b;
	while(cin >> b && b!=0){
		int l=1,r=2;
		int sum = 1;
		while(1){
			if(sum < b){
				sum += r;
				r++;
			} else if (b < sum){
				sum -= l;
			    l++;
			} else {
				break;
            }
		}
		cout << l << " " << r-l << endl;
	}
}





Measured memory_bytes: 3108
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#define ll long long
#define pi (acos(-1))
using namespace std;
int main()
{   
ll a,b;
cin>>a>>b;
cout<<lcm(a,b)<<endl;
    return 0;
}


Measured memory_bytes: 3624