akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
const int maxn = 5e3 + 5;
const int mod = 1e9 + 7;
const int logn = log2(maxn) + 1;

int f[maxn][maxn];
int Pow(int x , int y){
    if(y == 0)return 1;
    int r = Pow(x , y / 2);
    if(y & 1)return (ll)r * r  % mod * x % mod;
    return (ll)r * r % mod;
}
int n , m;
string s;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(taskname".inp", "r")) {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
    cin >> n >> s;
    m = s.size();
    f[0][0] = 1;
    for(int i = 1 ; i <= n ; ++i){
        for(int j = 0 ; j <= n ; ++j){
            if(j > 0)f[i][j] = f[i - 1][j - 1] * 2;
            else f[i][j] = f[i - 1][j];
            if(f[i][j] >= mod)f[i][j] -= mod;
            f[i][j] += f[i - 1][j + 1];
            if(f[i][j] >= mod)f[i][j] -= mod;
        }
    }
    cout << 1ll * f[n][m] * Pow(Pow(2,m),mod-2) % mod;
}


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

using namespace std;

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  double min_diff = 100000;
  int palace;

  for ( int i = 0; i < N; i++ ) {
    int H;
    cin >> H;
    double diff = abs( T - H * 0.006 - A );
    if ( min_diff > diff ) {
      min_diff = diff;
      palace = i + 1;
    }
  }
  cout << palace << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};


int main(void){
	int N,M,result;
	double base,mad=0.0;

	cin>>N>>M;
	base=1/pow(2,M);
	FOR(i,1,500000){
		mad+=(i*base*pow(1-base,i-1));
	}
	result=(int)(mad+0.5);

	print(M*result*1900+(N-M)*result*100);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

int main(){
	int N, count=0;
	cin>>N;
	int d1[N], d2[N];
	for(int i=1; i<=N; i++) cin>>d1[i]>>d2[i];
	for(int i=1; i<=N; i++){
		if(d1[i]==d2[i]){
			count++;
			if(count==3) break;
		}
		else count=0;
	}
	if(count==3) cout<<"Yes";
	else cout<<"No";
	
	return 0;
}

Measured memory_bytes: 3632
h,w=map(int,input().split())
l=list(map(list,[input() for i in range(h)]))
for i in range(h):
    for j in range(w):
        if l[i][j]=="#":
            continue
        num=0

        if i!=0 and j!=0 and l[i-1][j-1]=="#":
            num+=1
        if i!=0 and l[i-1][j]=="#":
            num+=1
        if i!=0 and j!=w-1 and l[i-1][j+1]=="#":
            num+=1
        if j!=0 and l[i][j-1]=="#":
            num+=1
        if j!=w-1 and l[i][j+1]=="#":
            num+=1
        if i!=h-1 and j!=0 and l[i+1][j-1]=="#":
            num+=1
        if i!=h-1 and l[i+1][j]=="#":
            num+=1
        if i!=h-1 and j!=w-1 and l[i+1][j+1]=="#":
            num+=1

        l[i][j]=str(num)
    print("".join(l[i]))


Measured memory_bytes: 3188
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    ll temp=n/11;
    n=n-temp*11;
    if(n==0){
        cout << temp*2 << "\n";
    }
    else if(n<=6){
        cout << temp*2+1 << "\n";
    }
    else{
        cout << temp*2+2 << "\n";
    }
}


Measured memory_bytes: 256
N,K = map(int,input().split())
P = list(map(int,input().split()))
memo = {}

exp = [0]
for p in P:
  exp.append(exp[-1]+(1+p)/2)

res = 0
for i in range(K,N+1):
  res = max(res, exp[i]-exp[i-K])

print(res)

Measured memory_bytes: 76040
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int d[1000];
int main()
{
	string s;
	cin >> s;
	vector<char>v;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'B')
		{
			if (!v.empty())v.pop_back();
		}
		else v.push_back(s[i]);
	}
	for (int i = 0; i < v.size(); i++)cout << v[i]; cout << endl;
}

Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

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


