akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int n,m;
    cin >> n >> m;
    vector<int>high(n);
    for(int i=0;i<n;i++){
        cin >> high.at(i);
    }
    vvll ma(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        ma.at(a).push_back(b);
        ma.at(b).push_back(a);
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        int now = high.at(i);
        bool che = 1;
        for(int j=0;j<ma.at(i).size();j++){
            int check = high.at(ma.at(i).at(j));
            if(now<=check)che=0;
        }
        if(che)ans++;
    }
    cout << ans << endl;
}
    



Measured memory_bytes: 9536
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	k := nextInt()
	s := nextString()

	if len(s) > k {
		fmt.Println(s[:k] + "...")
	} else {
		fmt.Println(s)
	}
}


Measured memory_bytes: 1788
#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>

//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 1LL<<30
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define slla(n) scanf("%lld", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };

const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 2e5 + 50;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes"); exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No"); exit(0); }
void one() { puts("-1"); exit(0); }

char val[maxn];
ll num[maxn];
int lowbit(int x)
{
	return x&(-x);
}
ll getsum(ll x)
{
	ll ans = 0;
	while (x>0)
	{
		ans += num[x];
		x -= lowbit(x);
	}
	return ans;
}
ll add(int x, int v)
{
	int up = maxn - 1;
	while (x <= up)
	{
		num[x] += v;
		x += lowbit(x);
	}
	return x;
}

int vis[maxn];
int num_char[30];
vector<int>pos[30];

void solve()
{
	scanf("%s", val + 1);
	int len = strlen(val + 1);

	repp(i, 1, len)
	{
		num_char[val[i] - 'a']++;
		pos[val[i] - 'a'].push_back(i);
	}
	int cnt = 0;
	repp(i, 0, 26)
	{
		if (num_char[i] & 1)
		{
			cnt++;
		}
	}
	if (cnt >= 2)
	{
		puts("-1");
		return;
	}
	repp(i, 1, len)
	{
		add(i, 1);
		vis[i] = 1;
	}
	ll ans = 0;
	repp(i, 1, len)
	{
		if (vis[i] == 0)continue;
		int p = pos[val[i] - 'a'].back();
		pos[val[i] - 'a'].pop_back();
		if (p == i)
		{
			ans += ((getsum(len) - getsum(i)) >> 1);
		}
		else
		{
			ans += (getsum(len) - getsum(p));
		}
		vis[i] = 0;
		vis[p] = 0;
		add(p, -1);
		add(i, -1);
	}
	printf("%lld\n", ans);
}

int main()
{

	solve();
	// system("pause");
	return 0;
}


Measured memory_bytes: 3960
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
  s = input()
  if s == 'AC':
    ac += 1
  elif s == 'WA':
    wa += 1
  elif s== 'TLE':
    tle += 1
  elif s== 'RE':
    re += 1
print('AC x '+str(ac)) 
print('WA x '+str(wa)) 
print('TLE x '+str(tle)) 
print('RE x '+str(re)) 

Measured memory_bytes: 9028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    // 問題:
    class A_165_We_Love_Golf
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            int k = int.Parse(Console.ReadLine());

            // 整数配列の入力
            var inputintArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            int a = inputintArray[0];
            int b = inputintArray[1];

            for (int i = a; i < b + 1; i++)
            {
                if (i % k == 0)
                {
                    Console.WriteLine("OK");
                    break;
                }
                else if (i == b)
                {
                    Console.WriteLine("NG");
                }
            }
            //for (int i = 1; i < b + 1; i++)
            //{
            //    int keisan = k * i;

            //    if (keisan >= a && keisan <= b)
            //    {
            //        Console.WriteLine("OK");
            //        break;
            //    }
            //    else if (i == b)
            //    {
            //        Console.WriteLine("NG");
            //    }
            //}

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28292
#include<cstdio>
using namespace std;
long long stat[30]={};
int main(){
	long long res=0;
	char c;
	long long n=0;
	while(scanf("%c",&c)){
		if(c=='\n')break;
		++n;
		stat[c-'a']++;
	}
	res=n*(n+1)/2+1;
	for(int i=0;i<26;++i){
		res-=stat[i]*(stat[i]+1)/2;
	}
	printf("%lld\n",res);
}

