akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdlib>
#include <string.h>
using namespace std;

struct Node {
	int value;
	Node *prev, *next;
};

Node *nil;

void init() {
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void insert(int value) {
	Node *x = (Node *)malloc(sizeof(Node));
	x->value = value;
	nil->next->prev = x;
	x->next = nil->next;
	nil->next = x;
	x->prev = nil;
}

Node* search(int value) {
	Node *mark = nil->next;
	while (mark->value != value &&mark != nil) {
		mark = mark->next;
	}
	return mark;
}

void Delete(Node* node) {
	if (node == nil) { return; }
	node->prev->next = node->next;
	node->next->prev = node->prev;
	free(node);
}

void DeleteFirst() {
	Delete(nil->next);
}

void DeleteLast() {
	Delete(nil->prev);
}

void DeleteOne(int value) {
	Delete(search(value));
}

void ShowAll() {
	cout << nil->next->value;
	Node* node = nil->next->next;
	while (node != nil) {
		cout <<" "<< node->value;
		node = node->next;
	}
	cout << endl;
}


int main() 
{
	init();
	int n,value;
	cin >> n;
	char str[30];
	for (int i = 0; i < n; i++) {
		cin >> str;
		if (str[0] == 'i') {
			cin >> value;
			insert(value);
		}
		if (str[0] == 'd') {
			if (strlen(str) == 6) {
				cin >> value;
				DeleteOne(value);
			}
			else if (str[6] == 'F') {
				DeleteFirst();
			}
			else if (str[6] == 'L'){
				DeleteLast();
			}
		}
	}
	ShowAll();
	
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Union Find tree with potential
//-------------------------------------------------
template<typename T>
class pUnionFind
{
private:
    ::std::vector<int> par;
    ::std::vector<int> rank;
    ::std::vector<T> diff;
public:
    pUnionFind(int n):par(n), rank(n), diff(n){
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
            diff[i] = 0;
        }
    }
    int root(int x){
        if (par[x]==x) return x;
        int rx = root(par[x]);
        diff[x] += diff[par[x]];
        return par[x] = rx;
    }
    T weight(int x){
        root(x);
        return diff[x];
    }
    T climb(int x, int y){
        return weight(y)-weight(x);
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    void unite(int x, int y, T w){
        int rx = root(x);
        int ry = root(y);
        if (rx==ry) return;
        w += weight(x)-weight(y);
        if (rank[rx]>rank[ry]){
            diff[ry] = w;
            par[ry] = rx;
        }else{
            diff[rx] = -w;
            par[rx] = ry;
            if (rx==ry) rank[ry]++;
        }
    }
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    pUnionFind<int> uf(n);
    rep(i,m){
        int l,r,d; cin>>l>>r>>d; l--; r--;
        if (uf.same(l,r)){
            if (uf.climb(l,r)!=d){
                cout<<"No\n";
                return 0;
            }
        }else{
            uf.unite(l,r,d);
        }
    }
    cout<<"Yes\n";
    return 0;
}


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

int main(){
	int n;cin>>n;
	int x[n];
	int X[n];
	for(int i=0;i<n;++i){
		cin>>x[i];
		X[i]=x[i];
	}
	
	sort(x,x+n);
	int a=n/2;
	for(int i=0;i<n;++i){
		if(X[i]<x[a]){
			cout<<x[a]<<endl;
		}else{
			cout<<x[a-1]<<endl;
		}
	}
}



Measured memory_bytes: 3712
from sys import stdin


def iterate_tokens():
    for line in stdin:
        for word in line.split():
            yield word


def main():
    tokens = iterate_tokens()
    next(tokens)
    Q = int(next(tokens))
    S = next(tokens)
    L = []
    R = []
    for i in range(Q):
        L.append(int(next(tokens)) - 1)
        R.append(int(next(tokens)) - 1)
    AC = []
    pre = None
    cnt = 0
    for c in S:
        if c == "A":
            pre = "A"
        elif pre == "A" and c == "C":
            cnt += 1
            pre = None
        elif pre == "A":
            pre = None
        AC.append(cnt)
    for i in range(Q):
        print(AC[R[i]] - AC[L[i]])
    return


main()


Measured memory_bytes: 14196
#include<stdio.h>
#include<iostream>
using namespace std;

struct card{char suit,value;};
void bu(struct card a[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=n-1;j>=i+1;j--)
        {
            if(a[j].value<a[j-1].value)
            {
                card t=a[j];a[j]=a[j-1];a[j-1]=t;
            }
        }
    }
}
void se(struct card a[],int n)
{
    int minj;
    for(int i=0;i<n;i++)
    {
         minj=i;
        for(int j=i;j<n;j++)
        {
            if(a[j].value<a[minj].value)
                minj=j;
        }
        card t=a[i];a[i]=a[minj];a[minj]=t;
    }
}
void pr(struct card a[],int n)
{
    for(int i=0;i<n;i++)
    {
        if(i>0) cout<<" ";
        //printf("%c%d",a[i].suit,a[i].value);
        cout<<a[i].suit<<a[i].value;
    }
    cout<<endl;
}
bool is(struct card c1[],struct card c2[],int n)
{
    for(int i=0;i<n;i++)
    {
        if(c1[i].suit!=c2[i].suit)  return false;
    }
    return true ;
}
int main()
{
    card c1[100];
    card c2[100];
    char ch;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>c1[i].suit>>c1[i].value;
    }
    for(int i=0;i<n;i++)
    {
        c2[i]=c1[i];
    }
    bu(c1,n);
    se(c2,n);
    pr(c1,n);
   cout<<"Stable"<<endl;
    pr(c2,n);
    if(is(c1,c2,n))
    {
      cout<<"Stable"<<endl;
       }
      else
      {
          cout<<"Not stable"<<endl;
      }
      return 0;

}

Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


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

  std::vector<ll> x(N), y(N);
  rep(i,N) std::cin >> x[i] >> y[i];

  // O(N^4) x O(N)
  ll ans = (1LL<<62);
  for(int a=0;   a<N; a++) 
  for(int b=a+1; b<N; b++)
  for(int c=0;   c<N; c++) 
  for(int d=c+1; d<N; d++) {
    ll xup = std::max( { x[a], x[b] } );
    ll xdn = std::min( { x[a], x[b] } );
    ll yup = std::max( { y[c], y[d] } );
    ll ydn = std::min( { y[c], y[d] } );
    int tmp = 0;
    rep(i,N) if ( xdn <= x[i] && x[i] <= xup && ydn <= y[i] && y[i] <= yup ) tmp++;
    if ( tmp >= K ) ans = std::min(ans, std::abs(xup-xdn)*std::abs(yup-ydn) );
  }
  std::cout << ans << std::endl;
  return 0;
}


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

