akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int d,n,s[4];
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    s[0]=1;
    s[1]=100;
    s[2]=10000;
    s[3]=1000000;
    cin>>d>>n;
    int ans = s[d]*n;
    if(n==100){
        ans = s[d+1]+s[d];
    }
    cout<<ans<<newl;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll X;
    cin >> X;

    ll left = 0, right = 1000000000;
    while (right - left > 1) {
        ll mid = (left + right) >> 1;
        if (mid * (mid + 1) / 2 < X) {
            left = mid;
        }
        else {
            right = mid;
        }
    }

    cout << right << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
#include <deque>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int main(){
    int a,b,q;
    cin >> a >> b >> q;

    vector<ll> s(a);
    for(int i = 0;i < a;i++)cin >> s[i];

    vector<ll> t(b);
    for(int i = 0;i < b;i++)cin >> t[i];

    vector<ll> ans(q);
    for(int i = 0;i < q;i++){
        ll x;
        cin >> x;
        
        auto us = upper_bound(s.begin(),s.end(),x);
        auto ps = lower_bound(s.begin(),s.end(),x);

        auto ut = upper_bound(t.begin(),t.end(),x);
        auto pt = lower_bound(t.begin(),t.end(),x);

        ll d = 1e11;

        if(us != s.end() && ut != t.end())d = min(d,max(*us,*ut)-x);
        if(ps != s.begin() && pt != t.begin()){
            auto ds = ps;
            auto dt = pt;
            ds--,dt--;
            d = min(d,x-min(*ds,*dt));
        }
        if(ps != s.begin() && ut != t.end()){
            auto ds = ps;
            ds--;
            d = min(d,min(x-*ds,*ut-x)+*ut-*ds);
        }
        if(us != s.end() && pt != t.begin()){
            auto dt = pt;
            dt--;
            d = min(d,min(x-*dt,*us-x)+*us-*dt);
        }

        ans[i] = d;
    }


    for(int i = 0;i < q;i++)cout << ans[i] << endl;
}


Measured memory_bytes: 3712
N = int(input())
A = input().split()
A = [int(a) for a in A]

score_alice= 0
score_bob = 0

while True:
  alice_card = max(A)
  A.remove(alice_card)
  score_alice += alice_card
  
  if len(A) == 0:
    break

  bob_card = max(A)
  A.remove(bob_card)
  score_bob += bob_card
  
  if len(A) == 0:
    break

print(score_alice - score_bob)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=250001;

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

    int n,l;
    cin>>n>>l;
    int sum=0;
    for(int i=1;i<=n;++i)
    {
        sum+=l+i-1;
    }
    int ans,diff=INT_MAX;
    for(int i=1;i<=n;++i)
    {
    	int ch=sum-(l+i-1);
    	int d=abs(sum-ch);
    	if(diff>d)
    	{
    		diff=d;
    		ans=ch;
    	}
    }
    cout<<ans;

	return(0);
}