int main(int argc, char const* argv[])
{
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(a, min(b, c)) * (a + b + c - min(a, min(b, c)) - max(a, max(b, c))) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline #文字列入力はするな！！
sys.setrecursionlimit(10**9) #再帰の上限をあげる
n=int(input())
a=list(map(int,input().split()))
z=[0]*(10**6+1)
ans=0
for i in a:
    z[i]+=1

x=[-1]*(10**6+1) #2以上の自然数に対して最小の素因数を表す
x[0]=0
x[1]=1
i=2
prime=[]
while i<=10**6:
    if x[i]==-1:
        x[i]=i
        prime.append(i)
    for j in prime:
        if i*j>10**6 or j>x[i]:break
        x[j*i]=j
    i+=1

for i in a:
    f=0
    u=i
    if z[u]>=2:
        f=1
    w=[[1,0]]
    p=x[u]
    cnt=1
    while u>1:
        if p==x[u//p]:
            cnt+=1
            u=u//p
        else:
            w.append([p,cnt])
            cnt=1
            u=u//p
            p=x[u]

    m=len(w)

    def s(d,y):
        global m
        global i
        global f
        if d==m-1:
            p=y
            if p!=i and z[p]>=1:
                f=1
        else:
            for j in range(w[d+1][1]+1):
                s(d+1,y*(w[d+1][0]**j))

    s(0,1)
    if f==0:
        ans+=1
print(ans)


Measured memory_bytes: 122472
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << "\n"
typedef long long ll;

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

  int n = 7 % k;
  ll ans = -1;
  for (int i = 1; i <= 10e6; i++)
  {
    if (n == 0)
    {
      ans = i;
      break;
    }
    n = (n * 10 + 7) % k;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){ 
  Int K, N;
  cin >> K >> N;
  
  vector<Int> A(N);
  rep(i,N) cin >> A[i];
  
  Int l = A[0] + K - A[N-1];
  
  rep(i,N-1) {
    if (A[i+1]-A[i] > l) l = A[i+1]-A[i];
  }
  
  cout << K - l << endl;

}

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"strconv"
)

func main() {
	n := make([]int, 2)
	for i := 0; i < 2; i++ {
		fmt.Scan(&n[i])
	}
	strA := strconv.Itoa(n[0])
	strB := strconv.Itoa(n[1])
	if n[0] > n[1] {
		createAnswer(strB, n[0])
	} else if n[0] == n[1] {
		createAnswer(strB, n[0])

	} else {
		createAnswer(strA, n[1])
	}
}

func createAnswer(word string, count int) {
	var answer string

	for i := 0; i < count; i++ {
		answer += word
	}
	fmt.Println(answer)
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
 
int main()
{
  
    int n,Y,x,y,z;
    cin>>n>>Y;
    for(x=0;x<=Y/10000;x++)
        for(y=0;y<=Y/5000;y++)
        {
            z=n-x-y;
            if(z>=0 && x*10000+y*5000+z*1000==Y)
            {
                cout<<x<<' '<<y<<' '<<z<<endl;
                return 0;
            }
        }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

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

int main(){
  int n;
  int d,a;
  cin>>n>>d>>a;
  vector<pair<int,int>> vec(n);
  vector<ll> s(n+1,0);
  for(int i=0;i<n;i++){
    ll x,h;
    cin>>x>>h;
    h=(h+a-1)/a;
    vec[i]=make_pair(x,h);
  }
  sort(vec.begin(),vec.end());
  ll ans=0;
  for(int i=0;i<n;i++){
    if(vec[i].second-s[i]<=0){
      s[i+1]+=s[i];
      continue;
    }
    int now=vec[i].first+d;
    int edge=now+d;
    int x;
    if(edge>=vec[n-1].first){
      x=n-1;
    }
    else{
      int ok=-1,ng=n-1;
      while(ng-ok!=1){
        int check=(ok+ng)/2;
        if(vec[check].first<=edge){
          ok=check;
        }
        else{
          ng=check;
        }
      }
      x=ok;
    }
    int y=vec[i].second-s[i];
    ans+=y;
    s[i]+=y;
    s[x+1]-=y;
    s[i+1]+=s[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6288
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

bool calc(const vector<string> &words) {
	const int n = words.size();
	bool mat[26][26] = {};

	for(int i = 0; i < n - 1; ++i) {
		for(int j = i + 1; j < n; ++j) {
			if(words[i] != words[j] && words[i].find(words[j]) == 0)
				return false;

			const int l = min(words[i].size(), words[j].size());
			for(int k = 0; k < l; ++k) {
				if(words[i][k] != words[j][k]) {
					mat[words[i][k] - 'a'][words[j][k] - 'a'] = true;
					break;
				}
			}
		}
	}

	int in[26] = {};
	for(int i = 0; i < 26; ++i) {
		for(int j = 0; j < 26; ++j) {
			if(mat[i][j]) ++in[j];
		}
	}

	queue<int> que;
	for(int i = 0; i < 26; ++i) if(in[i] == 0) que.push(i);

	int cnt = 0;
	while(!que.empty()) {
		const int v = que.front();
		que.pop();
		++cnt;

		for(int i = 0; i < 26; ++i) {
			if(mat[v][i] && --in[i] == 0)
				que.push(i);
		}
	}

	return cnt == 26;
}

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

	for(int n; cin >> n && n;) {
		vector<string> words(n);
		for(auto &word : words) {
			cin >> word;
		}

		cout << (calc(words) ? "yes" : "no") << endl;
	}

	return EXIT_SUCCESS;
}

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

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
ll INF=1e18+10;

int main()
{
    int n,a,b;
    cin>>n>>b>>a;
    if(n*b<a)
        cout<<n*b;
    else
        cout<<a;
}


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

const ll INF = 1001001001;

int main(){
  int a,b;
  cin>>a>>b;
  int ans =min(a,b);
  int n=max(a,b);
  rep(i,n){
    cout<<ans;
  }
}

Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<double>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<vector<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll x, y, z, k;
	cin >> x >> y >> z >> k;
	Vec a(x), b(y), c(z);
	rep(i, x) cin >> a[i];
	rep(i, y) cin >> b[i];
	rep(i, z) cin >> c[i];
	sort(all(a));
	sort(all(b));
	sort(all(c));
	reverse(all(a));
	reverse(all(b));
	reverse(all(c));

	priority_queue<P> que;
	que.push({a[0]+b[0]+c[0], 0});
	unordered_set<ll> ust;
	ll i = 0;
	while(i < k){
		P p = que.top(); que.pop();
		if(ust.find(p.sc) == ust.end()){
			i++;
			co(p.fs);
			ust.insert(p.sc);
			ll u, v, w;
			w = p.sc%z;
			p.sc /= z;
			v = p.sc%y;
			p.sc /= y;
			u = p.sc;
			if(u+1 < x) que.push({a[u+1]+b[v]+c[w], ((u+1)*x+v)*y+w});
			if(v+1 < y) que.push({a[u]+b[v+1]+c[w], (u*x+v+1)*y+w});
			if(w+1 < z) que.push({a[u]+b[v]+c[w+1], (u*x+v)*y+w+1});
		}
	}

	return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

inline int64 modPow(int64 x, int64 n) {
  if(n == 0) return (1);
  int64 ret = modPow(x, n / 2);
  (ret *= ret) %= mod;
  if(n & 1) (ret *= x) %= mod;
  return (ret);
}

inline int64 modInv(int64 a) {
  return (modPow(a, mod - 2));
}

inline int64 modCombination(int p, int q) {
  static int64 fact[202020], rfact[202020];
  if(fact[0] == 0) {
    fact[0] = rfact[0] = 1;
    for(int i = 1; i < 102020; i++) {
      fact[i] = fact[i - 1] * i % mod;
      rfact[i] = modInv(fact[i]);
    }
  }
  if(q < 0 || p < q) return (0);
  return (fact[p] * rfact[q] % mod * rfact[p - q] % mod);
}

inline int64 count2_2(int n, int k) {
  return (modCombination(k, n));
}

int main() {
  int N, K;
  cin >> N >> K;
  cout << count2_2(N, K) << endl;
}






Measured memory_bytes: 4800
#include <stdio.h>

int main() {
	int A,B,C,K,i;
	scanf("%d %d %d %d", &A, &B, &C, &K);
		if (K <= A + B) {
			if (K >= A) {
				printf("%d", A);
			}
			else {
				printf("%d", K);
			}
		}
		else{
			printf("%d", A - (K - A - B));
		}
	return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;

int main()
{
    ll x,y;
    cin>>x>>y;
    if(x%y==0)
    {
        printf("-1\n");
    }
    else
    {
        if(y!=2)
            printf("%lld\n",x*(y-1));
        else
            printf("%lld\n",x*3);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな　オーバーフローする
//開区間と閉区間どうにかしろ
//アルファベットが何番目かは x=s[i]-'a'
const ll MOD = 1000000007;
const int INF = 1001001001;
int main(){
    string x,y; cin >> x >> y;
    int lx=x.size();
    int ly=y.size();
    int dp[ly][lx];
    bool b1=0,b2=0;
    if(x[0]!=y[0]) dp[0][0]=1;
    else{
        dp[0][0]=0;
        b1=b2=1;
    }
    rep(i,ly-1){
        if(y[i+1]!=x[0]||b1) dp[i+1][0]=dp[i][0]+1;
        else{
            dp[i+1][0]=dp[i][0];
            b1=1;
        }
    }
    rep(i,lx-1){
        if(y[0]!=x[i+1]||b2) dp[0][i+1]=dp[0][i]+1;
        else{
            dp[0][i+1]=dp[0][i];
            b2=1;
        }
    }
    for(int i=1;i<ly;i++){
        for(int j=1;j<lx;j++){
            int c=0;
            if(y[i]!=x[j])c++;
            dp[i][j]=min(dp[i-1][j]+1,min(dp[i][j-1]+1,dp[i-1][j-1]+c));
        }
    }
    cout << dp[ly-1][lx-1] << endl;
    return 0;
}



Measured memory_bytes: 7072
use std::str::FromStr;
use std::io::*;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = AtRead::from(i);
    let (a, b, c) = i.read3::<usize, usize, usize>();
    writeln!(o, "{}", solve([a, b, c])).unwrap();
}
fn solve(mut abc: [usize; 3]) -> usize {
    let mut r = 0;
    let m = *abc.iter().max().unwrap();
    let mut mc = 0;
    for i in 0..3 {
        let d = m - abc[i];
        let ri = d / 2;
        r += ri;
        abc[i] += ri * 2;
        if abc[i] == m {
            mc += 1;
        }
    }
    if mc == 3 {
        mc = 0;
    }
    r + mc
}

mod utils {
    use super::*;

    pub struct AtRead<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        {$f:ident($($v:ident: $t:ident),*)} => {
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                $(
                    let $v = next(i);
                )*
                ($($v),*)
            }
        };
    }

    impl<R: BufRead> AtRead<R> {
        pub fn from(r: R) -> Self {
            AtRead {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read3(v1: T1, v2: T2, v3: T3) }
    }

    fn next<'a, T: FromStr, I: std::iter::Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void)
{
   int n,m,i,q,tyu;
   int a[100][100];
   int b[100], c[100];
   
   scanf("%d", &n);   scanf("%d", &m);
   
   for(i=0; i<n; i++){
      for(q=0; q<m; q++){
         scanf("%d", &a[i][q]);}}
         
   for(q=0; q<m; q++){
      scanf("%d", &b[q]);}
      
   for(i=0; i<n; i++){
      tyu = 0;
      for(q=0; q<m; q++){
         tyu += a[i][q] * b[q];}
         c[i] = tyu;}
         
   for(i=0; i<n; i++){
      printf("%d\n", c[i]);}
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll N = 2300000 + 10, inf = 1e18 + 10, mod = 1e9 + 7;
ll d[30][N], a[30][30];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("prices.in", "r", stdin);
    //freopen("prices.out", "w", stdout);
    ll n, k;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            cin >> a[i][j];
        }
    }
    d[0][0] = 1;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= (1 << n); j++)
        {
            if(__builtin_popcount(j) == i)
            {
                for(int k = 0; k <= n; k++)
                {
                    if(((1 << k) & j) && a[i][n - k])
                    {
                        d[i][j] += d[i - 1][j - (1 << k)];
                        d[i][j] %= mod;
                    }
                }
            }
        }
    }
    cout << d[n][(1 << n) - 1];
}


Measured memory_bytes: 332032
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" "<<x<<"\n";
#define lli long long int
int main()
{
   lli a,x;
   long double b,ans;
    cin>>a>>b;
  ans=floor(a*b);
  x=ans;
    cout<<x<<endl;;
    return 0;
}


Measured memory_bytes: 3704
def gcd(a,b):
    if a*b<0:
        return -a*b
    while b!=0:
        tmp=a%b
        a=b
        b=tmp
    return a

# def gcd_list(numbers):
#     # print(numbers)
#     g=numbers[0]
#     for i in range(n-1):
#         g=gcd(g,numbers[i])
#     return g
#
# n=int(input())
# a=list(map(int,input().split()))
# gcd_without_i=[gcd_list(a[:i]+a[i+1:]) for i in range(n)]
# # print(gcd_without_i)
# print(max(gcd_without_i))

n=int(input())
a=list(map(int,input().split()))
# gcd_lhs[i]=gcd(a[0],...,a[i-1])
gcd_lhs=[-1 for _ in range(n)]
# gcd_rhs[i]=gcd(a[i+1],...,a[n-1])
gcd_rhs=[-1 for _ in range(n)]
gcd_lhs[1]=a[0]
gcd_rhs[n-2]=a[n-1]
for i in range(1,n):
    gcd_lhs[i]=gcd(gcd_lhs[i-1],a[i-1])
    gcd_rhs[n-1-i]=gcd(gcd_rhs[n-i],a[n-i])

gcd_without_i=[gcd(gcd_lhs[i],gcd_rhs[i]) for i in range(n)]
print(max(gcd_without_i))


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

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if ((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d)
        cout<<"Yes";
    else  cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22){
        cout<<"bust"<<endl;
    }
    else{
        cout<<"win"<<endl;
    }
}


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


int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    cin >> s.at(i) >> p.at(i);
  }
  string minStr;
  int minIndex = 0;
  int minScore = 0;
  for(int i = 0; i < n; i++){
    minStr = "zzzzzzzzzzzzz";
    for(int j = 0; j < n; j++){
      if(minStr > s.at(j) || (minStr == s.at(j) && minScore < p.at(j))){
        minStr = s.at(j);
        minIndex = j;
        minScore = p.at(j);
      }
    }
    cout << minIndex+1 << endl;
    s.at(minIndex) = "zzzzzzzzzzzzz";
  }
  return 0;
}


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