int main()
{
	int n,t;
	cin >> n >> t;
	vector<int> imos(100002);

	int ans = 0;
	for(int i = 0;i<n;i++)
	{
		int l,r;
		cin >> l >> r;
		///r ++;
		imos[l]++;
		imos[r]--;
	}
	ans = imos[0];
	for(int i=0;i<=100000;i++)
	{
		imos[i+1] += imos[i];
		ans = max(imos[i+1],ans);
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 3104
def main():
    N = int(input())

    max_zoro = 0
    current_zoro = 0

    for _ in range(N):
        D1, D2 = map(int, input().split())

        if D1 == D2:
            current_zoro += 1
        else:
            current_zoro = 0
        max_zoro = max(max_zoro, current_zoro)

    if 3 <= max_zoro:
        print("Yes")
    else:
        print("No")


main()


Measured memory_bytes: 9168
#include<stdio.h>
#include<math.h>
int main()
{
	int n,a[1005],s=0,i,t=0,minn=199999999;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s+=a[i];
	}
	for(i=0;i<n;i++)
	{
		t+=a[i];
		if(minn>abs(s-2*t))
		minn=abs(s-2*t);
	}
	printf("%d",minn);
}

Measured memory_bytes: 128
N = int(input())
Ws = []
for i in range(N):
  W = input()
  Ws.append(W)
if len(set(Ws)) != N:
  print("No")
  exit()
for i in range(1, N):
  if Ws[i-1][-1] != Ws[i][0]:
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int sco[4];
	int rekisi;
	int tiri;
	int add = 0;
	int i;
	int max = 0;
	int num;
	int j;
	
	for (i = 0;i < 4; i++){
		scanf("%d", &sco[i]);
	}
	
	scanf("%d", &rekisi);
	
	scanf("%d",&tiri);
	
	if(tiri >= rekisi){
		add += tiri;
	}
	else if(tiri < rekisi){
		add += rekisi;
	}
	
	for (j = 0; j < 3; j++){
		for (i = 0; i < 4; i++){
			if(max <= sco[i]){
				max = sco[i];
				num = i;
			}
		}
		add += sco[num];
		sco[num] = 0;
		max = 0;
	}
	
	printf("%d\n", add);
	
	return (0);
}

Measured memory_bytes: 1816
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
 
const int maxn = int(1e5)+5;
 
int sz[maxn], P[maxn];
vector<int> graph[maxn];
 
void dfs(int node, int par)
{
	sz[node] = 1, P[node] = par;
	for(auto it: graph[node])
	{
		if(it != par)
		{
			dfs(it, node);
			sz[node] += sz[it];
		}
	}
}
 
int main(void)
{
	int n, a, b;
	scanf("%d", &n);
 
	for(int i = 1;i < n;i++)
	{
		scanf("%d%d", &a, &b);
		a--, b--;
		graph[a].push_back(b), graph[b].push_back(a);
	}
 
	dfs(0, -1);
 
	int cur = n-1;
	vector<int> path;
	while(cur != -1)
	{
		path.push_back(cur);
		cur = P[cur];
	}
	reverse(path.begin(), path.end());
 
	int meet = ceil(int(path.size())/2.0);
 
	int aa = n-sz[path[meet]]-meet, bb = sz[path[meet]]-(int(path.size())-meet);
	for(int i = 0;i <= n;i++)
	{
		if((int(path.size())+i)%2)
		{
			if(bb <= 0)
			{
				printf("Fennec\n");
				exit(0);
			}
			bb--;
		}
		else
		{
			if(aa <= 0)
			{
				printf("Snuke\n");
				exit(0);
			}
			aa--;
		}
	}
}


