akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main()
{
    int n,m,l;
    cin>> n>> m>>l;
    long long a[n][m],b[m][l],c[n][l];

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >>a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin >> b[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            c[i][j]=0;
        }
    }
    for (int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j==0){
                cout << c[i][j];
            }
           else {cout << " "<< c[i][j];
           }

        }
        cout << endl;
    }
    return 0;
}



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

int main(void){
    int l1, l2, l3, l4;
    cin >> l1 >> l2 >> l3 >> l4;
    int total = l1 + l2 + l3 + l4;

    int m = total / 60;
    int s = total - m * 60;
    
    cout << m << endl;
    cout << s << endl;
    
    return 0;
}



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

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) "FUCK YOU"
#endif
	

const int mod=1e9+7;
#define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);
const int N=500006;


void solve()
{
	vi a(5);
	cin>>a;
	int ans=0,sum=0;
	for(int i=0;i<5;i++)
	{
		sum+=a[i];
		if(a[i]%10)
		{
			sum+=(10-a[i]%10);ans=max(ans,10-a[i]%10);
		}
	}
	cout<<sum-ans;
}




signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc=1;
	//~ cin>>tc;	
	for(int i=0; i<tc; i++)
	{
		solve();
	}

}


int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}

void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	if(a<0)a+=mod;
}
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;	
}


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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

long long gcd(long long a, long long b){
    if (a < b) swap(a, b);
    return b ? gcd(b, a % b) : a;
}

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

long long powi(long long x, long long n) {
    if (n == 0) return 1;
    long long res = powi(x * x, n / 2);
    if (n & 1) res = res * x;
    return res; 
}

//--------------------------- Solve ---------------------------//

int f(int n) {
    int res = 0;
    while (n % 2 == 0) {
        n /= 2;
        res++;
    }
    return res;
}

void solve() {
    int N, M; cin >> N >> M;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        a[i] /= 2;
    }

    int num = f(a[0]);
    long long l = 1;
    for (int i = 0; i < N; i++) {
        if (f(a[i]) != num) {
            cout << 0 << '\n';
            return;
        }

        l = lcm(l, a[i]);
        if (l > M) {
            cout << 0 << '\n';
            return;
        }
    }

    int ans = (M - l) / (2*l) + 1;
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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;}

const ll mod = 1000000007;
const int INF = 1<<29;

ll choose(ll n){
  return n * (n - 1) / 2;
}

int main(){
  int N; cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  rep(i, N) a[i]--;

  map<int, int> vec;
  rep(i, N) vec[a[i]]++;

  ll res = 0;
  for (int i = 0; i < N; ++i){
    res += choose(vec[i]);
  }

  for (int i = 0; i < N; ++i){
    ll plus = vec[a[i]] - 1;
    ll minus = vec[a[i]];
    cout << res + choose(plus) - choose(minus) << endl;
  }
}


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