int main(void) {
	string s;
  cin>>s;
  int h[26],i;
  for(i=0;i<26;++i)
       h[i]=0;
  
  for(i=0;i<s.length();++i)
       h[s[i]-97]++;
  
  
  int flag=0;
  for(i=0;i<26;++i)
  {
    if(h[i]==0)
    { flag=1;
      break;
    }
  }
  
  if(flag==1)
      printf("%c",i+97);
  
  else
     printf("None");
     
      
	return 0;
}

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

int main() {
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];

    set<int> values;
    for (int i = 0; i < N; ++i) {
        values.insert(d[i]);
    }
    cout << values.size() << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
typedef long long ll;
using namespace std;
ll intpow(int n,int m){
    if(m==0)return 1;
    return n*intpow(n,m-1);
}
ll gcd(ll n,ll m){
    n = max(n,m);
    m = min(n,m);
    if(n%m == 0)return m;
    return gcd(m,n%m);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int count(vector<int>h,int left,int right){//[left,right)
    if(left == right)return 0;
  
    auto litr = next(h.begin(),left);
    auto ritr = next(h.begin(),right);
    auto mitr = min_element(litr,ritr);
    int a=*mitr;
    for(int i=left;i<right;i++)h[i] -= a;
    return a + count(h,left,distance(h.begin(),mitr)) + count(h,distance(h.begin(),mitr)+1,right);
}
int main(){
    int n;
  cin >> n;
  vector<int>h;
  h.resize(n);
  for(int i=0;i<n;i++)cin >> h[i];
  cout <<count(h,0,n) <<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int x,y,b,p,s,t,u,ans;
  for(int i=0; i<n; i++){
    cin >> x >> y >> b >> p;
  //int x[100],y[100],b[100],p[100];
  //for(int i=0; i<n; i++) cin >> x[i] >> y[i] >> b[i] >> p[i];
    ans = x * b + y * p;
    for(int j=b; j<=6; j++){
	for(int k=p; k<=6; k++){
	  if(j>=5 && k>=2){
	  //x = x-((double)x*0.2);
	  //y = y-((double)y*0.2);
	  t = x * j + y * k;
	  t = t-(t*0.2);
	  ans = min(ans,t);
	  }
	}
    }
    cout << ans << endl;
  }
  return 0;
}
  


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
ll a[200003];
ll b[2003];
bool vis[1009][1009];
struct threeElements{
int f,s,t;
};
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   int x;
   cin>>x;
   printf("%.20f",x*6.28318530717958623200);
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
  int a[2], k;
  cin >> a[0] >> a[1] >> k;

  rep(i, 0, k){
    if(a[i%2] == 1){
      a[i%2]--;
    }
    a[(i+1)%2] += a[i%2]/2;
    a[i%2] /= 2;
  }

  cout << a[0] << " " << a[1] << endl;

  return 0;
}


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