Measured memory_bytes: 13436
n = int(input())
a = list(map(int, input().split()))
c_ki = 0
c_4 = 0
c_2 = 0
for i in range(n):
  if a[i] % 2 == 1:
    c_ki += 1
  elif a[i] % 4 == 0:
    c_4 += 1
  else:
    c_2 += 1
if c_ki <= c_4:
  print("Yes")
elif c_ki-1 == c_4 and c_2 == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 20144
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <assert.h>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n = in();
    VI c(n);
    REP(i,n) c[i] = in();

    VI a(n);

    int q = in();
    while (q--){
        int t = in(), x = in() - 1, d = in();
        if (t == 1){
            a[x] += d;
            if (a[x] > c[x]){
                cout << x + 1 << endl;
                return 0;
            }
        }else{
            a[x] -= d;
            if (a[x] < 0){
                cout << x + 1 << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 3232
def getmode(ary)
  data = {}
  sorted = ary.sort()
  sorted.each do |val|
    unless data.include? val
      data[val] = 1
    else
      data[val] += 1
    end
  end
  data.sort {|(cur_key, cur_val), (nxt_key, nxt_val)|
    cur_val <=> nxt_val
  }.reverse
end
n = gets.chomp!.to_i
ary = gets.chomp!.split(' ').map(&:to_i)
count = 0
even = ary.select.with_index{ |_, idx| idx % 2 == 0 }
odd = ary.select.with_index{ |_, idx| idx % 2 != 0 }
data1 = getmode(even).to_a
data2 = getmode(odd).to_a
e1, e2 = data1[0], data1[1]
o1, o2 = data2[0], data2[1]
if e1[0] == o1[0]
  if data1.length == 1
    puts n - e1[1]
    exit
  end
  if e2[1] >= o2[1]
    puts n - e2[1] - o1[1]
  else  
    puts n - e1[1] - o2[1]
  end
else
  puts n - e1[1] - o1[1]
end

Measured memory_bytes: 20096
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

N, M = map(int, input().split())
h = list(map(lambda s: (-int(s), int(s)), input().split()))
heapify(h)

for _ in range(M):
    _, a = heappop(h)
    a //= 2
    heappush(h, (-a, a))

print(sum(i for _, i in h))





Measured memory_bytes: 74776
def main():
  value1 = input().split()[0]
  count_list = input().split()

  if value1 == input():
    count_list[0] = str(int(count_list[0]) - 1)
  else:
    count_list[1] = str(int(count_list[1]) - 1)

  print(count_list[0] + ' ' + count_list[1])

main()

Measured memory_bytes: 2940
#include<iostream>
#include<queue>
#include<algorithm>
#include<stack>
#include<vector>
#include<string>
using namespace std;


char S[100010];

int main()
{
	cin >> S;
	int size;
	for (int i = 0; i < 100010; i++)
	{
		if (S[i] == '\0')
		{
			size = i;
			break;
		}
	}

	int ans1 = 0, ans2 = 0;

	for (int i = 0; i < size; i++)
	{
		if (i % 2 == 0)
		{
			if (S[i] == '1')
				ans1++;
		}

		else
		{
			if (S[i] == '0')
				ans1++;
		}
	}

	for (int i = 0; i < size; i++)
	{
		if (i % 2 == 1)
		{
			if (S[i] == '1')
				ans2++;
		}

		else
		{
			if (S[i] == '0')
				ans2++;
		}
	}

	if (ans1 < ans2)
		cout << ans1;
	else
		cout << ans2;
	return 0;
}

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

int main()
{
  int N, A, ans = 100000000 / 2;
  cin >> N;

  for (int i = 0; i < N; i++)
  {
    cin >> A;
    int cnt = 0;
    while (A % 2 == 0)
    {
      cnt++;
      A /= 2;
    }
    ans = min(ans, cnt);
    if (ans == 0)
      break;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const int MOD = 1000000007;
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; }

ll com[55][55];
int main() {
    com[0][0]=1;
    for(int i=1; i < 55; ++i){
        for(int j=0; j <= i; ++j){
            com[i][j] += com[i-1][j];
            if(j>0)com[i][j] += com[i-1][j-1];
        }
    }
    int N,A,B;
    cin >> N >> A >> B;
    vector<ll> v(N);
    rep(i, N) cin >> v[i];
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    ll max_sum = 0;
    rep(i, A) max_sum += v[i];
    double ave = (double)(max_sum)/A;
    int num = 0;
    ll ans = 0;
    rep(i, N) if(v[i]==v[A-1]) ++ num;
    if(v[0] == v[A-1]){
        for(int j=A; j<= B; ++j){
            ans += com[num][j]; 
        }
    }else{
        int a = 0;
        rep(i, A) if(v[i]==v[A-1]) ++a;
        ans = com[num][a];
    }
    cout << fixed << setprecision(10) << ave << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

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

int W,H,N;
bool field[1000][1000];
bool used[4][1000][1000];

int main(){

  while(cin>>W>>H>>N&&(W|H|N)){
    memset(field,0,sizeof(field));
    memset(used,0,sizeof(used));
    for(int i=0;i<=2*H;i++){
      field[i][0]=true;
      field[i][2*W]=true;
    }
    for(int i=0;i<=2*W;i++){
      field[0][i]=true;
      field[2*H][i]=true;
    }
    for(int i=0;i<N;i++){
      int x1,x2,y1,y2;
      cin>>x1>>y1>>x2>>y2;
      if(y1==y2){
	int minx=min(x1,x2);
	int maxx=max(x1,x2);
	for(int j=minx*2;j<=maxx*2;j++)
	  field[2*y1][j]=true;
      }
      else{
	int miny=min(y1,y2);
	int maxy=max(y1,y2);
	for(int j=miny*2;j<=maxy*2;j++)
	  field[j][2*x1]=true;
      }
    }
    int xe1,ye1,xe2,ye2;
    int gx,gy;
    int sx,sy;
    int sang;
    cin>>xe1>>ye1>>xe2>>ye2;
    cin>>gx>>gy;
    gx=gx*2+1;
    gy=gy*2+1;
    if(ye1==ye2){
      if(ye1==0){
	sang=3;
	sx=min(xe1,xe2)*2+1;
	sy=ye1;
      }
      else{
	sang=1;
	sx=min(xe1,xe2)*2+1;
	sy=ye1*2;
      }
    }
    else{
      if(xe1==0){
	sang=0;
	sx=xe1;
	sy=min(ye1,ye2)*2+1;
      }
      else{
	sang=2;
	sx=xe1*2;
	sy=min(ye1,ye2)*2+1;
      }
    }
    field[sy][sx]=false;
    // for(int i=2*H;i>=0;i--){
    //   for(int j=0;j<=2*W;j++){
    // 	if(field[i][j])cout<<"*";
    // 	else cout<<" ";
    //   }
    //   cout<<endl;
    // }
    int cx=sx;
    int cy=sy;
    int cang=sang;
    bool ok=true;
    int tern=0;
    while(1){
      if(used[cang][cy][cx]){
	tern++;
	ok=false;
	break;
      }
      else if(cy==gy&&cx==gx)break;
      //cout<<cang<<" "<<cy<<" "<<cx<<" "<<tern<<endl;
      used[cang][cy][cx]=true;
      int ny=cy+dy[cang];
      int nx=cx+dx[cang];
      int nyl=ny+dy[(cang+3)%4];
      int nxl=nx+dx[(cang+3)%4];
      int ry=cy+dy[(cang+1)%4];
      int rx=cx+dx[(cang+1)%4];
      if(!field[ny][nx]&&!field[nyl][nxl]){
	cy=nyl;
	cx=nxl;
	cang=(cang+3)%4;
	tern++;
	//if(cy%2==1&&cx%2==1)tern++;
      }
      else if(!field[ny][nx]&&field[nyl][nxl]){
	cy=ny;
	cx=nx;
	if(cy%2==1&&cx%2==1)tern++;
      }
      else if(field[ny][nx]&&!field[ry][rx]){
	cy=ry;
	cx=rx;
	cang=(cang+1)%4;
	if(cy%2==1&&cx%2==1)tern++;
      }
      else cang=(cang+1)%4;
    }
    if(!ok)cout<<"Impossible"<<endl;
    else cout<<tern<<endl;
  }
  
  
  return 0;
}

    

Measured memory_bytes: 5748
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<set>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	int N,K;
	cin>>N>>K;
	vector<int> arr(N);
	
	REP(i,N)cin>>arr[i];
	
	bool flag = false;	
	
	int max_num = 0;
	for(auto& s: arr)max_num = max(max_num,s);
	
	if(max_num < K){
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	
	int max_yaku = 0;
		int a;
		int b = arr[0];
		int r;
	for(int i = 0; i <N - 1; i++){
		
		a = max(b,arr[i+1]);
		b = min(b,arr[i+1]);
		while(1){
			 r = a % b;
			 if(r == 0)break;
			 a = b;
			 b = r;
		}
	}
	max_yaku = b;
	if(max_yaku == 1)flag = true;
	else if(K % max_yaku  == 0)flag = true;
	
	
	cout<< (flag ? "POSSIBLE" : "IMPOSSIBLE" ) <<endl;
	return 0;
}


Measured memory_bytes: 640
n,m = gets.split.map(&:to_i)
a = []
flag = Array.new(n+1,true)
MD = 10**9+7

m.times do
  a = gets.to_i
  flag[a] = false
end

step = []
step[0] = 0
step[1] = flag[1] ? 1 : 0
if n == 1
  puts step[1]
  exit
end
step[2] = flag[2] ? step[1]+1 : 0
(3..n).each do |i|
  if flag[i]
    step[i] = (step[i-1]+step[i-2])%MD
  else
    step[i] = 0
  end
end

puts step[-1]


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

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

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
a.sort()
x=[a[0]]
for i in range(1,n):
    x.append(gcd(x[-1],a[i]))
y=[a[-1]]
for i in range(2,n+1):
    y.append(gcd(y[-1],a[-i]))
y=y[::-1]
res=[x[-2],y[1]]
for i in range(n-2):
    res.append(gcd(x[i],y[i+2]))
print(max(res))

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

int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<double> a;
	for (int i = 0;i < n;i++) {
		int temp;
		cin >> temp;
		a.push(temp);
	}
	for (int i = 0;i < m;i++) {
		double temp = a.top();
		a.pop();
		temp /= 2;
		a.push(temp);
	}
	long long cnt = 0;
	for (int i = 0;i < n;i++) {
		cnt += a.top();
		a.pop();
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  cin >> N;
  v(string) S(2);
  cin >> S;

  i64 ans; 
  i64 i = 0;
  if(S[0][i] == S[1][i]){
    ans = 3;
    i++;
  } else {
    ans = 6;
    i += 2;
  }

  while(i<S[0].size()){
    if(S[0][i-1] == S[1][i-1]){
      if(S[0][i] == S[1][i]){
        ans *= 2;
        ans %= MOD;
        i++;
      }else{
        ans *= 2;
        ans %= MOD;
        i += 2; 
      }
    } else {
      if(S[0][i] == S[1][i]){
        i++;
      } else {
        ans *= 3;
        ans %= MOD;
        i += 2;
      }
    }
  }
  cout << ans << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 256
n,k,c = map(int,input().split())
s = input()
l = [0]*k
r = [0]*k

start = 0
count = 0
while count <= k-1 and start <= n-1:
    if s[start] == "o":
        l[count] = start
        count += 1
        start += 1+c
    else:
        start += 1
# print(l)

start = n-1
count = k-1
while count >= 0 and start >= 0:
    if s[start] == "o":
        r[count] = start
        count -= 1
        start -= 1+c
    else:
        start -= 1
# print(r)

for i in range(k):
    if l[i] == r[i]:
        print(l[i] + 1)

Measured memory_bytes: 78188
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[200000],b[21][200000],c[21][200000];

int cal(int x,int y){
  int l=x,r=n;
  while(l<r){
    int m=(l+r)/2;
    if(b[y][m]-(!c[y][x])>b[y][x])r=m;
    else l=m+1;
  }
  return l-1;
}

signed main(){

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    int j=0;
    while(a[i])c[j][i]=b[j][i]=a[i]%2,a[i]/=2,j++;
  }
  
  for(int i=0;i<21;i++)
    for(int j=1;j<n;j++)b[i][j]+=b[i][j-1];

  int ans=0;
  for(int i=0;i<n;i++){
    int idx=n;
    for(int j=0;j<21;j++){
      idx=min(idx,cal(i,j));
    }
    ans+=idx-i+1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 67456
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>

#include <sstream>
#include <iostream>

using namespace std;
typedef long long llint;
const llint inf = 1000000000000000000LL;

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

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

const int MAXN = 2 * 10005;

int N, pos[MAXN];
int bio[MAXN], color[MAXN];
set<pair<int,int>> _G, G;

void init() {
  G = _G;
  memset(bio, 0, sizeof bio);
}

int cnt;

void dfs(int i, int r, int d, vector<int> &v) {
  if (bio[i]) return;
  bio[i] = 1;
  
  int x = pos[i ^ r];

  auto last = make_pair(x - d, 2 * N);

  for (;;) {
    auto it = G.upper_bound(last);
    last = *it;
    
    if (it == G.end() || it->first >= x + d) break;
    if (it->second / 2 == i / 2) continue;

    int j = it->second ^ r ^ 1;
    G.erase(it);
    dfs(j, r, d, v);
    ++cnt;
  }

  v.push_back(i);
}

const int MAX = 100;
int adj[MAX][MAX];

bool brute_check(int d) {
  memset(adj, 0, sizeof adj);
  REP(i, N) adj[i][i] = 1;
  
  REP(i, N) REP(j, N) {
    if (i == j) continue;
    REP(ii, 2) REP(jj, 2) {
      int I = 2 * i + ii;
      int J = 2 * j + jj;
      if (abs(pos[I] - pos[J]) < d) 
	adj[I][J^1] = 1;
    }
  }
  
  REP(k, 2 * N) REP(i, 2 * N) REP(j, 2 * N)
    adj[i][j] |= adj[i][k] && adj[k][j];

  REP(i, N)
    if (adj[2 * i][2 * i + 1] && adj[2 * i + 1][2 * i])
      return false;

  return true;
}

bool check(int d) {
  vector<int> topsort;
  init();
  REP(i, N) REP(j, 2) 
    if (!bio[2 * i + j]) 
      dfs(2 * i + j, 0, d, topsort);

  int ncom = 0;
  init();

  reverse(topsort.begin(), topsort.end());
  
  for (auto i : topsort) {
    if (bio[i]) continue;
    
    ++ncom;
    vector<int> com;
    dfs(i, 1, d, com);

    for (int j : com)
      color[j] = ncom;
  }

  REP(i, N) 
    if (color[2 * i] == color[2 * i + 1])
      return false;

  return true;
}

int main(void) 
{
  scanf("%d", &N);
  REP(i, N) {
    scanf("%d%d", pos+2*i, pos+2*i+1);
    _G.insert({pos[2 * i], 2 * i});
    _G.insert({pos[2 * i + 1], 2 * i + 1});
  }

  int lo = 0, hi = *max_element(pos, pos + 2 * N) - *min_element(pos, pos + 2 * N);

  while (lo < hi) {
    int mid = (lo + hi + 1) / 2;
    if (check(mid))
      lo = mid;
    else
      hi = mid - 1;
  }

  printf("%d\n", lo);

  return 0;
}


Measured memory_bytes: 4188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int 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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    map<ll, ll> mp;
    rep(bit, 61) {
        ll num = 1ll<<bit;
        int cnt = 0;
        rep(i, n) {
            if (num & a[i]) cnt++;
        }
        mp[num%MOD] = cnt;
    }
    ll ans = 0;
    for(const auto& m: mp) {
        if (m.se) {
            // debug(m.fi, m.se, m.fi * m.se * (n-m.se));
            ans += (((m.fi%MOD) * m.se)%MOD * (n-m.se))%MOD;
            ans %= MOD;
        }
    }
    cout << ans%MOD << endl;

}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include <time.h> 
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 100010
#define inf 1001000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pc pair<char ,int>
#define pi pair<int ,int>
#define pii pair <pi,pi>
using namespace std;
ll dp[nax][2];
vector< int > v[nax];
void dfs(int s, int p)
{
  bool leaf = true;
  for(int i = 0; i < sz(v[s]); i++)
  {
      if(v[s][i] != p)
      {
        dfs(v[s][i], s);
        leaf = false;
      }
  }
  if(leaf)
    dp[s][0] = dp[s][1] = 1;
  else
  {
     ll p1,p2;
     p1 = p2 = 1;
     for(int i = 0; i < sz(v[s]); i++)
     {
        if(v[s][i] != p)
        {
          p1 = p1 * dp[v[s][i]][1] % MOD;  // cur black
          p2 = p2 * (dp[v[s][i]][0] + dp[v[s][i]][1]) % MOD; // cur white
        }
     }
     dp[s][0] = p1;
     dp[s][1] = p2;
  }
}
int main(int argc, char const *argv[])
{
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  int n,a,b;
  sd(n);
  for(int i = 0; i < n - 1; i++)
  {
      sd2(a,b);
      v[a].pb(b);
      v[b].pb(a);
  }
  dfs(1, 0);
  printf("%lld\n", (dp[1][0] + dp[1][1]) % MOD);
  return 0;
} 

Measured memory_bytes: 14208
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] p = new int[n];
		for(int i = 0; i < n; i++){
		    p[i] = sc.nextInt();
		}
		Arrays.sort(p);

		
		// 計算
		int result = 0;
		for(int i = 0; i < k; i++){
		    result += p[i];
		}
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 25964
#include <iostream>
#include <math.h>
#include <string>

using namespace std;
int main()
{
    int n,a;
    cin>>n;
    if(n % 2 == 1){
        n=n-1;
        a= n/2;
        a=a+1;
    }
    else{
        a = n/2;
    }
    cout<<a;
    return 0;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;
    
    i64 N;
    cin >> N;
    vector<i64> W(N);
    rep(i,0,N){
        cin >> W[i];
    }
    
    i64 ans=inf64;
    rep(i,0,N-1){
        i64 s1=0,s2=0;
        rep(j,0,i+1) s1+=W[j];
        rep(j,i+1,N) s2+=W[j];
        chmin(ans,abs(s1-s2));
    }
    
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

		int N = in.nextInt();
		int M = in.nextInt();

		ArrayList<Pair<Long, Long>> ab = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			ab.add(new Pair<Long, Long>(in.nextLong(), in.nextLong()));
		}
		ab.sort((a, b) -> a.compareTo(b));

		long total = 0;
		for (Pair<Long, Long> pair : ab) {
			if (pair.value >= M) {
				total += pair.key * M;
				break;
			}
			total += pair.key * pair.value;
			M -= pair.value;
		}
		System.out.println(total);
	}

	private static class Pair<K extends Comparable<K>, V extends Comparable<V>>
			implements Map.Entry<K, V>, Comparable<Pair<K, V>> {

		private K key;
		private V value;

		public Pair(K key, V value) {
			this.key = key;
			this.value = value;
		}

		@Override
		public K getKey() {
			return key;
		}

		@Override
		public V getValue() {
			return value;
		}

		@Override
		public V setValue(V value) {
			V v = this.value;
			this.value = value;
			return v;
		}

		@Override
		public String toString() {
			return "[" + key.toString() + ", " + value.toString() + "]";
		}

		@Override
		public int compareTo(Pair<K, V> o) {
			int c1 = this.key.compareTo(o.key);
			if (c1 != 0) {
				return c1;
			}
			return this.value.compareTo(o.value);
		}
	}
}


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

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

    ll ans1 = (N * (N - 1)) / 2;
    ll ans2 = (M * (M - 1)) / 2;

    cout << (ans1 + ans2) << endl;
}


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

#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ld					  long double

#define ss                       second
#define ff                        first

#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)

#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())

#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define pd					 pair<ld,ld>
#define endl                 '\n'

#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define mod					 1000000007
#define inf                  1000000007
#define eps                  0.000000000000001

typedef vector<int> vi; 
typedef vector< ll > vl;
typedef vector< ld > vd;
typedef vector< pi > vpi;
typedef vector< pll > vpl;
typedef vector< vi > vvi;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//vector<int> adj[200010],value(200010),par(200010),vis(200010,0),dis(200010,0),g(200010,0),col(200010,-1);
//int myrandom (int i) { return std::rand()%i;}

int main()
{
	char c; cin>>c;
	if(c>=97 && c<=122) cout<<'a'<<endl;
	else cout<<'A'<<endl;
}


Measured memory_bytes: 3624
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	vector<int> nums(n); fore(e, nums) cin >> e;
	int mx1 = 0, mx2 = 0;
	fore(e, nums) {
		if(e > mx1) {
			mx1 = e;
		}
		else if(e > mx2) {
			mx2 = e;
		}
	}
	fore(e, nums) {
		if(mx1 == e) println(mx2);
		else println(mx1);
	}
}


Measured memory_bytes: 2432
#include<iostream>
#include<cmath>
#define dou double

using namespace std;

const dou pie = acos(-1.0);

int main()
{
	dou a,b,h,m;
	cin>>a>>b>>h>>m;
	double x = h * 60 + m;
	x /= 720;
	x *= 2 * pie;
	double y = m / 60 * 2 * pie;
	double z = abs(x - y);
	dou ans = sqrt(a*a + b*b -2*a*b*cos(z));
	printf("%.9lf",ans);
	return 0;
} 

Measured memory_bytes: 3644
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
double v[1000000];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>v[i];
	}
	sort(v+1,v+n+1);

	for(int i=1;i<=n-1;i++)
	{
		v[i+1]=(v[i]+v[i+1])*1.0/2;
	}
	cout<<v[n];
}

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