int main(){
	vector<int> v;
	int a[10];
	for(int i = 0;i < 10;i++){
		cin >> a[i];
	}
	v.assign(&a[0], &a[10]);
	sort(v.begin(), v.end());
	for(int i = 9;i > 6;i--)cout << v[i] << endl;
    return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <climits>

using namespace std;
#define ll long long
#define ve vector
#define umap unordered_map
int n;
ll ans=0;
string s;
void solve(ll x, ll sum) {
    if(x>n) {
        ans+=sum;
        return;
    }
    ll c=0;
    for(ll i=x;i<=n;i++) {
        c=(c*10) + (s[i]-'0');
        solve(i+1, sum+c);
    }
}

int main() {
    cin>>s;
    n=s.size();
    s=' '+s;
    solve(1,0);
    cout <<ans<<endl;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
ll dfs(ll k,vector<vector<ll>>&g,ll par){
  ll now=0;
  for(auto to:g[k]){
    if(to != par){
      now^=dfs(to,g,k); 
    }
  }
  return now+1;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<vector<ll>>g(n);
  rep(i,0,n-1){
    ll x,y;cin>>x>>y;x--;y--;
    g[x].PB(y);
    g[y].PB(x);
  }
  auto k=dfs(0,g,-1);
  ans(k==1,"Bob","Alice");
  return 0;
}

Measured memory_bytes: 12032
#include <iostream>
#include<math.h>
#include<string>
#include<iomanip>
#include <limits>
using namespace std;

int main()
{
int a,b; cin>>a>>b;
if(a==b)
    cout<<"Draw";
else if(a==1)
    cout<<"Alice";
else if(a>b&&b!=1)
    cout<<"Alice";
else
    cout<<"Bob";

}


Measured memory_bytes: 3580
def main():
  a, b, _, k = map(int, input().split())

  ans = 0

  v = min(a, k)
  ans += v
  k -= v

  if k < 0:
    print(ans)
    return

  k -= min(b, k)

  if k < 0:
    print(ans)
    return

  ans -= k

  print(ans)


main()


Measured memory_bytes: 9208
#include <stdio.h>
int main(){
	int s;
	scanf("%d",&s);
	int m;
	int n=s%100;
	m=(s-n)/100;
	if(m>=1&&m<=12&&n>=1&&n<=12){
		printf("%s\n","AMBIGUOUS");
	}
	else if(m>=1&&m<=12){
		printf("%s\n","MMYY");
	}
	else if(n>=1&&n<=12){
		printf("%s\n","YYMM");
	}
	else{
		printf("%s\n","NA");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;



using ll = long long;
using ull = unsigned long long;
constexpr ll N = 2e5;

constexpr ull max_num = 1e18;
ull a[N];



int main()
{




	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		scanf("%lld", &a[i]);
	}


	Bint sum = a[0];
	bool f = false;
	for (int i = 1; i < n; i++)
	{
		sum *= a[i];
		
		if (sum > max_num) {
			for (int j = i+1; j < n; j++)
			{
				if (a[j] == 0) {
					sum = 0;
					goto r;
				}
					
			}
			f = true;
			break;
		}

	}

	r:
	if (f)
		cout << "-1" << endl;
	else
		cout << sum << endl;


	return 0;

}

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

int main(){
  string s;
  cin >> s;
  int ans = s.size()/2; 
  for (int i=0; i<s.size(); i++){
    ans -= (s[i]=='p') ? 1 : 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, k,check,num,count = 0,sum_ans = 0;
	cin >> n >> k;
	vector <int> a(n),ans;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		num = a[i];
		if (num == a[i + 1])check++;
		else {
			check++;
			ans.push_back(check);
			check = 0;
			count++;
		}
	}
	sort(ans.begin(), ans.end());
	for (int i = 0; i < count - k; i++)sum_ans += ans[i];
	cout << sum_ans << endl;
	return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int n,h;
  cin >> n >> h;
  vector<int> a(n);
  vector<int> b(n);
  int i;
  for(i = 0;i < n;++i){
    cin >> a.at(i) >> b.at(i);
  }
  sort(a.begin(),a.end());  sort(b.begin(),b.end());
  reverse(a.begin(),a.end()); reverse(b.begin(),b.end());
  int maxa = a.at(0);
  int ans = 0;
  int modeb = 0;
  while(h > 0){
    if(modeb < n && b.at(modeb) > maxa){
      h -= b.at(modeb);
      ++ans;
      ++modeb;
    }else{
      h -= maxa;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
from collections import deque

MOVE = {'U': (0, -1), 'D': (0, 1), 'L': (-1, 0), 'R': (1, 0)}

def next(numbers):
    for d in 'UDLR':
        z = numbers.index(0)
        tx, ty = z % 3 + MOVE[d][0], z // 3 + MOVE[d][1]
        if 0 <= tx < 3 and 0 <= ty < 3:
            t = ty * 3 + tx
            result = list(numbers)
            result[z], result[t] = numbers[t], 0
            yield d, tuple(result)

def bfs(puzzle):
    queue = deque([(puzzle, '')])
    seen = set()
    while queue:
        numbers, route = queue.popleft()
        seen.add(numbers)
        if numbers == (1, 2, 3, 4, 5, 6, 7, 8, 0):
            return route
        for direction, new_numbers in next(numbers):
            if new_numbers not in seen:
                queue.append((new_numbers, route + direction))
    return route

puzzle = ()
for i in range(3):
    a,b,c = map(int, input().split())
    puzzle += (a,b,c)

print(len(bfs(puzzle)))



Measured memory_bytes: 55808
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int maxn = 2005;

struct Fenwick {
    int t[maxn][maxn];

    int get(int x, int y) {
        int res = 0;
        for (int i = x - 1; i >= 0; i = (i & (i + 1)) - 1)
            for (int j = y - 1; j >= 0; j = (j & (j + 1)) - 1)
                res += t[i][j];
        return res;
    }

    void put(int x, int y) {
        for (int i = x; i < maxn; i |= i + 1)
            for (int j = y; j < maxn; j |= j + 1)
                t[i][j]++;
    }

    int get(int x1, int y1, int x2, int y2) {
        return get(x2, y2) + get(x1, y1) - get(x2, y1) - get(x1, y2);
    }
};

string s[maxn];
Fenwick f[3];

int main() {
    #ifdef LOCAL
    assert(freopen("c.in", "r", stdin));
    #else
    #endif
    int n, m, q;
    cin >> n >> m >> q;
    forn (i, n)
        cin >> s[i];
    forn (i, n) {
        forn (j, m) {
            if (s[i][j] != '1')
                continue;
            f[0].put(i, j);
            if (i + 1 < n && s[i + 1][j] == '1')
                f[1].put(i, j);
            if (j + 1 < m && s[i][j + 1] == '1')
                f[2].put(i, j);
        }
    }
    forn (i, q) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        --x1, --y1;
        int res = f[0].get(x1, y1, x2, y2);
        res -= f[1].get(x1, y1, x2 - 1, y2);
        res -= f[2].get(x1, y1, x2, y2 - 1);
        cout << res << '\n';
    }
}


Measured memory_bytes: 52864
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
s=input()
l=len(s)
if s[l-1]=="s":
    ans=s+"es"
else:
    ans=s+"s"
print(ans)

Measured memory_bytes: 61916
A="abcdefghijklmnopqrstuvwxyz"
S=input()
k=int(input())
n=len(S)

C=[]

for a in A:
    now=""
    cnt=0
    if not a in S:
        continue
    for i in range(n):
        if S[i]==a:
            for j in range(5):
                if i+j<n:
                    C.append(S[i:i+j+1])
                else:
                    break
    C.sort()
    for c in C:
        if now!=c:
            now=c
            cnt+=1
        if cnt==k:
            break
    if cnt==k:
        break
print(now)        

Measured memory_bytes: 4340
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
  int n, l;
  cin >> n >> l;
  vector<int> vec(n);
  for (int i = 1; i <= n; ++i)
    vec[i - 1] = l + i - 1;

  sort(vec.begin(), vec.end(),
       [](auto const &lhs, auto const &rhs) { return abs(lhs) < abs(rhs); });

  int ans = accumulate(vec.begin() + 1, vec.end(), 0);
  cout << ans << endl;
}

Measured memory_bytes: 3604
N,*ss=$<.read.split.map(&:to_i)

sum=ss.inject(&:+)
if sum % 10 != 0
    puts sum
    exit 0
end

ss.sort.each do |s|
    if s % 10 != 0
        puts(sum-s)
        exit 0
    end
end

puts 0

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

int main(){

    string s;
    cin >> s;

    if(s == "SUN"){
        cout << 7 << endl;
    }
    else if(s == "MON"){
        cout << 6 << endl;
    }
    else if(s == "TUE"){
        cout << 5 << endl;
    }
    else if(s == "WED"){
        cout << 4 << endl;
    }
    else if(s == "THU"){
        cout << 3 << endl;
    }
    else if(s == "FRI"){
        cout << 2 << endl;
    }
    else if(s == "SAT"){
        cout << 1 << endl;
    }


}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

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

    sort(d, d+n);

    cout << d[n/2] - d[n/2-1] << "\n";
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000001;

int main(){
  int N;
  cin >> N;
  int d[100000];
  rep(i, N){
    cin >> d[i];
  }
  sort(d,d+N);
  cout << d[N/2] - d[N/2 - 1] <<endl;
}

Measured memory_bytes: 640
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int n;
char pattern[30];
char board[110];
int main()
{
  cin >>n;
  cin >>pattern;
  int ans = 0;
  for(int i = 0;i < n;i++){
    cin >>board;
    bool flag = false;
    for(int j = 0;j <strlen(board)&&!flag;j++){
      if(board[j] ==pattern[0]){//始点を探す
	for(int k = 1;k <strlen(board)&&!flag;k++){
	  int current = j + k;
	  for(int l = 1;l <strlen(pattern)&& current <strlen(board);l++){
	    if(board[current] != pattern[l]){
	      break;
	    }
	    if(l ==strlen(pattern)-1){
	      flag = true;
	    }
	    current +=k;
	  }
	}
      }
    }
    if(flag)
      ans++;
      }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  int up = (N + 1000 - 1) / 1000 * 1000;
  int ans = up - N;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
vec hnum(400000,0),wnum(400000,0),hh[400000];
template< typename Monoid >
struct SegmentTree
{
  using F = function< Monoid(Monoid, Monoid) >;
 
  int sz;
  vector< Monoid > seg;
 
  const F f;
  const Monoid M1;
 
  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }
 
  void set(int k, const Monoid &x)
  {
    seg[k + sz] = x;
  }
 
  void build()
  {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  void update(int k, const Monoid &x)
  {
    k += sz;
    seg[k] += x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  Monoid query(int a, int b)
  {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }
 
  Monoid operator[](const int &k) const
  {
    return seg[k + sz];
  }
};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll H,W,M;
    cin>>H>>W>>M;
    int h,w;
    rep(i,M) cin>>h>>w,hnum[h]++,wnum[w]++,hh[h].push_back(w);
    ll ans=0;
    SegmentTree< ll > seg(W+1, [](int a, int b){ return max(a, b); }, LLONG_MIN);
    rep1(i,W) seg.set(i,wnum[i]);
    seg.build();
    rep1(i,H){
        ll a=0;
        a+=hnum[i];
        for(auto j:hh[i]){
            seg.update(j,-1);
        }
        ans=max(ans,a+seg.query(1,W+1));
        for(auto j:hh[i]){
            seg.update(j,1);
        }
    }
    cout<<ans;
}

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

int main(){
	while(true){
		int n,s;
		int nlist[20001];
		cin >> n >> s;
		if(n==0&&s==0){
			break;
		}

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

		sort(nlist,nlist+n);

		int ans = 0;
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(nlist[i]+nlist[j] > s){
					ans += n-j;
					break;
				}
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,ans[200001]={0};
  string s;
  cin>>n>>s;
  reverse(s.begin(),s.end());
  rep(i,n) if(s[i]=='#') ans[0]++;
  rep(i,n){
    if(s[i]=='#') ans[i+1]=ans[i]-1;
    else ans[i+1]=ans[i]+1;
  }
  sort(ans,ans+n+1);
  cout<<ans[0];
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);
int dev2(int n, int* a);

int main(void) {
	int N, A[200];
	int cnt = 0;

	i_cin(N);
	i_cins(N, A);

	while (!dev2(N,A))
		cnt++;

	i_cout(cnt);
	return 0;
}

int dev2(int n, int* a) {
	int i;

	for (i = 0; i < n; i++) {
		if (a[i] % 2) return 1;
		a[i] /= 2;
	}
	return 0;
}

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const double eps = 1e-9;
const ll N = 1e6 + 10;
const int M = 1e9 + 7;
const ll MAX = 1e18 + eps;
int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};


int main() {
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    sort(a, a + n);
    sort(b, b + n);
    int mn = (n % 2 == 0 ? a[n / 2 - 1] + a[n / 2] : a[n / 2]);
    int mx = (n % 2 == 0 ? b[n / 2 - 1] + b[n / 2] : b[n / 2]);

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

Measured memory_bytes: 5204
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int main()
{
    int a, b, c;
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    cin >> a >> b >> c;
    if (a == 5 && b == 7 && c == 5) cout << "YES";
    else if (a == 5 && b == 5 && c == 7) cout << "YES";
    else if (a == 7 && b == 5 && c == 5) cout << "YES";
    else cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
#include<cassert>
#include<functional>
typedef long long ll;

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	
	ll make_level;
	ll eat_layers;

	//プロトタイプ宣言
	ll layers(ll level);
	ll patties(ll level);
	ll ans(ll level, ll eat);

	std::cin >> make_level >> eat_layers;
	//入力終わり

	std::cout << ans(make_level, eat_layers) << '\n';

	return 0;
}

ll layers(ll level){
	if (level == 0)
		return 1;
	return layers(level - 1) * 2 + 3;
}

ll patties(ll level){
	if (level == 0)
		return 1;
	return patties(level - 1) * 2 + 1;
}

ll ans(ll level, ll eat){
	//終点
	if (level == 0){
		if (eat == 1)
			return 1;
		else
			return 0;
	}

	if (eat == 1){
		return 0;
	}
	else if (eat <= 1 + layers(level - 1)){
		return ans(level - 1, eat - 1);
	}
	else if (eat == 2 + layers(level - 1)){
		return patties(level - 1) + 1;
	}
	else if (eat <= 2 + layers(level - 1) * 2){
		return patties(level - 1) + 1 + ans(level - 1, eat - layers(level - 1) - 2);
	}
	else{
		return patties(level - 1) * 2 + 1;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{

  int tate,yoko;
  int s,l;

  scanf("%d %d",&tate,&yoko);

  s = tate * yoko;

  l = 2 * (tate + yoko);

  printf("%d %d\n",s,l);

  return 0;

}

  

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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n;
ll a[310][310];
int fl[310][310];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			scanf("%lld", &a[i][j]);
	for (int k = 0; k < n; ++k)
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j) {
				if (a[i][k] + a[k][j] < a[i][j]) {
					cout << -1 << "\n";
					return 0;
				}
				else if (k != i && k != j && a[i][k] + a[k][j] == a[i][j]) {
					fl[i][j] = 1;
				}
			}
	ll ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j)
			if (!fl[i][j])
				ans += a[i][j];
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 1280
// Author : Hardik Upadhyay
// college: SVNIT 
// slogan : Ab to phod dunga
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int MAXN = 100005;
ll mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int a[n];
	rep(i,0,n-1)cin>>a[i];
	int f = 0;
	rep(i,0,n-1){
		if(a[i]%2==0){
			if(a[i]%3 == 0 || a[i]%5==0) {
			
			}
			else{
				f = 1;
				break;
			}
		}
	}
	if(f){ cout<<"DENIED"<<nl;}
	else cout<<"APPROVED"<<nl;
	return 0;
}



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

int main() {
	char c;
	cin >> c;
	const string vowel = "aeiou";
	vowel.find(c) == string::npos ? cout << "consonant" << endl : cout << "vowel" << endl;
	}

Measured memory_bytes: 256
#include <iostream>

#define u unsigned
#define s short
#define ll long long
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, a, b) for (int i = (a-1); i >= (b); i--)

using namespace std;

bool hasSeven(string N);

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

    string N;

    cin >> N;

    cout << (hasSeven(N) ? "Yes" : "No") << "\n";

    return 0;
}

bool hasSeven(string N)
{
    REP(i, 0, 3)
        if (N[i] == '7')
            return true;

    return false;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
#define fi first
#define se second
#define maxn 200003
#define mod 1000000007
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;

string s;

int main() {
	cin >> s;
	int len = s.length();
	if(s[len-1] == 's')
		s += "es";
	else
		s += "s";
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>

using namespace std;


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

    int counter = 1;
    int breakblock = 0;
    for ( int i=0; i < n; ++i) {
        int b;
        cin >> b;
        if ( b == counter ) ++counter;
        else ++breakblock;
    }
    if ( breakblock == n ) breakblock = -1;
    cout << breakblock;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i =(b)-1;i>=(a);--i)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 10; 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	cin >> n >> s;
	int len = sz(s);
	rep(i,0,len){
		if(i < n)
			cout << s[i];
		else
			{cout << "...";break;} 
	}
	return 0;
}


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

int main(){
    int x[10];
    for (int i = 0; i < 5;i++)
    {
        cin >> x[i];
    }

    for (int i = 0; i < 5;i++)
    {
    if(x[i]==0)
    {
        cout << i + 1 << endl;
        break;
    }
    }
    return 0;
}

Measured memory_bytes: 3600
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] v = new int [n];
        for(int i = 0; i < n ; i++) {
        	v[i] = sc.nextInt();
        }
        solve(v);
	}

	private static void solve(int [] num) {
		Arrays.sort(num);
		double ans = num[0];
		for(int i = 1; i < num.length; i++) {
			ans = (ans + num[i]) / 2;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力(スペース改行関係なし)
		int n = sc.nextInt();
		int m = sc.nextInt();
        int syukudai = 0;
      	int asobi = 0;
      
      for(int i = 0; i < m ; i++){
      	syukudai += sc.nextInt();
      
      }
      asobi = n - syukudai;
		if(asobi < 0){
			// 出力
			System.out.println(-1);
		}else{
			System.out.println(asobi);
		}
		
	}
}

Measured memory_bytes: 46396
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++){cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	for(int i=0;i<n;i++)
	{
		if(a[i]!=b[n-1])
		cout<<b[n-1]<<endl;
		else
		cout<<b[n-2]<<endl;
	}
	return 0;
}