using namespace std;

int main(){
  int N,A;
  cin >> N;
  cin >> A;

  int div = N % 500;

  if (div <= A){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }

  return 0;
}



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

int main() {
    long long int n,a[5],ans;cin>>n;
    
    
    for(int i=0;i<5;++i){
        cin>>a[i];
    }
    sort(a,a+5);
    if(n<=a[0])ans=5;
    else if(n%a[0]==0)ans = n/a[0] + 4;
    else ans = n/a[0] + 5;

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

Measured memory_bytes: 256
s = input()
K = int(input())

L = []
for i in range(len(s)):
    L.append(s[i])
    
L.sort()
cnt = 0
for i in range(len(L)):
    if L[i] == L[0]:
        cnt += 1

word_list = []
idx = 0
if len(s) >= 20:
    if cnt <= 5:
        while idx < len(s):
            if s[idx] == L[0] or s[idx] == L[cnt]:
                for j in range(1, K+1):
                    word_list.append(s[idx:idx+j])
            idx += 1
    else:
        while idx < len(s):
            if s[idx] == L[0]:
                for j in range(1, K+1):
                    word_list.append(s[idx:idx+j])
            idx += 1
else:
    for i in range(len(s)):
        for j in range(i+1, len(s)+1):
            word_list.append(s[i:j])
    
word_set = set(word_list)
word_list = list(word_set)
word_list.sort()
print(word_list[K-1])

Measured memory_bytes: 42352
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))

