akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
const int MAX_N = 1000;

int par[MAX_N];
int Rank[MAX_N];
int size;

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        Rank[i] = 0;
    }
    size = n;
}

int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    size--;
    if (Rank[x] < Rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (Rank[x] == Rank[y]) {
            Rank[x]++;
        }
    }
}
bool same(int x, int y) {
    return find(x) == find(y);
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int a[51], b[51];
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    int ans = 0;
    rep(i, M) {
        init(N);
        rep(j, M) {
            if (i == j) continue;
            unite(a[j], b[j]);
        }
        bool ok = true;
        rep(j, N) {
            rep(k, N) {
                if (!same(j, k))ok = false;
            }
        }
        if (ok) ans++;
    }
    cout << M - ans << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string S, T;
    cin >> S >> T;

    bool f = true;

    REP(i, S.size()) {
        if (S[i] != T[i]) f = false;
    }

    if (f) print("Yes");
    else print("No");


    
}


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

int main() {
  int n;
  cin >> n;
  int64_t a=2,b=1,l=1;
  for(int i=2;i<=n;i++){
    l = a + b; // Li
    a = b;
    b = l;
  }
  
  cout << l << endl;
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());

	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			res += (lower_bound(A.begin(), A.end(), A[i] + A[j]) - A.begin()) - j - 1;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
vector<int> G[100005];
int dp[100005];
bool vis[100005];
int longest = 0;
void dfs(int u) {
	for (auto v : G[u]) {
		if (not vis[v]) {
			vis[v] = true;
			dfs(v);
		}
		dp[u] = max(dp[u], dp[v] + 1);
		longest = max(longest, dp[u]);
	}
}
int main() {
	int N, M; cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int x, y; cin >> x >> y;
		G[x].push_back(y);
	}
	for (int i = 1; i <= N; i++) {
		if (not vis[i]) {
			vis[i] = true;
			dfs(i);
		}
	}
	cout << longest << endl;
}


Measured memory_bytes: 8192
N,M=map(int,input().split())
h=[list(map(int, input().split())) for i in range(M)]
a=0
def s(n,m,l):
    for j in range(n,m):
        if l[h[j][0]-1] or l[h[j][1]-1]:
            l[h[j][0]-1],l[h[j][1]-1]=1,1
    return(l)
for i in range(M):
    l=[1]+[0]*(N-1)
    for _ in range(N-1):
        l=s(0,i,l)
        l=s(i+1,M,l)
    if 0 in l:
        a+=1
print(a)

Measured memory_bytes: 3188
N = gets.to_i
AB = N.times.map{|i|
	a, b = gets.split.map(&:to_i)
	next [a, -b]
}
p AB.sort_by{|a,b| a-b }.reverse_each.with_index.inject(0){|sum,(ab,i)| sum+ab[i%2] }


Measured memory_bytes: 12664
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAXN = 1000002;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
#define fill(x,y) memset(x,y,sizeof(x))
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
ll fastpow(ll n,ll x)
{
	if(x==0)
	return 1 ;
	if(x%2==0)
	return (fastpow(n*n%MOD2,x/2)%MOD2) ;
	return (x*fastpow(n*n%MOD2,(x-1)/2)%MOD2)%MOD2 ; 
}
 ll dp[101][100001] ;
 ll knap(ll i,ll wt[],ll val[],ll w)
 {  if(i<0)
    return 0 ;
 	if(dp[i][w]!=-1)
 	return dp[i][w] ;
 	else if(wt[i]>w)
 	{
 		return knap(i-1,wt,val,w) ;
	 }
	 else
	 {
	 	dp[i][w]=max(knap(i-1,wt,val,w),val[i]+knap(i-1,wt,val,w-wt[i])) ;
	 	return dp[i][w] ;
	 }
 }
 
int main(int argc, char** argv)
{   sws ;
  
 // tcase
    {
     ll n,w;
     cin>>n>>w ;
     ll val[n],wt[n] ;
     forn(i,n)
     {
     	cin>>wt[i]>>val[i] ;
	 }
    
     forn(i,n)
     {
     	forn(j,w+1)
     	{
     		dp[i][j]=-1;
		 }
	 }
	 cout<<knap(n-1,wt,val,w)<<"\n";
    }
return 0 ;
}

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