Measured memory_bytes: 4736
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}
func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}
func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}
func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}
func main() {
	sc.Split(bufio.ScanWords)
	n := scanInt()
	x := scanInt()
	y := scanInt()
	ans := make([]int, n-1)
	for i := 1; i < n+1; i++ {
		var k int
		for j := i + 1; j < n+1; j++ {
			k = min(j-i, abs(x-i)+abs(y-j)+1)
			ans[k-1] += 1
		}
	}
	for _, v := range ans {
		fmt.Println(v)
	}
}


Measured memory_bytes: 640
let n = Scanf.scanf "%d" (fun x -> x)
let xs = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x / 400)) |> Array.to_list
let () =
  let colors = xs |> List.filter ((>) 8) |> List.sort_uniq (-) |> List.length in
  let num_arb = xs |> List.filter ((<=) 8) |> List.length in
  let min_colors, max_colors = max 1 colors, (colors + num_arb) in
  Printf.printf "%d %d\n" min_colors max_colors



Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
  int n; cin >> n;
  double x;
  string u;
  double sum = 0;
  for(int i = 0;i < n;i++){
    cin >> x >> u;
    if(u == "JPY"){
      sum += x;
    }else{
      sum += x * 380000;
    }
  }
  cout << sum << endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define Komachi is retarded
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define bcnt __builtin_popcount
#define clz __builtin_clz
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define LB lower_bound
#define UB upper_bound
#define IN insert
#define lp (p<<1)
#define rp (p<<1|1)
#define lson l,mid,lp
#define rson mid+1,r,rp
#define LL long long
#define uLL unsigned long long
#define DB double 
#define INF 1000000000
#define EPS 1e-6
#define debug(a,p) cerr<<a<<p;
#define REP(i,a,b) for(int i=(a),i##_end_=(b);i<i##_end_;i++)
#define DREP(i,a,b) for(int i=(a),i##_end_=(b);i>i##_end_;i--)
 
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0;}
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0;}
 