(defun binary-search (l r f)
  (if (eq l r)
	l
	(let ((m (ash (+ l r) -1)))
	  (if (funcall f m)
		(binary-search (1+ m) r f)
		(binary-search l m f)))))

(let ((n (read)))
  (princ (expt (1- (binary-search 1 (1+ n) (lambda (x) (<= (* x x) n)))) 2)))


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

using namespace std;

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

using llong = long long;
using ld = long double;
using ii = pair<int, int>;
using ull = unsigned long long;
using pll = pair<llong, llong>;
using vi = vector<int>;


#define endl "\n"
#define fi first
#define se second
#define left LEVO
#define right PRAVO
#define time CHAS
#define all(a) (a).begin(), (a).end()
#define prev PAPEREDNIKXD
#define next NASTUPNIKXD
#define pb push_back
#define deb cout<<"CHECK\n";
#define last(a) (a)[(a).size()-1]

#define elif else if
#define cclear cout<<flush;
#define fclear fflush(stdout);
#define x_files freopen("exam.in","r",stdin);freopen("exam.out","w",stdout);
#define kchay ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
const llong over999 = 1e14;
const ld eps = 1e-9;
const int base = 1000*1000;
const ld Pi = acos(-1);
const llong md = 1e9+7;
const llong ya = 0;