int n, k;
ll ans;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;

    for (int b = k + 1; b <= n; ++b) {
        if (b == 1) {
            ans++;
            continue;
        }

        ans += (n / b) * (b - k);
        ans += max(0, n % b - k + 1);
    }

    cout << ans;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<bits/stdc++.h>
int dp[3002][3223];
using namespace std;
int main()
{
    string s;
    string d;
    cin>>s;
    cin>>d;
    int ss=s.length();
    int dd=d.length();
    for(int i=0;i<ss;i++)
    {
        for(int j=0;j<=dd;j++)
        {
            if(s[i]==d[j])
            {
                dp[i+1][j+1]=dp[i][j]+1;
            }
            else
            {
                dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
            }
        }
    }
  //  cout<<dp[ss][dd]<<endl;
    int p=dp[ss][dd]-1;
    int i=ss,j=dd;
    char ans[p+1];
    while(i>0&&j>0)
    {
        if(s[i-1]==d[j-1])
        {
            ans[p]=s[i-1];
            i--;j--;p--;
        }
        else
        {
            if(dp[i][j-1]>dp[i-1][j])
                j--;
            else i--;
        }
    }
    for(int i=0;i<dp[ss][dd];i++)
        cout<<ans[i];
}


Measured memory_bytes: 38016
#include <iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main()
{
    int N, K;
    vector<int> p;

    cin >> N >> K;
    p.resize(N);
    for (int i = 0; i < N; i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int sum = 0;
    for (int i = 0; i < K; i++){
        sum += p[i];
    }

    cout << sum << endl;
}


Measured memory_bytes: 3612
#include<stdio.h>
int main(void)
{
	int n,m,a[100],x,z[100],y,i,k;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++) a[i]=0;
	for(i=0;i<m;i++){
		scanf("%d",&z[i]);
	}
	for(i=0;i<m;i++){
		x=0;
		for(k=0;k<n;k++){
			scanf("%d",&y);
			if(y==z[i]) a[k]++;
			else x++;
		}
		a[z[i]-1]=a[z[i]-1]+x;
	}
	for(i=0;i<n;i++) printf("%d\n",a[i]);
	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//main code

int main(int argc, char const* argv[])
{
	LL n;
	cin >> n;
	LL ans = 0;
	for (LL i = 1; i < min(n,(LL)10000000); i++) {
		if ((n-i)%i == 0) {
			if ((n-i)/i <= i) {
				break;
			}
			ans += (n-i) / i;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.math.*;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());
		
		int d = a / b;
		int r = a % b;
		double f = (double)a / b;
		
		System.out.println(d + " " +r+ " " + BigDecimal.valueOf(f).toPlainString());
	}
}

Measured memory_bytes: 26452
MOD = 10**9+7
N,M = map(int,input().split())
DP = [0]*(N+3)
DP[0] = 1
state = [1]*(N+3)
for _ in range(M):
    i = int(input())
    state[i] = 0

for i in range(N):
    for j in range(1,3):
        if state[j+i]:
            DP[j+i] += DP[i]
            DP[j+i] %= MOD

print(DP[N])


Measured memory_bytes: 7668
#include <bits/stdc++.h>
using namespace std;
const int nax = 1e3+3;
using pi = pair<int,int>;
#define x first
#define y second

pair<int,int> operator+( const pi &a, const pi &b ) {
	return make_pair(a.x+b.x,a.y+b.y);
}
// 0-1 BFS is Dijkstra.
bool bor[nax][nax];
int lvl[nax][nax];
int n,m;
bool safe( int i, int j ) {
	return !( i < 0 or j < 0 or i > n-1 or j > m-1 or !bor[i][j] );
}
vector<pair<int,int>> pts( int i, int j ) {
	vector<pi> ret;
	for( int x = i-2; x <= i+2; x++) {
		for( int y = j-2; y <= j+2; y++) {
                  if(!safe(x,y)) continue;
			ret.emplace_back(x,y);
		}
	}
	return ret;
}

void _read() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	// freopen("input.txt","r",stdin);
}