#define M 500007

int n,A[M<<1],a,l=M,r=M-1;
int main(){
	scanf("%d",&n);
	REP(i,0,n){
		scanf("%d",&a);
		if(i&1)A[--l]=a;
		else A[++r]=a;
	}
	if(n&1)DREP(i,r,l-1)printf("%d ",A[i]);
	else REP(i,l,r+1)printf("%d ",A[i]);
	return 0;
}

Measured memory_bytes: 2944
import math

A, B, H, M = map(int, input().split())

thetaA = (math.pi * H / 6) + (math.pi * M / 360)
thetaB = (math.pi * M / 30)
Ax = A * math.cos(thetaA)
Ay = A * math.sin(thetaA)
Bx = B * math.cos(thetaB)
By = B * math.sin(thetaB)

X = Ax - Bx
Y = Ay - By

ans = (X ** 2 + Y ** 2) ** 0.5

print(ans)

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

int main() {
  ll n,a,b; cin>>n>>a>>b;
  if (a==0) cout<<0<<endl;
  else {
    ll k=a+b;
    ll res=(n/k)*a;
    if (n%k>a) res+=a;
    else res+=(n%k);
    cout<<res<<endl;
  }
}


Measured memory_bytes: 256
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1145141919
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=r;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=r;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    long long n,i,a[262144],sum=0,res=llinf,sum2=0;
    scanf("%lld",&n);
    for(i = 1;i <= n;i++){scanf("%lld",&a[i]);sum+=a[i];}
    for(i = 1;i < n;i++){
        sum2+=a[i];sum-=a[i];
        res=llmin(res,llmax(sum,sum2)-llmin(sum,sum2));
    }
   printf("%lld\n",res);
    return 0;
}

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