ll f(ll x) {
  if (x == 1) return 1;
  ll a = f(x/2);
  return a*2+1;
}

int main() {
  ll h;
  cin >> h;
  cout << f(h) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main() {
	int x[5];
	int y[5];
	int a, b;
	scanf("%d %d %d %d", &x[1], &y[1], &x[2], &y[2]);
//	if (y[1] < y[2]) {
		a = x[2] - x[1];
		b = y[2] - y[1];
		x[4] = x[1] - b;
		y[4] = y[1] + a;
		y[3] = y[2] + a;
		x[3] = x[2] - b;
	//}
	//else {

	//}

	printf("%d %d %d %d\n", x[3], y[3], x[4], y[4]);
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

bool ch(string s){
    unordered_set<char>q;
    for (int i = 0; i <(int)s.size(); ++i) {
        q.insert(s[i]);
    }
    if(q.size()==1)return true;
    else return false;
}

int main(){
    string s;cin >>s;
    ll ans=INF;
    string c=s;
    int n=s.size();
    for (int i = 0; i <n; ++i) {
        c=s;
        string b;
        char key=s[i];
        ll now=0;
        while(!ch(c)){
            for (int j = 0; j < c.size() - 1; ++j) {
                if(c[j]==key||c[j+1]==key){
                    b.push_back(key);
                }
                else b.push_back(c[j]);
            }
            c=b;
            b="";
            now++;
        }
        ans=min(ans,now);
    }
    cout <<ans <<endl;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<ll> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, w;
	cin >>n >>w;
	VI dp(105000, mod); dp[0]=0;
	rep(i,n){
		ll g, v;
		cin >>g >>v;
		repr(j, 100000, 0) if(dp[j] <mod){
			if(dp[j] + g <= w) 
				dp[j+v] = min(dp[j+v], dp[j] + g);
		}
	}
	repr(i,100010, 0) if(dp[i] <mod){
		cout << i <<"\n";
		return 0;
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,k,ans = 0,sum = 0;
	string s;
	cin >> n >> k >> s;
	s += "2";
	vector<int> vec;
	int cnt = 0,prev = '1';
	for(int i = 0;i < s.length();i++){
		if(s[i] != prev){
			vec.pb(cnt);
			cnt = 1;
		}else cnt++;
		prev = s[i];
	}
	if(s[n - 2] == '0') vec.pb(0);
	for(int i = 0;i < vec.size();i++){
		sum += vec[i];
		if(i - (k * 2 + 1) >= 0) sum -= vec[i - (k * 2 + 1)];
		if(i % 2 == 0) ans = max(ans,sum);
	}
	cout << ans << endl;
}


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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");

int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}

vi vis(100001,0);
vi adj[100001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    int n,k,q;cin>>n>>k>>q;
    vi vec(n+1,k);
    for(int i=1; i<vec.size(); ++i)
    {
    	vec[i]-=q;
    }
    while(q--)
    {
    	int x;cin>>x;
    	++vec[x];
    }
    for(int i=1; i<vec.size(); ++i)
    {
    	if(vec[i]<=0)
    		cout<<"No"<<"\n";
    	else
    		cout<<"Yes"<<"\n";
    }
}

Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int main(void){
  string S, T; cin >> S >> T;
  int table1[26], table2[26];
  for (int i = 0; i < 26; i++) { table1[i] = -1; table2[i] = -1; }

  for (int i = 0; i < S.size(); i++) {
    if (table1[S[i] - 'a'] >= 0) {
      if (table1[S[i] - 'a'] != T[i] - 'a') {
        cout << "No" << endl;
        return 0;
      }
    }
    if (table2[T[i] - 'a'] >= 0) {
      if (table2[T[i] - 'a'] != S[i] - 'a') {
        cout << "No" << endl;
        return 0;
      }
    }
    if (table1[S[i] - 'a'] < 0)
      table1[S[i] - 'a'] = T[i] - 'a';
    if (table2[T[i] - 'a'] < 0)
      table2[T[i] - 'a'] = S[i] - 'a';
  }
  cout << "Yes" << endl;
  return 0;
}


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

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[] L = new int[N];
        for (int i = 0; i < N; i++) {
            L[i]=sc.nextInt();
        }

        int count = 0;

        for (int i = 0; i < N; i++) {
            for (int j = i+1; j < N ; j++) {
                for (int k = j+1; k < N; k++) {
                    int a = L[i];
                    int b = L[j];
                    int c = L[k];

                    if(a+b > c && a+c > b &&c+b > a && a!=b && a!=c && c!=b ){
                        count++;
                    }


                }
            }
        }



        System.out.println(count);

    }}

