akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	int nitime = s.length();
	int ans = (15-nitime)+ s.replace("x","").length();

	if(ans >= 8)System.out.println("YES");
	else System.out.println("NO");
    }
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

class BIT {
   public:
    explicit BIT(int64_t nn) : n(1 << (int64_t)ceil(log2(nn))), data(n + 1) {}

    // [0, i)
    int64_t query(int64_t i) {
        int64_t s = 0;

        while (i > 0) {
            s += data[i];
            i -= (i & -i);
        }

        return s;
    }

    void add(int64_t i, int64_t v) {
        int64_t idx = i + 1;

        while (idx <= n) {
            data[idx] += v;
            idx += (idx & -idx);
        }
    }

   private:
    int64_t n;
    vector<int64_t> data;
};

int main() {
    int64_t n, q;
    cin >> n >> q;

    vector<int64_t> c(n);
    for (auto&& cc : c) {
        cin >> cc;
    }

    vector<int64_t> prev(n + 1, -1);
    vector<std::tuple<int64_t, int64_t, int64_t>> intervals;

    for (auto i : irange(0L, q)) {
        int64_t l, r;
        cin >> l >> r;

        intervals.emplace_back(l - 1, i, r - 1);
    }

    for (auto i : irange(0L, n)) {
        int64_t cc = c[i];

        if (prev[cc] >= 0) {
            intervals.emplace_back(prev[cc], q, i);
        }

        prev[cc] = i;
    }

    sort(intervals.rbegin(), intervals.rend());

    BIT bit(n);
    vector<int64_t> ans(q, 0L);

    for (const auto [l, i_query, r] : intervals) {
        if (i_query == q) {
            bit.add(r, 1);
        } else {
            ans[i_query] = r - l + 1 - bit.query(r + 1);
        }
    }

    for (auto a : ans) {
        cout << a << "\n";
    }
}

Measured memory_bytes: 42908
using System;
using System.Linq;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            int input;
            while((input = int.Parse(Console.ReadLine())) != 0) {
                string output = "NA";
                for(int i = 1; i <= 12; ++i) {
                    var data = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    input -= data[0] - data[1];
                    if(input <= 0) {
                        output = i.ToString();
                        for(int j = i + 1;j <= 12; ++j) {
                            Console.ReadLine();
                        }
                        break;
                    }
                }
                Console.WriteLine(output);
            }
        }
    }
}

Measured memory_bytes: 6144
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	H := readint()
	A := readint()
	ans := H / A
	if H%A != 0 {
		ans++
	}
	fmt.Println(ans)
}

const (
	iobufsize = 1 * 1024 * 1024 // 1 MB
)

var stdinsc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, iobufsize), iobufsize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func readint() int {
	stdinsc.Scan()
	v, err := strconv.Atoi(stdinsc.Text())
	if err != nil {
		panic(err)
	}
	return v
}

func readstr() string {
	stdinsc.Scan()
	return stdinsc.Text()
}