#define ll long long int 
#define all(v) v.begin(),v.end()
#define MOD 1000000007
#define PB push_back
#define F first
#define S second

ll cost(vector< ll >&v,ll n,ll index,vector< ll > &dp,ll k){
      
      
     if(index == n-1) return 0;

     if(dp[index]>-1) return dp[index];

     ll one=INT_MAX;
     for(ll i=1;i<=k;i++){
     	if(index+i<n){
     		one = + min(one,abs(v[index]-v[index+i])+cost(v,n,index+i,dp,k));
     	}else{
     		break;
     	}
     }
     dp[index] = one;
     return dp[index];

}

int main(){
	 
	 ll n,k; cin>>n>>k;

	 vector< ll > v(n); for(auto &i:v) cin>>i;

	 vector< ll > dp(n,-1);

	 ll ans = cost(v,n,0,dp,k);

	 cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 14044
arr=list(map(int,input()))
N=int(len(arr)//2)
count_ichi=0
count_zero=0

if len(arr)%2==0:
    zero=[0,1]*N
    ichi=[1,0]*N
else:
    zero=[0,1]*N+[0]
    ichi=[1,0]*N+[1]

for i in range(len(arr)):
    if zero[i]!=arr[i]:
        count_zero+=1
    if ichi[i]!=arr[i]:
        count_ichi+=1

print(min(count_zero,count_ichi))

Measured memory_bytes: 6160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> G(h);
  rep(i, h) {
    string s;
    cin >> s;
    G[i] = s;
  }
  int sum[h][w] = {};
  rep(i, h) {
    int befor = 0, cnt = 0;
    rep(j, w) {
      if (G[i][j] == '.') {
        cnt++;
      } else {
        for (int k = befor; k < befor + cnt; ++k) {
          sum[i][k] += cnt;
        }
        befor = j + 1;
        cnt = 0;
      }
    }
    for (int k = befor; k < befor + cnt; ++k) {
      sum[i][k] += cnt;
    }
  }
  rep(i, w) {
    int befor = 0, cnt = 0;
    rep(j, h) {
      if (G[j][i] == '.') {
        cnt++;
      } else {
        for (int k = befor; k < befor + cnt; ++k) {
          sum[k][i] += cnt;
        }
        befor = j + 1;
        cnt = 0;
      }
    }
    for (int k = befor; k < befor + cnt; ++k) {
      sum[k][i] += cnt;
    }
  }
  /* rep(i, h) {
    rep(j, w) cout << sum[i][j];
    cout << endl;
  } */
  int ans = 0;
  rep(i, h) rep(j, w) ans = max(ans, sum[i][j]);
  cout << ans - 1 << endl;
  return 0;
}


Measured memory_bytes: 19968
#include<iostream>
// #include<vector>
// #include<algorithm>
// #include <iterator>

using namespace std;
int main()
{
  int h, a;
  cin >> h >> a;

  int ans = h / a;
  if(h%a != 0) {
    ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <numeric>
#include <functional>
#include <climits>



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

int main(int argc, char *argv[]){
  int n;
  cin >> n;
  set<int> s;
  for (size_t i = 0; i < n; i++) {
    int k;
    cin >> k;
    s.insert(k);    
  }
  int m;
  cin >> m;
  int ret = 0;
  for (size_t i = 0; i < m; i++) {
    int k;
    cin >> k;
    if(s.find(k) != s.end()) ret++;
  }
  cout << ret << endl;


  
  return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    ll n, p; cin >> n >> p;
    map<ll, ll> map;
    for (ll i = 2; i * i <= p; ++i) {
        while (p % i == 0) {
            p /= i;
            ++map[i];
        }
    }
    if (p != 1)++map[p];

    ll ans = 1;
    for (auto i : map)if (n <= i.second)ans *= pow(i.first, i.second / n);
    cout << ans << "\n";
    /*
    int n, q; cin >> n >> q;
    VL x(n); cin >> x;

    while (q--) {
        ll c, d; cin >> c >> d;
    }
    */
}


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

int main(){
    int x; cin >> x;
    x = x%10;
    if(x == 3) puts("bon");
    else if(x== 0 || x == 1|| x == 6 || x == 8) puts("pon");
    else puts("hon");
    return  0;
}


Measured memory_bytes: 3624
def print2(s, a, b):
    print(s[a:b+1])
    return s

def reverse2(s, a, b):
    if a == 0:
        return s[b::-1] + s[b+1:]
    else:
        return s[:a] + s[b:a-1:-1] + s[b+1:]
   
def replace2(s, a, b, p):
    return s[:a] + p + s[b+1:]

s = input()
q = int(input())
for i in range(q):
    lst = input().split()
    a = int(lst[1])
    b = int(lst[2])
    if len(lst) == 4:
        p = lst[3]
        s = eval(lst[0] + "2(s, a, b , p)")
    else:
        s = eval(lst[0] + "2(s, a, b)")


Measured memory_bytes: 5616
using System;

public class hello
{
    public static void Main()
    {
        var count = 0;
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var s = line.Trim();
            if (KaibunChk(s)) count++;
        }
        Console.WriteLine(count);
    }
    public static bool KaibunChk(string s)
    {
            for (int i = 0; i<s.Length/2; i++)
                if(s[i] != s[s.Length - 1 - i])
                    return false;
            return true;
    }
}

Measured memory_bytes: 9068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll p=998244353ll;
const int N=200005;
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}

int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if((a^b)&1)printf("IMPOSSIBLE");
	else printf("%d",(a+b)>>1);
	return 0;
}

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