Measured memory_bytes: 128
//"BISMILLAHIR RAHMANIR RAHIM"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1e8 ;
int main()
{
    ll n,i,j,k,cnt=0,x;
    cin>>n;
    vector< ll > ara;
    for(i=0;i<n;i++){
        cin>>x;
        ara.pb(x);
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            if(ara[i]==ara[j])
                continue;
            for(k=j+1;k<n;k++){
                    if(ara[j]==ara[k] || ara[k]==ara[i] )
                    continue;
                if(ara[i]+ara[j]>ara[k] && ara[j]+ara[k]>ara[i]
                   && ara[k]+ara[i]>ara[j])
                    cnt++;
            }

        }
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class  Main{
   static   Integer arr[];
   static int b[];
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;


        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int n=sc.nextInt();
        long sum=0;
        for (int i=1;i<=n;i++)
        {
            if ( i%5!=0 && i%3!=0 )
            {
                sum+=i;
            }


        }
        System.out.println(sum);

    }
}

Measured memory_bytes: 32804
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int h, w;
    scanf("%d %d", &h, &w);
    char s[h][w];
    rep(i, h)
    {
        rep(j, w)
        {
            scanf(" %c", &s[i][j]); //scanfするとき改行がある場合、" %c"とする
        }
    }
    int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
    int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
    rep(i, h)
    {
        rep(j, w)
        {
            if (s[i][j] != '#')
            {
                int count = 0;
                rep(d, 8)
                {
                    int ni = i + dy[d];
                    int nj = j + dx[d];
                    if(ni < 0 || h <= ni) continue; //s[-1][*]やs[h以上][*]など表からはみ出す場合は除外する
                    if(nj < 0 || w <= nj) continue; //s[*][-1]やs[*][w以上]など表からはみ出す場合は除外する
                    if(s[ni][nj] == '#') count++;
                }
                printf("%d", count);
            }
            else printf("#");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
lli idx(int u, int d)
{
  return 3 * u + d;
}
struct dijkstra
{
  using lli = long long int;
  vector<vector<pair<lli, lli>>> e;
  int n;
  lli inf = 1e18;
  dijkstra(int n) : n(n)
  {
    e.resize(n);
  }
  void add(int a, int b, lli c)
  {
    e[a].push_back(make_pair(b, c));
  }
  void biadd(int a, int b, lli c)
  {
    add(a, b, c);
    add(b, a, c);
  }
  vector<lli> get(int s)
  {
    vector<lli> dist(n, inf);
    dist[s] = 0;
    using p = pair<lli, lli>;
    priority_queue<p, vector<p>, greater<p>> que;
    que.push(make_pair(0, s));
    while (!que.empty())
    {
      lli d = que.top().first;
      lli cur = que.top().second;
      que.pop();
      if (dist[cur] < d)
        continue;
      dist[cur] = d;
      for (auto s : e[cur])
      {
        lli wei = s.second;
        lli to = s.first;
        if (dist[to] > dist[cur] + wei)
        {
          dist[to] = dist[cur] + wei;
          que.push(make_pair(dist[cur] + wei, to));
        }
      }
    }
    return dist;
  }
};
void solve(long long N, long long M, std::vector<long long> u,
           std::vector<long long> v, long long S, long long T)
{
  dijkstra dij(3 * N);
  rep(i, M) v[i]--, u[i]--;
  rep(i, M)
  {
    rep(j, 3)
    {
      dij.add(idx(u[i], j), idx(v[i], (j + 1) % 3), 1);
      //      dij.add(idx(v[i], j), idx(u[i], (j + 1) % 3), 1);
    }
  }
  S--, T--;
  auto dis = dij.get(idx(S, 0))[idx(T, 0)];
  cout << (dis < 1e9 ? dis / 3 : -1) << endl;
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> u(M);
  std::vector<long long> v(M);
  for (int i = 0; i < M; i++)
  {
    scanf("%lld", &u[i]);
    scanf("%lld", &v[i]);
  }
  long long S;
  scanf("%lld", &S);
  long long T;
  scanf("%lld", &T);
  solve(N, M, std::move(u), std::move(v), S, T);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 20608
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

int main() {
	string S;
	cin >> S;
	if (S[0] == S[1] && S[1] == S[2])cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

point = [[[0 for i in range(4)] for j in range(5)] for k in range(5)]
raw = 0
for line in sys.stdin:
    way = list(map(int, line.strip()))
    if len(way) == 4:
        for col in range(4):
            if way[col] == 1:
                point[raw][col][1] = point[raw][col + 1][3] = 1

    elif len(way) == 5:
        for col in range(5):
            if way[col] == 1:
                point[raw][col][2] = point[raw + 1][col][0] = 1
        raw += 1

dict = {0:"U", 1:"R", 2:"D", 3:"L"}
cold = [0, 1, 0, -1]
rawd = [-1, 0, 1, 0]

raw = 0
col = 0
nowd = 1
ans = ""

while True:
    for dirc in [(x - 1) % 4 for x in range(nowd, nowd + 4)]:
        if point[raw][col][dirc] == 1:
            ans += dict[dirc]
            raw += rawd[dirc]
            col += cold[dirc]
            nowd = dirc
            break
    if raw == 0 and col == 0:
        break
        
print(ans)

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

int main() {
	int N, X,y,co;
	int ary[100];
	y = 0;
	co = 1;
	cin >> N >> X;
	
	for(int i=0; i < N; i++){
		cin >> ary[i];
	}
	for(int i=0; i< N; i++){
		y += ary[i];
		if (X >= y) {
			co += 1;
		}
	}
	cout << co << endl;
}

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

int main() {
  for (size_t i = 1; i < 10; i++) {
    for (size_t j = 1; j < 10; j++) {
      std::cout << i << "x" << j << '=' << i * j << '\n';
    }
  }

  return 0;
}



Measured memory_bytes: 3016
#include<stdio.h>

void swap(int *a, int *b){
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
    return;
}

int bubblesort(int n,int *r){
    int flag = 1;
    int i;
    int cnt=0;
    while(flag){
        flag = 0;
        for(i=n-1;i>0;i--){
            if(r[i]<r[i-1]){
                swap(&r[i], &r[i-1]);
                cnt++;
                flag = 1;
            }
        }
    }
    return cnt;
}

int main(){
    int n,i;
    int r[100];
    int res;
    
    scanf("%d", &n);
    for(i=0;i<n;i++) scanf("%d", &r[i]);

    res = bubblesort(n, r);
    for(i=0;i<n;i++) {
        printf("%d", r[i]);
        if(i+1<n) printf(" ");
    }
    printf("\n");
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 604
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, W; cin >> N >> W;
	vector<int> v(N), w(N); rep(i, 0, N) { cin >> v[i] >> w[i]; }
	vector<int>dp(100 * 101, INF); dp[0] = 0;
	rep(i, 0, N)rrep(j, v[i], 100 * 101) {
		chmin(dp[j], dp[j - v[i]] + w[i]);
	}
	int ans(0);
	rep(i, 0, 100 * 101) {
		if (dp[i] <= W)chmax(ans, i);
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  vector<pair<double, double>> v(n);
  rep(i, n) {
    double x, y;
    cin >> x >> y;
    v[i] = make_pair(x, y);
    arr[i] = i;
  }

  double ans = 0;
  int count = 0;
  do {
    double sum = 0;
    vector<int> r(n);
    rep(i, n) {
      r[i] = arr[i];
    }
    for(int i = 1; i < n; i++) {
      sum += sqrt(pow((v[r[i]].first - v[r[i-1]].first), 2) + pow((v[r[i]].second - v[r[i-1]].second), 2));
    }
    ans += sum;
    count++;
  } while (next_permutation(begin(arr), end(arr)));
  cout << setprecision(12) << ans / count;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <string>

int main() {
  char c;
  scanf("%c", &c);
  printf("%c\n", c+1);
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cstdio>
#include <stack>
#include <cstdlib>
#include <string>

using namespace std;

int main(){

	stack<int> S;
	int a, b, x;
	string s;

	while (cin >> s) {
		if (s[0] == '+') {
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a + b);
		}else if(s[0] == '-'){
			b = S.top(); S.pop();
			a = S.top(); S.pop();
			S.push(a - b);
		}else if(s[0] == '*'){
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a * b);
		}else{
			S.push(atoi(s.c_str()));
		}
	}

	cout << S.top() << endl;

	//system("PAUSE");
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>

using namespace std;

int main(){
    int N, i, j, min = 100000, tmp = 0;
    int *Wnum;
    int *Enum;
    string S;
    char direction;
    cin >> N >> S;
    Wnum = new int[N];
    Enum = new int[N];
    for(i = 0; i < N; i++){
        Wnum[i] = 0;
        Enum[i] = 0;
    }
    
    for(i = 0; i < N; i++){
        if(i == 0){
            if(S[0] == 'W') 
                Wnum[0] = 1;
            // else
            //     Enum[0] = 1;
        }else{
            if(S[i] == 'W')
                Wnum[i] = Wnum[i-1] + 1;  
            else
                Wnum[i] = Wnum[i-1];
        }
    }
    for(i = 0; i < N; i++){
        if(i == 0){
            if(S[0] == 'E') 
                Enum[0] = 1;
        }else{
            if(S[i] == 'E')
                Enum[i] = Enum[i-1] + 1;  
            else
                Enum[i] = Enum[i-1];
        }
    }
    // cout << "Wnum = " << Wnum[N-1] << endl;
    // cout << "Enum = " << Enum[N-1] << endl;
    


    for(i = 0; i < N; i++){
        if(i == 0){
            min = Enum[N-1] - Enum[0];
            // cout << "i = 0, min = " << min << endl;
            continue;
        }
        if(i == N-1){
            if(min > Wnum[N-2])
                min = Wnum[N-2];
            continue;
        }

        tmp = Wnum[i-1] + Enum[N-1] - Enum[i-1];
        // cout << "i = " << i << " tmp = " << tmp << endl;
        if(S[i] == 'E')
            tmp -= 1;
        if(min > tmp) 
            min = tmp;
    }
    cout << min << endl;
    return 0;
}

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


int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	rep(i, N) {
		cin >> a[i];
		a[i]--;
	}
	int ans = 1001001001;
	rep(i, 99){
		int sum = 0;
		rep(j, N) {
			sum += (i - a[j]) * (i - a[j]);
		}
		ans = min(ans, sum);
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

typedef pair<int, int> P;
vector<P> v[200010];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;

    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(a > b) swap(a, b);
        v[max(a, b)].push_back({a, b});
    }
    int cnt = 0;
    int maximam = 0;
    rep(i, N) maximam += i * (i + 1) / 2;
    int ans = N * (N + 1) / 2;
    rep(i, N) {
        for(auto& e: v[i]) {
            //cout << i + 1 << " " << e.first + 1 << " " << e.second + 1 << endl;
            int l = e.first + 1;
            int r = N - e.second;
            cnt += l * r;
        }
    }
    cout << maximam - cnt +  ans << endl;

    return 0;
}


Measured memory_bytes: 14572
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int M=60*10/4;
string table[60];
int group[60][10];
int minx[M];
int maxx[M];
int sumx[M];
int num[M];
vector<int> child[M];
int w,h;
bool done[60][10];
int dx[]={0,-1,0,1};
int dy[]={-1,0,1,0};
void dfs(int i,int j, char c, int g)
{
	if(i<0||h<=i||j<0||w<=j||done[i][j]||table[i][j]!=c)
	{
		return;
	}
	group[i][j]=g;
	done[i][j]=true;
	for(int k=0;k<4;k++){
		dfs(i+dx[k],j+dy[k],c,g);
	}
}
bool ok(int g)
{
	for(int gg:child[g]){
		if(!ok(gg)){
			return false;
		}
		num[g]+=num[gg];
		sumx[g]+=sumx[gg];
	}
	double cx=sumx[g]/(double)num[g]+0.5;
	//cout << g << ", " << cx << ", " << minx[g] << ", " << maxx[g] << ": " << num[g] << endl;
	if(minx[g]<cx&&cx<maxx[g]){
		return true;
	}
	return false;
}
void exec()
{
	cin >> w >> h;
	if(w==0&&h==0)exit(0);
	for(int i=h-1;i>=0;i--){
		cin >> table[i];
	}
	int g=0;
	memset(done,0,sizeof(done));
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(!done[i][j]&&table[i][j]!='.')
			{
				dfs(i,j,table[i][j],g);
				child[g].clear();
				sumx[g]=0;
				num[g]=0;
				minx[g]=100;
				maxx[g]=-100;
				g++;
			}
		}
	}
	//cout << g << endl;
	//cout << child[0].size() << endl;

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(table[i][j]=='.')
			{
				//cout << ". ";
				continue;
			}
			g=group[i][j];
			//cout << g << " ";
			if(i==0||(table[i-1][j]!='.'&&group[i-1][j]!=g))
			{
				minx[g]=min(minx[g],j);
				maxx[g]=max(maxx[g],j+1);
				if(i!=0){
					int gg=group[i-1][j];
					if(find(child[gg].begin(),child[gg].end(),g)==child[gg].end()){
						child[gg].push_back(g);
					}
				}
			}
			sumx[g]+=j;
			num[g]++;
		}
		//cout << endl;
	}
	//cout << child[0].size() << endl;
	if(ok(0)){
		cout << "STABLE" << endl;
	}
	else
	{
		cout << "UNSTABLE" << endl;
	}
}
int main() {
	while(1)exec();
}

Measured memory_bytes: 1232
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(t1) inp(t2)
	inp(a1) inp(a2)
	inp(b1) inp(b2)
	if(a1*t1+a2*t2==b1*t1+b2*t2)
	{
		cout<<"infinity\n";
		return 0;
	}
	if((a1<=b1 && a2<=b2) || (b1<=a1 && b2<=a2))
	{
		cout<<0<<'\n';
		return 0;
	}
	if(a1*t1+a2*t2<b1*t1+b2*t2)
	{
		swap(a1,b1);
		swap(a2,b2);
	}
	if(a1>b1)
	{
		cout<<0<<'\n';
		return 0;
	}
	assert(a1<b1 && a2>b2);
	a1*=t1;
	a2*=t2;
	b1*=t1;
	b2*=t2;
	int a=b1-a1;
	int b=a2-b2;
	// cout<<a1<<','<<b1<<'\n';
	int diff=b-a;
	if(diff<0)
	{
		cout<<0<<'\n';
		return 0;
	}
	// cout<<a<<','<<diff<<'\n';
	int ans=a/diff+1;
	cout<<ans*2-(a%diff==0)-1<<'\n';
	printclock;
}