func pow(x, y int) int {
	if y < 1 {
		return 1
	}
	return x * pow(x, y-1)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

int n;
map<pll,int> edge;
void dfs(const graph &g,int v,int p){
  int cnt=1;
  for(auto i:g[v]){
    if(i==p)continue;
    if(p!=-1 && edge[pll(p,v)]==cnt){
      cnt++;
    }
    edge[pll(v,i)]=cnt++;
  }
  for(auto i:g[v]){
    if(i==p)continue;
    dfs(g,i,v);
  }
}

int main(){
  int i,j,k,cnt=0;
  cin>>n;
  graph g(n);
  int a[n-1],b[n-1];
  for(i=0;i<n-1;i++){
    cin>>a[i]>>b[i];
    g[a[i]-1].push_back(b[i]-1);
    g[b[i]-1].push_back(a[i]-1);
  }
  int ma=0;
  for(i=0;i<n;i++){
    ma=max(ma,(int)g[i].size());
  }
  dfs(g,0,-1);
  cout<<ma<<endl;
  for(i=0;i<n-1;i++){
    cout<<edge[pll(a[i]-1,b[i]-1)]<<endl;
  }
}


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

#define ll long long
#define pii pair<int,int>
#define MAX 100005

int tree[4*MAX], arr[MAX], print[MAX];

map<int,int> cnt;

void bld(int n, int b, int e)
{
	if(b==e)
	{
		//cout << arr[b] << " = " << tree[n] << endl;
		cnt[arr[b]]+=tree[n];
		return;
	}

	int lft= 2*n;
	int rit= lft+1;
	int mid= (b+e)/2;

	tree[lft]+=tree[n];
	tree[rit]+=tree[n];

	bld(lft, b, mid);
	bld(rit,mid+1,e);
}

void up(int n, int b, int e, int l, int r)
{
	if(r<arr[b] or arr[e]<l) return;

	if(l<=arr[b] and arr[e]<=r)
	{
		//cout << l << " to " << r << " val " << arr[b] << " " << arr[e] << endl;
		tree[n]++;
		return;
	}

	int left= n*2;
	int right= left +1;
	int mid= (b+e)/2;

	up(left,b,mid,l,r);
	up(right,mid+1,e,l,r);
}

int main()
{
	int n, q;
	scanf("%d %d",&n,&q);

	for(int i=1;i<=n;i++) arr[i]=i;

	for(int i=0;i<q;i++)
	{
		int u, v;
		scanf("%d %d",&u,&v);

		if(q==1)
		{
			cout << v-u+1 << endl;
			return 0;
		}

		up(1,1,n,u,v);
	}

	bld(1,1,n);

	int cn=0;
	for(int i=1;i<=n;i++)
	{
		if(cnt[i]==q) cn++;
	}

	cout << cn << endl;

	return 0;
}


Measured memory_bytes: 6400
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program{
    static void Main(){
        var Mountains = new List<int>();
        for (int i = 0; i < 10; i++)
        {
            Mountains.Add(int.Parse(Console.ReadLine()));
        }
        var ans = Mountains.OrderByDescending(val => val)
                        .Where((val, idx) => idx < 3)
                        .ToArray();
        for (int i = 0; i < 3; i++)
        {
            Console.WriteLine(ans[i]);
        }
    }
}

Measured memory_bytes: 10080
from heapq import heappush, heappop
n=int(input())
a=list(map(int,input().split()))
l=[]
for v in a[:n]:
  heappush(l,v)
suml=[sum(a[:n])]
for i in range(n):
  suml.append(suml[i]+a[n+i])
  heappush(l,a[n+i])
  suml[i+1]-=heappop(l)
r=[]
for v in a[2*n:]:
  heappush(r,(10**10-v,v))
sumr=[sum(a[2*n:])]
for i in range(n):
  sumr.append(sumr[i]+a[2*n-i-1])
  heappush(r,(10**10-a[2*n-i-1],a[2*n-i-1]))
  _,t=heappop(r)
  sumr[i+1]-=t
ans=-10**20
for i in range(n+1):
  ans=max(ans,suml[i]-sumr[n-i])
print(ans)

Measured memory_bytes: 37212
#include<stdio.h>

long minv,maxv;
int n;
int main(){
  scanf("%d",&n);
  long r[200000];

for(int j=0;j<n;j++){
  scanf("%ld",&r[j]);
  if(j==0){minv = r[0];maxv=-10000000000;}
  else{
  if(maxv<=r[j]-minv){
    maxv=r[j]-minv;
  }
  if(minv>r[j]){
    minv=r[j];
  }}
  //printf("maxv;%lf minv;%lf\n",maxv,minv);
}
printf("%ld\n",maxv);
  return 0;
}



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

vector<vector<int>> G;
vector<int> indeg;

int main(void){
    int N, M; cin >> N >> M;
    G.resize(N);
    indeg.resize(N);
    for (int i = 0; i < N+M-1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        indeg[b] += 1;
    }
    
    
    vector<int> ans(N); 
    queue<int> q;
    for (int i = 0; i < N; i++) {
        if (indeg[i] == 0) {
            ans[i] = -1;
            q.push(i);
        }
    }
    
    while (!q.empty()) {
        int q_top = q.front();
        q.pop();
        
        for (int i = 0; i < G[q_top].size(); i++) {
            int to = G[q_top][i];
            indeg[to] -= 1;
            if (indeg[to] == 0) {
                ans[to] = q_top;
                q.push(to);
            }
        }
    }
    
    for (auto i : ans) {
        cout << i+1 << endl;
    }
}


Measured memory_bytes: 7040
#include<iostream>
#include<string>
using namespace std;
string S; int cnt = 0;
int main() {
	cin >> S; string T = "CODEFESTIVAL2016";
	for (int i = 0; i < 16; i++) { if (S[i] != T[i])cnt++; }
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

// UnionFind
struct UnionFind {
    vector<int> par;
    vector<int> siz;

    UnionFind(int N) : par(N), siz(N, 1LL) {
        for(int i = 0; i < N; i++)
            par[i] = i;
    }
    int root(int x) {
        if(par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)
            return;
        if(siz[rx] < siz[ry])
            swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    ll size(ll x) { return siz[root(x)]; }
};

// Edge
template <typename T> struct Edge {
    int from, to;
    T cost;
    Edge(int f, int t, T c) : from(f), to(t), cost(c) {}
};

// Kruskal Method
// @param edges := set of Edge
//        V := the number of vertice
template <typename T> T kruskal(vector<Edge<T>> &edges, int V) {
    sort(begin(edges), end(edges),
         [](const Edge<T> &a, const Edge<T> &b) { return (a.cost < b.cost); });
    UnionFind tree(V);
    T res = 0;
    for(auto &e : edges) {
        if(!tree.same(e.from, e.to)) {
            tree.unite(e.from, e.to);
            res += e.cost;
        }
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    using pii = pair<int, int>;
    vector<pair<int, pii>> city(N);
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        city[i] = MP(i, MP(x, y));
    }
    sort(All(city), [](const pair<int, pii> &a, const pair<int, pii> &b) {
        return a.second.first < b.second.first;
    });
    vector<Edge<ll>> edges;
    rep(i, N - 1) {
        edges.pb(Edge<ll>(city[i].first, city[i + 1].first,
                          city[i + 1].second.first - city[i].second.first));
    }

    sort(All(city), [](const pair<int, pii> &a, const pair<int, pii> &b) {
        return a.second.second < b.second.second;
    });
    rep(i, N - 1) {
        edges.pb(Edge<ll>(city[i].first, city[i + 1].first,
                          city[i + 1].second.second - city[i].second.second));
    }

    cout << kruskal(edges, N) << endl;

    return 0;
}

Measured memory_bytes: 7664
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
pairs = list(tuple(map(int, input().split())) for _ in range(Q))

init_sum = sum(A)
counter = Counter(A)
total = init_sum

for b, c in pairs:
    total -= counter[b] * b
    total += counter[b] * c
    counter[c] += counter[b]
    del counter[b]
    print(total)



Measured memory_bytes: 35628
P = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051,
1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381]
n = int(input())
for i in range(n):
    print(P[i], end = " ")
print()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define rep(i,a,n) for(int i=(a);i<(n);i++)
using namespace std;

int main() {
	map<string, long long> a;
	set<string> st;
	long long int l, r;
	cin >> l >> r;
	int ans = 2019;
	if (r - l >= 2019)ans = 0;
	else {
		l = l % 2019;
		r = r % 2019;
		rep(i, l, r) {
			rep(j, i+1, r + 1) {
				ans = min(ans, i * j % 2019);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const long long INF = 1LL<<60;

int calc_digit(long long n) {
    int res = 0;
    while (n > 0) {
        ++res;
        n /= 10;
    }
    return res;
}

int main() {
    long long N; cin >> N;
	long long res = INF;
	for (long long a = 1; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long b = N/a;
        long long tmp = max(calc_digit(a), calc_digit(b));
        res = min(res, tmp);
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
 
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
int main()
{
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    int min=a+b-n;
    if(min<0)min=0;
    int max;
    if(a>b)max=b;
    else max=a;
    printf("%d %d\n",max,min);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++)
using ll = long long;

int main() {
  ll n,k;
  cin >> n >> k;

  vector<ll> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

  vector<ll> prefix_sum(n + 1);
  for (int i = 1; i <= n; i++) {
    prefix_sum[i] = prefix_sum[i - 1] + a[i];
  }

  vector<int> mod(n + 1);
  for (int i = 1; i <= n; i++) {
    mod[i] = (prefix_sum[i] - i + k) % k;
  }

  ll answer = 0;
  map<int,int> mp;
  for (int i = 0; i <= n; i++) {
    if (i - k >= 0) mp[mod[i - k]]--;
    answer += mp[mod[i]];
    mp[mod[i]]++;
  }

  cout << answer << '\n';
  return 0;
}


Measured memory_bytes: 16376
import queue

H, W = map(int,input().split())
b = [list(input()) for _ in range(H)]
ini = 0
if b[0][0] == '#':
    ini = 1
dist = [[ini for _ in range(W)] for _ in range(H)]
start = (0,0)
qq = queue.Queue()
for i in range(H):
    for j in range(W):
        tgt = []
        if j==0:
            pass
        else:
            if b[i][j-1] == '.' and b[i][j] == '#':
                tgt.append(dist[i][j-1] + 1)
            else:
                tgt.append(dist[i][j-1])
        if i==0:
            pass
        else:
            if b[i-1][j] == '.' and b[i][j] == '#':
                tgt.append(dist[i-1][j] + 1)
            else:
                tgt.append(dist[i-1][j])
        if i+j==0:
            continue
        dist[i][j] = min(tgt)
print(dist[H-1][W-1])

Measured memory_bytes: 4464
str = gets.chomp
n = gets.to_i

n.times do
  command = gets.chomp.split

  case command[0]
  when 'print'
    a, b = command[1].to_i, command[2].to_i
    puts str[a..b]
  when 'reverse'
    a, b = command[1].to_i, command[2].to_i
    str[a..b] = str[a..b].reverse
  when 'replace'
    a, b = command[1].to_i, command[2].to_i
    str[a..b] = command[3]
  end
end

Measured memory_bytes: 8732
#include<bits/stdc++.h>
using namespace std;
#define N 1116
#define mod 1000000007
typedef long long ll;
typedef long long matrix[2][2];

int n,m,x,y;
ll k;
char s[N][N];
matrix f,g;

void mul(matrix a,matrix b){
	static matrix c;
	memset(c,0,sizeof(c));
	for (int i=0;i<2;i++)
		for (int j=0;j<2;j++)
			for (int k=0;k<2;k++)
				c[i][j]=(c[i][j]+a[i][k]*b[k][j])%mod;
	memcpy(b,c,sizeof(c));
}

ll read(){
	ll x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();m=read();k=read()-1;
	for (int i=1;i<=n;i++) scanf(" %s",s[i]+1);
	for (int i=1;i<=n;i++) x+=s[i][1]=='#'&&s[i][m]=='#';
	for (int i=1;i<=m;i++) y+=s[1][i]=='#'&&s[n][i]=='#';
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			f[0][0]+=s[i][j]=='#';
	if (x&&y) f[0][0]=1;
	if (x&&!y)
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m-1;j++)
			f[0][1]-=s[i][j]=='#'&&s[i][j+1]=='#';
	if (!x&&y)
	for (int i=1;i<=n-1;i++)
		for (int j=1;j<=m;j++)
			f[0][1]-=s[i][j]=='#'&&s[i+1][j]=='#';
	f[0][1]+=mod;f[1][1]=x+y;g[0][0]=g[1][0]=1;
	for (;k;k/=2,mul(f,f))
		if (k&1) mul(f,g);
	printf("%lld\n",g[0][0]);
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,s,e) for(register int i=s;i<=e;i++)
#define repp(i,s,e) for(register int i=s;i<e;i++)
#define dep(i,e,s) for(register int i=e;i>=s;i--)
#define pb push_back
#define pf(a) printf("%d",a)
#define sf(a) scanf("%d",&a)
#define pii pair<int,int>
#define R register
#define mst(a,x) memset(a,x,sizeof(a))
#define db double
const ll inf=0x7fffffff;
const int N=1e5+1;

int main(){
	int n;
	db d,x,ans;
    scanf("%d%lf%lf",&n,&d,&x);
    db nn=n+n;
    dep(i,n,1){
    	ans+=d+(nn-1)/2*x;
    	d+=(2*d+5*x)/nn;
    	x+=4*x/nn;
    	nn-=2;
	}
	printf("%.10lf\n",ans);
	return 0;
}

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

int dfs(int v, vector<set<int>> &g, vector<int> &dp){
    if(v == 0) return 0;
    if(dp[v]) return dp[v];
    int res = dfs(v-1,g,dp);
    for(int to : g[v]){
        res = max(res,v-to + dfs(to,g,dp));
    }
    return dp[v] = res;
}

int main(void){
    int n;
    while(cin>>n, n){
        vector<int> w(n+1);
        rep1(i,n) cin>>w[i];
        w[0] = -1;

        // g[i][j] := i番目が消える時に右側に会わせられる
        //             ブロックのindex
        vector<set<int>> g(n+1);
        rep1(i,n){
            if(abs(w[i]-w[i-1]) <= 1){
                g[i] = g[i-2];
                g[i].insert(i-2);
            }
            for(int l : g[i-1]){
                if(abs(w[i]-w[l]) <= 1){
                    for(int ll : g[l-1]){
                        g[i].insert(ll);
                    }
                    g[i].insert(l-1);
                }
            }
        }
        vector<int> dp(n+1);
        cout<<dfs(n,g,dp)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3836
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    ll a,b,h; cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
}





























































































Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
int MOD=1e9+7;
int INF=1e9+7;
//
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A%2||B%2||C%2){
    cout<<0<<endl;
  }else if(A==B&&B==C){
    cout<<-1<<endl;
  }else{
    int cnt=0;
    while(1){
      cnt++;
      int a=(B+C)/2,b=(A+C)/2,c=(A+B)/2;
      A=a;B=b;C=c;
      if(A%2||B%2||C%2){
        cout<<cnt<<endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

int main(){
    llong ans=0;
    llong N,K,X,Y;
    cin >> N >> K >> X >> Y;
    ans = min(K*X, N*X);
    ans = ans + max((llong)0, (N-K)*Y);

    cout << ans << endl;
}

Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};

signed main() {
  int H, W;
  cin >> H >> W;

  vector<string> s(H);
  REP(i, H) cin >> s[i];

  vector<vector<int>> dp(H, vector<int>(W, INF));
  dp[0][0] = ((s[0][0] == '.')? 0: 1);

  REP(i, H) REP(j, W){
    REP(k, 2){
      int x = i+dx[k];
      int y = j+dy[k];
      if(OUT(0, x, H)) continue;
      if(OUT(0, y, W)) continue;
      int d = dp[i][j]+((s[i][j] == '.' && s[x][y] == '#')? 1: 0);
      chmin(dp[x][y], d);
    }
  }

  cout << dp[H-1][W-1] << "\n";

  return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define For(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    vector<int> a(n);
    bool denied = false;
    rep(i, n){
        cin >> a[i];
        if(a[i]%2 == 0 && !(a[i]%3 == 0 || a[i]%5 == 0) && !denied)
            denied = true;
    }

    cout << (denied ?  "DENIED" : "APPROVED") << endl;

return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, x;
	cin >> n >> x;
	if(n==2){
		if(x==2){
			cout << "Yes" << endl;
			for(int i=1; i<=3; i++) cout << i << endl;
			return 0;
		}else{
			cout << "No" << endl;
			return 0;
		}
	}

	if(x==1 || x==2*n-1){
		cout << "No" << endl;
		return 0;
	}

	vector<int> v(2*n-1, 0);
	vector<bool> b(2*n, false);
	if(x!=2){
		v[n-2]=x-1; b[x-1]=true;
		v[n-1]=x; b[x]=true;
		v[n]=x+1; b[x+1]=true;
		v[n+1]=x-2; b[x-2]=true;
		int tmp=1;
		for(int i=0; i<2*n-1; i++){
			if(v[i]!=0) continue;
			while(b[tmp]) tmp++;
			v[i]=tmp;
			b[tmp]=true;
		}
	}else{
		v[n-2]=3;
		v[n-1]=2;
		v[n]=1;
		v[n+1]=4;
		for(int i=0; i<n-2; i++) v[i]=5+i;
		for(int i=n+2; i<2*n-1; i++) v[i]=i+1;
	}

	cout << "Yes" << endl;
	for(int i=0; i<2*n-1; i++) cout << v[i] << endl;
	return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define N 200000
typedef long long LL;
using namespace std;
int a[N], n;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i], a[i] -= i;
    sort(a + 1, a + 1 + n);
    LL ans = 0, now;
    for(int i = 1; i <= n; i++) ans += abs(a[1] - a[i]);
    now = ans;
    for(int i = 2; i <= n; i++)
        now += (LL)(i + i - n - 2) * (a[i] - a[i - 1]), ans = min(ans, now);
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// 最大公約数
ll GCD(ll a, ll b)
{
    if (a < 0)
        a = -a;
    if (b < 0)
        b = -b;
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

// 最小公倍数
ll LCM(ll a, ll b)
{
    ll g = GCD(a, b);
    return a / g * b;
}

int main()
{
    int in;
    cin >> in;
    
    cout << (in * in) << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<vector<int>>a(n-1, vector<int>(3));
	for (int i = 0; i < n-1; i++)cin >> a.at(i).at(0) >> a.at(i).at(1) >> a.at(i).at(2);
	for (int i = 0; i < n - 1; i++) {
		int ans = a.at(i).at(1) + a.at(i).at(0);
		for (int j = i+1; j < n -1 ; j++) {
			if (ans <= a.at(j).at(1)) ans = a.at(j).at(1) + a.at(j).at(0);
			else {
				int gap = (ans - a.at(j).at(1)) % a.at(j).at(2);
				if (gap == 0)gap = a.at(j).at(2);
				ans = ans + a.at(j).at(2) - gap + a.at(j).at(0);
			}
		}
		cout << ans << endl;
	}
	cout << 0 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
using namespace std;

int main(){
	int latte[2][1001]={},n=0;
	char str[100];
	for(int i=0;i<2;i++){
		while(fgets(str,100,stdin)){
			if(str[0]==10) break;
			latte[i][atoi(str)]++;
			n = max(n,atoi(str));
		}
	}
	for(int i=0;i<=n;i++){
		if(latte[0][i]>0 && latte[1][i]>0) printf("%d %d\n",i,latte[0][i]+latte[1][i]);
	}
    return 0;
}

Measured memory_bytes: 1132
import java.io.PrintStream;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        doit(args, new Scanner(System.in), System.out);
    }

    static void doit(String[] args, Scanner scanner, PrintStream out) {
        while (scanner.hasNext()) {
            long a = scanner.nextLong();
            long b = scanner.nextLong();
            long gcd = gcd(a, b);
            long lcm = a * b / gcd;
            out.println(String.format("%d %d", gcd, lcm));
        }
    }

    static long gcd(long a, long b) {
        long large = Math.max(a, b);
        long small = Math.min(a, b);
        while (true) {
            long r = large % small;
            if (r == 0) {
                return small;
            }
            large = small;
            small = r;
        }
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

ll n, l;
char buf[100010];

int pnxt[100001][2];
int dep[100001];
char term[100010];
const int root = 1;
int pn = root;

ll ans;

void dfs(int x){
	if(term[x]) return;
	for(int d=0; d<2; ++d){
		if(pnxt[x][d]) dfs(pnxt[x][d]);
		else {
			ll df = l-dep[x];
			ans ^= (df&-df);
		}
	}
}

int main()
{
	read(n, l);
	for(;n--;){
		scanf("%s", buf);
		int p = root;
		for(int i=0; buf[i]; ++i){
			int& nxt = pnxt[p][buf[i]-'0'];
			if(!nxt) dep[nxt = ++pn] = dep[p]+1;
			p = nxt;
		}
		term[p] = 1;
	}
	dfs(root);
	puts(ans?"Alice":"Bob");
	return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <string>
void swap(int &a,int &b){
    int tmp=a;
    a=b;
    b=tmp;
}
void roll(int &dice1,int &dice2,int &dice3,int &dice4){
    swap(dice1,dice2);
    swap(dice2,dice3);
    swap(dice3,dice4);
}
using namespace std;
int main()
{
   int one[7];
    char ch;
    int sum=0;
    for(int i=1;i<=6;i++)
    cin>>one[i];
    while(true) {
            cin.get(ch);
            if(ch=='\n'&&sum!=0)
                break;
            if (ch == 'E')
                roll(one[1], one[4], one[6], one[3]);
            if (ch == 'N')
                roll(one[1], one[2], one[6], one[5]);
            if (ch == 'S')
                roll(one[1], one[5], one[6], one[2]);
            if (ch == 'W')
                roll(one[1], one[3], one[6], one[4]);
            sum++;
        }
    cout<<one[1]<<endl;
    return 0;
}


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

int main() {
	while(true){
		vector<int> vi(3);
		for(int i=0; i<6; ++i){
			int tmp;
			cin >> tmp;
			vi[i%3]+=tmp;
		}
		bool flag=true;
		for(int i=0; i<3; ++i){
			if(vi[i]!=0) flag=false;
		}
		if(flag) break;
		int ans=0;
		for(int i=0; i<3; ++i){
			vector<int> hoge=vi;
			int sum=0;
			{
				int tmp=min(hoge[0],min(i,min(hoge[1],hoge[2])));
				for(int j=0; j<3; ++j) hoge[j]-=tmp;
				sum+=tmp;
			}
			for(int j=0; j<3; ++j){
				int tmp=hoge[j]/3;
				hoge[j]-=tmp*3;
				sum+=tmp;
			}
			ans=max(ans,sum);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]+a[1]==a[2]){
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}


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

#define int long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second


signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    string s;
    cin >> s;
    bool a = false,b = false;
    ffor(i,s.length()){
        if(s[i] == 'A')a = true;
        else if(s[i] == 'B')b = true;
    }    
    if(a&b){
        cout << "Yes";
    }else{
        cout << "No";
    }
}		

Measured memory_bytes: 256
n = int(input())
s = [int(input()) for i in range(n)]
s.sort()
b = [ele%10 for ele in s]
if not any(b):
  print(0)
  exit()

ans = sum(s)
if ans%10==0:
  for i in range(n):
    if s[i]%10:
      ans -= s[i]
      break
print(ans)

Measured memory_bytes: 3064
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty), +) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
                assert!(_it.next().is_none());
        }
    };
}

fn main() {
    loop {
        from_line!(a: i64, op: String, b: i64);
        if op == "?" {
            break;
        }
        let v = match &*op {
            "+" => a + b,
            "-" => a - b,
            "*" => a * b,
            "/" => a / b,
            _ => break 
        };
        println!("{}", v);
    }
}




Measured memory_bytes: 5032
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	long long int K, A, B, i;
	scanf("%lld %lld %lld", &K, &A, &B);

	long long int bisket = 1, yen = 0;
	if (K < A || (B - A) <= 2) {
		printf("%lld", K + 1);
		return 0;
	}
	for (i = 1; i <= K; i++) {
		if (i == K) {
			if (yen == 0) bisket++;
			else bisket += B;
			break;
		}
		
		if(yen == 1 ) {
			bisket += B;
			yen = 0;
		}
		else if (bisket >= A) {
			bisket -= A;
			yen = 1;
		}
		else bisket++;
	}



	printf("%lld", bisket);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A > B)swap(A, B);
	if (C > D)swap(C, D);
	cout << A + C << endl;
	int x;
	cin >> x;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  int vc = N * (N - 1) / 2;

  auto vn = [&](int i, int j) {
    if (i > j) swap(i, j);
    return((N - 1) + (N - i)) * i / 2 + j - i - 1;
  };

  vector<vector<int>> os(vc);
  vector<int> is(vc, 0);

  F0R(i, N) {
    int p, a;
    F0R(j, N - 1) {
      cin >> a;
      a--;
      if (j) {
        os[vn(i, p)].push_back(vn(i, a));
        is[vn(i, a)]++;
      }
      p = a;
    }
  }

  vector<int> vs;
  F0R(i, vc) {
    if (is[i] == 0) {
      vs.push_back(i);
    }
  }
  int rest = vc, result = 0;
  while (vs.size()) {

    vector<int> vs2;
    F0R(i, vs.size()) {
      for (auto c : os[vs[i]]) {
        if (!--is[c]) {
          vs2.push_back(c);
        }
      }
    }
    rest -= vs.size();
    if (rest < 0) break;
    result++;
    vs = move(vs2);
  }
  cout << (rest != 0 ? -1 : result);
}
#endif


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,d;
    cin>>n>>d;
    vvl x(n,vl(d));
    rep(i,n)rep(j,d)cin>>x[i][j];
    set<ll> s;
    rep(i,1000)s.insert(i*i);
    ll res=0;
    rep(i,n){
        rep2(j,i+1,n){
            ll a=0;
            rep(k,d){
                a+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            if(s.count(a))res++;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3700
N = int(input())
A = list(map(int, input().split()))


def gcd(x,y):
  if x < y:
    tmp = x
    x = y
    y = tmp
    
  while y:
    x, y = y, x % y
  return x  
    
ans = gcd(A[0], A[1])  
for i in range(2,N):
  ans = gcd(ans,A[i])
  
  
print(ans)

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

class Step {
public:
	int begin, end, length;
	Step(int begin, int end):begin(begin), end(end), length(end - begin + 1){}
};

int main() {
	int i, j, n, k, tmp, begin, end, maxstep;
	bool flag;

	while (1) {
		cin >> n >> k;
		if (n == 0 && k == 0)break;

		vector<int> card;
		vector<Step> step;

		for (i = 0; i < k; i++) {
			cin >> tmp;
			card.push_back(tmp);
		}
		sort(card.begin(), card.end());
		if (card[0] == 0) {
			flag = true;
			card.erase(card.begin());
		} else {
			flag = false;
		}

		begin = end = card[0];
		for (i = 1; i < k - flag; i++) {
			if (card[i] == end + 1) {
				end = card[i];
			} else {
				Step tmpstep(begin, end);
				step.push_back(tmpstep);
				begin = end = card[i];
			}
		}
		Step tmpstep(begin, end);
		step.push_back(tmpstep);

		if (flag) {
			maxstep = 0;
			for (i = 0; i < step.size() - 1; i++) {
				if (step[i].end + 2 == step[i + 1].begin) {
					maxstep = max(maxstep, step[i].length + step[i + 1].length + 1);
				} else {
					maxstep = max(maxstep, step[i].length + 1);
				}
			}
			maxstep = max(maxstep, step[i].length + 1);


			cout << maxstep << endl;

		} else {
			maxstep = 0;
			for (i = 0; i < step.size(); i++) {
				maxstep = max(maxstep, step[i].length);
			}
			cout << maxstep << endl;

		}
		
	}




	return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define mod 1000000007
#define inf 999999999999999ll
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vi a(n);
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
            ans+=a[i]*a[j];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = 0;
		int k = sc.nextInt();
		int s = sc.nextInt();
		for(int x = 0; x <= k; x++) {
			for(int y = 0; y <= k; y++) {
				int z = s - x - y;
				if(0 <= z && z <= k) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}

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

using namespace std;

int main() {
  int n, sz = 3;
  cin >> n;
  if (n == 1) {
    cout << "Yes" << endl;
    cout << 2 << endl;
    cout << 1 << " " << 1 << endl;
    cout << 1 << " " << 1 << endl;
    return 0;
  }
  bool ng = true;
  for (int i = 3, m = 3; m <= n; i++) {
    if (m == n) {
      ng = false;
      break;
    }
    m += i;
    sz++;
  }
  if (ng) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  cout << sz << endl;
  vector<vector<int>> S(sz);
  S[0].emplace_back(1);
  S[0].emplace_back(3);
  S[1].emplace_back(1);
  S[1].emplace_back(2);
  S[2].emplace_back(2);
  S[2].emplace_back(3);

  int add = 4;
  for (int i = 3; i < sz; i++) {
    for (int j = 0; j < i; j++) {
      S[j].emplace_back(add);
      S[i].emplace_back(add);
      add++;
    }
  }

  for (int i = 0; i < sz; i++) {
    cout << S[i].size() << " ";
    for (auto x : S[i]) cout << x << " ";
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll x; cin>>x;
	if(360%x==0){
		cout<<360/x;
		return 0;
	}
	else{
		cout<<((360*x)/gcd(360,x))/x;
	}
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

int main() {
    string ans;
    ll n;
    cin>>n;

    int nsize= 0;
    
    int ins = 0;

    for(ll i = 1; i < n; i = i*10)
        nsize++;

    REP(i,nsize+1) {
        ins += (n % (ll)pow(10,i+1)) / pow(10,i);
    }

    //DEBUG(ins);

    ans = (n % ins == 0) ? "Yes" : "No";

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

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

using namespace std;

string s;

bool check(int k){
	string t=s;
	int n=s.size();
	int ch = 0;
	for(int i=0;i<k;i++){
		if(ch){
			t[i]=char('1'+'0'-t[i]);
		}
		if(i>=n-k+1){
			if(t[i]=='1'){
				return 0;
			}
			continue;
		}

		if(t[i]=='1'){
			ch=1-ch;
		}
	}
	return 1;
}

int main(){
	cin >> s;
	int l=1, r=s.size()+1;

	while(l+1<r){
		int mid=(l+r)>>1;
		if(check(mid)){
			l=mid;
		}
		else{
			r=mid;
		}
	}
	cout << l << endl;
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
int main(){
  int n,k;
  scanf("%d %d",&n,&k);
  double win;
  int c =n;
  while(n>=1){
    int z=n;
    int cnt=0;
    while(z<k){
      z=z*2;
      cnt++;
    }
    win+=(1/pow(2,cnt));
    n--;
  }
  win /= c;
  printf("%.10lf",win);
  return 0;
}

Measured memory_bytes: 2564
N = int(input())
A = [int(input()) for _ in range(N)]

ret = 0
for i in range(N) :
    if A[i] > 2 :
        x = (A[i] - 1) // 2
        ret += x
        A[i] -= x * 2

for i in range(N - 1) :
    if A[i] == 2 :
        ret += 1
    elif A[i] == 1 and A[i + 1] >= 1 :
        ret += 1
        A[i + 1] -= 1

if A[-1] == 2 :
    ret += 1
    
print(ret)

Measured memory_bytes: 50520