ans=0
for i in range(N-1):
    if A[i]+1==A[i+1]:
        ans+=C[A[i]-1]
        
ans+=sum(B)

print(ans)

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

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

lint mypow(int a, int n) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res = res * a;
		a *= a;
		n >>= 1;
	}
	return res;
}

vector<int> make753() {

	vector<int> vec753;
	int bit_used = 0, range = 9;
	int tmp, ternary, n753;

	for (int digit = 3; digit <= 9; digit++) {

		range *= 3;

		for (int i = 0; i <= range; i++) {

			bit_used = 0;
			ternary = i;
			n753 = 0;

			for (int j = 0; j < digit; j++) {

				tmp = ternary % 3;
				ternary /= 3;
				
				if (tmp == 0) {
					n753 += 3 * mypow(10,j);
					bit_used |= 1;
				}				
				if (tmp == 1) {
					n753 += 5 * mypow(10, j);
					bit_used |= 2;
				}
				if (tmp == 2) {
					n753 += 7 * mypow(10, j);
					bit_used |= 4;
				}

			}

			if (!(bit_used ^ 7)) vec753.push_back(n753);

		}

	}

	//sort(vec753.begin(), vec753.end());

	return vec753;

}

int main() {

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

	int N;
	cin >> N;

	vector<int> vec = make753();
	int ans = upper_bound(vec.begin(), vec.end(), N) - vec.begin();

	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 512