akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int M, D, cnt = 0;
  cin >> M >> D;
  for (int m = 1; m <= M; m++)
  {
    for (int d = 1; d <= D; d++)
    {
      int d1 = d % 10;
      int d10 = d / 10;
      if (m == d1 * d10 && d1 >= 2 && d10 >= 2)
        cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Maxn 707
using namespace std;
int n,m;
bool g[Maxn][Maxn];
int c[Maxn];
bool f[Maxn][Maxn];
int now1=0,now2=0;
bool flag=true;
void dfs(int u,int col)
{
	c[u]=col;
	if (col==1) ++now1; else ++now2;
	for (int i=1;i<=n;i++)
		if (!g[u][i])
		{
			if (c[i]==-1) dfs(i,3-col);
			else if (c[i]==col) flag=false;
		}
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		g[a][b]=1;
		g[b][a]=1;
	}
	for (int i=1;i<=n;i++)
		g[i][i]=1;
	memset(c,-1,sizeof(c));
	f[0][0]=1;
	int pos=0;
	for (int i=1;i<=n;i++)
		if (c[i]==-1)
		{
			++pos;
			now1=0,now2=0;
			dfs(i,1);
			for (int j=0;j<=n;j++)
			{
				f[pos][j+now1]|=f[pos-1][j];
				f[pos][j+now2]|=f[pos-1][j];
			}
			if (!flag)
			{
				printf("%d\n",-1);
				return 0;
			}
		}
	int ans=700*700*2;
	for (int i=0;i<=n;i++)
		if (f[pos][i]&&f[pos][n-i]) ans=min(ans,(i*(i-1))/2+((n-i)*(n-i-1))/2);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <complex>
using namespace std;
typedef complex<double> P;
double cross(P a, P b) {return (a.real() * b.imag() - a.imag() * b.real());}
int main(){
  char z;
  double p,q,r,s,t,u,v,w;
  P a,b,c,d;
  while(cin>>p>>z>>q>>z>>r>>z>>s>>z>>t>>z>>u>>z>>v>>z>>w){
  a = P(p,q);b = P(r,s);c = P(t,u);d = P(v,w);
  if ((cross(b-a,c-a)*cross(d-a,c-a))<0&&(cross(a-b,d-b)*cross(c-b,d-b))<0)cout<<"YES"<<endl;
  else cout << "NO" << endl;}
}

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

int main()
{
  long long result;
  long long a,b,c,d;
  cin >> a >> b >> c >> d;
  long long A[4];
  A[0] = a*c;
  A[1] = a*d;
  A[2] = b*c;
  A[3] = b*d;
  sort(A,A+4);
  result = A[3];
  cout << result << endl;
}

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

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long double dp[3005][3005];
    long double arr[3005];
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    dp[1][1]=arr[1];
    dp[1][0]=(1-arr[1]);
    for(int i=2;i<=n;i++)
    {
        dp[i][0]=(dp[i-1][0]*(1-arr[i]));
        for(int j=1;j<=i;j++)
            dp[i][j]=(dp[i-1][j]*(1-arr[i])) + (dp[i-1][j-1]*arr[i]);
        dp[i][i+1]=0;
    }
    long double ans=0;
    for(int i=(n/2)+1;i<=n;i++)
        ans+=dp[n][i];
    std::cout << std::setprecision(10) << ans;

}


Measured memory_bytes: 85636
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a,b,c;
  cin>>a>>b>>c;
  
  char d=a.at(0),e=b.at(0),f=c.at(0);
   d,e,f;
  char rr=d-32,ee=e-32,ff=f-32;
  cout<<rr<<ee<<ff;
  
  return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector< vector<long long> > dp(110, vector<long long>(10100, 0));

int n, W;
struct vwdata {
    int v; int w;
};

int main() {
    cin >> n >> W;
    vector<vwdata> vw(n);
    for(int i = 0; i < n; ++i) {
        cin >> vw.at(i).v >> vw.at(i).w;
    }

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= W; ++j) {
            if(j-vw.at(i).w >= 0) {
                chmax(dp[i+1][j], dp[i][j-vw.at(i).w]+vw.at(i).v);
            }
            chmax(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[n][W] << endl;
}


Measured memory_bytes: 11440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll K,ans=0;

ll gcd(ll x,ll y){
	if(y==0)
		return x;
	return gcd(y,x%y);
}

int main(){
	ll i,j,k;
	cin>>K;
	for(i=1;i<=K;++i)
		for(j=1;j<=K;++j)
			for(k=1;k<=K;++k){
				ans+=gcd(gcd(i,j),k);
			}
	cout<<ans;
	
	
	return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdlib>
using namespace std;
const long long int mod = 1000000007;
char ch[4][100];
int n;
long long int ans;
int main(){
    scanf("%d%s%s",&n,ch[1],ch[2]);
    int rem = 0;
    int i = 0;
    if(ch[1][0] == ch[2][0]){
        rem = 1;
        ans = 3;
        i ++;
    }
    else{
        rem = 2;
        ans = 6;
        i += 2;
    }
    for( ; i < n; i ++){
        if(ch[1][i] != ch[2][i]){
            if(rem == 1)
                ans *= 2;
            else
                ans *= 3;
            i ++;
            rem = 2;
        }
        else{
            
            if(rem == 1)
                ans *= 2;
            rem = 1;
        }
        ans %= mod;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 128
#include "iostream"
#include "cstdio"
#include "map"
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	int flag=0;
	map<int,int>mp;
	for(int i=1;;i++)
	{
		int t=a*i;
		int mod=t%b;
		if(mod==(c%b)){
			break;
		}
		if(mp[mod]){
			flag=1; break;
		}
		mp[mod]=1;
	}
	if(!flag)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}

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

int main(){
    ll n;
    cin >> n;
    ll ans=0;
    vector<ll> v(5,0);
    for(ll i=0;i < n;i++)
    {
        string s;
        cin>> s;
        if(s.at(0)=='M'){
            v.at(0)++;
        }else if(s.at(0)=='A'){
            v.at(1)++;
        }else if(s.at(0)=='R'){
            v.at(2)++;
        }else if(s.at(0)=='C'){
            v.at(3)++;
        }else if(s.at(0)=='H'){
            v.at(4)++;
        }
    }

    for(ll i=0;i < 3;i++)
    {
        for(ll j=i+1;j < 4;j++)
        {
            for(ll k=j+1;k < 5;k++)
            {
                ans += v.at(i)*v.at(j)*v.at(k);
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define reps(i, s, n) for (int i = s; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define repsl(i, s, n) for (ll i = s; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl
#define readVarll(nam) ll nam; cin >> nam
struct UniFind{
  ll value;
  UniFind* root;

  UniFind()
  {
    value = -1;
    root = NULL;
  }
  UniFind(ll val)
  {
    value = val;
    root = NULL;
  }

  UniFind* getRoot()
  {
    if(root == NULL)
    {
      return this;
    }
    else
    {
      return (root = root->getRoot());
    }
  }

  ll getRank()
  {
    if(root == NULL) return 1;
    else return root->getRank() + 1;
  }

  void merge(UniFind* target)
  {
    if(target->getRoot()->value == this->getRoot()->value) return;
    if(target->getRank() > this->getRank())
    {
      this->getRoot()->root = target;
    }
    else
    {
      target->getRoot()->root = this;
    }
  }
};

int main()
{
  ll n, m;
  cin >> n >> m;
  UniFind mydata[n];
  rep(i, n)
  {
    mydata[i] = UniFind(i);
  }

  rep(i, m)
  {
    ll a,b;
    cin >> a >> b;
    a--; b--;

    mydata[a].merge(&mydata[b]);
  }

  ll cnt[n];
  rep(i,n)
  {
    cnt[i] = 0;
  }

  rep(i, n)
  {
    cnt[mydata[i].getRoot()->value]++;
  }

  ll ans = -1;
  rep(i, n)
  {
    ans = max(ans, cnt[i]);
  }

  cout << fixed << ans << endl;

  return 0;
}

Measured memory_bytes: 8256
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;

int main(){

  int n, m;
  cin >> n >> m;

  atcoder::dsu d(n);
  int res = n-1;

  for(int i = 0; i < m; ++i){
    int a, b;
    cin >> a >> b;
    --a; --b;
    if(!d.same(a, b)){
      --res;
      d.merge(a, b);
    }
  }
  cout << res << '\n';

  return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int sum=0;
    for(int i=1;i<n-1;i++){
      sum+=a[i];
    }
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}



Measured memory_bytes: 3156
function main(input) {
    new Main(input).walk();   
}
  
var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    input += chunk;
});
process.stdin.on('end', function() {
    main(input);
});
var tmp = `6
5 2 4 6 1 3`
class Main{
    constructor(input){
        var splits = input.split("\n");
        this.N = Number(splits[0]);
        this.list = splits[1].split(" ").map(v=>Number(v));
    }
    walk(){
        for(var i=1; i < this.N; i++){
            console.log(this.list.join(" "));
            var v = this.list[i];
            var j = i - 1;
            while(j >= 0 && this.list[j] > v){
                this.list[j+1] = this.list[j]
                j--;
            }
            this.list[j+1] = v;
        }
        console.log(this.list.join(" "));
    }
}
// new Main(tmp).walk();


Measured memory_bytes: 16704
#include<cstdio>
#include<iostream>
using namespace std;
char c;
int main()
{
	scanf("%c",&c);
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
	{
		printf("vowel\n");
	}
	else
	{
		printf("consonant\n");
	}
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main(){
	int n,l,i,j,k;
	char s[200][200];
	char temp[200];
	scanf("%d %d",&n,&l);
	getchar();
	for(i=0;i<n;i++)
		scanf("%s",s[i]);
	for(i=0;i<n-1;i++)
		for(j=i+1;j<n;j++)
			if(strcmp(s[i],s[j])>0){
				strcpy(temp,s[i]);
				strcpy(s[i],s[j]);
				strcpy(s[j],temp);
			}
	for(i=0;i<n;i++){
		printf("%s",s[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
// heeeyyyy Mooortyyyyyy!!
#include <bits/stdc++.h>
#include <chrono>
#include <random>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#define rep(i,n) for(ll i = 0; i < n; ++i)
#define ed end()  
#define bg begin()
# define ld long double
#define ll long long
#define ub(v,a) upper_bound(all(v),a)
#define lb(v,a) lower_bound(all(v),a)
#define sz(a) (int)(a.size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tr(v,it) for(auto it=v.begin();it!=v.end();it++)
#define present(v,x) (v.find(x)!=v.end()) //set/map etc.
#define vpresent(v,x) (find(all(v),x)!=v.end()) // vector
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
typedef vector< long long > vll;
typedef vector<pair<ll,ll>> vp;
typedef vector< vll > vvll;
typedef pair< int,int > pi;
const long long max_sz = 1e5 + 1;
const long long mod = 1e9 + 7;
const long long MAXN = 4e18 + 1;
const int N=500023;
#define PI 3.1415926535897932384626
char flip(char k){ if(k=='0') return '1'; return '0'; }
ll sum_digit(ll n){ ll a=0,i; for(i=n;i>0;i=i/10){ a+=(i%10);} return a; }
ll gcd(ll a, ll b){if(b == 0) return a;return gcd(b, a%b);}
bool isPowerOfTwo(int n){if(n==0)return false;return (ceil(log2(n)) == floor(log2(n)));}
//DEBUGGING
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
const int LG = 20;
//__builtin_popcount(n) -> returns number of set bits in n
ll expo(ll a, ll b, ll m); // a^(b) %m
//=======================

//vector<bool> vis;vis.assign(n,false); g.assign(n,{});
//vector<vll> g;
//void ipgraph(ll m){ll  u, v;while(m--){cin>>u>>v; u--, v--;g[u].pb(v);g[v].pb(u);}}
//ll lvl[N], p[N][LG];
//ll lca(ll u,ll v){if(lvl[u]<lvl[v])swap(u,v);ll i,lg; for(lg=0;(1<<lg)<=lvl[u];lg++);lg--;for(i=lg;i>=0;i--){if(lvl[u]-(1<<i)>=lvl[v]){u=p[u][i];}}if(u==v)return v;else{for(i=lg;i>=0;i--){if(p[u][i]!=-1 && p[u][i]!=p[v][i]){u=p[u][i];v=p[v][i];}}}return p[u][0];}

void solve(){
    ll i, j, n, m,k,x,y;
    cin>>n;
    vll a(n);rep(i,n)cin>>a[i];
    ll chair=0;
    for(ll i=1;i<n;i++){
        if(a[i]<a[i-1]){
            chair+=a[i-1]-a[i];  a[i]=a[i-1];
        }  
    }
    cout<<chair<<endl;
}

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


ll expo(ll a, ll b, ll m) 
{ 
    if (b == 0)return 1; 
    ll p = expo(a, b / 2, m) % m; 
    p = (p * p) % m; 
  
    return (b % 2 == 0) ? p : (a * p) % m; 
} 

Measured memory_bytes: 4856
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont,from,to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

using namespace std;
typedef long long ll;
typedef long double ld;
int N;
int main() {
    cin >> N;
    if (N<=2) cout<<0<<endl;
    else cout << (N-1)/2<< endl;

    return 0;
}


Measured memory_bytes: 384
n=input()
for _ in [0]*n:
  i=0
  b=0
  c=0
  while i<3:
    s=raw_input()[1]
    if s=='I':
      if b==3:c+=1
      else: b+=1
    elif s=='O':
      c+=b+1
      b=0
    elif s=='U':i+=1
  print c

Measured memory_bytes: 4212
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, A: int, B: int, C: int, l: "List[int]"):
    e = [A, B, C]

    ret = float('inf')
    for i in range(4 ** N):
        ls = [0, 0, 0, 0]
        cs = [0, 0, 0, 0]
        for j, ll in enumerate(l):
            key = (i >> (2 * j)) & 0x03
            ls[key] += ll
            cs[key] += 10

        if cs[0] == 0 or cs[1] == 0 or cs[2] == 0:
            continue

        for i0, i1, i2 in permutations([0, 1, 2], 3):
            cc = cs[0] + abs(e[i0] - ls[0]) - 10
            cc += cs[1] + abs(e[i1] - ls[1]) - 10
            cc += cs[2] + abs(e[i2] - ls[2]) - 10
            if cc < ret:
                ret = cc
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    l = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, A, B, C, l)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5508
#include<iostream>
#include<vector>
using namespace std;
#define MAX_COST 4000
struct Data{
  int a,b,c;
};

Data data[40];

int dp[40][400][400];

int main(){
  int N,Ma,Mb;

  cin>>N>>Ma>>Mb;
  for(int i=0;i<N;i++){
    Data &d=data[i];
    cin>>d.a>>d.b>>d.c;
  }
  int max_a=0,max_b=0,ac,bc;

  for(int i=0;i<N;i++){
    Data &d=data[i];
    if(dp[i][d.a][d.b]==0||dp[i][d.a][d.b]>d.c){
      dp[i][d.a][d.b]=d.c;
    }
    for(int a=1;a<=max_a;a++)
      for(int b=1;b<=max_b;b++)
	if((bc=dp[i-1][a][b])>0){
	  if(dp[i][a][b]==0||bc<dp[i][a][b])
	    dp[i][a][b]=bc;
	  if((ac=dp[i][a+d.a][b+d.b])==0||bc+d.c<ac)
	    dp[i][a+d.a][b+d.b]=bc+d.c;
	}
    max_a+=d.a;
    max_b+=d.b;
  }
  int ans = MAX_COST;
  for(int i=1;i*Ma<=400&&i*Mb<=400;i++){
    if (dp[N-1][i*Ma][i*Mb]!=0&&dp[N-1][i*Ma][i*Mb]<ans)
      ans = dp[N-1][i*Ma][i*Mb];
  }
  if (ans == MAX_COST)
    cout<< "-1"<<endl;
  else
    cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 8448
using System;
using System.Linq;
using System.Collections.Generic;


namespace ABC127_1
{
    class A
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = a[0];
            var B = a[1];

            if (13 <= A) Console.WriteLine(B);
            else if (6 <= A && A <= 12) Console.WriteLine(B / 2);
            else Console.WriteLine(0);
        }
    }
}


Measured memory_bytes: 11220
using System.Collections.Generic;
using System.Linq;
using System;
class Program
{
	static HashSet<int>[] Edge;

	static void Main()
	{
		var firstLine = Console.ReadLine();
		string[] splitedLine = firstLine.Split(' ');
		int maxIsland = int.Parse(splitedLine[0]);
		int maxBridge = int.Parse(splitedLine[1]);

		Edge = Enumerable.Range(0, maxIsland).Select(i => new HashSet<int>()).ToArray();
		for (int i = 0; i < maxBridge; i++)
		{
			string[] inputsStr = Console.ReadLine().Split(' ');
            int[] inputs = new int[2];
			inputs[0] = int.Parse(inputsStr[0]);
			inputs[1] = int.Parse(inputsStr[1]);
            //Console.WriteLine("inputs[0]: " + inputs[0]);
            //Console.WriteLine("inputs[1]: " + inputs[1]);
            Edge[inputs[0]-1].Add(inputs[1]);
            Edge[inputs[1]-1].Add(inputs[0]);
		}
        bool isPossible = false;
        foreach(var items in Edge[0]){
            foreach(var item in Edge[items-1]){
				//Console.WriteLine("item: " + item);
				//Console.WriteLine("n: " + maxIsland);
                if (item == maxIsland){
                    //Console.WriteLine("Match!");
                    isPossible = true;
                    break;
                }
            }
        }
        if(isPossible){
            Console.WriteLine("POSSIBLE");
        }else{
            Console.WriteLine("IMPOSSIBLE");
        }
    }
}

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

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  
  for (int i = min(a, b); i > 0; i--) {
    if (a % i == 0 && b % i == 0) {
      k--;
    }
    if (k == 0) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/arc081/tasks/arc081_a
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int N;
    scanf("%d", &N);
    vector<ll> A(N);
    REP(i, N) scanf("%lld", &A[i]);
    sort(A.begin(), A.end(), greater<ll>());
    ll ans = -1;
    for (int i = 0; i < N; ++i)
    {
        if (i < N - 3 && A[i] == A[i + 1] && A[i] == A[i + 2] && A[i] == A[i + 3])
        {
            if (-1 == ans)
                ans = A[i] * A[i];
            else
                ans *= A[i];
            printf("%lld\n", ans);
            return 0;
        }
        else if (i < N - 2 && A[i] == A[i + 1] && A[i] == A[i + 2])
        {
            if (-1 == ans)
            {
                ans = A[i];
                i += 2;
                continue;
            }
            else
            {
                ans *= A[i];
                printf("%lld\n", ans);
                return 0;
            }
        }
        else if (i < N - 1 && A[i] == A[i + 1])
        {
            if (-1 == ans)
            {
                ans = A[i];
                i += 1;
                continue;
            }
            else
            {
                ans *= A[i];
                printf("%lld\n", ans);
                return 0;
            }
            
        }
        else
        {
            continue;
        }
        

    }
    printf("0\n");
    return 0;
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int m, d;
  cin >> m >> d;

  int ans = 0;
  for ( int i = 1; i <= m; i++ ) {
    for ( int j = 1; j <= d; j++ ) {
      int a = j%10;
      int b = j/10;
      if ( a >= 2 && b >= 2 && a*b == i ) ans++;
    }
  }

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


Measured memory_bytes: 256
def m():
    d = {1: 0, 2: 0, 3: 0, 4: 0}
    for _ in range(3):
        a, b = map(int, input().split())
        d[a] +=1
        d[b] +=1

    cnt1 = 0
    cnt2 = 0
    for k,v in d.items():
        if v == 1:
            cnt1 += 1
            continue

        if v == 2:
            cnt2 += 1
            continue
        return "NO"
    if cnt1 == 2 and cnt2 == 2:
        return "YES"
    else:
        return "NO"
print(m())


Measured memory_bytes: 3064
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1].to!long;
    auto G = new int[][](N);
    foreach (i; 0..N-1) {
        s = readln.split.map!(to!int);
        G[s[0]-1] ~= s[1]-1;
        G[s[1]-1] ~= s[0]-1;
    }


    auto f = new long[](N);
    auto l = new long[][](N);
    auto r = new long[][](N);
    auto g = new long[](N);

    long dfs1(int n, int p) {
        long[] a;
        f[n] = 1;
        foreach (m; G[n]) {
            if (m == p) continue;
            auto v = dfs1(m, n) + 1;
            f[n] = f[n] * v % M;
            a ~= v;
        }

        l[n] = new long[](a.length+1);
        r[n] = new long[](a.length+1);
        l[n][0] = r[n][a.length] = 1;

        foreach (i; 0..a.length.to!int) {
            l[n][i+1] = l[n][i] * a[i] % M;
        }

        foreach_reverse (i; 0..a.length.to!int) {
            r[n][i] = r[n][i+1] * a[i] % M;
        }

        return f[n];
    }


    void dfs2(int n, int p, long pv) {
        if (p == -1) {
            g[n] = f[n];
        } else {
            g[n] = f[n] * pv % M;
        }

        int i = 0;
        foreach (m; G[n]) {
            if (m == p) continue;
            dfs2(m, n, l[n][i] * r[n][i+1] % M * pv % M + 1);
            i += 1;
        }
    }


    dfs1(0, -1);
    dfs2(0, -1, 1);
    g.each!writeln;
}


Measured memory_bytes: 24828
N,M=map(int,input().split())
a=[];b=[]
for i in range(N):
    ai,bi=map(int,input().split())
    a.append(ai);b.append(bi)
c=[];d=[]
for j in range(M):
    cj,dj=map(int,input().split())
    c.append(cj);d.append(dj)
for i in range(N):
    ind=0;dis=10**9
    for j in range(M):
        if abs(a[i]-c[j])+abs(b[i]-d[j])<dis:
            ind=j;dis=abs(a[i]-c[j])+abs(b[i]-d[j])
    print(ind+1)

Measured memory_bytes: 39536
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int A = sc.nextInt();
        int count = 0;

        while (H > 0) {
            H -= A;
            count++;
            if (H < 0) {
                break;
            }
            
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

const int N = 222222;
int l[N], r[N];
string s;
int n, k, c;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k >> c >> s;
    int wait = 0;
    rep(i, 1, n) {
        if(s[i - 1] == 'o') {
            if(!wait) {
                l[i] = l[i - 1] + 1;
                wait = c + 1;
            } else {
                l[i] = l[i - 1];
            }
        } else {
            l[i] = l[i - 1];
        }
        if(wait) {
            wait--;
        }
    }
    rrep(i, 1, n) {
        if(s[i - 1] == 'x') {
            r[i] = r[i + 1];
        } else {
            int ni = min(n + 1, i + c + 1);
            r[i] = max(r[i + 1], r[ni] + 1);
        }
    }
    if(l[n] == k) {
        rep(i, 1, n) {
            if(s[i - 1] == 'o' && l[i - 1] + r[i + 1] < k) {
                cout << i << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 5012
n = int(input())
P = list(map(int, input().split()))
N = sorted(P)
if N == P:
  print('YES')
else:
  c = 0
  for i in range(0,n):
    if N[i] - P[i] != 0:
      c += 1
  if c == 2:
    print('YES')
  else:
    print('NO')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "trace.h"
#else
#define trace(args...)
#endif

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()

void solve(int test) {
    int n;
    cin >> n;
    if (n >= 30)
        cout << "Yes\n";
    else
        cout << "No\n";
}

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


Measured memory_bytes: 3616
#include<stdio.h>
int main()
{
	char a,b;
	scanf("%c",&a);
	getchar();
	scanf("%c",&b);
	if(a=='H')
	{
		if(b=='H')
		printf("H");
		else
		printf("D");
	}
	else
	{
		if(b=='D')
		printf("H");
		else
		printf("D");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<limits.h>

int main(void) {
    int size, i, j, min=INT_MAX, max_dif=INT_MIN, dif;
    scanf("%d", &size);
    
    int data[size];
    scanf("%d", &data[0]);
    
    min = data[0];
    for(i=1; i<size; i++) {
        scanf("%d", &data[i]);
        
        dif = data[i] - min;
        if(dif > max_dif) max_dif = dif;

        if(min > data[i]) min = data[i];
        
    }
    
    printf("%d\n", max_dif);
    
    return 0;
}

Measured memory_bytes: 1376
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val s = sc.next()

  println(agc037a(s))
}

private fun agc037a(s: String): Int {
  var ans = 1
  var pre = s.get(0).toString()
  var now = ""
  for (i in 1 until s.length) {
    now += s.get(i)
    if (now != pre) {
      ans++
      pre = now
      now = ""
    }
  }

  return ans
}


Measured memory_bytes: 41524
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(void){
    int n, a[100005], b[100005], c[100005];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];

    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);

    ll ans = 0;
    for (int i = 0; i < n; i++){
        ans += (lower_bound(a, a + n, b[i]) - &a[0])*(&c[n] - upper_bound(c, c + n, b[i]));
    }

    cout << ans << endl;

}

Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
    long long a[100];
    int n;
    scanf("%d",&n);
    a[0]=2;
    a[1]=1;
    for(int i=2; i<=n; i++)
    {
        a[i]=a[i-1]+a[i-2];
    }
    printf("%lld\n",a[n]);
    return 0;
}

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

int main() {
  int s;
  cin>>s;
  vector<int>vec(10000);
  int tmp=s;
  vec.at(0)=s;
  for(int i=0;i<9999;i++){
    
    if(vec.at(i)==4||vec.at(i)==2||vec.at(i)==1){
      cout<<i+4<<endl;
      break;
    }
    tmp=vec.at(i);
    if(tmp%2==0)
      vec.at(i+1)=tmp/2;
    else
      vec.at(i+1)=3*tmp+1;

  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,A[100];
int dp[100][205];
signed main(){
	cin>>N;
	rep(i,N)cin>>A[i];
	int Zero=1000;
	rep(i,N){
		rep(j,201){
			chmax(dp[i+1][j],dp[i][j]);
			chmax(Zero,j+A[i]*dp[i][j]);
		}
		chmax(dp[i+1][Zero%A[i]],Zero/A[i]);
	}
	cout<<Zero<<endl;
}

Measured memory_bytes: 3696
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <unordered_map>

using namespace std;

template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}

template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}

template<class T>
vector<T> reads(size_t n)
{
    vector<T> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(read<T>());
    });
    return a;
}

int main()
{
    size_t N,M;
    cin >> N;
    auto s = reads<string>(N);
    cin >> M;
    auto t = reads<string>(M);
    
    unordered_map<string, int> ct;
    
    for(const auto& x : s){ ct[x]++; }
    for(const auto& x : t){ ct[x]--; }
    
    auto m = max_element(begin(ct), end(ct), [](const auto& x, const auto& y){ return x.second < y.second; });
    
    cout << max(0, m->second) << '\n';

    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main(){
    const ll c = 1000000007;
    int N, M;
    cin >> N >> M;
    vector<ll> dp(N+1, 1);
    for(int i=0; i<M; i++) {
        int broken;
        cin >> broken;
        dp[broken] = 0;
    }
    for(int i=2; i<=N; i++) {
        if(dp[i] == 0) continue;
        dp[i] = (dp[i-1] + dp[i-2]) % c;
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 4012
'use strict'

function main(input) {


    input = input.split(/\n|\s/)//.map(v => ~~v)
    const a = ~~input[0]
    const b = ~~input[1]
    const s = input[2]

    let ans = 'No'
    if (s.slice(0, a).match(/^[0-9]+$/) &&
        s[a] === '-' &&
        s.slice(a + 1, a + 1 + b).match(/^[0-9]+$/)) {

        ans = 'Yes'
    }

    console.log(ans)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>

using namespace std;
using ll = long long;

// inf
const ll infl = 1LL << 60;
const int inf = 1 << 30;

ll gcd(ll a, ll b) {
    if (b > a) swap(a, b);
    return a % b != 0LL ? gcd(b, a % b) : b;
}

int main() {
    int N; cin >> N;
    ll ans;
    cin >> ans;
    for (int i = 0; i < N - 1; ++i) {
        ll a; cin >> a;
        ans = gcd(ans, a);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll N; cin >> N;
    vector<ll> a(N+1);
    rep(i,N) cin >> a[i];
    a[N] = a[0];

    vector<ll> b(N);
    rep(i,N) b[i] = a[i+1] - a[i];

    ll target = *max_element(all(b));
    vector<ll> c(N);
    rep(i,N){
        if((target - b[i])%N){
            cout << "NO" << endl;
            return 0;
        }
        c[i] = (target - b[i]) / N;
    }


    ll p = a[0];
    ll p2 = a[1];
    rep(i,N){
        p -= (N-i) * c[i];

        ll t = (N-i+1)%N;
        if(t==0) t=N;
        p2 -= c[i] * t;
    }
    debug(p);
    debug(p2);

    ll sum = N * (N+1) / 2;
    if(p<0 || (p%sum>0)){
        cout << "NO" << endl;
        return 0;
    }

    cout << "YES" << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int MAXN=200010;
int n,m,a[2*MAXN],b[MAXN],c[2*MAXN],d[MAXN],nx[MAXN],bl[MAXN],ans[MAXN];
int main () {
    scanf("%d",&n);
    for (int i=1;i<=n;i++) {scanf("%d",&a[i]);}
    for (int i=1;i<=n;i++) {scanf("%d",&b[i]);}
    for (int i=n+1;i<=n+n;i++) {a[i]=a[i-n];}
    m=n;
    n=m+m; 
    for (int ii=0;ii<30;ii++) {
        memset(bl,0,sizeof(bl));
        int tmp1=0,tmp2=0,flg=0;
        for (int j=1;j<=n;j++) {c[j]=((a[j]>>ii)&1);tmp1+=c[j]*(j<=m);}
        for (int j=1;j<=m;j++) {d[j]=((b[j]>>ii)&1);tmp2+=d[j];}
        if (tmp1==tmp2) {
            nx[1]=0;
            for (int i=2,j=0;i<=m;i++) {
                while (j>0&&d[i]!=d[j+1]) {j=nx[j];}
                if (d[i]==d[j+1]) {j++;}
                nx[i]=j;
            }
            for (int i=1,j=0;i<=n;i++) {
                if (j==m) {j=nx[j];}
                while (j>0&&c[i]!=d[j+1]) {j=nx[j];}
                if (c[i]==d[j+1]) {j++;}
                if (i>=m&&j!=m) {bl[i-m]++;}
            }
            flg=1;
        }
        if (m-tmp1==tmp2) {
            for (int j=1;j<=m;j++) {d[j]^=1;}
            nx[1]=0;
            for (int i=2,j=0;i<=m;i++) {
                while (j>0&&d[i]!=d[j+1]) {j=nx[j];}
                if (d[i]==d[j+1]) {j++;}
                nx[i]=j;
            }
            for (int i=1,j=0;i<=n;i++) {
                if (j==m) {j=nx[j];}
                while (j>0&&c[i]!=d[j+1]) {j=nx[j];}
                if (c[i]==d[j+1]) {j++;}
                if (i>=m&&j!=m) {bl[i-m]++;}
            }
            flg=1;
        }
        if (!flg) {
            return 0;
        }
        if (tmp1==tmp2&&m-tmp1==tmp2) {
            for (int j=0;j<=m;j++) {
                if (bl[j]==2) {ans[j]=1;}
            }
        } else {
            for (int j=0;j<=m;j++) {
                if (bl[j]==1) {ans[j]=1;}
            }
        }
    }
    for (int i=0;i<m;i++) {
        if (!ans[i]) {printf("%d %d\n",i,a[i+1]^b[1]);}
    }
    return 0;
}

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

using namespace std;
typedef pair<int, int> P;

int main(void) {
  int w, h;
  while (cin >> w >> h, w) {
    vector<string> a(h);
    for (int i = 0; i < h; i++) {
      cin >> a[i];
    }

    bool white[51][51] = {}, black[51][51] = {};
    int di[] = {0, -1, 0, 1}, dj[] = {1, 0, -1, 0};
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (a[i][j] == 'W') {
          queue<P> que;
          que.push(P(i, j));

          while (!que.empty()) {
            P p = que.front(); que.pop();
            int ci = p.first, cj = p.second;
            for (int k = 0; k < 4; k++) {
              int ni = ci + di[k], nj = cj + dj[k];
              if (ni >= 0 && ni < h && nj >= 0 && nj < w && a[ni][nj] != 'B' && white[ni][nj] == false) {
                que.push(P(ni, nj));
                white[ni][nj] = true;
              }
            }
          }
        } else if (a[i][j] == 'B') {
          queue<P> que;
          que.push(P(i, j));
          while (!que.empty()) {
            P p = que.front(); que.pop();
            int ci = p.first, cj = p.second;
            for (int k = 0; k < 4; k++) {
              int ni = ci + di[k], nj = cj + dj[k];
              if (ni >= 0 && ni < h && nj >= 0 && nj < w && a[ni][nj] != 'W' && black[ni][nj] == false) {
                que.push(P(ni, nj));
                black[ni][nj] = true;
              }
            }
          }
        }
      }
    }

    int ans_w = 0, ans_b = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (black[i][j] && white[i][j]) continue;
        if (a[i][j] == '.' && black[i][j]) ans_b++;
        if (a[i][j] == '.' && white[i][j]) ans_w++;
      }
    }

    cout << ans_b << " " << ans_w << endl;
  }

  return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  cin >>n;
  cin.ignore();
  while(n--){
    string s;
    getline(cin,s);
    for(;;){
      string::size_type x = s.find("Hoshino");
      if(x == string::npos){break;}
      s[x+6] = 'a';
    }
    cout <<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  ll ans = 1e13;
  for(ll i = 1; i*i <= N; i++){
    if(N%i == 0){
      ans = min(ans, (i-1)+(N/i-1));
    }
  }
  cout << ans << endl;
}

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

int head[maxn],cnt,vis[maxn];ll cnt1,cnt2,n,m;

struct edge{
	int to,nxt;
}e[maxn<<1];

void add(int u,int v){
	e[++cnt]=(edge){v,head[u]};
	head[u]=cnt;
}

void dfs(int u,int fa,int col){
	if(!vis[u]) vis[u]=col;
	else {
		if(vis[u]!=col){
			printf("%lld",(n-1)*n/2-m);
			exit(0);
		}
		return ;
	}
	col&1?cnt1++:cnt2++;
	for(int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		if(v==fa) continue;
		dfs(v,u,(col&1)+1);
	}
}

int main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1,u,v;i<=m;i++){
		scanf("%d%d",&u,&v);
		add(u,v);add(v,u);
	}
	dfs(1,0,1);
	printf("%lld",cnt1*cnt2-m);
}

Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

int main() {
	long long Q, H, S, D, N; std::cin >> Q >> H >> S >> D >> N;
	long long small = std::min({ Q * 4, H * 2, S});
	std::cout << std::min((N * small), ((small * (N % 2)) + (D * (N / 2)))) << std::endl;

	return 0;
}


Measured memory_bytes: 3608
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map int . tail . words
printer = unlines . map show

solver as = ans
  where
    asz = [0] ++ as ++ [0]
    df1 = zipWith (\x y -> abs(x-y)) asz $ tail asz
    df2 = zipWith (\x y -> abs(x-y)) asz $ tail(tail asz)
    sm = sum df1
    pl = zipWith (+) df1 $ tail df1
    sb = zipWith (-) df2 pl
    ans = map (sm+) sb


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

int w, h;

void dfs(int hh, int ww, vector<vector<int>> &c, vector<vector<bool>> &seen)
{
    int dh[8] = {1, 1, 1, 0, 0, -1, -1, -1};
    int dw[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
    seen[hh][ww] = true;
    for (int i = 0; i < 8; i++)
    {
        int hhh = hh + dh[i];
        int www = ww + dw[i];
        if (hhh < 1 || hhh > h || www < 1 || www > w)
        {
            continue;
        }
        if (c[hhh][www] == 0)
        {
            continue;
        }
        if (seen[hhh][www])
        {
            continue;
        }
        dfs(hhh, www, c, seen);
    }
}

int main()
{
    vector<int> ans;
    while (1)
    {
        cin >> w >> h;
        if (w == 0 && h == 0)
            break;
        vector<vector<int>> c(h + 1, vector<int>(w + 1));
        vector<vector<bool>> seen(h + 1, vector<bool>(w + 1, false));
        for (int i = 1; i <= h; i++)
        {
            for (int j = 1; j <= w; j++)
            {
                cin >> c[i][j];
                if (c[i][j] == 0)
                {
                    seen[i][j] = true;
                }
            }
        }
        int count = 0;
        for (int i = 1; i <= h; i++)
        {
            for (int j = 1; j <= w; j++)
            {
                if (seen[i][j] || c[i][j] == 0)
                    continue;
                dfs(i, j, c, seen);
                count++;
            }
        }
        ans.push_back(count);
    }
    for (int i : ans)
    {
        cout << i << endl;
    }
}



Measured memory_bytes: 3320
#include <stdio.h>

main(){

long long a;
long long b1, b2;
long long k;

scanf("%lld",&a);
scanf("%lld.%lld",&b1, &b2);

// printf("%d %d\n", b1, b2);

k=a*(100*b1+b2);
k /=  100;

printf("%lld",k);

}

Measured memory_bytes: 1736
S = input()
p1, p2 = 0, 0
for i in range(len(S)):
    if i%2 == 0:
        if S[i] == "0":
            p1 += 1
        else:
            p2 += 1
    else:
        if S[i] == "1":
            p1 += 1
        else:
            p2 += 1
print(min(p1,p2))

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

//解説AC　方針を確信できなかった。

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, A, B;
	cin >> N >> A >> B;
	if ((B - A) % 2 == 0)cout << "Alice" << endl;
	else cout << "Borys" << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
N = int(input())
a = [int(x) for x in input().split()]
for i in range(N):
    if a[i] % 2 == 1:
        continue
    if a[i] % 3 != 0 and a[i] % 5 != 0:
        print("DENIED")
        exit()
print("APPROVED")

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
#include <stdio.h>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;

#define rep(i,N) for(int (i)=0; (i)<(N); (i)++)
#define revrep(i,N) for(int (i)=(N)-1; (i)>=0; (i)--)
#define dump(vec) for(int i = 0; i < (vec).size(); i++){cout << vec.at(i) << ",";}cout << endl

typedef long long ll;

int main(void)
{
    int N = 0;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) {
        cin >> A.at(i);
    }

    vector<ll> keta(101,0);
    rep(k,61){
        ll s = 0;
        ll t = 0;
        rep(i,N) {
            if (((A.at(i) >> k )& 0x01) == 1) {
                t++;
            } else {
                s++;
            }
        }
        ll u = s*t;
        keta.at(k) = u;
    }
    //dump(keta);

    rep(k,keta.size()-1){
        keta.at(k+1) += (keta.at(k)/2);
        if(keta.at(k) % 2 == 1) {
            keta.at(k) = 1;
        } else {
            keta.at(k) = 0;
        };
    }

    //dump(keta);

    ll ret = 0;
    rep(k,keta.size()){
        if (keta.at(k)) {
            ll temp = 1;
            rep(i,k){
                temp *= 2;
                temp %= (1000000000+7);
            }
            ret += temp;
            ret %= (1000000000+7);
        }        
    }

    cout << ret << endl;
    

    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define N 400005
using namespace std;
int n,u,v,fa[N],fst[N],to[N],nxt[N],l,dep[N],dis[N],Ans,f[N],q[N];
struct T
{
	int x,y;
}a[N],b[N];
vector<int>e[N];
void link(int x,int y)
{
	to[++l]=y;nxt[l]=fst[x];fst[x]=l;
	to[++l]=x;nxt[l]=fst[y];fst[y]=l;
}
void dfs(int x)
{
	for (int i=fst[x];i;i=nxt[i])
		if (to[i]!=fa[x])
		{
			fa[to[i]]=x;
			dep[to[i]]=dep[x]+1;
			dfs(to[i]);
		}
}
int Gdis(int x,int y)
{
	if (x==y) return 0;
	if (fa[x]==y||fa[y]==x) return 1;
	if (fa[x]==fa[y]||fa[fa[x]]==y||fa[fa[y]]==x) return 2;
	return 3;
}
int main()
{
	scanf("%d%d%d",&n,&u,&v);
	//if (u==v){puts("0");,return 0;}
	for (int i=1;i<n;i++)
		scanf("%d%d",&a[i].x,&a[i].y);
	for (int i=1;i<n;i++)
	{
		scanf("%d%d",&b[i].x,&b[i].y);
		link(b[i].x,b[i].y);
	}
	dfs(v);
	for (int i=1;i<n;i++)
	{
		int tmp=Gdis(a[i].x,a[i].y);
		if (tmp==1)
		{
			e[a[i].x].push_back(a[i].y);
			e[a[i].y].push_back(a[i].x);
		}
		else if (tmp==2)
		{
			if (fa[a[i].x]!=v||fa[a[i].y]!=v)
			{
				e[a[i].x].push_back(a[i].y);
				e[a[i].y].push_back(a[i].x);
			}
		}
		else f[a[i].x]=f[a[i].y]=1;
	}
	memset(dis,0x3f,sizeof dis);
	int l=0,r=1;
	q[1]=u;dis[u]=0;
	while(l<r)
	{
		int t=q[++l];
		//cout<<t<<' '<<dis[t]<<endl;
		if (f[t]==1){puts("-1");return 0;}
		else Ans=max(Ans,dep[t]*2);
		for (int i=0;i<e[t].size();i++)
			if (dis[e[t][i]]>dis[t]+1&&dis[t]+1<dep[e[t][i]])
			{
				dis[e[t][i]]=dis[t]+1;
				q[++r]=e[t][i];
			}
	}
	printf("%d\n",Ans);
}

Measured memory_bytes: 37632