/*.st*/

llong n, x, cnt, ff;
int main() {
    kchay;   
    //x_files;
    
    cin >> n;
    
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        if(x && x%4==0)cnt++; 
            elif(x && x%2==0)ff++;
    }
    ff -= ff&1;
    if(cnt >= (n-ff)/2)cout << "Yes"; else cout << "No";
    cout << endl;
    return 0;
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

n = inputI()
a = inputIL()

count = 0
for i in range(1,n-1):
  if a[i-1]<a[i]<a[i+1] or a[i-1]>a[i]>a[i+1]:
    count += 1
print(count)

Measured memory_bytes: 72736
import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))
  val MAX = 100001

  val(n, k) = br.readLine().split(" ").map { it.toLong() }

  val table = LongArray(MAX+1)
  (0L until n).forEach {
    val(a, b) = br.readLine().split(" ").map { it.toInt() }
    table[a] += b.toLong()
  }

  tailrec fun rec(acc: Long, i: Int, t: Long): Int {
    val v = acc + table[i]
    if(v >= t) return i
    return rec(v, i+1, t)
  }

  val ans = rec(0L, 0, k)
  println(ans)
}

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

bool compare(vector<ll> a, vector<ll> b){
	if(a[0]<b[0]) return true;
	if(a[0]==b[0]){
		if(a[1]<b[1]) return true;
		return false;
	}
	return false;
}

