akhauriyash/Code-Regression huggingface dataset:
(* O(n) *)
let rec fold_btw f a i n = if i >= n then a else fold_btw f (f a i) (i + 1) n
let fold_int f a n = fold_btw f a 0 n

let is_acgt_char = function
| 'A' | 'C' | 'G' | 'T' -> true
| _ -> false

(* O(|s|) *)
let solve s =
  let s = s ^ "_" in
  fold_int
    (fun (acc_max, (acc, prev)) i ->
      if is_acgt_char s.[i] then
        acc_max, (acc + 1, true)
      else
        if prev then
          max acc_max acc, (0, false)
        else
          acc_max, (acc, false))
    (0, (0, false))
    (String.length s) |> fst

let _ = read_line () |> solve |> string_of_int |> print_endline

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void MAIN() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> w(n), e(n);
  for (int i = 0; i < n - 1; i++) {
    e[i] = (s[i] == 'E');
    if (i) e[i] += e[i - 1];
  }
  for (int i = n - 1; i > 0; i--) {
    w[i] = (s[i] == 'W');
    if (i != n - 1) w[i] += w[i + 1];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int t = 0;
    if (i) t += e[i - 1];
    if (i != n - 1) t += w[i + 1];
    ans = max(ans, t);
  }
  cout << (n - 1) - ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 8228
#include<bits/stdc++.h> 
using namespace std; 
#define x first
#define y second
#define forn(i, n) for(int i = 0; i < int(n); ++i)
typedef pair<int, int> pii;

int mat[20][20];
int cost[20];
int N,M,X;
int mon = 1000000000;
void solve(){
	int u = (1<<N);
	forn(j,u){
		vector<int> bina(N,0);
		int c =j;
		int y =0;
		while(c){
			bina[y] = (c%2);
			c/=2;
			y++;
		}
		vector<int> skill(M,0);
		int cos = 0;
		forn(i,N){
			if(bina[i]){
				cos+=cost[i];
				forn(ii,M){
					skill[ii]+=mat[i][ii];
				}
			}
		}
		int found = 1;
		forn(i,M){
			if(skill[i]<X){
				found =0;
				break;
			}
		}
		if(found){
			mon = min(mon,cos);
		}
		
	}
}
int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin>>N>>M>>X;
	forn(i,N){
		cin>>cost[i];
		forn(j,M){
			cin>>mat[i][j];
		}
	}
	solve();
	if(mon ==1000000000){
		cout<<-1<<endl;
	}
	else{
		cout<<mon<<endl;
	}
	return 0;	
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define cal(a,b) ((a+=b)%=mo)
using namespace std;
const int N=4050,mo=1e9+7,P=2001;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int fap(int a,int b){
    int s=1;
    while(b){
	if (b&1) s=1ll*s*a%mo;
	b>>=1,a=1ll*a*a%mo;
    }
    return s;
}
int a[200050],b[200050],f[N][N],ml[N*10],np[N*10];
int c(int n,int m){
    return 1ll*ml[n]*np[n-m]%mo*np[m]%mo;
}
int main(){
    int n=gi();
    for (int i=1; i<=n; ++i){
	a[i]=gi(),b[i]=gi();
	++f[P-a[i]][P-b[i]];
    }
    ml[0]=np[0]=1;
    for (int i=1; i<=8000; ++i)
	ml[i]=1ll*i*ml[i-1]%mo,np[i]=1ll*fap(i,mo-2)*np[i-1]%mo;
    for (int i=1; i<N; ++i)
	for (int j=1; j<N; ++j)
	    cal(f[i][j],f[i-1][j]+f[i][j-1]);
    int ans=0;
    for (int i=1; i<=n; ++i){
	cal(ans,f[P+a[i]][P+b[i]]);
	cal(ans,mo-c((a[i]+b[i])*2,a[i]*2));
    }
    cout<<1ll*ans*fap(2,mo-2)%mo;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    set<string> S;
    for(int i = 0; i < N; i++) {
        string c;
        cin >> c;
        S.insert(c);
    }
    cout << S.size() << endl;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  int a[2000];
  int b[2000];
  fill(b,b+2000,0);
  for(int i=0; i<N; i++) cin >> a[i];
  for(int i=0; i<M; i++){
    int in;
    cin >> in;
    for(int j=0; j<N; j++){
      if(a[j] <= in) {b[j]++; break;}
    }
  }

  int ansA,ansB;
  ansA = ansB = 0;
  for(int i=0; i<N; i++){
    if(ansA < b[i]){
      ansA = b[i];
      ansB = i+1;
    }
  }

  cout << ansB << endl;
  return 0;
}

Measured memory_bytes: 1176
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;

const int mod = 1e9 + 7;

map<int, int> get_factorization(int n){
    map<int, int> ret;
    for (int i = 2; i * i <= n; ++i)
        while (n % i == 0)
            ++ret[i], n /= i;
    if (n != 1)
        ++ret[n];
    return ret;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    int n;
    cin >> n;
    vector<map<int, int>> prime_factorization(n + 1);
    for (int i = 2; i <= n; ++i){
        prime_factorization[i] = get_factorization(i);
    }
    map<int, int> mp;
    for (int i = 2; i <= n; ++i){
        for (auto &it : prime_factorization[i]){
            mp[it.first] += it.second;
        }
    }
    int ans = 1;
    for (auto &it : mp){
        ans = 1LL * ans * (it.second + 1) % mod;
    }
    cout << ans << '\n';
    return 0;
}

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