Measured memory_bytes: 256
function main(a){
	var reg=/[aiueo]/;
	(reg.test(a))?op("vowel"):op("consonant");
}
function op(a){
	console.log(a);
}
function stn(a){
		return a.map(function(x){return parseInt(x,10);});
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

char a[1000000];
int b;
int g=0;
struct JOI
{
	int J, O, I;
};
JOI c(int d) {
	JOI e;
	e.J = e.O = e.I = 0;
	int f;
	for (f = d; f < b; f++) {
		if (a[f] != 'J')break;
	}
	e.J = f - d;
	d = f;
	for (f = d; f < b; f++) {
		if (a[f] != 'O')break;
	}
	e.O = f - d;
	d = f;
	for (f = d; f < b; f++) {
		if (a[f] != 'I')break;
	}
	e.I = f - d;
	g = f - 1;
	return e;
}
int main() {
	scanf("%s", a);
    b = strlen(a);
	int MAX = 0;
	for (;g < b;g++) {
		if (a[g] == 'J') {
			JOI s = c(g);
			if (s.O <= s.I&&s.O <= s.J)MAX = max(MAX, s.O);
		}
	}
	cout << MAX << endl;
}

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

int main() {

	ll a, v, b, w, t; cin >> a >> v >> b >> w >> t;
	string ans = "NO";
	ll dist = abs(a - b);
	if (dist <= (v - w) * t) {
		ans = "YES";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

sys.setrecursionlimit(2147483647)
INF = float('inf')

if os.getenv('LOCAL'):
    sys.stdin = open('_in.txt')


N = int(sys.stdin.readline())
print((N-2)*180)


Measured memory_bytes: 23116
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{

    double a;
    cin >> a;
    cout << setprecision(20);
    cout << 2 * a * M_PI << endl;


    return 0;

}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
int N,D,X;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>N>>D>>X;
        D--;
    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        X+=D/x+1;
    }
    cout<<X<<'\n';
    return 0;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

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

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

//const ll INF=(ll)1e19;
const int INF=(1<<30);

int MAX=1000000;
int dp1[1000001];
int dp2[1000001];

int main(){
  REP(i,MAX+1)dp1[i] = INF;
  dp1[0]=0;
  REP(i,MAX+1)dp2[i] = INF;
  dp2[0]=0;

  for(int i=0; ; i++){
    int x=i*(i+1)*(i+2)/6;
    if(x >= MAX)break;

    FOR(i,x,MAX+1){
      dp1[i] = min(dp1[i-x]+1, dp1[i]);
      if(x%2==1)dp2[i] = min(dp2[i-x]+1, dp2[i]);
    }
  }


  while(true){
    int n;
    cin >> n;
    if(n==0)break;
    cout << dp1[n] << " " << dp2[n] << endl;
  }
  return(0);
}



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

int main(){
  int N,A,B,C,D;
  cin >> N >> A >> B >> C >> D;
  string S;
  cin >> S;
  bool ans=1;
  if(B<C&&C<D){
    for(int i=A-1;i<D-1;i++){
      if(S[i]=='#'&&S[i+1]=='#')
        ans=0;
    }
    //Aマス目からDマス目まで2連の岩があればNo
    if(ans)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  else if(B<D&&D<C){
    ans=0;
    for(int j=B-2;j<D-1;j++){
      if(S[j]=='.'&&S[j+1]=='.'&&S[j+2]=='.')
        ans=1;
    }
    //Bマス目からDマス目まで3連の空きがなければNo
    for(int k=A-1;k<C-1;k++){
      if(S[k]=='#'&&S[k+1]=='#')
        ans=0;
    }
  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  }
  else{
    for(int l=A-1;l<C-1;l++){
      if(S[l]=='#'&&S[l+1]=='#')
        ans=0;
    }
    for(int m=B-1;m<D-1;m++){
      if(S[m]=='#'&&S[m+1]=='#')
        ans=0;
    }
    if(ans)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

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

int order_check(long long N){
    int digits=0;
    while (N > 0) {
        N /= 10;
        digits++;
    }

    return digits;
}

int main(){
    long long N, a;
    int ans;
    cin >> N;
    for (a=1; a * a <=N; a++) {
        if (N % a ==0) {
            ans = max(order_check(N / a), order_check(a));
        }
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		boolean[] painted = new boolean[n];
		for(int i=0;i<m;i++) {
			int a = sc.nextInt();
			int l = sc.nextInt();
			for(int j=0;j<l;j++) {
				painted[(a+j)%n] = true;
			}
		}
		int start = 0;
		for(int i=0;i<n;i++) {
			if (!painted[i]) {
				start = i;
				break;
			}
		}
//		System.out.println(Arrays.toString(painted));
		boolean[] p2 = new boolean[n+1];
		for(int i=0;i<n;i++) {
			p2[i] = painted[(start+i)%n];
		}
		int[] count = new int[n+1];
		int len = 0;
		for(int i=0;i<=n;i++) {
			if (p2[i]) {
				len++;
			}else{
				count[len]++;
				len = 0;
			}
		}
		for(int i=n;i>=1;i--) {
			if (count[i] >= 1) {
				System.out.println(i + " " + count[i]);
			}
		}
	}
}


Measured memory_bytes: 18312
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#include <cmath>
#include <set>
#include <unordered_set>
#include <iterator>
#include <deque>
#include <assert.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}


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


    int n, m, sum = 0;
    cin>>n>>m;
    int a[n];
    for (int i = 0; i < n; i++){
        cin>>a[i];
        sum += a[i];
    }
    sort(a,a+n);
    if (a[n-m]>=(sum+4*m-1)/(4*m)){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }


    return 0;
    
}



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

int main() {
  int N,L;
  cin >> N >> L;
  vector<string> A(N);
  for(int i=0; i<N; ++i){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  for(int j=0; j<N; ++j) {
    cout << A.at(j);
  }
  cout << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


LL gcd(LL v1, LL v2){
    assert(v2 > 0);
    if(v1 < v2) swap(v1, v2);
    if(v1 % v2 == 0) return v2;
    return gcd(v2, v1 % v2);
}

int main(){
    LL a, b;
    cin >> a >> b;
    cout << a * b / gcd(a, b) << endl;
    return 0;
}



Measured memory_bytes: 256
N=int(input())
for n in range(N):
    gx,gy=map(int,input().split())
    T=[[0 for i in range(gy+1)] for j in range(gx+1)]
    left=[[0 for i in range(gy+1)] for j in range(gx+1)]
    upper=[[0 for i in range(gy+1)] for j in range(gx+1)]
    p=int(input())
    
    for i in range(p):       

        x1,y1,x2,y2=map(int,input().split())

        if x1==x2:

            upper[x1][max(y1,y2)]=1

        if y1==y2:

            left[max(x1,x2)][y1]=1

    for i in range(gx+1):

        for j in range(gy+1):

            if i==0:

                left[i][j]=1

            if j==0:

                upper[i][j]=1
                
    for i in range(gx+1):

        for j in range(gy+1):

            if i==0 and j==0:

                T[i][j]=1

            else:   

                if left[i][j]==1 and upper[i][j]==1:

                    T[i][j]=0

                elif left[i][j]==0 and upper[i][j]==1:

                    T[i][j]=T[i-1][j]

                elif left[i][j]==1 and upper[i][j]==0:

                    T[i][j]=T[i][j-1]

                else:

                    T[i][j]=T[i-1][j]+T[i][j-1]

    
    if T[gx][gy]==0:

        print("Miserable Hokusai!")

    else:

        print(T[gx][gy])


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

import sys
import subprocess
import json
import time
import math
import re
import sqlite3

N = int(input())
s = input()
x = 0
max_x = 0

for c in s:
    if c == 'I': x += 1
    else: x -= 1
    max_x = max(max_x, x)

print(max_x)



Measured memory_bytes: 5320
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const double INF = 1e9;
const int maxn = 105, maxm = 105;
int M, N, X1[maxm], Y1[maxm], X2[maxn], Z2[maxn];
double width(int *X, int *Y, int n, double x)
{
    double lb = INF, ub = -INF;
    for(int i = 0; i < n; i++){
        double x1 = X[i], y1 = Y[i], x2 = X[(i + 1) % n], y2 = Y[(i + 1) % n];
        if((x1 - x) * (x2 - x) <= 0 && x1 != x2){
            double y = y1 + (y2 - y1) * (x - x1) / (x2 - x1);
            lb = min(lb, y);
            ub = max(ub, y);
        }
    }
    return max(0.0, ub - lb);
}
void solve()
{
    int min1 = *min_element(X1, X1 + M), max1 = *max_element(X1, X1 + M);
    int min2 = *min_element(X2, X2 + N), max2 = *max_element(X2, X2 + N);
    vector<int> xs;
    for(int i = 0; i < M; i++)
        xs.push_back(X1[i]);
    for(int i = 0; i < N; i++) xs.push_back(X2[i]);
    sort(xs.begin(), xs.end());
    double res = 0;
    for(int i = 0; i + 1 < xs.size(); i++){
        double a = xs[i], b = xs[i + 1], c = (a + b) / 2;
        if(min1 <= c && c <= max1 && min2 <= c && c <= max2){
            double fa = width(X1, Y1, M, a) * width(X2, Z2, N, a);
            double fb = width(X1, Y1, M, b) * width(X2, Z2, N, b);
            double fc = width(X1, Y1, M, c) * width(X2, Z2, N, c);
            res += (b - a) / 6 * (fa + 4 * fc + fb);
        }
    }
    printf("%.10f\n", res);
}
int main()
{
    while(scanf("%d%d", &M, &N) && M){
        for(int i = 0; i < M; i++){
            scanf("%d%d", &X1[i], &Y1[i]);
        }
        for(int i = 0; i < N; i++){
            scanf("%d%d", &X2[i], &Z2[i]);
        }
        solve();
    }
    return 0;
}



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

int main() {
  int N, L, i;
  cin >> N >> L;
  vector<string> S(N);
  for (i = 0; i < N; i++) cin >> S.at(i);
  
  sort(S.begin(), S.end());
  for (i = 0; i < N; i++) cout << S.at(i);
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B,C;
    cin >> A >> B >> C;
    for(int i=1;i<100;i++){
        if(A*i%B == C){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	string str;
	cin >> str;
	int ans = 0;
	for(int i = 1;i < str.size()/2;i++){
		bool ok = true;
		for(int j = 0;j < i;j++){
			if(i+j > str.size()){
				ok = false;
				break;
			}
			if(str[j] != str[i+j]){
				ok = false;
				break;
			}
		}
		if(ok) ans = i*2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
ans = 0
dict = {}
for _ in range(n):
  	#文字列をキーとする辞書型に出現回数を保持する
    s = str(''.join(sorted(list(input()))))
    try:
        ans += dict[s]
        dict[s] += 1
    except:
        dict[s] = 1
print(ans)

Measured memory_bytes: 17808
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll N;
  cin >> N;
  ll ans=0;
  ll k=sqrt(N)+1;
  FOR(i,1,k){
    if(N%i==0){
      ll m=N/i-1;
      if(i<=m-1){
        ans+=m;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));

const ll MOD = 1e9+7;
const int MAX = 1001001;
ll fac[MAX],finv[MAX],inv[MAX];
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;
    }
}
ll 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;
}
ll powmod(ll x, ll n){
    ll ret=1;
    while(n>0){
        if(n&1){
            ret*=x;
            ret%=MOD;
            n-=1;
        }
        else{
            x*=x;
            x%=MOD;
            n>>=1;
        }
    }
    return ret;
}
signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    COMinit();
    int n; cin >> n;
    vector<int> v(1001001,0);
    vector<int> b(n);
    rep(i,n){
        cin >> b[i];
        int a=b[i];
        for(int j=2;j*j<=a;j++){
            int cnt=0;
            while(a%j==0){
                a/=j;
                cnt++;
            }
            chmax(v[j],cnt);
        }
        if(a!=1) chmax(v[a],1);
    }
    ll ans=0;
    ll lcm=1;
    rep(i,1001001){
        lcm*=powmod(i,v[i]);
        lcm%=MOD;
    }
    //cout << lcm << endl;
    rep(i,n){
        ll res=(inv[b[i]]*lcm)%MOD;
        ans+=res; ans%=MOD;
    }
    ans%=MOD;
    cout << ans << endl;
    
}




Measured memory_bytes: 30656
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
int u[20][1100000];
vector<int> y;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=1,g=0;
  cin >>a;
  for(int n=0;n<=a;n++){
    u[1][n]=n;
  }
  e=6;
  for(int n=0;n<=a;n++){
    if(n>=6) u[2][n]=min(u[2][n-6]+1,u[1][n]);
    else u[2][n]=n;
  }
  e=9;
  for(int n=0;n<=a;n++){
    if(n>=9) u[3][n]=min(u[3][n-9]+1,u[2][n]);
    else u[3][n]=u[2][n];
  }
  e=36;
  for(int n=0;n<=a;n++){
    if(n>=36) u[4][n]=min(u[4][n-36]+1,u[3][n]);
    else u[4][n]=u[3][n];
  }
  e=81;
  for(int n=0;n<=a;n++){
    if(n>=81) u[5][n]=min(u[5][n-81]+1,u[4][n]);
    else u[5][n]=u[4][n];
  }
  e=216;
  for(int n=0;n<=a;n++){
    if(n>=e) u[6][n]=min(u[6][n-e]+1,u[5][n]);
    else u[6][n]=u[5][n];
  }
  e=216;
  for(int n=0;n<=a;n++){
    if(n>=e) u[6][n]=min(u[6][n-e]+1,u[5][n]);
    else u[6][n]=u[5][n];
  }
  e=729;
  for(int n=0;n<=a;n++){
    if(n>=e) u[7][n]=min(u[7][n-e]+1,u[6][n]);
    else u[7][n]=u[6][n];
  }
  e=1296;
  for(int n=0;n<=a;n++){
    if(n>=e) u[8][n]=min(u[8][n-e]+1,u[7][n]);
    else u[8][n]=u[7][n];
  }
  e=6561;
  for(int n=0;n<=a;n++){
    if(n>=e) u[9][n]=min(u[9][n-e]+1,u[8][n]);
    else u[9][n]=u[8][n];
  }
  e=7776;
  for(int n=0;n<=a;n++){
    if(n>=e) u[10][n]=min(u[10][n-e]+1,u[9][n]);
    else u[10][n]=u[9][n];
  }
  e=46656;
  for(int n=0;n<=a;n++){
    if(n>=e) u[11][n]=min(u[11][n-e]+1,u[10][n]);
    else u[11][n]=u[10][n];
  }
  e=59049;
  for(int n=0;n<=a;n++){
    if(n>=e) u[12][n]=min(u[12][n-e]+1,u[11][n]);
    else u[12][n]=u[11][n];
  }

  cout <<u[12][a]<<'\n';
  return (0);
}


Measured memory_bytes: 28928
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define lb(v,x) lower_bound(all(v),x)
#define ub(v,x) upper_bound(all(v),x)
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}

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

const int N = 105;

int n,k;
bool win[100005];

int main(){
    IOS
    
    cin>>n>>k;
    int a[n+1];
    FOR(i,1,n+1){
        cin>>a[i];
    }
    FOR(i,0,k+1){
        FOR(j,1,n+1){
            if(a[j]<=i && !win[i-a[j]]){
                win[i]=1;
            }
        }
    }
    if(win[k]){
        cout<<"First";
    }
    else{
        cout<<"Second";
    }
    cerr<<1.0/CLOCKS_PER_SEC<<endl;
    return 0;
}

Measured memory_bytes: 384
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll N; cin >> N;
    cout << N*(N-1)/2 << endl;
}


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

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

    vector<int> counter(N, 0);

    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        counter.at(a-1)++;
        counter.at(b-1)++;
    }

    for (int i = 0; i < N; i++)
    {
        cout << counter.at(i) << "\n";
    }
}

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

typedef long long int ll;
#define    mod      1000000007
#define    speed    ios_base::sync_with_stdio(false);
#define    up       cin.tie(NULL);
#define    pb       push_back
#define    mp       make_pair
#define    T        int t; cin >> t; while(t--)

int main(){
  speed up
  int n, m,l , x, y , r;
  cin >> n >> m;
  l = 1; r = n;
  while(m--){
      cin >> x >> y;
      l = max(l , x);
      r = min(r , y);
  }
  r = r - l + 1;
  if(r < 0){r = 0;}
  cout << r << '\n';
}

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

int main()
{
    int n;
    cin >> n;
    unordered_set<int> st;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        st.insert(x);
    }

    int q;
    cin >> q;
    int ans = 0;
    for (int i = 0; i < q; i++) {
        int x;
        cin >> x;
        if (st.count(x)) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3128
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

int main(void){
	string S, T; cin>>S>>T;

	bool can = false;
	int pos = 0;
	for(int i=S.size() - T.size();i>=0;i--) {
		int cnt = 0;
		for(int j=0;j<T.size();j++) {
			if((T[j] == S[i+j]) || (S[i+j] == '?')) cnt++;
		}

		if(cnt == T.size()) {
			pos = i;
			can = true;
			break;
		}
	}

	S.replace(pos, T.size(), T);
	while(S.find("?") != -1) S[S.find("?")] = 'a';

	if(can) cout<< S <<endl;
	else cout<< "UNRESTORABLE" <<endl;
	
	return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
int k,n;
ll c[303030];

void off(int n, ll x){
    if (n==0)return;
    if(x==1)return;
    printf("%d ",(x-2)/c[n-1]+1);
    off(n-1, (x-2)%c[n-1] + 1);
}
void mid(int n, int odd, ll offset){
    if (n == 0)return;
    if (c[n]){
        off(n, (c[n]+1)/2 - offset);
    }
    else{
        printf("%d ", k/2+1);
        mid(n-1, !odd, offset+!odd);
    }
}
int main(){
    scanf("%d%d",&k,&n);
    if (k%2 == 0){
        printf("%d ", k/2);
        for(int i=0;i<n-1;i++){
            printf("%d ", k);
        }
        puts("");
        return 0;
    }
    c[0] = 1;
    for(int i=1;i<=n;i++){
        c[i] = c[i-1]*k+1;
        if (c[i] > 1000000000000000LL/k)break;
    }
    printf("%d ", k/2+1);
    mid(n-1,n%2,0);
}


Measured memory_bytes: 2816
import sys
input = sys.stdin.readline
from collections import deque

H,W=map(int,input().split())
sh,sw=map(int,input().split())
gh,gw=map(int,input().split())
MAP=[input().strip() for i in range(H)]

ANS=[[1<<30]*W for i in range(H)]

sh-=1
sw-=1
gh-=1
gw-=1

ANS[sh][sw]=0

Q=deque([(sh,sw)])

while Q:
    x,y=Q.popleft()

    for i in range(x-2,x+3):
        if 0<=i<H:           
            for j in range(y-2,y+3):
                if 0<=j<W:                
                    if MAP[i][j]=="." and abs(i-x)+abs(j-y)==1 and ANS[i][j]>ANS[x][y]:
                        ANS[i][j]=ANS[x][y]
                        Q.appendleft((i,j))
                    elif MAP[i][j]=="." and abs(i-x)+abs(j-y)>1 and ANS[i][j]>ANS[x][y]+1:
                        ANS[i][j]=ANS[x][y]+1
                        Q.append((i,j))

if ANS[gh][gw]==1<<30:
    print(-1)
else:
    print(ANS[gh][gw])



Measured memory_bytes: 89460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	vector<ll> A(N+1), B(N+1);
	for (auto& x : A) cin >> x;
	B[N] = A[N];
	for (int i = N-1; i >= 0; -- i) B[i] = B[i+1] + A[i];
	for (int i = 0; i < 50 && i <= N; ++ i) {
		B[i] = min(B[i], 1LL<<i);
	}
	ll hoge = 1;
	ll res = 0;
	for (int i = 0; i <= N; ++ i) {
		hoge = min(hoge, B[i]);
		res += hoge;
		if (A[i] > hoge) {
			cout << -1 << endl;
			return 0;
		}
		hoge -= A[i];
		hoge = hoge*2;
	}
	cout << res << endl;
}


Measured memory_bytes: 4844
function Main(input){
  var inp = input.trim().split('\n');
  var N = parseInt(inp[0].trim());
  var S = inp[1].split(' ');

  var answer = 'Three';
  for(var i = 0; i < S.length; i++){
    if (S[i] === 'Y'){
      answer = 'Four';
    }
  }
  console.log(answer);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <list>

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
const int INF = 100000000;
const ll LINF = (ll)1e18;

using Graph = vector<vector<P>>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin >> n >> m;
    
    int a[1000],b[1000],c[1000],dist[100][100];
    
    for(int i = 0; i < m; ++i){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--,b[i]--;
    }
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            if(i==j){
                dist[i][j]=0;
            }
            else
            {
                dist[i][j]=INF;
            }
        }
    }
    for(int i = 0; i < m; ++i){
        dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
        dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
    }
    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    int ans=m;
    for(int i = 0; i < m; ++i){
        bool shortest=false;
        for(int j = 0; j < n; ++j){
            if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;
        }
        if(shortest==true){
            ans=ans-1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

char str1[100];
char str2[100];

int main() {
#ifdef TEST
    freopen("input", "r", stdin);
#endif

    scanf("%s", str1);
    scanf("%s", str2);
    int len1 = strlen(str1);
    int len2 = strlen(str2);
    int flag = 0;
    for (int i = 0; i < len1; ++i) {
        if(str1[i] == str2[0]) {
            int j = 0;
            for (; j < len2; ++j) {
                if(str1[(j + i) % len1] != str2[j]) break;
            }
            if(j == len2) {
                flag = 1;
                break;
            }
        }
    }

    if(flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}



Measured memory_bytes: 2132
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[]
for i in range(n-k+1):
    ans.append(min(abs(a[i])+abs(a[i]-a[i+k-1]),abs(a[i+k-1])+abs(a[i+k-1]-a[i])))
print(min(ans))


Measured memory_bytes: 14392
(N, K) = map(int, input().split())
S = input()

fpos_list = []
ps = ''
for i in range(len(S)):
    if ps != S[i]:
        fpos_list.append([i, S[i]])
        ps = S[i]

ans = 0
for i in range(len(fpos_list)):
    bp = fpos_list[i][0]
    bs = fpos_list[i][1]
    l = 0
    if bs == '0':
        ep = N
        if i+2*K < len(fpos_list):
            ep = fpos_list[i+2*K][0]
        l = ep-bp
    else:
        ep = N
        if i+1+2*K < len(fpos_list):
            ep = fpos_list[i+1+2*K][0]
        l = ep-bp
    if l > ans:
        ans = l
    # debug
    #print('i: ', i)
    #print('bp: ', bp)
    #print('bs: ', bs)
    #print('l: ', l)

print(ans)


Measured memory_bytes: 16500
n,k,q=gets.split.map &:to_i
a=$<.map &:to_i
na=Array.new(n,0)
a.each do |ai|
  na[ai-1]+=1
end
n.times do |i|
  if k-q+na[i]>0
    puts "Yes"
  else
    puts "No"
  end
end

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    ll a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        cout << 0 << endl;
    } else {
        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > b) swap(a, b);
        
        cout << a * b << endl;
    }
    
    
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        
        BufferedReader stdInput = new BufferedReader(new InputStreamReader(System.in));
        String std = stdInput.readLine();
        String[] input = std.split(" ");
        int a = Integer.parseInt(input[0]);
        int b = Integer.parseInt(input[1]);
        int c = Integer.parseInt(input[2]);
        
        int count = 0;
        
        for(int i = a; i < (b+1); i++){
            if(c % i == 0){
                count++;
            }
        }
        
        System.out.println(count);
    }
}

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


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

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

    int dp[n];
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);

    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]), dp[i-1]+abs(arr[i]-arr[i-1]));
    }

    cout<<dp[n-1];
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,((n)+1))
#define repst(i,s,n) reps(i,s,((n)+1))
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (i==n-1?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}
#define YES cout<<"YES"<<ln
#define NO cout<<"NO"<<ln
#define Yes cout<<"Yes"<<ln
#define No cout<<"No"<<ln

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n;