Measured memory_bytes: 37148
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int n;
int a[110];
int cnt1=0,cnt2=0;
bool vis[10];

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]>=1&&a[i]<=399&&vis[0]==0)
        {
            vis[0]=1;
            cnt1++;
        }
        else if(a[i]>=400&&a[i]<=799&&vis[1]==0)
        {
            vis[1]=1;
            cnt1++;
        }
        else if(a[i]>=800&&a[i]<=1199&&vis[2]==0)
        {
            vis[2]=1;
            cnt1++;
        }
        else if(a[i]>=1200&&a[i]<=1599&&vis[3]==0)
        {
            vis[3]=1;
            cnt1++;
        }
        else if(a[i]>=1600&&a[i]<=1999&&vis[4]==0)
        {
            vis[4]=1;
            cnt1++;
        }
        else if(a[i]>=2000&&a[i]<=2399&&vis[5]==0)
        {
            vis[5]=1;
            cnt1++;
        }
        else if(a[i]>=2400&&a[i]<=2799&&vis[6]==0)
        {
            vis[6]=1;
            cnt1++;
        }
        else if(a[i]>=2800&&a[i]<=3199&&vis[7]==0)
        {
            vis[7]=1;
            cnt1++;
        }
        else if(a[i]>=3200) cnt2++;
    }
    printf("%d %d",max(cnt1,1),cnt1+cnt2);
    return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;


const ll M = 1000000007;
ll Y, X;
string a[2000];
ll dp[2000][2000];

signed main() {
  cin >> Y >> X;
  rep(y, Y)
    cin >> a[y];
  dp[Y-1][X-1] = 1;
  for (ll y=Y-1; y>=0; y--) {
    for (ll x=X-1; x>=0; x--) {
      if (dp[y][x] > 0)
        continue;
      if (a[y][x] == '#')
        continue;
      ll t = 0;
      if (y+1 < Y && a[y+1][x] == '.') {
        (t += dp[y+1][x]) %= M;
      }
      if (x+1 < X && a[y][x+1] == '.') {
        (t += dp[y][x+1]) %= M;
      }
      dp[y][x] = t;
    }
  }
  cout << dp[0][0] << endl;
  return 0;
}


Measured memory_bytes: 17152
x, y = map(int, input().split())
prize = 0
if x == 1:
  prize += 300000
elif x == 2:
  prize += 200000
elif x == 3:
  prize += 100000

if y == 1:
  prize += 300000
elif y == 2:
  prize += 200000
elif y == 3:
  prize += 100000
if x == 1 and y == 1:
  prize += 400000
print(prize)

Measured memory_bytes: 3064