Measured memory_bytes: 256
import sys
import copy
from collections import deque
import collections
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
dp = {i+1:0 for i in range(n)}

for x in range(1, n, 1):
    if 3*x*x+3*x > n:
        break
    for y in range(x, n, 1):
        if x*x+y*y+y*y+x*y+y*y+y*x > n:
            break
        for z in range(y, n, 1):
            tmp = x*x+y*y+z*z+x*y+x*z+y*z
            if n < tmp:
                break
            if x==y==z:
                dp[tmp] += 1
            elif x==y:
                dp[tmp] += 3
            elif y==z:
                dp[tmp] += 3
            else:
                dp[tmp] += 6

for i in range(n):
    print(dp[i+1])


Measured memory_bytes: 70116
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b,x=0,y=0;
  string s;
  cin >> n >> a >> b >> s;
  for(auto p:s) {
    if(p=='c') {
      cout << "No" << endl;
    }
    else if(p=='a') {
      if(x<a+b) {
        cout << "Yes" << endl;
        x++;
      }
      else {
        cout << "No" << endl;
      }
    }
    else {
      if(x<a+b&&y<b) {
        cout << "Yes" << endl;
        x++,y++;
      }
      else {
        cout << "No" << endl;
      }
    }
  }
}

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

int main(){
  int a,b,d,r;
  double f;

  cin >> a >> b;
  
  d = a/b;
  r = a%b;
  f = ((double)a)/b;
  printf("%d %d %.5lf\n",d,r,f);

}