signed main() {
	cin >> n;
	cout << n/3 << ln;
}

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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
}


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

#define MAX_N 2000

// int A = 2;
// int B = 5;
int A, B;
int main() {
    cin >> A >> B;
    if (A < 1 || 9 < A || B < 1 || 9 < B) {
        cout << -1 << endl;
        return 0;
    };

    cout << A * B << endl;
}

Measured memory_bytes: 256
/* Filename: ABC045A.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main{

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

		while (input.hasNext()) {
			int a = input.nextInt();
			int b = input.nextInt();
			int h = input.nextInt();
			
			System.out.println((a + b) * h / 2);
		}
	}

}


Measured memory_bytes: 8788
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
import itertools as it
ans=0
for i in it.permutations(range(n),n):
    x=xy[i[0]][0]
    y=xy[i[0]][1]
    for k in range(1,n):
        j=i[k]
        ans+=((x-xy[j][0])**2+(y-xy[j][1])**2)**0.5
        x=xy[j][0]
        y=xy[j][1]
N=1
for i in range(1,n+1):
    N*=i
print(ans/N)


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

using namespace std;

int main(){
 long long  N,A,B; cin>> N >> A >> B;
  vector<long long > X(N);
  for(long long i = 0; i < N ; i++){ cin >> X[i];}
  
  long long ans = 0;
  
  for(long long j = 0; j < N - 1; j++){
    long long x = X[j+1] - X[j];
    
    if( x * A <= B){ ans+= x * A;}
    else{ ans += B;}
  }
  
  cout << ans << endl; return 0;}

Measured memory_bytes: 1024
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_B() {}


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vi h(N); REP(i, N) cin >> h[i];

    vi a(N, 0); // a[i]: highest in [0,i]
    int hi = 0;
    REP(i, N){
        hi = max(hi, h[i]);
        a[i] = hi;
    }

    int ans=0;
    REP(i,N){
        if (h[i] >= a[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int N,D;
	cin>>D>>N;
	
	vector<int> ans;
	
	for(int i=1;i<=50000000;i++){
		int cnt = 0;
		int now = i;
		while(now%100==0){
			cnt++;
			now/=100;
		}
		if(cnt==D)ans.push_back(i);
	}
	
	
	cout<<ans[N-1]<<endl;
		
	
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    if(n==1){
        cout << "Hello World" << endl;
        return 0;
    }

    int a, b;
    cin >> a >> b;
    cout << a+b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include <math.h>
#include <string>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
typedef long long int ll;
using namespace std;

int main(){
	int h,w; cin >>h>>w;
	string s;
	int cnth=-1;  int cntw=-1;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> s;
			if(s=="snuke"){
				cnth=i; cntw=j;
			}
		}
	}
	char a='A';
	for(int i=0;i<cntw;i++){
		a++;
	}
	cout << a <<cnth+1 << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define long int64_t
using namespace std;

struct Solver {
	void solve() {
		int X;
		cin >> X;
		cout << (X >= 30 ? "Yes" : "No") << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3676
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, std.datetime;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto Y = s[1];

    for (int i = 0; i * 10000 <= Y && i <= N; ++i) {
        for (int j = 0; i * 10000 + j * 5000 <= Y && i + j <= N; ++j) {
            int k = Y - i*10000 - j*5000;
            if (i + j + k/1000 == N) {
                writeln(i, " ", j, " ", k/1000);
                return;
            }
        }
    }

    writeln(-1, " ", -1, " ", -1);
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main{
	int N,M;
	int[] union,rank;
	boolean[] used;

	public boolean same(int x,int y){
		return find(x) == find(y);
	}

	public int find(int x){
		if(union[x] == x)return x;
		return union[x] = find(union[x]);
	}

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

		if(x == y)return;

		if(x < y){
			union[y] = x;
			rank[x] += rank[y];
		}else{
			union[x] = y;
			rank[y] += rank[x];
		}
	}

	public void solve() {
		N = nextInt();
		M = nextInt();

		union = new int[N];
		rank = new int[N];
		used = new boolean[N];
		for(int i = 0;i < N;i++)union[i] = i;
		Arrays.fill(rank, 1);


		for(int i = 0;i < M;i++){
			int a = nextInt()-1;
			int b = nextInt()-1;

			unite(a,b);
		}

		int big = 0;
		int small = 0;
		for(int i = 0;i < N;i++){
			int root = find(i);
			if(used[root])continue;
			used[root] = true;

			if(rank[root] == 1)small++;
			else big++;
		}

		out.println(Math.abs(big-small));
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24456
using System;
//using System.Collections.Generic;
//using System.Collections;
using System.Linq;

namespace solution
{
  class Class1
  {
    static void Main()
    {
      var s = Console.ReadLine().Split().ToArray();
      int n = int.Parse(s[0]);
      int c = int.Parse(s[1]);

      if (c < 0)
      {
        if (n == 2) Console.WriteLine("11");
        else Console.WriteLine((decimal)Math.Pow(10, n * 2) - 1);
      }
      else
      {
        int a = 0;

        for (double i = Math.Pow(10, n * 2 + 1) - 1; i >= Math.Pow(10, n * 2) + 1; i--)
        {
          int flag = 0;
          string t = i.ToString();
          string d = c.ToString();

          if (t.Length % 2 == 0 || t.Substring((t.Length - 1) / 2, 1) != d) continue;

          for (int j = 0; j < t.Length / 2; j++)
          {
            if (t[j] != t[t.Length - 1 - j]) { flag = 1; break; }
          }

          if (flag == 1) continue;

          if (PrimeCheck(i) == true)
          {
            a = 1;
            Console.WriteLine(i);
            break;
          }
        }
        if (a == 0) Console.WriteLine(Math.Pow(10, n * 2) - 1);
      }
    }

    public static bool PrimeCheck(double num)
    {
      if (num % 2 == 0) return false;

      for (int i = 3; i < (int)Math.Sqrt(num); i += 2)
      {
        if (num % i == 0) return false;
      }
      return true;
    }
  }
}








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

struct X {
    int day;
    int pay;
};

int main() {
    int n, m;
    cin >> n >> m;
    auto works = vector<X>(n);
    for (int i = 0; i < n; i++) {
        cin >> works[i].day >> works[i].pay;
    }

    sort(works.begin(), works.end(), [](auto x, auto y) { return (x.pay > y.pay) || (x.pay == y.pay && x.day > y.day); });

    auto insert_pos_for = vector<int>(100'005, -1);
    for (int a = 1; a <= 100'000; a++) {
        insert_pos_for[a] = m - a;
    }

    auto scheduled = vector<int>(m, -1);
    auto sum = 0LL;
    for (int i = 0; i < n; i++) {
        const auto &w = works[i];
        auto day = insert_pos_for[w.day];
        if (day < 0)
            continue;

        while (day >= 0) {
            if (scheduled[day] < 0)
                break;
            day--;
        }

        if (day >= 0) {
            scheduled[day] = i;
            sum += w.pay;
        }
        insert_pos_for[w.day] = day;
    }

    cout << sum;
    return 0;
}


Measured memory_bytes: 1792