void solve(){
	
}

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

#ifndef ONLINE_JUDGE
	//for getting input from input1.txt
	freopen("input1.txt", "r", stdin);
	//for getting output from output1.txt
	freopen("output1.txt", "w", stdout);
#endif

	ll n,a,b,i,j,count=0,temp;
	cin>>n>>a>>b;
	temp = max(a,b);
	a = min(a,b); b = temp;
	if((b-a)%2==0){ cout<<(b-a)/2; return 0; }
	cout<<min(n-b+1,a)+(b-a)/2;


}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
const ll INF = (ll)1e18 + 1;

int main()
{
  int N;
  std::cin >> N;

  ll min_num = INF;
  ll sum = 0;
  for (ll i = 0; i < N; i++) {
    ll a, b;
    std::cin >> a >> b;
    sum += a;
    if (a > b) min_num = std::min(min_num, b);
  }

  ll ans;
  if (min_num == INF) {
    ans = 0;
  } else {
    ans = sum - min_num;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N;
    cin >> N;
    long long ans = 0;
    rep(i,N) {
        int a;
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            ans++;
        }
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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 long long ll;
typedef pair<int,int> P;

vector<int> to[100005];

int main(){
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int>dist(n,-1);
    queue<int> q;
    vector<int> parent(n);
    dist[0]=0;
    q.push(0);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int u:to[v]){
            if(dist[u]!=-1)continue;
            dist[u]=dist[v]+1;
            parent[u]=v;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    rep(i,n){
        if(i==0)continue;
        cout << parent[i] + 1 << endl;
    }
}

Measured memory_bytes: 10548
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    cout << MAX(a)-MIN(a) << endl;
}

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

import sys
import os

for s in sys.stdin:
    a, b = list(map(int, s.split()))
    c = a + b

    if c == 1:
        print(1)
        continue

    for i in range(7):
        left = 10 ** i
        right = 10 ** (i + 1)
        if left <= c < right:
            print(i + 1)
            break

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

int main()
{
    int N;
    int W;
    cin >> N >> W;
    long int w[N];
    long int v[N];
    long int sum_v = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> w[i] >> v[i];
        sum_v += v[i];
    }
    long int dp[N + 1][sum_v + 1];

    dp[0][0] = 0;
    for (int j = 1; j < sum_v + 1; j++)
    {
        dp[0][j] = 1000000000;
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < sum_v + 1; j++)
        {
            if (j < v[i])
            {
                dp[i + 1][j] = dp[i][j];
            }
            else
            {
                long int dp1 = dp[i][j];
                long int dp2 = dp[i][j - v[i]] + w[i];
                dp[i + 1][j] = min(dp1, dp2);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < sum_v + 1; i++)
    {
        if (dp[N][i] <= W)
        {
            ans = i;
        }
    }
    cout << ans;
}

Measured memory_bytes: 79104
import sys
sys.setrecursionlimit(10**7)

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

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return
    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
  def size(self, x):
    return -self.parents[self.find(x)]
  def same(self, x, y):
    return self.find(x) == self.find(y)
  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]
  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]
  def group_count(self):
    return len(self.roots())
  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}
  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