const int maxn = 22;
int main()
{
    int T;
    int H[maxn];
    scanf("%d", &T);
    for (int i = 0; i < T; ++i)
    {
        scanf("%d", &H[i]);
    }
    int high = 0;
    int ans = 0;
    for (int i = 0; i < T; ++i)
    {
        high = max(high, H[i]);
        if (H[i] >= high)
            ans++;
    }
    printf("%d\n", ans);
    return 0;
}

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

money = 1000
num_stock = 0
for a, b in zip(A, A[1:]):
    if a < b:
        cnt, money = divmod(money, a)
        num_stock += cnt
    elif a > b:
        money += num_stock * a
        num_stock = 0
money += num_stock * A[-1]
print(money)


Measured memory_bytes: 61484
#include<bits/stdc++.h>
using namespace std;
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define __ cout<<fixed;cout<<setprecision(10);
#define int long long

void solve() {
	int n;
	cin >> n;
	int arr[4] = {0};
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s == "AC") {
			arr[0]++;
		}
		else if (s == "WA") {
			arr[1]++;
		}
		else if (s == "TLE") {
			arr[2]++;
		}
		else {
			arr[3]++;
		}
	}
	cout << "AC x " << arr[0] << "\n";
	cout << "WA x " << arr[1] << "\n";
	cout << "TLE x " << arr[2] << "\n";
	cout << "RE x " << arr[3] << "\n";
}

int32_t main() {
	_ __
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}

#ifndef ONLINE_JUDGE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif

	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9

using namespace std;

ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 

// max({a, b, c, d})

vector<ll>adj[200005];
ll update[200005];
ll ans[200005];

int binaryToDecimal(string n) 
{ 
    string num = n; 
    int dec_value = 0; 
  
    // Initializing base value to 1, i.e 2^0 
    int base = 1; 
  
    int len = num.length(); 
    for (int i = len - 1; i >= 0; i--) { 
        if (num[i] == '1') 
            dec_value += base; 
        base = base * 2; 
    } 
  
    return dec_value; 
} 

bool isPerfectSquare(long double x) 
{   
  // Find floating point value of  
  // square root of x. 
  long double sr = sqrt(x); 
  
  // If square root is an integer 
  return ((sr - floor(sr)) == 0); 
} 