int main() { _read();
	cin >> n >> m;
	
	pi src,des;
	cin >> src.x >> src.y >> des.x >> des.y;
      src.x--,src.y--,des.x--,des.y--;

      for( int i = 0; i < n; i++) {
		char c;
		for ( int j = 0; j < m; j++) {
			cin >> c;
			bor[i][j] = ( c == '.');
                  lvl[i][j] = (int) 1e9 + 7;
		}
	}

	deque<pair<int,int>> q;
	q.push_back(src);
      lvl[src.x][src.y] = 0;
	while(!q.empty()) {
		pi u = q.front();
		q.pop_front();
		for( pi dir : (vector<pi>) { {1,0},{0,1},{-1,0},{0,-1}}) {
			pi v = u + dir;
			if(!safe(v.x,v.y)) continue;
			int x = v.x, y = v.y;
                  if(lvl[x][y] > lvl[u.x][u.y]) {
                        lvl[x][y] = lvl[u.x][u.y];
                        q.push_front(v);
                  }
		}
		vector<pi> r = pts(u.x,u.y);
		for( pi v : r ) {
                  if(lvl[u.x][u.y] + 1 < lvl[v.x][v.y]) {
			      lvl[v.x][v.y] = lvl[u.x][u.y]+1;
			      q.push_back(v);
                  }
		}
	}
      int ans = lvl[des.x][des.y];
      cout << ( ans == (int) 1e9 + 7 ? -1 : ans ) << '\n';
	return 0;
}



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

int main() {
    string  S;
    cin >> S;

    if( S == "RRR"){
        cout << 3 << endl;
    }
    else if ( S == "RRS" || S == "SRR"){
        cout << 2 << endl;
    }
    else if ( S == "SSS"){
        cout << 0 << endl;
    }
    else {
        cout << 1 << endl;
    }
    
}

Measured memory_bytes: 3616
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	long long n, a, b;
	cin >> n >> a >> b;

	long long k = n / (a + b);
	long long ans = k * a;
	long long left = n - k * (a + b);

	ans += min(a, left);

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

Measured memory_bytes: 256
a, b = gets.chomp.split.map(&:to_i)
res = -1
(1..1000).each do |i|
  a_lb = (0.08 * i).to_i
  b_lb = (0.10 * i).to_i
  break if a_lb > a || b_lb > b
  if a_lb == a && b_lb == b
    res = i
    break
  end
end
puts res

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int mod=10e8+7,maximum=-1;;

 string getmax(string str1,string str2)
{
    string s;
    long long int n1,n2;
    n1=str1.length();
    n2=str2.length();
    long long int i,j;
    long long int dp[n1+1][n2+1];
   
    for(i=0;i<n1+1;i++)
    dp[i][0]=0;
    for(j=0;j<n2+1;j++)
    dp[0][j]=0;
    
     for(i=1;i<n1+1;i++)
     {
         for(j=1;j<n2+1;j++)
         {
             if(str1[i-1]==str2[j-1])
             dp[i][j]=(1+dp[i-1][j-1]);
             else
             {
                 dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
             }
             
         }}

    i=n1,j=n2;
    while(i>0&&j>0)
    {
        if(str1[i-1]==str2[j-1])
        {
            s.push_back(str1[i-1]);
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
            i--;
            else 
            {
                j--;
            }
            
        }
        
    }

    reverse(s.begin(),s.end());
     
         
   
 
  
    return s;

    

}
int main()
{
     long long int n,weight;
    
    string str1,str2;
   
      
         long long int i;
   
        cin>>str1;
        cin>>str2;
        cout<<getmax(str1,str2)<<"\n";
    
}

Measured memory_bytes: 73940
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const double pi = acos(-1.0);

int main() {
	string S; cin >> S;
	string s;
	for (auto c : S) {
		if (c == 'A' || c == 'Z')s += c;
	}
	s.erase(unique(all(s)), s.end());
	if (s.front() == 'Z')s.erase(s.begin());
	if (s.back() == 'A')s.erase(s.end() - 1);

	cout << (s.empty() ? "-1": s) << endl;
}


Measured memory_bytes: 3192
h,w = map(int,input().split())
c = []
for i in range(h):
    l = list(input())
    c.append(l)
for i in range(h):
    for k in range(2):
        for j in range(w-1):
            print(c[i][j],end='')
        print(c[i][w-1])

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;