Measured memory_bytes: 3188
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans=sum(b)
bef = a[0]
for ai in a:
  if ai - bef == 1:
    ans += c[ai - 2]
  bef = ai

print(ans)

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

long long MOD=1000000007;

int main(){

  int n;
  cin >>n;
  vector<long> a(300000,0);
  for(int i=0; i<n; i++) cin >>a[i];
  
  long ans=0;
  
  for(int i=0; i<60; i++){
    long x=0;
    for(int j=0; j<n; j++){ if(a[j] >> i&1) x++;}
    long now= x*(n-x)%MOD;
    for(int j=0; j<i; j++) now=now*2%MOD;
    ans+=now;
    ans%=MOD;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>
#include <sstream>
#include <iomanip>

bool sort_pair( std::pair< int64_t, std::string > origin, std::pair< int64_t, std::string > another )
{
    return origin.first < another.first;
}


int main()
{

    int64_t a,b,c;
    
    std::cin>> a;
    std::cin>> b;

    std::priority_queue<int> que;
    
    for( int i = 0; i < a; i++ )
    {
        std::cin>> c;
        que.push( c );
    }

    for( int i = 0; i < b; i++ )
    {
        int max = que.top() / 2;
        que.pop();
        que.push( max );
    }

    int64_t s = 0;

    while( !que.empty() )
    {
        s += que.top();
        que.pop();
    }
    
    std::cout<< s;
}


Measured memory_bytes: 892
<?php

$t = [];
for($i = 0; $i < 2; $i++){
	$d = explode(" ", fgets(STDIN));
	$cn = 0 + array_shift($d);
	while($cn--){
		$t[] = 60 * array_shift($d) + array_shift($d);
	}
}
$t = array_unique($t);
sort($t);
for($i = 0; $i < count($t); $i++){
	printf("%d:%02d", $t[$i] / 60, $t[$i] % 60);
	echo($i + 1 == count($t) ? PHP_EOL : " ");
}

Measured memory_bytes: 15488
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    xs <- U.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve $ U.toList xs

solve :: [Int] -> Int
solve xs0 = go x [x] $ xs
  where
    (x:xs) = sort xs0
    go !acc !res (x:xs)
      | x <= acc * 2 = go (acc+x) (x:res) xs
      | otherwise = go (acc+x) [x] xs
    go _ res _ = length res


Measured memory_bytes: 17788
#include <stdio.h>

int main()
{
    int a,b,n,m;
    
    scanf("%d%d",&a,&b);
    
    if (a<b)
    {
        n = a;
        a = b;
        b = n;
    }
    
    m = a%b;
    while(m != 0)
    {
        a = b;
        b = m;
        m = a%b;
    }
    printf("%d\n",b);
    
    return 0;
}


Measured memory_bytes: 2100
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var N = intShift();
  
  var d = Array.from({length:200},()=>false);
  
  for(var i = 0; i < N ; i++){
  	d[intShift()]=true;
  }
  
  return ~~(d.filter(a=>a).length);
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
7
50
30
50
100
50
80
30
`);

Measured memory_bytes: 7500
#include<iostream>
#include<stack>
using namespace std;
int main(){
    int n,c;
    cin>>n;
    int A[200005],C[200005]={};
    stack<int> B;
    for(int i=1;i<=n;i++) cin>>A[i];
    for(int i=n;i>=1; i--){
        c=0;
        for(int j=0;j<n/i;j++){
            if(C[i+i*j]==1) c++;
        }
        if(A[i]==0){
            if(c%2==0) C[i]=0;
            else{
                C[i]=1;
                B.push(i);
            }
        }
        else{
            if(c%2==1) C[i]=0;
            else{
                C[i]=1;
                B.push(i);
            }
        }
    }
    cout<<B.size()<<endl;
    if(B.size()>0){
        int i=0;
    while(B.size()>0){
        if(i==0) cout<<B.top();
        else cout<<" "<<B.top();
        B.pop();
        i++;
    }
    cout<<endl;
    }
    return 0;
}   

Measured memory_bytes: 3072
#include<iostream>
using namespace std;
int main()
{
  int l ,r, d;
  cin>>l>>r>>d;
  
  int n1 = r/d;
  int n2 = l/d;
  if(l%d ==0)
    n2--;
  cout<<( n1-n2);
  return 0;
}

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

using namespace std;

typedef long long ll;

const ll M=1e9+7;
typedef vector<ll> Vec;
typedef vector<Vec> Mat;

int main()
{
    int n,k;
    while(cin>>n>>k)
    {
        Mat dp(n+1,Vec(k+1));
        for(int i=0;i<=k;i++)
        {
            dp[0][i]=1;
        }
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=k;j++)
            {
                if(i>=j) dp[i][j]+=dp[i-j][j];
                dp[i][j]+=dp[i][j-1];
                dp[i][j]%=M;
            }
        }
        cout<<dp[n][k]<<endl;
    }

    return 0;
}





Measured memory_bytes: 10760
import java.util.*;
public class Main {

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

}

Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int N, C, K;
int t[101010];
int h[101010];

int main() {
    cin >> N >> C >> K;
    for (int j = 0; j < N; ++j) {
        cin >> t[j];
    }
    sort(t, t+N);
    fill(h, h+N, C);

    int sum_bus = 0;
    int pending = 0;
    for (int j = 0; j < N; ++j) {
        if (t[pending] + K <= t[j]) {
            ++sum_bus;
            if (t[pending] + K == t[j]) {
                pending = j+1;
            } else {
                pending = j;
            }
        } else if (j - pending >= C-1) {
            ++sum_bus;
            pending = j+1;
        }
    }
    if (pending <= N-1) {
        ++sum_bus;
    }
    cout << sum_bus << endl;
    return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl
#define DEBUG 0

const ll inf = (ll)1e8;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-15;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int main() {
	pii s, t;	cin >> s.fst >> s.scn >> t.fst >> t.scn;
	int n;	cin >> n;
	vector<pii> dat(n);
	rep(i, n)	cin >> dat[i].fst >> dat[i].scn;
	t = mp(t.fst - s.fst, t.scn - s.scn);
	rep(i, n)	dat[i] = mp(dat[i].fst - s.fst, dat[i].scn - s.scn);
	while (t.fst < 0 || t.scn < 0) {
		t = mp(-t.scn, t.fst);
		rep(i, n)	dat[i] = mp(-dat[i].scn, dat[i].fst);
	}
	vector<pii> p;
	rep(i, n)	if (0 <= dat[i].fst&&dat[i].fst <= t.fst && 0 <= dat[i].scn&&dat[i].scn <= t.scn) {
		p.push_back(dat[i]);
	}
	sort(all(p));
	vint lis;
	n = p.size();
	rep(i, n) {
		auto it = lower_bound(all(lis), p[i].scn);
		if (it == lis.end())	lis.push_back(p[i].scn);
		else	*it = p[i].scn;
	}
	ld ret = (t.fst + t.scn) * 100.0;
	ret += (5.0 * M_PI - 20.0)*lis.size();
	if (lis.size() == min(t.fst, t.scn) + 1) {
		ret += 5.0 * M_PI;
	}
	printf("%.15Lf\n", ret + eps);
	return 0;
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	cout << string(ty - sy, 'U') + string(tx - sx, 'R') + string(ty - sy, 'D') + string(tx - sx, 'L');
	cout << "L" + string(ty - sy + 1, 'U') + string(tx - sx + 1, 'R') + "D";
	cout << "R" + string(ty - sy + 1, 'D') + string(tx - sx + 1, 'L') + "U\n";
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	hawawa();
}


Measured memory_bytes: 256
#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 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 DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    if(n>=m){
        cout << "0" << endl;
        return 0;
    }

    vi x(m);
    vi dists(m+1,0);
    ll ans = 0;

    REP(i,m) cin>>x[i];

    sort(ALL(x));
    //DEBUG_VEC(x);

    FOR(i,1,m){
        dists[i] = x[i] - x[i-1];
        ans += dists[i];
    }

    //DEBUG_VEC(dists);
    sort(ALL(dists),greater<int>());
    
    REP(i,n-1){
        ans -= dists[i];
    }

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

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
using namespace std;

typedef long long ll;
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define rerepi(i, a, b) for(int i = int(a)-1; i >= b; --i)
#define rerep(i, n) rerepi(i, n, 0)

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; }

const long long INF = 1LL << 60;

// ここから開始だよ！
ll a, b, h;

int main() {
	// 呪文エリア
	cin.tie(0);
	ios::sync_with_stdio(false);
	// 詠唱完了

	cin >> a;
	cin >> b;
	cin >> h;

	cout << (a+b) * h /2 << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())

SP = []

for i in range(N):
    s, p = input().split()
    SP.append([s, int(p), i])

SP.sort(key=lambda x:x[1], reverse=True)
SP.sort(key=lambda x:x[0])

for i in range(N):
    print(SP[i][2]+1)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
    int W,H,x,y,r,f;
    scanf("%d %d %d %d %d %d",&W,&H,&x,&y,&r);
    f=0;
    if(x+r>W)f=1;
    if(y+r>H)f=1;
    if(r>x)f=1;
    if(r>y)f=1;
    
    if(f==0)printf("Yes\n");
    else printf("No\n");
    return 0;
}



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

int main(){
  long n;
  long ans = 0;
  cin >> n;
  long a[n],d[n][21];
  for(long i = 0;i < n;i++){
    cin >> a[i];
    for(long j = 0;j < 21;j++){
      d[i][j] = a[i]>>j & 1;
    }
  }
  long left = 0,right = 0,sum[21];
  for(long i = 0;i < 21;i++){
    sum[i] = (a[0]>>i & 1);
    //cout << sum[i] << ' ';
  }
  //cout << ' ' << endl;
  while(right < n){
    bool ok = true;
    for(long i = 0;i < 21;i++){
      if(sum[i] > 1){
        ok = false;
      }
    }
    if(ok != true){
      for(long i = 0;i < 21;i++){
        sum[i] -= d[left][i];
      }
      left++;
    }
    else{
      //cout << left << ' ' << right << endl;
      ans += right - left + 1;
      right++;
      for(long i = 0;i < 21;i++){
        if(right < n){
          sum[i] += d[right][i];
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 34560
#include <cstdio>
#define fo(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=5500,mo=1e9+7;
int m,n,K,ans;
int f[2][N];
int main()
{
	scanf("%d%d%d",&n,&m,&K);
	--n;--K;
	fo(i,1,n+m)
	{
		register int I=i&1,q=1;
		fo(j,1,m)
		{
			if(j>K)((q-=f[!I][j-K-1])<0?q+=mo:0);
			if(j%K==m%K&&(K*i-j)%K==n%K&&(K)*i-j<=n)((ans+=q)>=mo?ans-=mo:0);
			((q+=f[!I][j])>=mo?q-=mo:0);
			f[I][j]=q;
			if(j==K)--q;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    y = 0
    for i in range(1, n - 1):
        for j in range(i + 1, n):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    y += 1
    print(y)

Measured memory_bytes: 7660
#include <iostream>
#include <vector>

using namespace std;

int main() {
    string S;
    cin >> S;
    vector<int> a(S.size() + 1, 0);
    for(int i = 0; i < S.size(); i++) {
        if(S.at(i) == '<') {
            a.at(i + 1) = a.at(i) + 1;
        }
    }
    for(int i = S.size() - 1; i >= 0; i--) {
        if(S.at(i) == '>' && a.at(i) <= a.at(i + 1)) {
            a.at(i) = a.at(i + 1) + 1;
        }
    }
    long long int ans = 0;
    for(int i = 0; i < a.size(); i++) {
        ans += a.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2820
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}


struct edge{
    ll u,v,c;
    edge():u(0),v(0),c(0){}
    edge(ll u,ll v,ll c):u(u),v(v),c(c){}
};
typedef vector<vector<edge>> Graph;
Graph G;
class LCA{
public:
    const ll n = 0;
    const ll log2_n = 0;
    vector<vector<ll>> parent;
    vector<ll> depth;
    LCA();
    LCA(const Graph &g,ll root):n((ll)g.size()),log2_n(log2(n)+1),parent(log2_n,vector<ll>(n)),depth(n){
        dfs(g,root,-1,0);
        for(int k = 0; k+1 < log2_n; k++){
            for(int v = 0; v < (int)g.size();v++){
                if(parent[k][v] < 0) parent[k+1][v] = -1;
                else parent[k+1][v] = parent[k][parent[k][v]];
            }
        }
    }
    
    void dfs(const Graph &g,ll v,ll p,ll d){
        parent[0][v] = p; depth[v] = d;
        for(auto &e :g[v]){
            if(e.v != p) dfs(g, e.v, v, d+1);
        }
    }
    
    ll get(ll u,ll v){
        if(depth[u] > depth[v]) swap(u,v);
        for(int k = 0; k < log2_n; k++){
            if(((depth[v]-depth[u])>>k) & 1) v = parent[k][v];
        }
        if(u == v) return u;
        for(int k = (int)log2_n - 1; k >= 0; k--){
            if(parent[k][u] != parent[k][v]){
                u = parent[k][u]; v = parent[k][v];
            }
        }
        return parent[0][u];
    }
};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C&lang=jp
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n; cin >> n;
    G.resize(n);
    for(int i = 0; i < n;i++){
        ll k; cin >> k;
        for(int j = 0; j < k;j++){
            ll c; cin >> c;
            G[i].push_back(edge(i,c,0));
            G[c].push_back(edge(c,i,0));
        }
    }
    LCA lca(G,0);
    ll q; cin >> q;
    while(q--){
        ll u,v; cin >> u >> v;
        cout << lca.get(u,v) << endl;
    }
    return 0;
}



Measured memory_bytes: 29456
// AtCoder Beginner Contest 119 A
// [URL]      https://atcoder.jp/contests/abc119/tasks/abc119_a
// [compiler] C++14 (GCC 5.4.1)
// [reference]
// <1> https://cpprefjp.github.io/reference/string/basic_string/substr.html
// 
#include <iostream>
#include <string>

int main (void)
{
	// variables for main process
	std::string date;


	// STEP.01
	// read out the target date as a string
	std::cin >> date;

	// STEP.02
	// 1. judge the read date
	if( date <= "2019/04/30" )
	{ std::cout << "Heisei" << std::endl; }
	else
	{ std::cout << "TBD" << std::endl; }

	// STEP.END
	return 0;
}


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

int main(){
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    auto k = (N - 2) * (N - 1) / 2;
    if(k < K)return 0 & puts("-1");
    cout << N - 1 + k - K << endl;
    for(unsigned long i = 2; i <= N; ++i)cout << "1 " << i << endl;
    for(unsigned long i = 0, m = 2, n = 3; i + K < k; ++i){
        cout << m << " " << n << endl;
        ++n;
        if(n > N){
            ++m;
            n = m + 1;
        }
    }
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int n;
    cin >> n;

    vector<pair<int,int>> a(n);
    rep(i,n) cin >> a[i].first >> a[i].second;

    map<pair<int,int>,int> mp;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j) continue;
            int p,q;
            p = a[i].first - a[j].first;
            q = a[i].second - a[j].second;
            mp[{p,q}]++;
        }
    }

    int ans = 0;
    for(auto i : mp){
        ans = max(ans,i.second);
    }
    cout << n - ans << endl;
}



Measured memory_bytes: 384
#include<stdio.h>
#define N 10000
 
int main(){
  int n, q;
  int i, j, num=0;
  int s[N]={0}, t[N][2]={0};
 
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &s[i]);
  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) scanf("%d", &t[i][0]);
 
  for( i = 0 ; i < n ; i++){
    for( j = 0; j < q ; j++){
      if( s[i] == t[j][0] ){
        t[j][1] = 1;
      }
    }
  }
 
  for( j=0 ; j < q ; j++){
    if(t[j][1]==1){
      num++;
    }
  }
 
  printf("%d\n" ,num);
  return 0; // Don't forget return 0
}

Measured memory_bytes: 724