uf=UnionFind(N)
for _ in range(Q):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  uf.union(a,b)
from collections import Counter
a=[-1]*N
for i in range(N):
  a[i]=uf.find(i)
ca=Counter(a)
ans=0
for c in ca.values():
  ans=max(ans,c)
print(ans)


Measured memory_bytes: 110924
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main{

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		int n;
		int[] arr = new int[5001];
		
		while ((line = br.readLine()) != null) {
			if (line.equals("0"))
				break;
			
			n = Integer.parseInt(line);
			int sum = 0;
			int a;
			arr[0] = 0;
			for (int i = 1; i <= n; i++) {
				a = Integer.parseInt(br.readLine());
				sum += a;
				arr[i] = sum;
			}
			
//			System.out.println(Arrays.toString(arr));
			
			int ans = -999999999;
			for (int i = 1; i <= n; i++) {
				for (int j = i; j <= n; j++) {
					if (ans < arr[j] - arr[i - 1])
						ans = arr[j] - arr[i - 1];
				}
			}
			
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 27408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll N, M;
  cin >> N >> M;

  vector<ll> V(N);
  for (ll i = 0; i < M; i++)
  {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    V.at(a)++, V.at(b)++;
  }
  
  for (ll i = 0; i < N; i++)
  {
    if (V.at(i) % 2 == 1)
      FINALANS("NO");
  }
  FINALANS("YES");
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    
    if(c - (a+b) <= 0) {
        out("No");
        re0;
    }

    if(4*a*b < (c - (a+b))*(c - (a+b))) {
        out("Yes");
    }
    else {
        out("No");
    }

    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
  
int main(){
  int a,b;
  cin >> a >> b;
  string s;
  int target, sq_int;
  double q, sq;
  s = to_string(a) + to_string(b);
  target = stoi(s);
  q = target;
  sq = std::sqrt(q);
  sq_int = sq;
  
  if(std::pow(sq_int, 2) == target){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())

cntA = Counter(map(int, input().split()))
cntB = Counter(map(int, input().split()))
cntC = Counter(map(int, input().split()))

keyA = sorted(list(cntA.keys()))
keyB = sorted(list(cntB.keys()))
keyC = sorted(list(cntC.keys()))

lenA = len(keyA)
lenC = len(keyC)
iA = 0
iC = 0
numA = 0
numC = N
ans = 0
for kB in keyB:
    for i in range(iA, lenA):
        if keyA[i] >= kB:
            iA = i
            break
        numA += cntA[keyA[i]]
    else:
        iA = lenA

    for i in range(iC, lenC):
        if keyC[i] > kB:
            iC = i
            break
        numC -= cntC[keyC[i]]
    else:
        iC = lenC

    ans += numA * numC * cntB[kB]

print(ans)


Measured memory_bytes: 45004
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
using namespace std;

typedef unsigned long long ll;
#define max 1000000000000000000

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

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

int main(){
  int N;
  ll T[100]={0}, max_T = 0;

  cin >> N;

  for(int i= 0; i < N; i++){
    scanf("%lld", &T[i]);
    if(T[i] > max_T)
      max_T = T[i];
  }
  ll box = T[0];
  for(int i = 1; i < N; i++){
    if(box > T[i])
      box = lcm(box, T[i]);
    else
      box = lcm(T[i], box);
  }

  cout << box << endl;

  return 0;
}



Measured memory_bytes: 256