LL x[100009];
LL dp[100009];

int main(){
	DRI(n);LL A,B;scanf("%lld%lld",&A,&B);
	REP(i,n)scanf("%lld",&x[i]);
	dp[0]=0;
	LL cmin=INF;
	REPP(i,1,n){
		dp[i]=dp[i-1]+min(B,A*(x[i]-x[i-1]));
		dp[i]=min(dp[i],cmin+B*2+A*x[i-1]);
		if(i+1<n)cmin=min(cmin,dp[i-1]-A*x[i]);
	}
	//REP(i,n)printf("%lld ",dp[i]);
	printf("%lld",dp[n-1]);
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    string s ;cin >> s;
    if(s[0]==s[2])cout << "Yes" << ln;
    else cout << "No" << ln;
}
    


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, a, b, c, d, n;
  cin >> N;
  a = N/1000;
  b = N/100 - 10 * a;
  c = N/10 - 100 * a - 10 * b;
  d = N - 1000 * a - 100 * b - 10 * c;
  if((a == b && b== c) || (b == c && c== d) || (a == b && b == c && c== d)){
  cout << "Yes" << endl;    
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  long long int n,k,ans=1,i;
  scanf("%lld %lld",&n,&k);
  for(i=0;i<n;i++)
    {
      if(i==0)
	{
	  ans *= k;
	}
      else
	{
	  ans *= (k-1);
	}
    }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
int n;
int main(){
  cin>>n;
  int x=0,y=0;
  for(int i=0;i<n;++i){
    int a;
    cin >> a;
    a%=4;
    if(a==0)
      ++x;
    else if(a!=2)
      ++y;
  }

  if(n-x-y>0){
    if(x>=y)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  else{
    if(x>=y-1)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
HOUSE_CNT = 4
FLOOR_CNT = 3
ROOM_CNT = 10

def init(houses):
    for h in range(0, HOUSE_CNT):
        floors = []
        for f in range(0, FLOOR_CNT):
            rooms = []
            for r in range(0, ROOM_CNT):
                rooms.append(0)
            floors.append(rooms)
        houses.append(floors)


def in_out(houses):
    n = int(input())
    for i in range(0, n):
        b, f, r, v = tuple(map(int, input().split(' ')))
        houses[b-1][f-1][r-1] += v;


def output(houses):
    line = False
    for house in houses:
        if line:
            print('####################')
        else:
            line = True
        for floor in house:
            for room in floor:
                print(' %d' % room, end='')
            print()


houses = []
init(houses)
in_out(houses)
output(houses)



Measured memory_bytes: 5624
import java.io.*;
import java.util.*;


public class Main{
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        // Start writing your solution here. -------------------------------------
        long MOD = 1000000007;
        //int t = sc.nextInt();
        int t = 1;
        while(t -- > 0)
        {
            int n = sc.nextInt();
            double res = 0.0;
            double p[]=  new double[n + 1];
            for(int i = 1; i <= n; i++) p[i] = sc.nextDouble();
            double dp[][] = new double[n + 1][n + 1];
            dp[0][0] = 1.0;
            for(int i = 1; i <= n; i++)
                dp[i][0] = dp[i - 1][0] * (1 - p[i]);
            for(int i = 1; i <= n; i++)
                for(int j = 1; j <= i; j++)
                    dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1.0 - p[i]);
            for(int i = n / 2 + 1; i <= n; i++)
                res += dp[n][i];
            out.println(res);
            //for(int ii = 0; ii <= n; ii++) System.out.println(Arrays.toString(dp[ii]));
        }

        out.close();

        /*
        int n      = sc.nextInt();        // read input as integer
        long k     = sc.nextLong();       // read input as long
        double d   = sc.nextDouble();     // read input as double
        String str = sc.next();           // read input as String
        String s   = sc.nextLine();       // read whole line as String

        int result = 3*n;
        out.println(result);                    // print via PrintWriter
        */
        // Stop writing your solution here. -------------------------------------
        out.close();
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

Measured memory_bytes: 132556
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll int n,m;
    cin>>n>>m;
    ll int g=(n*(n-1)/2)+(m*(m-1)/2);
    cout<<g;
    return 0;
}

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

using namespace std;

int main()
{
    int N, X;
    cin>>N>>X;
    vector<int> S(N);
    for (int &s: S)
        cin>>s;

    sort(S.begin(), S.end());

    long long M = 1000000007LL;
    vector<long long> T(X+1);
    for (int i=0; i<=X; i++)
        T[i] = i;
    for (int i=0; i<N; i++)
    {
        vector<long long> P = T;
        T = vector<long long>(X+1);
        for (int j=0; j<=X; j++)
            T[j] = (P[j]*i + P[j%S[i]]) % M;
    }
    cout<<T[X]<<endl;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/27  Problem: ABC 111 A / Link: http://abc111.contest.atcoder.jp/tasks/abc111_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

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


	LL ans = 0;
	LL N; cin >> N;
	ans = 1110 - N;


	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ll  long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define MAX_N 10005
using namespace std;
// int dx[4] = {1,-1,0,0};
// int dy[4] = {0,0,1,-1};
ll dp[MAX_N][100][2];

ll getSum(string &num, ll pos, ll sum, bool flag, ll D){
    if(pos==num.length()){
        return sum==0;
    }
    if(dp[pos][sum][flag]!=-1)
        return dp[pos][sum][flag];
    ll limit = 9;
    if(flag)
        limit = num[pos]-'0';
    ll ans = 0;
    repA(i,0,limit){
        ans += getSum(num, pos+1, (sum+i)%D, flag&&i==limit,D);
        ans%=mod;
    }
    return dp[pos][sum][flag] = ans;
}


void solve(){

    memset(dp, -1, sizeof(dp));

    string num;
    cin>>num;

    ll d;
    cin>>d;

    ll ans = (getSum(num, 0, 0, true,d)-1+mod)%mod;

    db1(ans);

}


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





Measured memory_bytes: 16896
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  for(int i;i<N;i++){
    cin>>A.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>B.at(i);
  }
  for(int i=0;i<N-1;i++){
    cin>>C.at(i);
  }
  int ans=B.at(0);
  for(int i=1;i<N;i++){
    ans=ans+B.at(i);
    if(A.at(i-1)+1==A.at(i)){
      ans=ans+C.at(A.at(i-1)-1);
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#coding : utf-8

import os
import sys

N = int(input())

if N < 10:
	print(N)

elif N < 100:
	print(9)

elif N < 1000:
	print(9 + N - 99)

elif N < 10000:
	print(9 + 999 - 99)

elif N < 100000:
	print(9 + 900 + N - 9999)

elif N == 100000:
	print(9 + 900 + 90000)


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

int main() {
	int N, K; cin >> N >> K;
	vector<ll> x(N), y(N);
	vector<P> xy(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
		xy[i] = P(x[i], y[i]);
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	ll ans = (x[N - 1] - x[0])*(y[N - 1] - y[0]);
	for (int x0 = 0; x0 < N - 1; x0++) {
		for (int x1 = x0 + 1; x1 < N; x1++) {
			for (int y0 = 0; y0 < N - 1; y0++) {
				for (int y1 = y0 + 1; y1 < N; y1++) {
					int cnt = 0;
					for (int i = 0; i < N; i++) {
						if (x[x0] <= xy[i].first && xy[i].first <= x[x1] && y[y0] <= xy[i].second && xy[i].second <= y[y1]) {
							cnt++;
						}
					}

					if (K <= cnt) {
						ans = min(ans, (x[x1] - x[x0])*(y[y1] - y[y0]));
					}
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,ans= 0;
    double avg,sum = 0;
    cin>>m;
    int a[m];
    
    for(int i=0;i<m;i++)
    {
        cin >>a[i];
        sum += a[i];
    }
    avg = round(sum/m);
    
    for(int i = 0;i<m;i++)
    {
        ans += (avg-a[i])*(avg-a[i]);
    }
    cout<<ans;
    return 0;
    
}

Measured memory_bytes: 256
# coding: utf-8
import sys


def main(argv=sys.argv):

    inputs_ = list(input())

    string_ = []

    for input_ in inputs_:

        if input_ == 'B':

            if not string_ == []:

                string_.pop(-1)

        else:

            string_.append(input_)

    print(''.join(string_))

    return 0


if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

typedef long long int ll;

int main() {
  ll a, b, c, k;
  ll ans;

  cin >> a >> b >> c >> k;

  if (k % 2 == 1) ans = b - a;
  else ans = a - b;
  
  if (ans > 10e18) cout << "Unfair" << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    vi v(999);
    int sum=0;
    for(int i=1; i<=999; i++) {
        sum+=i;
        v.at(i-1)=sum;
    }
    int a,b;
    cin>>a>>b;
    rep(i,998) {
        if(v.at(i)-a==v.at(i+1)-b) {
            cout<<v.at(i)-a<<endl;
        }
    }
}

Measured memory_bytes: 256
// Problem : D - Banned K
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << " | ";
	err(++it, args...);
}

const ll inf = 1e18;
const int nax = 1e5 + 5;

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	while (t--)
	{
		ll n;
		cin>>n;
		
		ll a[n];
		ll cnt[n+1] = {0};
		forn(i,0,n)
		{
			cin>>a[i];
			cnt[a[i]]++;
		}
			
		ll ans = 0;
		forn(i,1,n+1)
		{
			ans += (cnt[i]*(cnt[i]-1))/2;
		}
		ll orz = ans;
		forn(i,0,n)
		{
			ans -= (cnt[a[i]]*(cnt[a[i]]-1))/2;
			ans += ((cnt[a[i]]-1)*(cnt[a[i]]-2))/2;
			
			cout<<ans<<endl;
			ans = orz;
		}
	}

	return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int dist(int len, string a, string b)
{
    int neq = 0;
    for (int i = 0; i < len; ++i)
    {
        if (a.at(i) != b.at(i))
        {
            neq++;
        }
    }
    return neq;
}

int main()
{
    string S;
    string T;
    cin >> S;
    cin >> T;
    int len_S = S.length();
    int len_T = T.length();
    int d_min = len_T;
    for (int i = 0; i <= len_S - len_T; ++i)
    {
        d_min = min(d_min, dist(len_T, S.substr(i,len_T), T));
    }
    cout << d_min;
    return 0;
}

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

const int mo=int(1e9+7);
int h,w,a,b,fac[200010],ifac[200010],ans;

int qpow(int a,int b)
{
	int x=a;  a=1;
	while (b)
		{
			if (b&1)  a=1LL*a*x%mo;
			x=1LL*x*x%mo,b>>=1;
		}
	return a;
}

int C(int n,int m){return 1LL*fac[n]*ifac[m]%mo*ifac[n-m]%mo;}

void work()
{
	scanf("%d %d %d %d",&h,&w,&a,&b),fac[0]=1;
	for (int i=1; i<=h+w; i++)  fac[i]=1LL*fac[i-1]*i%mo;
	ifac[h+w]=qpow(fac[h+w],mo-2);
	for (int i=h+w; i; i--)  ifac[i-1]=1LL*ifac[i]*i%mo;
	ans=C(h+w-2,h-1);
	for (int i=1; i<=b; i++)
		ans=(ans+mo-1LL*C(h-a+i-2,i-1)*C(w-i+a-1,w-i)%mo)%mo;
	printf("%d",ans);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 1792
/*
                ******
		
        Author: Nguyen Phuc Chuong

                ******
*/

#include <bits/stdc++.h>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	if (s.back() == 's') {
		s += "es";
	} else {
		s += 's';
	}
	cout << s;
	return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 1 << 18;
const int MM = 1000000007;

vector<pii> G[MX];
ll L;

ll find_value(vector<pll> &B, ll v){
	auto it = lower_bound(B.begin(), B.end(), pll(L-v+1, -1));
	if( it == B.begin() ) return 1e18; --it;
	return it->second;
}

void dfs(int x, vector<pll> &S)
{
	if( G[x].empty() ){
		S.emplace_back(0ll, 0ll);
		return;
	}
	vector<pll> A, B, T;
	dfs(G[x][0].first, A);
	dfs(G[x][1].first, B);
	for(pll &c : A) c.first += G[x][0].second, c.second += G[x][0].second;
	for(pll &c : B) c.first += G[x][1].second, c.second += G[x][1].second;
	if( A.size() > B.size() ) swap(A, B);
	
	for(pll c : A){
		ll u = find_value(B, c.second), v = c.first;
		T.emplace_back(u, v);
		T.emplace_back(v, u);
	}
	sort(T.begin(), T.end());
	for(pll c : T){
		if( S.size() && S.back().second <= c.second ) continue;
		S.push_back(c);
	}
}

int main()
{
	int N;
	scanf("%d", &N);
	for(int i = 2; i <= N; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		G[a].emplace_back(i, b);
	}
	ll s = 0, e = 1e18;
	while(s <= e){
		L = (s+e) / 2;
		vector<pll> S;
		dfs(1, S);
		int ch = 0;
		for(pll c : S) if( c.first <= 1e17 && c.second <= 1e17 ) ch = 1;
		if( !ch ) s = L+1;
		else e = L-1;
	}swap(s, e);
	printf("%lld\n", e);
}


Measured memory_bytes: 21760
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;
using ll = long long;
 
int main() {
  int N;
  cin >> N;

  ll INF = pow(10, 18);
 
  ll A, ans = 1;
  bool zero = false, overflow = false;
  rep(i,0,N-1) {
    cin >> A;
    if (A == 0) zero = true;
    else if (INF / A < ans) overflow = true;
    ans *= A;
  }
 
  if (zero) cout << 0 << endl;
  else if (overflow) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
from fractions import gcd
a,b=map(int,input().split())
g=gcd(a,b)
l=[]
for i in range(2,int(g**0.5)+1):
  while g%i==0:
    l.append(i)
    g//=i
#print(l)
if g>1:
  l.append(g)
#print(l)
print(len(set(l))+1)

Measured memory_bytes: 5048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();

        int x = in.intNext(), n = in.intNext();
        HashSet<Integer> doNotInclude = new HashSet<>();
        for (int i = 0; i < n; i++) doNotInclude.add(in.intNext());

        int min = Integer.MAX_VALUE;
        int val = 0;
        for (int i = -101; i <= 101; i++) {
            if (!doNotInclude.contains(i) && Math.abs(x - i) < min) {
                min = Math.abs(x - i);
                val = i;
            }
        }
        out.println(val);

        out.close();
    }


    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}




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

int main(){
    int h,w;
    cin >> h >> w;
    char a[h][w];
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin >> a[i][j];
    while(true){
        bool change = 0;

        for(int i=0;i<h;i++){
            bool allw = true;
            for(int j=0;j<w;j++){
                if(a[i][j]=='#'){
                    allw = false;
                    break;
                }
            }
            if(allw){
                change = 1;
                for(int k=i+1;k<h;k++){
                    for(int j=0;j<w;j++)
                        a[k-1][j] = a[k][j];
                }
                h--;
                break;
            }
        }

        for(int j=0;j<w;j++){
            bool allw = true;
            for(int i=0;i<h;i++){
                if(a[i][j]=='#'){
                    allw = false;
                    break;
                }
            }
            if(allw){
                change = 1;
                for(int k=j+1;k<w;k++){
                    for(int i=0;i<h;i++)
                        a[i][k-1] = a[i][k];
                }
                w--;
                break;
            }
        }
        if(!change)
            break;
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
            cout << a[i][j];
        cout << endl;
    }
}

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

int main() {
  
  string s;
  cin >> s;
  
  if(s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi"){
    cout << "Yes";
  } else {
    cout << "No";
  }
  
}


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

int main(void){
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  if(x == w/2 && y == h/2) printf("%f %d\n", w*h/2, 1);
  else printf("%f %d\n", w*h/2, 0);
  return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_W = 100000, MOD = 1e9+7;
int H, W, A, B;

int fact[2*MAX_W], inverse_fact[2*MAX_W];

//整数a,bに対し、ax + by = gcd(a,b) を満たす整数x,y,gcd(a,b) を計算する
int extgcd(int a, int b, int& x, int& y) {
  int d = a;
  if (b != 0) {
    d = extgcd(b, a%b, y, x);
    y -= (a/b) * x;
  } else {
    x = 1; y = 0;
  }
  return d;
}

//ax ≡ gcd(a,m) (mod m) を満たすxを計算する。
int mod_inverse(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x%m) % m;
}

void init_fact(int n) {
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fact[i] = int((ll)fact[i-1] * (ll)i % MOD);
  }
}



void init_inverse(int n) {
  inverse_fact[0] = 1;
  for (int i = 1; i <= n; ++i) {
    inverse_fact[i] = mod_inverse(fact[i], MOD);
  }
}

void init(int n) {
  init_fact(n);
  init_inverse(n);
}

ll mod_comb(int n, int k) {
  return ((ll)fact[n] * (ll)inverse_fact[k] % MOD) * (ll)inverse_fact[n-k] % MOD;
}


int main() {
  cin >> H >> W >> A >> B;
  init(H+W-2);

  ll ans = 0;
  for (int i = B+1; i <= W; ++i) {
    (ans += mod_comb(H-A+i-2, i-1) * mod_comb(W+A-i-1, A-1)) %= MOD;
  }

  cout << ans << endl;

  return 0;
} 


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
	int a, b;
  	cin >> a >> b;
  	if ((a * b) % 2 == 0) {
    	cout << "Even" << endl;
    } else {
    	cout << "Odd" << endl;
    }
}



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

typedef long long ll;

ll N;
vector<ll> L;
ll R;
int main() {
  cin >> N;
  L.resize(N);
  for (ll i = 0; i < N; ++i) cin >> L[i];
  sort(L.begin(), L.end());
  for (ll i = 0; i < N; ++i)
    for (ll j = i + 1; j < N; ++j)
      for (ll k = j; k < N; ++k) {
        if (L[i] == L[j] || L[j] == L[k]) continue;
        if (L[i] + L[j] <= L[k]) continue;
        ++R;
      }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 3644
N,M,X = map(int, input().split())
a = list(map(int, input().split()))
b=0
c=0
for i in range(M):
    if a[i] < X:
        b = b + 1
    else:
        c = c + 1
if b > c:
    print(c)
else:
    print(b)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << setprecision(16);
    int a,b,c; cin >> a >> b >> c;
    int i = max(a,max(b,c));
    while(1){
        if(i*3 % 2 == (a+b+c) % 2){
            cout << (i*3-a-b-c) / 2 << endl;
            return 0;
        }
        i++;
    }
    return 0;
}

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

const int maxn = 1e5+22;
const int inf = 0x3f3f3f3f;
int a[maxn];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	int aim=a[n]/2;
	int b=lower_bound(a+1,a+1+n,aim)-a;
	int k=0;
	int ans=inf;
	int c[4];
	c[1]=0,c[2]=1,c[3]=-1;
	if(a[n]&1){
		for(int i=1;i<=3;i++){
			int now = b+c[i];
			if(now>=1&&now<n){
				if(a[now]>=aim+1){
					if(ans>a[now]-(aim+1)){
						ans=a[now]-(aim+1);
						k=now;
					}
				}else{
					if(ans>aim-a[now]){
						ans=aim-a[now];
						k=now;
					}
				}
			}
		}
	}else{
		for(int i=1;i<=3;i++){
			int now = b+c[i];
			if(now>=1&&now<n){
				if(ans>abs(aim-a[now])){
					ans=abs(aim-a[now]);
					k=now;
				}
			}
		}
	}
	printf("%d %d\n",a[n],a[k]);


	return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int[] x = new int[5];
        int ans = 0;
        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int i=0; i<5; i++){
            x[i] = sc.nextInt();
            for(int j=0; j<=130; j += 10){
                if(j>=x[i]){
                    list.add(j-x[i]);
                    break;
                }
            }
            ans += x[i];
        }
        Collections.sort(list);

        for(int i=0; i<4; i++){
            ans += list.get(i);
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 21844
N, M = map(int, input().split())
ba = []
for i in range(M):
  a, b = map(int, input().split())
  ba.append([b, a])

ba.sort()
removed_id = 0 # 取り除かれた橋の中で最も右の橋
ans = 0
for b, a in ba:
  if a >= removed_id:
    ans += 1
    removed_id = b

print(ans)

Measured memory_bytes: 20072
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int h,m,s,ss;
	scanf("%d",&ss);
	h=ss/3600;
	ss=ss%3600;
	m=ss/60;
	s=ss%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}


Measured memory_bytes: 1020