akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
// for文短縮類
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// iteratorのbeginとendをまとめて渡す
#define ALL(x) (x).begin(), (x).end()
//略
#define PB push_back  // vectorヘの挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素
//出力
#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "
#define ENDL cout << endl
/************ Combination wtih MOD ************
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// preprocess for some tables
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
// combination
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*******************************************************/
int main(int argc, char *argv[]) {
  // input高速化。cinとcoutの結合解除。scanfとprintfは使えない。
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  string s;
  string t;
  cin >> s;
  cin >> t;

  ll ans = 0;
  REP(i, s.size()){
      if(s[i] != t[i])
          ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset> 
using namespace std;
typedef long long ll;
ll n;
struct node{
	ll l,r;
}a[200005];
bool cmp1(node a1,node a2)
{
	return a1.l<a2.l;
}
bool cmp2(node a1,node a2)
{
	return a1.r>a2.r;
}
int main(void)
{
	scanf("%lld",&n);
	for(ll i=0;i<n;i++)
	{
		scanf("%lld%lld",&a[i].l,&a[i].r);
	}
	ll ans=0;
	if(n%2==1)
	{
		sort(a,a+n,cmp1);
		ans=a[n/2].l;
		sort(a,a+n,cmp2);
		ans=a[n/2].r-ans+1;
		printf("%lld",ans);
	}
	else
	{
		sort(a,a+n,cmp1);
		ll l1=a[n/2-1].l,l2=a[n/2].l;
		sort(a,a+n,cmp2);
		ll r2=a[n/2-1].r,r1=a[n/2].r;
		printf("%lld",r1+r2-l1-l2+1);
	}
}

Measured memory_bytes: 6956
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n, k;
/**********************************************/

int main(){
    cin >> n >> k;
    int ans = 1;
    while(n--){
        ans = min(ans * 2, ans+k);   
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# 入力
N = int(input())
A = [int(x) for x in list(input())]
ans = 0

AA = [x for x in range(10)]

for i in AA:
    for j in AA:
        for k in AA:
            v = [i, j, k]
            now=0
            temp=v[now]
            for l in A:
                if (l ==temp):
                    now += 1
                    if (now == 3):
                        # print(v)
                        break
                    temp = v[now]
            if (now == 3):
                ans += 1

print(ans)

Measured memory_bytes: 3656
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

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

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, q = map(int, input().split())
UF = UnionFind(n)
for _ in range(q):
    t, u, v = map(int, input().split())
    if t == 0:
        UF.union(u, v)
    else:
        if UF.same(u, v):
            print(1)
        else:
            print(0)

Measured memory_bytes: 11536
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
map<pii, int> dp;
LL ans[10];
int main(){
    int h, w, n;
    scanf("%d%d%d", &h, &w, &n);
    vector<pii> v;
    for(int i=1;i<=n;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        dp[pii(a, b)]++;
        for(int j=max(3, a);j<=min(h, a+2);j++){
            for(int k=max(3, b);k<=min(w, b+2);k++) v.push_back(pii(j, k));
        }
    }   
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    for(int i=0;i<v.size();i++){
        int y = v[i].first, x = v[i].second;
        int sum = 0;
        for(int j=y-2;j<=y;j++){
            for(int k=x-2;k<=x;k++){
                sum += dp[pii(j, k)];
            }
        }
        ans[sum]++;
    }
    ans[0] = (h-3+1)*1ll*(w-3+1);
    for(int i=1;i<=9;i++) ans[0] -= ans[i];
    for(int i=0;i<=9;i++) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 164072
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define maxn 10005
using namespace std;
int n;
ll ans1,ans2;
int main()
{

    scanf("%d",&n);
   int a,t;


scanf("%lld%lld",&ans1,&ans2);

for(int i=1;i<n;i++)
{ll num1,num2,num;
    scanf("%d%d",&a,&t);

    if(ans1%a==0)
        num1=ans1/a;
    else
        num1=ans1/a+1;
    if(ans2%t==0)
        num2=ans2/t;
    else
        num2=ans2/t+1;
        num=max(num1,num2);
    ans1=num*a;
    ans2=num*t;

}
printf("%lld\n",ans1+ans2);
return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 1e6+10;
const int MOD = 1000000007;

// factorial, factorial inverse, inverse
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理 O(n)
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算 O(1)
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll X,Y; cin >> X >> Y;
    if ((X+Y)%3!=0) cout << 0 << endl;
    else{
        COMinit();
        ll n = (X+Y) / 3;
        ll k = min(X,Y) - n;
        cout << COM(n, k) << endl;
    }
    return 0;
}

Measured memory_bytes: 27036
#include<cstdio>
#include<stack>

using namespace std;

stack<int> Stack;

int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		if(n==0)
		{
			printf("%d\n",Stack.top());
			Stack.pop();
		}
		else
		{
			Stack.push(n);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N;
  cin>>N;
  ll S=sqrt(N);
  while(1){
    if(!(N%S)){
    cout<<to_string(N/S).size()<<endl;
    break;
    }
    S--;
  }
}

Measured memory_bytes: 256
input = gets.split(" ").map{|item|item.to_i}
moji= gets.chomp
if moji[input[1]-1] == "A" then
  moji[input[1]-1] = "a"
elsif moji[input[1]-1] == "B" then
  moji[input[1]-1] = "b"
else
  moji[input[1]-1] = "c"
  end
  print moji

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

int main() {
    string s;
    cin >> s;
    int K;
    cin >> K;

    vector<string> subs;
    int N = (int)s.size();
    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= K && j <= N - i; j++) {
            string t = s.substr(i, j);
            subs.push_back(t);
        }
    }
    sort(subs.begin(), subs.end());
    subs.erase(unique(subs.begin(), subs.end()), subs.end());

    cout << subs[K - 1] << endl;
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <cmath>

int main(int argc, char** argv) {
  int N;
  std::cin >> N;
  std::vector<long long> a(N);
  std::vector<long long> b(N);
  std::vector<long long> c(N);
  for (auto i = 0;i < N;++i) std::cin >> a[i] >> b[i] >> c[i];
  std::vector<std::vector<long long>> max_happines(N, std::vector<long long>(3, 0));
  max_happines[0][0] = a[0];
  max_happines[0][1] = b[0];
  max_happines[0][2] = c[0];
  for (auto i = 1;i < N;++i) {
    max_happines[i][0] = std::max(max_happines[i-1][1], max_happines[i-1][2])+a[i];
    max_happines[i][1] = std::max(max_happines[i-1][0], max_happines[i-1][2])+b[i];
    max_happines[i][2] = std::max(max_happines[i-1][0], max_happines[i-1][1])+c[i];
  }

  long long max_happy = std::max(max_happines[N-1][0], max_happines[N-1][1]);
  max_happy = std::max(max_happy, max_happines[N-1][2]);
  std::cout << max_happy << '\n';
}


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

int main(){
	ll N,A,B;
  cin >> N >> A >> B;
  
  	ll kumisuu=0;
  kumisuu=N/(A+B);

  	ll amari=0;
  amari=N%(A+B);
  
  ll ans=0;
  	if(amari<A){
    	ans=kumisuu*A+amari;
    }else{
    	ans=kumisuu*A+A;
    }
  
  cout << ans << endl;

	return 0;
}

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

int main() {
   int a,b;
   string s;
   cin >> a >> b >> s;
   string ans="Yes";
   for(int i=0;i<a;i++){
      if(!(s[i]>='0'&&s[i]<='9'))
      ans="No";
   }
   if(s[a]!='-')
   ans="No";
   for(int i=a+1;i<=a+b;i++){
      if(!(s[i]>='0'&&s[i]<='9'))
      ans="No";
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    n,m = map(int,input().split())
    h = list(map(int,input().split()))
    A = [0] * n
    for i in range(m):
        a,b = map(int,input().split())
        A[a-1] = max(A[a-1],h[b-1])
        A[b-1] = max(A[b-1],h[a-1])

    cnt = 0

    for i in range(n):
        if A[i] < h[i]:
            cnt += 1

    print(cnt)
    
if __name__ == "__main__":
    main()


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

#define INF 1000

typedef long long LL;

struct p{
  int x;
  int c;
};

int main(){
  int n,m;
  cin >> n >> m;
  vector<list<int>> e(n,list<int>()),ne(n,list<int>());
  int a,b;
  for(int i=0;i<m;i++){
    cin >> a >> b;
    a--;
    b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  vector<bool> flag(n);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      flag[j]=false;
    }
    for(auto itr=e[i].begin();itr!=e[i].end();itr++){
      flag[(*itr)]=true;
    }
    for(int j=0;j<n;j++){
      if((!flag[j])&&i!=j){
        ne[i].push_back(j);
      }
    }
  }
  queue<struct p> bfs;
  struct p now;
  vector<int> color(n,0);
  int count;
  int num=0;
  vector<int> retu(n,INF);
  for(int i=0;i<n;i++){
    if(!color[i]){
      bfs.push({i,1});
      color[i]=1;
      count=1;
      while(!bfs.empty()){
        now=bfs.front();
        bfs.pop();
        for(auto itr=ne[now.x].begin();itr!=ne[now.x].end();itr++){
          if(!color[(*itr)]){
            color[(*itr)]=-now.c;
            count+=(-now.c);
            bfs.push({(*itr),-now.c});
          }else{
            if(color[(*itr)]==color[now.x]){
              cout << -1 << endl;
              return 0;
            }
          }
        }
      }
      retu[num]=count;
      num++;
    }
  }
  vector<vector<bool>> dp(n+1,vector<bool>(2*n+1,false));
  dp[0][n]=true;
  for(int i=1;i<=num;i++){
    // cout << retu[i-1] << endl;
    for(int j=0;j<2*n+1;j++){
      if(dp[i-1][j]){
        dp[i][j-retu[i-1]]=true;
        dp[i][j+retu[i-1]]=true;
      }
    }
    // for(int j=0;j<2*n+1;j++) cout << dp[i][j] << " ";
    // cout << endl;
  }
  for(int i=0;i<=n;i++){
    if(dp[num][n+i]){
      cout << (n/2-i/2)*(n/2-i/2-1)/2+(n/2+(i+1)/2)*(n/2+(i+1)/2-1)/2 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 15744
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int a, b;

	while (cin >> a >> b, a != 0 && b != 0) {

		int dp[17][17] = { 0 };
		int n;

		cin >> n;

		dp[1][1] = 1;

		for (int i = 1; i <= n; i++) {
			int x, y;
			cin >> x >> y;
			dp[x][y] = -1;
		}

		for (int i = 1; i <= a; i++) {
			for (int j = 1; j <= b; j++) {

				if (dp[i][j] != -1) {
					if (j != 1 && dp[i][j - 1] != -1) {
						dp[i][j] += dp[i][j - 1];
					}

					if (i != 1 && dp[i - 1][j] != -1) {
						dp[i][j] += dp[i - 1][j];
					}
				}
			}
		}

		cout << dp[a][b] << endl;
	}

	return 0;

}


Measured memory_bytes: 2984
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long int64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5;
struct Edge
{
    int next, to;
    Edge(int next = 0, int to = 0):next(next), to(to) {};
}edge[N<<1];
int tot, head[N], deg[N];
void _add(int x, int y) { edge[++tot] = Edge(head[x], y), head[x] = tot, ++deg[x]; }
void add(int x, int y) { _add(x, y), _add(y, x); }
int n, w[N];
int64 s[N];
bool dfs(int x, int fa)
{
    int64 f = -1; if(!edge[head[x]].next) return s[x] = w[x], true;
    for(int i = head[x]; i; i = edge[i].next)
    {
        int y = edge[i].to; if(y == fa) continue;
        if(!dfs(y, x)) return false;
        f = max(f, s[y]), s[x] += s[y];
    }
    int64 x1 = 2*w[x]-s[x], x2 = s[x]-w[x];
    if(x1 < 0||x2 < 0||w[x] < f||(!fa&&x1)) return false;
    return s[x] = x1, true;
}
int p;
int main()
{
    n = read();
    for(int i = 1; i <= n; ++i) w[i] = read();
    for(int i = 1, x, y; i < n; ++i) x = read(), y = read(), add(x, y);
    for(p = 1; deg[p] == 1; ++p);
    if(p == n+1) return puts(w[1] == w[2]?"YES":"NO"), 0;
    puts(dfs(p, 0)?"YES":"NO");
    return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

int main(){
    int N, M;
    int a[60], b[60];

    cin >> N >> M;
    rep(i,M) cin >> a[i] >> b[i];

    int pac[N] = {0};
    rep(i,M){
        pac[a[i] - 1]++;
        pac[b[i] - 1]++;
    }

    rep(i,N){
        cout << pac[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
const ll mod=998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
int main(void){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    vector<vector<mint>> t(c+10,vector<mint>(d+10,0));
    t[a][b]=1;
    rep(i,c+1)rep(j,d+1){
        if(i==0||j==0)continue;
        if(i<=a&&j<=b)continue;
        t[i][j]=t[i-1][j]*j+t[i][j-1]*i-t[i-1][j-1]*(i-1)*(j-1);
    }
    cout<<t[c][d].x<<endl;
}

Measured memory_bytes: 74280
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
int n;
int h[100100];
int dp[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=1;i<=n;i++){
		if(h[i-1]>=h[i])
			dp[i]=dp[i-1]+1;
	}
	cout<<*max_element(dp+1,dp+n+1);
	return 0;
}


Measured memory_bytes: 1024
// atcoder/abc151/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

const int N = 20 + 3;
char g[N][N];

int gi, gj;
int cost[N][N];
int h, w;

bool vis[N][N];

int bfs(int si, int sj)
{
  assert(g[si][sj] == '.');
  fill(&vis[0][0], &vis[N - 1][N - 1] + 1, false);
  fill(&cost[0][0], &cost[N - 1][N - 1] + 1, -(1 << 29));

  vis[si][sj] = true;
  cost[si][sj] = 0;
  queue<pair<int, int>> q;
  for (q.push(make_pair(si, sj)); q.size(); q.pop()) {
    const int I = q.front().first;
    const int J = q.front().second;
    for (int d = 0; d < 4; ++d) {
      int di[] = {0, 0, -1, +1};
      int dj[] = {-1, +1, 0, 0};
      int ni = I + di[d];
      int nj = J + dj[d];
      unless (0 <= ni && ni < h) continue;
      unless (0 <= nj && nj < w) continue;
      if (vis[ni][nj]) continue;
      if (g[ni][nj] == '#') continue;
      cost[ni][nj] = cost[I][J] + 1;
      vis[ni][nj] = true;
      q.push(make_pair(ni, nj));
    }
  }

  return *max_element(&cost[0][0], &cost[N - 1][N - 1] + 1);
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  while (cin >> h >> w) {
    int si, sj;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> g[i][j];
      }
    }

    int mx = 0;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (g[i][j] == '.') {
          setmax(mx, bfs(i, j));
          // si = i;
          // sj = j;
        }
      }
    }
    // cout << cost[gi][gj] << endl;
    cout << mx << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/*

The idea is that we construct the graph in 3 parts (let's call them first, second and third), 
such that if there is an edge between u and v, then in our graph, there is an edge 
between u.first -> v.second, u.second -> v.third and u.third -> v.first. Now, if you run BFS on 
this Graph starting from vertex S.first and if you keep the destination as T.first, then you will
find a path whose length is always divisible by 3, and hence you will get the answer by 
dividing the path length by 3. And if you cannot reach T.first, then print -1.



Think of it like every vertex is being split into three vertices, let's say vertex u is being 
converted into three copies of vertices u0,u1,u2 where u0 denotes the vertex copy of u if u is 
reachable with distance equal to 0 modulo 3 from some source vertex ,and similarly u1 denotes 
the vertex if you can reach u with distance modulo 3 as 1 from some source vertex , similarly for u2 ,
so that's why for every u->v edge it is equivalent to u0 -> v1 , u1 -> v2 , u2->v0 as if you move one
step from u0 then the distance modulo 3 becomes 1 as initially it was(=0%3) , so from u0 you can go
to v1 , similarly for u1 if we move one more step towards v we actually reach v2 since now distance
modulo 3 is 2 , .. Now we need to find the shortest distance from S0 to T0 as when we start at S 
our distance is 0 and when we reach at T our distance modulo 3 must be 0 which implies that we have 
taken steps in multiples of 3 .

*/

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

typedef long long ll;

vector<ll> Adj[500005];

int main() {
    
    
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        Adj[x].push_back(y+n);
        Adj[x+n].push_back(y+2*n);
        Adj[x+2*n].push_back(y);
        
    }
    
    ll src,des;
    cin>>src>>des;
    
    queue<ll> pq;
    pq.push(src);
    ll visited[5*n];
    ll dist[5*n];
    visited[src]=1;
    
    memset(visited,0,sizeof(visited));
    memset(dist,-1,sizeof(dist));
    dist[src]=0;
    
    while(!pq.empty())
    {
        ll top=pq.front();
        pq.pop();
        for(auto it:Adj[top])
        {   
            if(!visited[it])
           { pq.push(it);
           visited[it]=1;
           dist[it]=dist[top]+1;
           }
        }
    }
    
    
    if(dist[des]!=-1)
    
    {  ll x=dist[des]/3;
        cout<<x<<endl;
    }
	
	else cout<<"-1"<<endl;
	return 0;
}



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

#define ll long long

int i,t,j;
int n,nt,s1[105],s2[105];

int main(){
	scanf("%d\n",&n);
	
	for (i=1; i<=n; ++i) scanf("%c",&s1[i]);
	scanf(" ");
	for (i=1; i<=n; ++i) scanf("%c",&s2[i]);
	
	for (i=1; i<=n; ++i){
		printf("%c%c",s1[i],s2[i]);
	}
	printf("\n");
	
	return 0;
}

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

// main.cpp

int main() {
  std::int_fast64_t N;
  std::cin >> N;
  std::vector<char> S;
  S.reserve(N);
  std::copy_n(std::istream_iterator<char>(std::cin), N, std::back_inserter(S));

  std::cout << (std::any_of(S.begin(), S.end(), [](const char c) { return c == 'Y'; }) ? "Four" : "Three") << std::endl;
  return 0;
}

Measured memory_bytes: 256
#define KAKUSUKO
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#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 INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll A, B;

const int MAX_PRIME = 1000010;
bool is_prime[MAX_PRIME+1];

// is_primeテーブルを初期化
void sieve(ll n) {
  memset(is_prime, true, sizeof(is_prime));
  is_prime[0] = is_prime[1] = false;
  for (ll i = 2; i*i <= n; ++i) {
    if (is_prime[i]) {
      for (ll j = 2*i; j*j <= n; j += i) is_prime[j] = false;
    }
  }
}

set<ll> primelist(ll A) {
  set<ll> res;
  ll t = A;
  res.insert(1);
  for (ll i = 2; i*i <= A; ++i) {
    if (is_prime[i] && (A%i == 0)) {
      res.insert(i);
      while (t%i == 0) {
        t /= i;
      }
    }
  }

  bool souldAdd = true;
  for (ll i = 2; i*i <= t; ++i) {
    if (t%i == 0) {
      souldAdd = false;
      break;
    }
  }
  if (souldAdd) res.insert(t);
  return res;
}

int main() {

  cin >> A >> B;

  if (A == 1 || B == 1) {
    cout << 1 << endl;
    return 0;
  }

  sieve(max(A, B));

  set<ll> prime_a = primelist(A);
  set<ll> prime_b = primelist(B);

  int ans = 0;
  for (ll p : prime_a) {
    if (prime_b.count(p) > 0) ++ans;
  }

  cout << ans << endl;

  return 0;
}



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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] H = new int[n];
        int[] dp = new int[n];
        Arrays.setAll(H, i -> Integer.parseInt(sc.next()));
        dp[1] = Math.abs(H[1] - H[0]);
        for(int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i-1] + Math.abs(H[i] - H[i-1]),
                            dp[i-2] + Math.abs(H[i] - H[i-2]));
        }
        System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 47532
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>

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

int n;
vector<P> g[100001];
ll s[100001], c[100001];
int nuee1, nuee2, nuee;
int size[100001];
ll d[100001];

void dfs(int x){
	size[x]=1;
	for(int i=0; i<g[x].size(); i++){
		int y=g[x][i].first;
		if(size[y]>0) continue;
		dfs(y);
		size[x]+=size[y];
	}
}

bool used[100001];

void dfs2(int x){
	used[x]=1;
	for(int i=0; i<g[x].size(); i++){
		int y=g[x][i].first;
		if(used[y]) continue;
		int k=g[x][i].second;
		if(size[y]==n-size[y]){
			nuee1=y, nuee2=x, nuee=k;
		}else{
			c[k]=(s[y]-s[x])/((ll)(n-2*size[y]));
		}
		dfs2(y);
	}
}

void dfs3(int x){
	used[x]=1;
	for(int i=0; i<g[x].size(); i++){
		int y=g[x][i].first;
		if(used[y]) continue;
		if(y==nuee1 || y==nuee2) continue;
		int k=g[x][i].second;
		d[y]=d[x]+c[k];
		dfs3(y);
	}
}

int main()
{
	cin>>n;
	for(int i=0; i<n-1; i++){
		int a, b;
		cin>>a>>b;
		a--; b--;
		g[a].push_back(P(b, i));
		g[b].push_back(P(a, i));
	}
	for(int i=0; i<n; i++){
		cin>>s[i];
	}
	dfs(0);
	dfs2(0);
	if(nuee1==0 && nuee2==0){
		for(int i=0; i<n-1; i++){
			cout<<c[i]<<endl;
		}
		return 0;
	}
	fill(used, used+n, 0);
	dfs3(nuee1);
	dfs3(nuee2);
	ll sum=0;
	for(int i=0; i<n; i++){
		sum+=d[i];
	}
	c[nuee]=(s[nuee1]-sum)/((ll)(n-size[nuee1]));
	for(int i=0; i<n-1; i++){
		cout<<c[i]<<endl;
	}
	return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    cin >> n;
    int digit = 0;
    int res = 0;
    int m = n, t = 1;
    while(m)
    {
        digit++;
        m /= 10;
    }
    for(int i = 1; i <= digit; i += 2)
    {
        res = res + min(t * 10 - 1, n) - t + 1;
        //if(min(t * 10 - 1, n) == n) res--;
        t *= 100;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	int E, x, y, z, min;
	
	while(cin >> E && E>0)
	{
		z=0; min = E;
		while(E-z*z*z>=0)
		{
			y=0;
			while(E-z*z*z-y*y>=0){
				x = E-z*z*z-y*y;
				if(min > x+y+z){
					min = x+y+z;
				}
				y++;
			}
			z++;
		}
		cout << min << endl;
	}
}


Measured memory_bytes: 3092
W, H, N = map(int, input().split())
minx = 0
maxx = W
miny = 0
maxy = H

for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        minx = max(minx, x)
    elif a == 2:
        maxx = min(maxx, x)
    elif a == 3:
        miny = max(miny, y)
    else:
        maxy = min(maxy, y)
    
ans = (maxx - minx) * (maxy - miny)
print(ans if minx < maxx and miny < maxy else 0)


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int m[10], c[10][10];

int min(int i, int *f){
  //printf("start: %d\n",i);
  int j, mini=10000, n;
  if(m[i]!=-1) return m[i];
  f[i]=1;
  for(j=0;j<10;j++){
    if(i==j) continue;
    if(f[j]==0){
      n = min(j, f)+c[i][j];
      //printf("%d,%d: %d\n",i,j,n);
      if(n<mini) mini=n;
    }
  }
  f[i]=0;
  return mini;
}

int main(void){
  int a[200][200], i, j, h, w, f[10], sum=0;
  for(i=0;i<10;i++) {m[i]=-1; f[i]=0;}
  m[1]=0;
  scanf("%d %d",&h, &w);
  for(i=0;i<10;i++) for(j=0;j<10;j++) scanf("%d",&c[i][j]);
  for(i=0;i<h;i++) for(j=0;j<w;j++) scanf("%d",&a[i][j]);
  for(i=0;i<10;i++) m[i]=min(i, f);
  //for(i=0;i<10;i++) printf("%d, ",m[i]);
  //printf("\n");
  for(i=0;i<h;i++) for(j=0;j<w;j++) if(a[i][j]!=-1) sum+=m[a[i][j]];
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a=0,b=0,d=0;
    char s[100000];  
  scanf("%s",s);
 for(a=0;s[a]!='\0';a++){
 if(a%2==1&&s[a]=='0'){b++;}
 if(a%2==0&&s[a]=='1'){b++;}
 if(a%2==1&&s[a]=='1'){d++;}
 if(a%2==0&&s[a]=='0'){d++;}
 }
  if(b>d){b=d;}
 printf("%d",b);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	cout<<a[n-1]-a[0]<<endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N;
	ll ans = 0, num;
	cin >> N;
	REP(i, 0, N){
		cin >> num;
		while(num %2 == 0){
			num /= 2;
			++ans;
		}
	}
	cout << ans;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int ans=0x3f3f3f3f;
int main(){
	cin>>s;
	int tmp=0;
	for(int i=0;i<s.size();i++){
		tmp=tmp*10+s[i]-'0';
		if(i>=2){
			ans=min(ans,abs(tmp-753));
			tmp-=100*(s[i-2]-'0');
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
const long long mod=1e9+7;
int n,m;
long long kq;
long long giaithua[2000001];
long long ndgiaithua[2000001];
long long power(long long n,long long x)
{
    if(x==0)
        return 1;
    if(x%2==0)
        return power(n*n%mod,x/2);
    else
        return n*power(n*n%mod,x/2)%mod;
}
long long nck(int n,int k)
{
    return (giaithua[n]*(ndgiaithua[k]*ndgiaithua[n-k]%mod))%mod;
}
int main()
{
    cin>>n>>m;
    giaithua[0]=1;
    for(int i=1;i<=n+m;i++)
    {
        giaithua[i]=(giaithua[i-1]*i)%mod;
    }
    ndgiaithua[n+m]=power(giaithua[n+m],mod-2);
    for(int i=n+m-1;i>=0;i--)
    {
        ndgiaithua[i]=(ndgiaithua[i+1]*(i+1))%mod;
    }
    int i=0;
    while(1)
    {
        int x1=i;
        int y1=2*i;
        int x2=n-x1;
        int y2=m-y1;
        if(x2<0||y2<0)
            break;
        if(2*y2==x2)
        {
            kq+=nck(i+y2,i);
            kq%=mod;
        }
        ++i;
    }
    cout<<kq;
    return 0;
}


Measured memory_bytes: 31488
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=998244353;
char s[100005]; 
int main()
{
	scs(s);
	int n=strlen(s);
	if(s[n-1]=='s')pf("%ses",s);
	else pf("%ss",s);
	pf("\n");
}


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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++)cin >> p[i];
    sort(p.begin(), p.end());

    int ret = 0;
    for (int i = 0; i < k; i++)ret += p[i];
    cout << ret << endl;
    return 0;
}

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

int main(){
    int N,K;
    cin >> N >> K;
    int a[60];

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

    sort(a,a + N,greater<int>());
    int Snak = 0;

    for(int i = 0;i < K;i++){
        Snak += a[i];
    }
    cout << Snak << endl;

}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B;
    cin >> A >> B;

    rep(i,A+1){
        if((2*i+4*(A-i)) == B){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

using namespace std;
bool Less(int h1,int m1,int h2,int m2)
{
    return h1<h2||h1==h2&&m1<m2;
}
void add(int &h1,int &m1,int k)
{
    m1+=k;
    h1+=m1/60;
    m1%=60;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int curh,curm,h,m,k;
    cin>>curh>>curm>>h>>m>>k;
    int ans=0;
    while(curh!=h||curm!=m)
    {
        int th=curh,tm=curm;
        add(th,tm,k);
        if(Less(th,tm,h,m)) ans++;
        add(curh,curm,1);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define MAX_S 100000
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s.size()==2){
    if(s[0]==s[1]) cout<< "1 2\n";
    else cout <<"-1 -1\n";
    return 0;
  }
  for(int i=0;i<s.size()-2;i++){
    if(s[i]==s[i+1]||s[i]==s[i+2]||s[i+1]==s[i+2]){
      cout << i+1 <<" "<< i+3<<endl;
      return 0;
    }
  }
  cout << "-1 -1\n";
}


Measured memory_bytes: 512
num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
s = int(input())
print(num_list[s-1])

Measured memory_bytes: 38384
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    double a,b,h;cin>>a>>b>>h;
    double ans=(a+b)*h/2.0;
    cout<<ans<<endl;
}






Measured memory_bytes: 256
N,HP=map(int,input().split())
K=0
listN=[]
 
for i in range(N):
    k,n=map(int,input().split())
    if k>K:
        K=k
    listN.append(n)
listN.sort(reverse=True)
cnt=0
for i in range(N):
    if listN[i]>=K:
        HP-=listN[i]
        cnt+=1
        if HP<=0:
            print(cnt)
            exit()
    else:
        break
 
cnt+=int((HP+K-1)/K)
print(cnt)

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

template<typename T>
void read(T &n){
    n = 0;
    T f = 1;
    char c = getchar();
    while(!isdigit(c) && c != '-') c = getchar();
    if(c == '-') f = -1, c = getchar();
    while(isdigit(c)) n = n*10+c-'0', c = getchar();
    n *= f;
}
template<typename T>
void write(T n){
    if(n < 0) putchar('-'), n = -n;
    if(n > 9) write(n/10);
    putchar(n%10+'0');
}

int n, m;
char s[MAX];

bool chk(int l, int r){
    for(int i = l, j = r; i < j; i++, j--){
        if(s[i] != s[j]) return false;
    }
    return true;
}

int main()
{
    scanf("%s", s+1);
    n = strlen(s+1);
    if(chk(1, n) && chk(1, (n-1)/2) && chk((n+3)/2, n)){
        puts("Yes");
    }
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end


n = inp[0]
ans = 0
(1..n).each do |i|
  if i%3!=0 and i%5!=0
    ans += i
  end
end
p ans


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

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i,N){
        cin >> X[i];
    }
    int m=1000000000;
    for(int i=1; i<=100; i++){
        int sum = 0;
        rep(j,N){
            sum += (X[j] - i)*(X[j] - i);
        }
        m = min(m,sum);
    }

    cout << m << endl;

}


Measured memory_bytes: 256
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


N, M, X = invr()

A = inlist()

l = 0
r = N
lef_gates = 0
right_gates = 0

for a in A:
    if a > X:
        right_gates += 1
    else:
        lef_gates += 1

print(min(lef_gates, right_gates))


Measured memory_bytes: 3064
#include <stdio.h>

int main() {
    int r, c;
    scanf("%d %d", &r, &c);
    int Table[r][c], Tablenew[r+1][c+1];
    for (int i = 0; i <= r; i++) {
        for (int j = 0; j <= c; j++) {
            Tablenew[i][j] = 0;
        }
    }
    for (int i = 0; i < r; i++){
        for (int j = 0; j < c; j++){
            scanf("%d", &Table[i][j]);
            Tablenew[i][j] = Table[i][j];
        }
    }
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            Tablenew[i][c] += Table[i][j];
        }
    }
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            Tablenew[r][j] += Table[i][j];
        }
    }
    Tablenew[r][c] = 0;
    for (int i = 0; i < c; i++){
        Tablenew[r][c] += Tablenew[r][i];
    }
    for (int i = 0; i < r + 1; i++) {
        for (int j = 0; j < c + 1; j++) {
            printf("%d", Tablenew[i][j]);
            if(j < c) {
                printf(" ");
            }
        }
        printf("\n");
    }
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    int n;cin>>n;
    int tmp =n%10;
    if(tmp==3)cout<<"bon";
    else if(tmp==0||tmp==1||tmp==6||tmp==8)cout<<"pon";
    else cout<<"hon";
 
return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll k,a,b;
    cin >> k >> a >> b;
    if(b-a < 3){
        cout << k + 1 << endl;
        return 0;
    }
    if(k <= a){
        cout << k + 1 << endl;
        return 0;
    }
    k -= (a-1);
    ll answer = a;
    answer += (k/2)*(b-a);
    if(k%2)answer++;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
input_lines = input().split()
N = int(input_lines[0])
M = int(input_lines[1])
S = input()
T = input()

def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

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

L = int(lcm(N,M))
x = 1
count = 0
while True:
    k = L*x
    flag = 1
    starti = 0
    startj = 0
    for i in range(starti, N):
        for j in range(startj, M):
            hoge = i*k/N+1
            fuga = j*k/M+1
            if(hoge < fuga):
                startj = j - 1
                break
            elif(hoge == fuga):
                if(S[i] != T[j]):
                    flag = 0
                    count += 1
                    break
        if(flag == 0):
            break
    if(flag == 1):
        print(k)
        break
    if(count == 2):
        print(-1)
        break
    x += 1


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i , x , y) for(register int i = (x) , _## i = ((y) + 1) ; i < _## i ; i ++)
#define Rep(i , x , y) for(register int i = (x) , _## i = ((y) - 1) ; i > _## i ; i --)
using namespace std ;
#define int long long
using ll = long long ;
using pii = pair < int , int > ;
const static int _ = 1 << 20 ;
char fin[_] , * p1 = fin , * p2 = fin ;
inline char gc() { return (p1 == p2) && (p2 = (p1 = fin) + fread(fin , 1 , _ , stdin) , p1 == p2) ? EOF : * p1 ++ ; }
inline int read() {
	bool sign = 1 ; char c = 0 ; while(c < 48) ((c = gc()) == 45) && (sign = 0) ;
	int x = (c & 15) ; while((c = gc()) > 47) x = (x << 1) + (x << 3) + (c & 15) ;
	return sign ? x : -x ;
}
template < class T > void print(T x , char c = '\n') {
	(x == 0) && (putchar(48)) , (x < 0) && (putchar(45) , x = -x) ;
	static char _st[100] ; int _stp = 0 ;
	while(x) _st[++ _stp] = x % 10 ^ 48 , x /= 10 ;
	while(_stp) putchar(_st[_stp --]) ; putchar(c) ;
}
template < class T > void cmax(T & x , T y) { (x < y) && (x = y) ; }
template < class T > void cmin(T & x , T y) { (x > y) && (x = y) ; }
signed main() {
#ifdef _WIN64
	freopen("testdata.in" , "r" , stdin) ;
#endif
	print(read() ^ read()) ;
	return 0 ;
}

Measured memory_bytes: 256
/*
                            Author: Ankit Kaul
*******Code Belongs to Respective Author Only*************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
/*freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
        {   if(n % 2 ==1)
            result=(result * x)%M;
            x=(x*x)%M;
            n=n/2;
        }
    return result%M;
}
bool isPrime(int n)
    {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
    }
int inv(int a,int m)
{   return power(a,m-2);
}   
int lcm(int a,int b)
{   return a*b/(gcd(a,b));
}
signed main()
{   jaldi  
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    cin>>a[i]>>b[i];
    bool x=true;
    for(int i=0;i<n-2;i++)
    {   if(a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2])
        x=false;  
    }
    if(!x)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3648