int main()
{
    ll ans = 0;
    ll n;

    cin >> n;

    ll a[n];

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

    for(int i=1;i<n-1;i++)
    {
        if(a[i-1] > a[i] && a[i] > a[i+1]) 
        {
            // see(a[i-1]);
            // see(a[i]);
            // see(a[i+1]);
            ans++;
        }
        else if(a[i-1] < a[i] && a[i] < a[i+1])
        {
            // see(a[i-1]);
            // see(a[i]);
            // see(a[i+1]); 
            ans++;
        }
    }

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




Measured memory_bytes: 6016
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

typedef pair <int, int> ii;

const int Maxn = 100005;
const int Maxc = 32;

int n, c;
vector <ii> recs[Maxc];
int delt[Maxn];
int cur, best;

int main()
{
	scanf("%d %d", &n, &c);
	for (int i = 0; i < n; i++) {
		int l, r, ci; scanf("%d %d %d", &l, &r, &ci);
		recs[ci].push_back(ii(l, r));
	}
	for (int i = 1; i <= c; i++) {
		sort(recs[i].begin(), recs[i].end());
		vector <ii> tmp;
		for (int j = 0; j < recs[i].size(); j++)
			if (tmp.empty() || tmp.back().second < recs[i][j].first) tmp.push_back(recs[i][j]);
			else tmp.back().second = recs[i][j].second;
		for (int j = 0; j < tmp.size(); j++) {
			delt[tmp[j].first]++;
			delt[tmp[j].second + 1]--;
		}
	}
	for (int i = 0; i < Maxn; i++) {
		cur += delt[i];
		best = max(best, cur);
	}
	printf("%d\n", best);
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
using lint = long long;

std::vector<lint> make_divisors(lint n)
{
    std::vector<lint> out;
    for (lint i = 1; i < sqrt(n) + 1; ++i)
    {
        if (n % i == 0)
        {
            out.push_back(i);
            if (i != n / i)
            {
                out.push_back(n / i);
            }
        }
    }

    std::sort(out.begin(), out.end());

    return out;
}

int main()
{
    lint n, m;

    scanf("%lld", &n);
    scanf("%lld", &m);

    auto divisors = make_divisors(m);

    for (auto div : divisors)
    {
        if (div >= n)
        {
            printf("%lld", m / div);
            return 0;
        }
    }

    return 0;
}


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

int main(){
    int k;
    string s;
    cin >> k >> s;
    int size = s.size();
    if (size <= k) cout << s << endl;
    else{
        rep(i, 0, k){
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}   

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

using namespace std;

int main(void){
    string T, S;
    int count = 0;
    cin >> S;
    cin >> T;
    for(int i = 0; i < 3; i++){
        if(S[i] == T[i]) count++;
    }
    cout << count  << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define INF 1<<25

using namespace std;

int a, b;

int main()
{

	while( cin >> a >> b, !cin.eof() )
	{
		int c = a+b;
		char str[100];
		sprintf( str, "%d", c );

		string s;
		s += str;

		cout << s.size() << endl;
	}

	return 0;

}

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

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

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K, S;
    cin >> N >> K >> S;
    rep(i, N) {
        if(i < K) cout << S << " ";
        else cout << (S == 1e9 ? 1 : S + 1) << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1280
program atcoder
implicit none
character(len=100) :: a, b, c
character :: t

read(*,*) a, b, c

t = a(1:1)
a = a(2:100)

do
	if (t == 'a') then
    	if (trim(a) == '')then
    		write(*,'(a)') 'A'
        	stop
    	end if
    	t = a(1:1)
        a = a(2:100)
	else if (t == 'b') then
    	if (trim(b) == '')then
    		write(*,'(a)') 'B'
        	stop
    	end if
    	t = b(1:1)
        b = b(2:100)
	else
    	if (trim(c) == '')then
    		write(*,'(a)') 'C'
        	stop
    	end if
    	t = c(1:1)
        c = c(2:100)
	end if
end do

end program atcoder

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

int main(){
    int r,g,b;	cin >> r >> g >> b;
    if((100*r+10*g+b)%4){
	cout << "NO" << endl;
    }else{
	cout << "YES" <<endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
using ll = long long;
using ull = unsigned long long;
const static int MOD = 1000000007;

int main(){
	int N;
	scanf("%d\n", &N);
	char top[N+1], bottom[N+1];
	scanf("%s", top);
	scanf("%s", bottom);
	ull answer;
	int begin = 1;
	if(top[0] == bottom[0]) answer = 3;
	else{
		answer = 6;
		begin++;
	}
	for (int i = begin; i < N; ++i){
		if(top[i] == bottom[i]){
			if(top[i-1] == bottom[i-1]){
				answer = answer*2 %MOD;
			}
		}else{
			answer *= top[i-1] == bottom[i-1] ? 2 : 3;
			answer %= MOD;
			i++;
		}
	}
	printf("%llu\n", answer);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
int main() {
	int a=_,b=_,c=_;
	cout<<min(b/a,c);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,m,s[110],t[110];
    while(1){
        cin>>n>>m;
        if(n==0||m==0)break;
        int sum1=0,sum2=0;
        for(int i=0;i<n;i++){
            cin>>s[i];
            sum1+=s[i];
        }
        for(int i=0;i<m;i++){
            cin>>t[i];
            sum2+=t[i];
        }
        int d=sum1-sum2,b=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                int a=s[i]-t[j];
                if(2*a==d&&b==0){
                    cout<<s[i]<<" "<<t[j]<<endl;
                    b=1;
                }
            }
        }
        if(b==0)cout<<"-1"<<endl;
    }
    return 0;
}



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


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

    int n, ans = 0;
    cin >> n;

    for (int a = 1; a < n; ++a) {
        int res = n / a;
        if (n % a == 0) res--;
        ans += res;
    }

    cout << ans << endl;

    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int x, y;
  cin >> x >> y;

  if (x <= y) {
    if ((x >= 0 && y >= 0) || (x <= 0 && y <= 0)) {
      cout << (y - x) << endl;
    } else {
      cout << abs(abs(x) - y) + 1 << endl;
    }
  } else {
    if ((x >= 0 && y >= 0) || (x <= 0 && y <= 0)) {
      cout << x - y + ((x == 0 || y == 0) ? 1 : 2) << endl;
    } else {
      cout << abs(abs(y) - x) + 1 << endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>

using namespace std;

typedef complex<double> Point;

inline double cross(const Point& a, const Point& b){
    return imag(conj(a) * b);
}

inline double dot(const Point& a, const Point& b){
    return real(conj(a) * b);
}

typedef vector<Point> Polygon;

Point next(const Polygon& g, int x){
    return g[(x+1) % (int)g.size()];
}

int contains(const Polygon& g, const Point& p){
    bool in = false;
    for(int i=0; i<(int)g.size(); ++i){
        Point a = g[i] - p, b = next(g, i) - p;
        if(imag(b) < imag(a))swap(a, b);
        if(imag(a) <= 0 && 0 < imag(b) && cross(a, b) < 0)in = !in;
        if(cross(a, b) == 0 && dot(a, b) <= 0)return 1;
    }
    return in? 2: 0;
}

int main(){
    int n;
    cin >> n;
    Polygon g;
    while(n--){
        int x, y;
        cin >> x >> y;
        g.emplace_back(x, y);
    }
    int q;
    cin >> q;
    while(q--){
        int x, y;
        cin >> x >> y;
        cout << contains(g, Point(x, y)) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if(h == 0 && w == 0) break;
			for(int i = 0;i<h;i++) {
				for(int j = 0;j<w;j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 33292
import java.util.ArrayList;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		ArrayList<Integer> caseNum = new ArrayList<Integer>();
		int num;
		Scanner sc = new Scanner(System.in);

		//??\??????????????????0?????§??°?????????
		while (sc.hasNext()) {
			num=sc.nextInt();

			//0??\??????????????????
			if(num==0){
				break;
			}
			//??\???????????´??°?????????????????????
			caseNum.add(num);
		}
		//??\???????????´??°?????¨???
		for (int i = 0; i < caseNum.size(); i++) {
			System.out.println("Case "+(i+1)+": "+caseNum.get(i));
		}
	}
}

Measured memory_bytes: 41032
#!/usr/bin/env python3
import itertools
import math
n, d = map(int, input().split())
a = [[] for m in range(n)]
for i in range(n):
    a[i] = list(map(int, input().split()))
count = 0
for i in range(n):
    for j in range(i+1,n):
        value = 0
        for k in range(d):
            value += (a[i][k] - a[j][k]) ** 2
        check = value ** 0.5
        count += check.is_integer()
print(count)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n; cin >> n;
  vector<ll> a(n);
  ll o=0, p=0;
  rep(i, n) {
    cin >> a[i];
    if(a[i] > o) o = a[i];
  }
  ll d1, d2;
  d1 = o/2;
  if(o%2) d2 = o/2+1;
  else d2 = o/2;
  for(auto i:a) {
    if(abs(d1-i) < abs(d1-p)) p=i;
    if(abs(d2-i) < abs(d2-p)) p=i;
  }
  cout << o << " " << p << endl;
}

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

using namespace std;

int main(){
	
	while(1){
		
		int n,count;
		
		cin >> n >> count;
		
		if(n==0 && count==0)
			return 0;
		
		int d[n];
		
		for(int i=0;i<n;i++)
			d[i] = n-i;
		
		for(int i=0;i<count;i++){
			int p,c;
			
			cin >> p >> c;
			
			int t[n];
			
			int j;
			for(j=0;j<c;j++){
				t[j]=d[p-1+j];
			}
			for(;j<c+p-1;j++){
				t[j]=d[j-c];
			}
			for(;j<n;j++){
				t[j]=d[j];
			}
			for(j=0;j<n;j++){
				d[j]=t[j];
			}
		}
		cout << d[0] <<endl;
		
	}
	return 0;
}


Measured memory_bytes: 2992
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define N 3
#define N2 9
using namespace std;

struct game{
  int b[N2];
  bool operator < (const game &other) const{
    for(int i=0;i<N2;i++){
      if(b[i]<other.b[i]){
        return true;
      }else if(b[i]>other.b[i]){
        return false;
      }
    }
    return false;
  }
};
game g;
map<game,int> checked;
queue<game> q;

void print(game _g){
  for(int i=0;i<N2;i++)
    printf("%d ",_g.b[i]);
  printf("\n");
}

bool clear(game _g){
  for(int i=0;i<N2;i++){
    if(_g.b[i]!=i+1) return false;
  }
  return true;
}

int solve(){
  q.push(g);
  checked.insert(make_pair(g,0));
  int depth;
  while(!q.empty()){
    g=q.front();q.pop();
    depth=checked[g];
    if(clear(g)){ return depth; }
    int w;
    for(int i=0;i<N2;i++){
      if(g.b[i]==N2) {
        w=i;
        break;
      }
    }
    vector<int> v;
    if(w%N<N-1) v.push_back(1);
    if(w%N>0  ) v.push_back(-1);
    if(w/N<N-1) v.push_back(N);
    if(w/N>0  ) v.push_back(-N);
    for(int i:v){
      game gt=g;
      swap(gt.b[w],gt.b[w+i]);
      if(checked.find(gt)==checked.end()){
        q.push(gt);
        checked.insert(make_pair(gt,depth+1));
      }
    }
  }
  return -1;
}


int main(){
  for(int i=0;i<N2;i++) {
    int tmp; cin>>tmp;
    if(tmp==0) tmp=N2;
    g.b[i]=tmp;
  }

  cout<<solve()<<endl;
}

Measured memory_bytes: 17728
using System;
    using System.Text;
    using System.Collections.Generic;
    using static System.Math;
    using System.Linq;
    using static System.Array;
    
    namespace ConsoleApp2
    {
    class Program
    {
        static string S;
        static void Main(string[] args)
        {
            
            var N = long.Parse(Console.ReadLine());
            var V = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            var dic1 = new Dictionary<long, long>();
            var dic2 = new Dictionary<long, long>();

            for (int i = 0; i < N; i++)
            {
                var now = V[i];
                if (i % 2 == 0)
                {
                    if (dic1.ContainsKey(now))
                    {
                        dic1[now]++;
                    }
                    else
                    {
                        dic1.Add(now,1);
                    }
                }
                else
                {
                    if (dic2.ContainsKey(now))
                    {
                        dic2[now]++;
                    }
                    else
                    {
                        dic2.Add(now, 1);
                    }
                }
            }
            dic2.Add(0,0);
            dic1.Add(0,0);
            var d1max  = -1L;
            var d1maxK  = -1L;
            var d1max2 = -1L;
            var d1max2K = -1L;
            foreach (var item in dic1)
            {
                if (item.Value > d1max)
                {
                    d1max2 = d1max;
                    d1max2K = d1maxK;
                    d1max = item.Value;
                    d1maxK = item.Key;
                }
                else if (item.Value > d1max2)
                {
                    d1max2 = item.Value;
                    d1max2K = item.Key;
                }
            }


            var d2max = -1L;
            var d2maxK = -1L;
            var d2max2 = -1L;
            var d2max2K = -1L;
            foreach (var item in dic2)
            {
                if (item.Value > d2max)
                {
                    d2max2 = d2max;
                    d2max2K = d2maxK;
                    d2max = item.Value;
                    d2maxK = item.Key;
                }
                else if (item.Value > d2max2)
                {
                    d2max2 = item.Value;
                    d2max2K = item.Key;
                }
            }

            if(d2maxK != d1maxK)
            {
                Console.WriteLine((N - d1max - d2max));
            }
            else
            {


                Console.WriteLine(Min((N - d1max2 - d2max), (N - d1max - d2max2)));
            }

            
        }
    }
}


Measured memory_bytes: 28384
#include<stdio.h>

int main() {
    char S[3];
    int i;

    for(i = 0; i < 3; i++) {
        scanf("%c", &S[i]);
    }

    if((S[0] == S[1]) && (S[0]== S[2])){
        printf("No");
    } else {
        printf("Yes");
    }


    return 0;
}

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

int main() {
    int A,B,C,D,P,x,y;
    cin >> A >> B >> C >> D >> P;
    x=A*P;
    if(C>=P) {
    y=B;
}
    else {
	y=B+(P-C)*D;
}
if(x>y) {
	cout << y << endl;
}
	else {
		cout << x << endl;
	
}
		return 0;
	}
	
    
    


Measured memory_bytes: 3084
N = int(input())
S = input()

w_cnt = [0] * N
for i in range(1, N):
    w_cnt[i] = w_cnt[i - 1] + (1 if S[i - 1] == "W" else 0)

e_cnt = [0] * N
for i in range(0, N - 1)[::-1]:
    e_cnt[i] = e_cnt[i + 1] + (1 if S[i + 1] == "E" else 0)

ans = 10**9
for i in range(N):
    ans = min(ans, w_cnt[i] + e_cnt[i])

print(ans)

Measured memory_bytes: 27164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> p(n),c(n);
  vector<vector<ll>> score(n,vector<ll>(n,-INFLONG));
  rep(i,n){
    cin >> p[i];
    p[i]--;
  }
  rep(i,n){
    cin >> c[i];
  }
  ll cnt;
  ll ans = -INFLONG;
  rep(i,n){
    cnt = 0;
    t1 = i;
    ll tscore = 0;
    tscore += c[t1];
    score[i][cnt] = tscore;
    t1 = p[t1];
    while(t1 != i){
      cnt++;
      tscore += c[t1];
      score[i][cnt] = tscore;
      t1 = p[t1];
    }
    if(tscore < 0){
      rep(j,min(k,n)){
        chmax(ans,score[i][j]);
      }
    }else{
      cnt++;
      t1 = k / cnt;
      //cout << t1 << endl;
      ll tk = k - t1 * cnt;
      //cout << tk << endl;
      ll tans,tsum;
      tans = t1 * tscore;
      tsum = -INFLONG;
      rep(j,tk){
        chmax(tsum,score[i][j]);
      }
      chmax(ans,tans + tsum);


      t1--;
      if(t1 >= 0){
        tans = tscore * t1;
        tsum = -INFLONG;
        rep(j,n){
          chmax(tsum,score[i][j]);
        }
        chmax(ans,tans + tsum);
      }
    }
  }
//  ll ans = -INFLONG;
//  cout << sum << endl;
////  rep(i,n){
////    cout << c[i] << endl;
////  }
//  if(sum < 0 || k/n == 0){
//    rep(i,n){
//      REP(j,1,n){
//        if(j <= k){
//          chmax(ans,score[i][j]);
//        }
//      }
//    }
//  }else{
//    t1 = k / n;
//    t1--;
//    ll tans = sum * t1;
//    //cout << tans << endl;
//    k -= t1 * n;
//    rep(i,n){
//      rep(j,2*n){
//        if(t1 == 0 && j == 0){continue;}
//        if(j <= k){
//          chmax(ans,score[i][j]);
//        }
//      }
//    }
//    ans += tans;
//  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

const ll INF = 1LL << 60;


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

vector<vector<pair<ll,ll>>> to; to.resize(N);

 vector<ll> dist(N,INF);
  
  dist[0] = 0;
   
   for(ll i = 0; i < M; i++){ 
     ll a,b,c; cin >> a >> b >> c; c -= P; a--; b--; c *= -1;
     to[a].push_back(make_pair(b,c));}
  
  bool flag = false;
  
   for(ll k = 0; k < 2 * N - 2; k++){
    for(ll i = 0; i < N; i++){
      // considering i- node
      if( dist[i] == INF){ continue;}
      for(auto ne: to[i]){
        ll p = ne.first;   ll q = ne.second; 
        if( dist[p] > dist[i] + q){ 
          dist[p] = dist[i] + q;
          if( p == N - 1 && k >= N - 1){ flag = true; break;}
        }
      }
    }
   }
  
  if( flag){ cout << "-1" << endl; }
  else{ cout << max(0LL,-dist[N-1]) << endl; } 
  
  return 0;}


Measured memory_bytes: 512
n, k, q = (int(x) for x in input().split())
n_list = [k] * n
a = []

for i in range(q):
    tmp = int(input())
    a.append(tmp)

for i in a:
    n_list[i - 1] += 1

for i in n_list:
    if i - q <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 10472
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;

  if(A1+A2+A3 >= 22){
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
}

Measured memory_bytes: 256
n, m, l = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
c = []
[c.append([0] * l) for _ in range(n)]

for i in range(n):
    tmp = []
    for j in range(l):
        tmp += map(str, [sum([a[i][k] * b[k][j] for k in range(m)])])
    print(' '.join(tmp))



Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
int main(){
    int n,k,r,s,p;
    long long ans=0;
    int result[100005];
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    for(int i=0;i<n;i++){
        if(i<k){
            if(t[i]-'p'==0) ans+=s;
        else if(t[i]-'r'==0) ans+=p;
        else ans+=r;
        result[i]=1;
        }
        else{
            if((t[i]-t[i-k])==0&&result[i-k]==1){
                result[i]=0;
            }
            else{
                    if(t[i]-'p'==0) ans+=s;
                    else if(t[i]-'r'==0) ans+=p;
                    else ans+=r;
                    result[i]=1;
                
        }
    }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 896
#!/usr/bin python3
# -*- coding: utf-8 -*-

class UnionFind():
    def __init__(self, n):      #初期化
        self.n = n
        # 親
        self.parents = [i for i in range(n)]
        # 木の深さ
        self.ranks = [0] * n
        # グループの要素数
        self.sizes = [1] * n

    def find(self, x):          #親を出力
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.ranks[x] < self.ranks[y]:
            self.parents[x] = y
            self.sizes[y] += self.sizes[x]
        else:
            self.parents[y] = x
            self.sizes[x] += self.sizes[y]
            if self.ranks[x]==self.ranks[y]:
                self.ranks[x] += 1

    def same(self, x, y):       #xとyが同じグループかどうか
        return self.find(x) == self.find(y)

    def members(self, x):       #xと同じグループの要素
        root = self.find(x)
        return {i for i in range(self.n) if self.find(i) == root}

    def size(self, x):          #グループの要素数
        root = self.find(x)
        return self.sizes[root]

    def roots(self):            #親の要素一覧
        return {i for i, x in enumerate(self.parents) if i == x}

    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())

################

def main():
    N, M, K = map(int, input().split())
    uf = UnionFind(N)
    dic = {i:set([i]) for i in range(N)}
    fcnt = {i:0 for i in range(N)}

    for i in range(M):
        a,b = map(int,input().split())
        uf.unite(a-1, b-1)
        fcnt[a-1] += 1
        fcnt[b-1] += 1

    for j in range(K):
        a,b = map(int,input().split())
        dic[a-1].add(b-1)
        dic[b-1].add(a-1)

    ret = [None]*N
    for i in range(N):
        ret[i] = uf.size(i)-fcnt[i]
        for x in dic[i]:
            if uf.same(x,i):
                ret[i] -= 1
#    ret = [len(uf.members(i) - dic[i]) for i in range(N)]
    print(" ".join(map(str,ret)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 69360
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int N,T;
	cin>>N>>T;
	vector<int> t(N);
	rep(i,N) cin>>t[i];
	t.pb(2e9);
	int ans = 0;
	rep(i,N){
		ans += min(T,t[i+1]-t[i]);
	}
	cout<<ans<<endl;
}


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

#define ll long long
#define ld long double
 
#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 err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 998244353;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 3005;

ll dp[N][N];

ll a,b,c,d;

ll dfs(ll x, ll y){
	if(x<a or y<b)	return 0;
	if(dp[x][y] != -1)
		return dp[x][y];
	return dp[x][y] = ((x * dfs(x, y-1) + y * dfs(x-1, y) - (x-1) * (y-1) * dfs(x-1, y-1)) % M + M)% M;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>a>>b>>c>>d;
    rep(i,0,N)	rep(j,0,N)	dp[i][j] = -1;
    dp[a][b] = 1;
    ll ans = dfs(c,d);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 74520
s = gets.chomp
a_c = s.count('a')
b_c = s.count('b')
c_c = s.count('c')

if [a_c, b_c, c_c].max - [a_c, b_c, c_c].min >= 2
  puts 'NO'
else
  puts 'YES'
end

Measured memory_bytes: 1916
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long ll;
const int MAX=2*1e5+5;
int num[MAX];
int minn=1e9+5;
int maxp=-1e9-5;
int main(){
	int n;
	scanf("%d",&n);
	scanf("%d",&num[0]);
	minn=num[0];
	for(int i=1;i<n;i++){
		scanf("%d",&num[i]);
		maxp=max(maxp,num[i]-minn);
		minn=min(minn,num[i]); 
	}
	printf("%d\n",maxp);
	return 0;
}


Measured memory_bytes: 3992
#include <stdio.h>

int main(void)
{
	int a, b;
	scanf("%d", &a);
	scanf("%d", &b);
	
	if (a < b)
	puts("a < b");
	if (a > b)
	puts("a > b");
	if (a == b)
	puts("a == b");
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
    
int main(){
  int n;
  double t,a;
  cin >> n >> t >> a;
  
  double T[n];
  rep(i,n){
    double h;
    cin >> h;
    T[i] = t - h*0.006;
  }
  
  int ans = 0;
  rep(i,n){
    if(abs(a-T[i]) < abs(a-T[ans])) ans = i;
  }
  
  cout << ans+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int disitsum(int a){
    int res = 0;
    while(a>0){
        res+=a%10;
        a/=10;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    if(n%disitsum(n)==0){
        put("Yes");
    }else{
        put("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <numeric>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <deque>
#include <bitset>
#include <cstring>
#include <sstream>
#include <complex>
 
#define f first
#define s second
#define ll long long
#define ld double
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp make_pair
#define y0 eto
#define y1 mezhdy
#define y2 nami
#define left extermination
#define right dismemberment
 
using namespace std;
 
void runtime(){cout<<fixed<<setprecision(5)<<1.0*clock()/CLOCKS_PER_SEC<<endl;}

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <class T>void read(vector<T> &a,int n){T x; a.clear();for(int i=0;i<n;i++){cin>>x;a.pb(x);}}
template <class T>void write(vector<T> &a){for(T x : a) cout<<x<<' ';cout<<'\n';}

int n;

set<int> bon={3};
set<int> pon={0,1,6,8};
set<int> hon={2,4,5,7,9};

int main()
{
    ios_base::sync_with_stdio(0);
//    freopen("INPUT.txt","r",stdin);
    
    cin>>n;
    n%=10;
    
    if(bon.count(n))
        cout<<"bon";
    if(hon.count(n))
        cout<<"hon";
    if(pon.count(n))
        cout<<"pon";
}


Measured memory_bytes: 3056
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 1000010
#define EPS 1e-7
using namespace std;
typedef long long ll;
double n,d,m;
double fsp(double x,ll y){
	double res=1;
	while(y){
		if(y&1ll)
			res=res*x;
		x=x*x;
		y>>=1ll;	
	}
	return res;
}
int main(){
	SF("%lf%lf%lf",&n,&m,&d);
	if(d<EPS)
		PF("%.6lf\n",1.0/n*(m-1.0));
	else{
		PF("%.6lf\n",(2.0-2.0*d/n)/n*(m-1.0));	
	}
}

Measured memory_bytes: 128
//Multiplication
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;
int main ()
{

    long A,B;
    cin >> A >> B;
    cout << (long long)A * B << endl;
    return 0;
}

Measured memory_bytes: 3212
#include<stdio.h>

#define N 10000

int linearSearch(int,int *,int);

int main(void){
  int S[N];
  int n,q,T,C=0;
  int i;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&T);
    C += linearSearch(n,S,T);
  }

  printf("%d\n",C);
  
  return 0;
}

int linearSearch(int n, int *S, int key){
  int i=0;
  S[n] = key;
  while(S[i] != key) i++;
  if(i == n) return 0;
  else return 1;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
const int N=3003;
using namespace std;
int n,M,tp,c[N][N],s[N][N],
ans,sum,ss;
inline int ksm(long long x,int t,int m=M){
	int y=1;
	for(;t;t>>=1)
	t&1?y=y*x%m:0,x=x*x%m;
	return y;
}
int main(){
	scanf("%d%d",&n,&M);
	s[0][0]=1;
	for(int i=0;i<=n;i++){
		c[i][0]=1;
		for(int j=1;j<=i;j++)
		c[i][j]=(c[i-1][j]+c[i-1][j-1])%M,
		s[i][j]=(s[i-1][j-1]+s[i-1][j]*1ll*j)%M;
	}
	for(int i=0;i<=n;i++){
		ss=1,sum=0,tp=ksm(2,n-i);
		for(int j=0;j<=i;j++){
			sum=(sum+(s[i][j]+(j+1ll)*s[i][j+1])%M*ss)%M;
			ss=ss*1ll*tp%M;
		}
		ans=(ans+(i&1?-1ll:1ll)*c[n][i]%M*sum%M*ksm(2,ksm(2,n-i,M-1)))%M;
	}
	printf("%d",(M+ans)%M);
}

Measured memory_bytes: 69376
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int h[n+5];
    int a[n+5];
    for (int i = 1; i <= n; i++)
    {
         cin >> h[i];
         a[i] = 0;
    }
 
    a[1] = 0;
    a[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= n; i++)
        a[i] = min(a[i-2] + abs(h[i] - h[i-2]), a[i-1] + abs(h[i-1] - h[i]));
    cout << a[n] << endl;       
 
}

Measured memory_bytes: 1024
import Control.Applicative
import Control.Monad

rInt s = read s :: Int

main  = do
	ss <- (map (map rInt) . map words . lines) <$> getContents
	mapM (mapM putStrLn . frame) $ takeWhile (\(h:(w:_)) -> h/=0 && w/=0) ss 
		where frame (h:(w:_)) = [hframe w] ++ (replicate (h-2) (hinner w)) ++ [hframe w] ++ [""]
		      hframe w = replicate w '#'
		      hinner w = ['#'] ++ (replicate (w-2) '.') ++ ['#']

Measured memory_bytes: 4068
n,m,c=map(int,input().split())
B=list(map(int, input().split()))
ans=0
for _ in range(n):
    A=list(map(int, input().split()))
    t=c
    for i,j in zip(A,B):t+=i*j
    if t>0:ans+=1
print(ans)

Measured memory_bytes: 3064
n,m = map(int,input().split())
l = 0
r = n
for i in range(m):
  ll,rr = map(int,input().split())
  l = max(l,ll)
  r = min(r,rr)
if r-l+1 >= 0:
  print(r-l+1)
else:
  print(0)

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

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;

    if(n % 2 == 0) {
        cout << n << endl;
    }else{
        cout << n*2 << endl;
    }

    return 0;
}


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

int main(){
  string N;
  cin >> N;
  int ans=0;
  if(N[0]=='2'){ans++;}
  if(N[1]=='2'){ans++;}
  if(N[2]=='2'){ans++;}
  if(N[3]=='2'){ans++;}
  cout << ans << endl;
}

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

const int N = 3005;
const long long IMPOSSIBLE = 4e18;

long long dp[N][N];
int arr[N];
int n;

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

long long solve(int l, int r) {
  if (l > r) return 0;

  int mode = (l + n-1-r) % 2;
  long long &ret = dp[l][r];
  if (ret != IMPOSSIBLE) return ret;

  if (mode == 0) {
    ret = max(arr[l] + solve(l+1, r), arr[r] + solve(l, r-1));
  } else {
    ret = min(solve(l+1, r) - arr[l], solve(l, r-1) - arr[r]);
  }

  return ret;
}

long long work() {
  for (int i = 0 ; i < N ; i++)
    for (int j = 0 ; j < N ; j++)
      dp[i][j] = IMPOSSIBLE;
  
  return solve(0, n-1);
}

int main() {
  read();
  cout << work() << endl;
  return 0;
}

Measured memory_bytes: 71040
#include <stdio.h>
#include <math.h>
int main(void)
{
    int A, B, C, D;
    scanf("%i %i %i %i", &A, &B, &C, &D);
    while (1)
    {
        C -= B;
        if (C <= 0)
        {
            printf("Yes\n");
            return 0;
        }
        A -= D;
        if (A <= 0)
        {
            printf("No\n");
            return 0;
        }
    }
}

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

int main() {
  int N, M, pass = 1;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  for (int i = 0; i < M; i++) {
    cin >> L.at(i) >> R.at(i);
  }
  sort(L.begin(), L.end());
  reverse(L.begin(), L.end());

  sort(R.begin(), R.end());
  if (L.at(0) <= R.at(0)) {
    cout << R.at(0) - L.at(0) + 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
} 


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

	int main() {
	
	string b;
	cin >> b;
	int a;
	char s = b.back();
	if (s=='3') {
		cout<<"bon"<<endl;
	}
	else if(s=='2'||s=='4'||s=='5'||s=='7'||s=='9') {
		cout<<"hon"<<endl;
	}
	else {
		cout << "pon" << endl;
	}
}


Measured memory_bytes: 3128
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)
    

def gcd_all(lst):
    g = gcd(lst[0], lst[1])
    for e in lst[2:]:
        g = gcd(g, e)
    return g


def submit():
    n = int(input())
    alist = list(map(int, input().split()))

    if n == 2:
        print(max(alist))
    else:
        # 左から計算したgcd列
        gcd_left = [alist[0]]
        for a in alist[1:]:
            gcd_left.append(gcd(gcd_left[-1], a))
        
        # 右から計算したgcd列
        gcd_right = [alist[-1]]
        for a in reversed(alist[:-1]):
            gcd_right.append(gcd(gcd_right[-1], a))
        gcd_right = gcd_right[::-1]

        gcd_max = 0
        for i in range(n):
            if i == 0:
                gcd_i = gcd_right[i + 1]
            elif i == n - 1:
                gcd_i = gcd_left[i - 1]
            else:
                gcd_i = gcd(gcd_left[i - 1], gcd_right[i + 1])

            if gcd_max < gcd_i:
                gcd_max = gcd_i

        print(gcd_max)


if __name__ == "__main__":
    submit()


Measured memory_bytes: 14052
def buy_ab(cost_a, cost_b, cost_ab, target_a, target_b, target_ab):
    target_a = max(0, target_a - target_ab // 2)
    target_b = max(0, target_b - target_ab // 2)
    return cost_ab * target_ab + cost_a *target_a  + cost_b * target_b


def main():
    cost_a, cost_b, cost_ab, target_a, target_b = map(int, input().split(" "))
    buy_whole = cost_a * target_a + cost_b * target_b
    print(min(buy_ab(cost_a, cost_b, cost_ab, target_a, target_b, min(target_b, target_a) * 2),
              buy_ab(cost_a, cost_b, cost_ab, target_a, target_b, max(target_b, target_a) * 2),
              buy_whole))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(0, a + 1):
    for j in range(0, b + 1):
        for k in range(0, c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                count += 1
print(count)

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

int main(){
    int64_t x;
    cin >> x;
    int64_t ans = 0;
    ans += 1000 * (x / 500);
    x %= 500;
    ans += 5 * (x / 5);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256