akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}

// end of Template

int ans = 1;
int n,k,sum,a[1000010];
vi f;
void solve (int x){
    multiset <ll> m;
    multiset <ll> :: iterator itr;
    ll cost = 0;
    for(int i=1;i<=n;i++){
        m.insert(a[i]%x);
        cost += x - (a[i]%x);
    }
    ll opt = 0;
    for(itr = m.begin(); itr!=m.end(); ++itr){
        opt += *itr;
        cost -= (x - *itr);
        if(cost==opt){
            if(opt<=k){ans = max(ans,x);break;}
        }
    }

}
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    for(int i=1;i<=sqrt(sum);i++){
        if(sum%i==0){
            f.pb(i);
            f.pb(sum/i);
        }
    }
    for(int i=0;i<f.size();i++){
        solve(f[i]);
    }
    cout<<ans<<newl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2019;
int n,ans;
bitset<N>L[N],R[N],a[N];
char str[N];
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		scanf("%s",str+1);
		for(int j=1;j<i;j++)a[i][j]=str[j]-'0',a[j][i]='1'-str[j];
	}
	for(int i=1;i<=n;i++)L[i][i]=R[i][i]=1;
	for(int l=2;l<=n;l++)
	for(int i=1,j;i+l-1<=n;i++)
	{
		j=i+l-1;
		L[j][i]=(R[i+1]&L[j]&a[i]).count()!=0;
		R[i][j]=(L[j-1]&R[i]&a[j]).count()!=0;
	}
	for(int i=1;i<=n;i++)ans+=R[1][i]&&L[n][i];
	printf("%d",ans);
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
    int flag,i,n,x,y,count;
    flag = 1;
    i = 0;
    count = 0;
    cin >> n;
    int A[100] = {};
    for(int j = 0; j < n; j++){
        cin >> A[j];
    }
    while (flag == 1){
        flag = 0;
        for(int j = n-1; j >= i + 1; j--){
            if(A[j] < A[j-1]){
                x = A[j];
                y = A[j-1];
                A[j-1] = x;
                A[j] = y;
                flag = 1;
                count ++;
            }
        }
        i ++;
    }
    for(int j = 0; j < n; j ++){
        if(j != 0){
            cout << " ";
        }
        cout << A[j];
    }
    cout << endl;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long X, long long Y){
    cout << X + Y/2 << endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>

#define N 300005
#define M 8000005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

int i,j,m,n,p,k,x,a[N],vis[N];

long long ans,cnt;

map<int,int>mp;

int main()
{
		scanf("%d",&n);
		for (i=1;i<=n;++i) scanf("%d",&a[i]);
		sort(a+1,a+n+1);
		for (j=30;j>=0;--j)
		{
				int r=n;
				for (i=1;i<=n;++i)
					if (!vis[i])
				{
						while (r>i&&(a[i]+a[r]>(1<<j)||vis[r])) --r;
						if (i==r) break;
						if (a[i]+a[r]==(1<<j)) vis[i]=vis[r]=1,ans++;
				}
		}
		printf("%d\n",ans);
}

Measured memory_bytes: 1792
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""

from collections import deque
from itertools import product
import numpy as np
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


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


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():

    N, M, X = wi()
    A = []
    for _ in range(N):
        A.append(wi())
    ans = 10**20
    flag = False
    for t in product([0, 1], repeat=N):
        plus = [0] * (M+1)
        plus = np.array(plus)
        flag = False
        for i in range(len(t)):
            if t[i] == 0:
                continue
            else:
                plus += np.array(A[i])
                #print(plus[0])
        for j in range(1, M+1):
            if plus[j] < X:
                flag = True
                break
        if flag == False:
            ans = min(ans, plus[0])

    if ans == 10**20:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27308
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static long ans=0;
	static St st;
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] a=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		st=new St(0,n-1);
		for(int i=0;i<n;i++){st.Ud(i,a[i]);}
		Fu(0,n-1,0);
		Console.WriteLine(ans);
	}
	static void Fu(int a,int b,long c){
		if(b-a>=0){
			Mo q=st.Get(a,b);
			if(c<q.d){ans+=q.d-c;}
			Fu(a,q.n-1,q.d);
			Fu(q.n+1,b,q.d);
		}
	}
}
public class Mo{
	public long d;
	public int n;
	public Mo(long d,int n){this.d=d;this.n=n;}
}
public class St{
	private Mo [] dat;
	private int m=1,f;
	private Mo du=new Mo(long.MaxValue,-1);
	public St(int f,int n){
		this.f=f;
		n+=f^1;
		while(m<n){m*=2;}
		dat=new Mo[m+n-1];
		for(int i=0;i<m+n-1;i++){dat[i]=du;}
	}
	private bool Compare(Mo x,Mo y){return x.d<y.d;}
	public void Ud(int q,long b){
		q+=m-1-f;
		if(dat[q]==du){
			int z=q;
			dat[q]=new Mo(b,q-(m-1-f));
			while(q>0&&Compare(dat[z],dat[(q-1)/2])){
				dat[(q-1)/2]=dat[z];
				q=(q-1)/2;
			}
		}
		else{
			dat[q].d=du.d;
			dat[q]=new Mo(b,q-(m-1-f));
			q=(q-1)/2;
			while(q>=0){
				Mo o=Compare(dat[2*q+1],dat[2*q+2])?dat[2*q+1]:dat[2*q+2];
				if(dat[q]==o){break;}
				dat[q]=o;
				q=(q-1)/2;
			}
		}
	}
	private Mo Fdg(int a,int b,int k,int l,int r){
		if(r<a||b<l){return du;}
		if(a<=l&&r<=b){return dat[k];}
		Mo p=Fdg(a,b,k*2+1,l,(l+r)/2);
		Mo q=Fdg(a,b,k*2+2,(l+r+1)/2,r);
		return Compare(p,q)?p:q;
	}
	public Mo Get(int a,int b){return Fdg(a,b,0,f,m-(f^1));}
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

const int N = 1501;

int n;
int m;
ll ans = 0;
int g[N][N];
ii q[N * N];
int used[N][N];
int was[N][N];
int cur;
int l, r;
int ct = 0;
int bad[N * N];

int go (int i, int j) {
	if (i > n || j > n || g[i][j] == 0 || was[i][j]) re 0;
	was[i][j] = 1;
	int cr = r;
	q[r++] = mp (i, j);
	ct++;
	int curct = ct;
	used[i][j] = ct;
	int add = 0;
	while (l < r) {
		int x = q[l].fi;
		int y = q[l].se;
		add += g[x][y];
		l++;
		if (bad[used[x - 1][y]]) {
			q[r++] = mp (x - 1, y);
			used[x - 1][y] = ct;
		}
		if (bad[used[x][y - 1]]) {
			q[r++] = mp (x, y - 1);
			used[x][y - 1] = ct;
		}
	}
	cur += add;
//	printf ("%d %d = %d\n", i, j, cur);
	ans += (ll)(cur - g[i][j]) * g[i][j];
	if (rand () & 1) {
		go (i, j + 1);
		go (i + 1, j);
	} else {
		go (i + 1, j);
		go (i, j + 1);
	}	
	r = l = cr;
	cur -= add;
	bad[curct] = 1;
	re 0;
}

int main () {
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < n; j++)
			if (s[j] == '#') {
				g[i + 1][j + 1] = 0;
				used[i + 1][j + 1] = 1;
			}
			else
				g[i + 1][j + 1] = s[j] - '0';	
	}	
	l = r = 0;
	cur = 0;
	ans = 0;
	ct = 1;
	bad[0] = 1;
	for (int i = 0; i <= n; i++)
		used[i][0] = used[0][i] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if (!was[i][j] && g[i][j] > 0)
				go (i, j);
	cout << ans << endl;
	cerr << clock () << endl;
	return 0;
}

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

int main()
{
    int j,i;
    char *a[7]= {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    char **p=a;
    char s[4];
    scanf("%s",s);
    int flag;
    for(j=0; j<7; j++,p++)
    {
        flag=0;
        for(i=0; i<3; i++)
        {
            if(s[i]!=(*p)[i])
            {
                flag=1;break;
            }
        }
      if(flag==0)
      {
          printf("%d",7-j); return 0;
      }

    }

    return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;


int main() {
    int a, b; cin >> a >> b;
    cout << max(0, a-b*2) << endl;

    return 0;
}


    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

template <std::uint_fast64_t Modulus> class mint {
public:
  ll a;
  constexpr mint(const ll x = 0) noexcept : a(x % Modulus) {}
  constexpr ll &value() noexcept { return a; }
  constexpr const ll &value() const noexcept { return a; }
  constexpr mint operator+(const mint rhs) const noexcept {
    return mint(*this) += rhs;
  }
  constexpr mint operator-(const mint rhs) const noexcept {
    return mint(*this) -= rhs;
  }
  constexpr mint operator*(const mint rhs) const noexcept {
    return mint(*this) *= rhs;
  }
  constexpr mint operator/(const mint rhs) const noexcept {
    return mint(*this) /= rhs;
  }
  constexpr mint &operator+=(const mint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr mint &operator-=(const mint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr mint &operator*=(const mint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr mint &operator/=(mint rhs) noexcept {
    ll exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

const ll MOD=1000000007;
void solve(){
  string k; cin>>k;
  ll D; cin>>D;
  auto dp=make_v(D,2,mint<MOD>(0)); // dp[r][lt]
  dp[0][0]=1;
  rep(i,k.size()){
    ll a=k[i]-'0';
    auto newdp=make_v(D,2,mint<MOD>(0));
    rep(r,D)rep(lt,2)rep(d,10){
      ll nr=(r+d)%D,nlt=lt;
      if((!lt)&&d>a) continue;
      if(d<a) nlt=1;
      newdp[nr][nlt]+=dp[r][lt];
    }
    dp=newdp;
  }
  cout<<(dp[0][0]+dp[0][1]-1).a<<"\n";
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
before = -100

for i in range(N):
    ans += B[A[i]-1]
    if before + 1 == A[i]-1:
        ans += C[before]
    before = A[i] - 1

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


//for(i=0; i<N; i++) cin >> a[i];

class sumSegTree {
public:
  ll n, height;
  vector<ll> data;
  
  sumSegTree(ll _n) {
    n=1;
    height=1;
    while(n<_n) {
      n*=2;
      height++;
    }
    data=vector<ll>(2*n-1);
  }
  
  void add(ll i, ll x) {
    i+=n-1;
    data[i]+=x;
    while(i>0) {
      i=(i-1)/2;
      data[i]+=x;
    }
  }
  
  //[a, b):要求区間，[l, r):対象区間
  ll _sum(ll a, ll b, ll k, ll l, ll r) {
    if(r<=a || b<=l) return 0;
    if(a<=l && r<=b) return data[k];
    else {
      ll s=_sum(a, b, 2*k+1, l, (l+r)/2);
      ll t=_sum(a, b, 2*k+2, (l+r)/2, r);
      return s+t;
    }
  }
  
  ll sum(ll a, ll b) {
    return _sum(a, b, 0, 0, n);
  }
  
};


ll c[MAX*5];
ll pos[MAX*5];

int main(void) {
  ll i, j, k;
  
  ll N, Q;
  cin >> N >> Q;
  for(i=1; i<=N; i++) cin >> c[i];
  
  vector<pair<pll, ll>> v;
  v.push_back({{0, 0}, -1});
  
  for(i=1; i<=Q; i++) {
    ll l, r;
    cin >> l >> r;
    //l--; r--;
    v.push_back({{r, l}, i});
  }
  sort(v.begin(), v.end());
  
  for(i=1; i<=Q; i++) swap(v[i].ft.ft, v[i].ft.sc);
  
  sumSegTree sst(N+5);
  
  set<ll> st;
  memset(pos, -1, sizeof(pos));
  
  ll ans[MAX*5];
  for(ll q=1; q<=Q; q++) {
    ll l=v[q].ft.ft;
    ll pr=v[q-1].ft.sc;
    ll r=v[q].ft.sc;
    
    for(i=pr+1; i<=r; i++) {
      if(st.find(c[i])!=st.end()) sst.add(pos[c[i]], -1);
      
      st.insert(c[i]);
      pos[c[i]]=i;
      sst.add(i, 1);
    }
    
    ans[v[q].sc]=sst.sum(l, r+1);
  }
  
  for(i=1; i<=Q; i++) pt(ans[i]);
  
}




Measured memory_bytes: 58964
#include <bits/stdc++.h>
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main(){
  ll n,k; cin >>n >>k; ll sum=0;
  for(int i=k; i<n+2; i++) sum+=i*(n+1-i)+1;
  cout <<sum%MOD;
return 0;}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main (){
  long long k;
  long long i=0;
  string s;
  cin >> s;
  cin >> k;
  while(true){
    if(s[i]=='1'){
      i++;
    }else{
      break;
    }
  }
  if(i>=s.length()-1){
    i=s.length()-1;
  }
  if(k<=i){
    cout << '1' << endl;
  }else{
    cout << s[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

  string a = "";
  string b = "";
  cin >> a;
  cin >> b;
  int r = 0;
  for(int i=0; i<3; i++)
  {
   	if (a[i] == b[i])
    {
      r++;
    }
  }

  cout << r;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {

            string S =Console.ReadLine();
            int a;
            int b;
            int c;
            int d;

            a = S[0];
            b = S[1];
            c = S[2];
            d = S[3];

            if (a == b || b == c || c == d)
            {
                Console.WriteLine("Bad");
            }
            else
            {
                Console.WriteLine("Good");
            }
        }
    }
}

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

namespace otameshi
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b,c;
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            c = 6 - (a + b);
            Console.WriteLine(c);
            Console.ReadKey();
            
        }
    }
}

Measured memory_bytes: 13140
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define mod 100000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
ll rui[100005]={};
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	rui[1]=0ll;
	for(int i=2;i<=n;i++)
	{
		ll f; scanf("%lld",&f);
		rui[i]=(rui[i-1]+f);
	}
	int cur=1;
	ll ans=0;
	for(int i=1;i<=m;i++)
	{
		int x; scanf("%d",&x);
		ans+=abs(rui[cur+x]-rui[cur]);
		cur+=x;
	}
	printf("%lld\n",ans%mod);
}

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

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

  std::vector<std::pair<int, int> > a(n);
  for (auto& p : a)
    scanf("%d%d", &p.first, &p.second);

  int max = 0;
  std::map<std::pair<int, int>, int> map;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int p = a[i].first - a[j].first;
      int q = a[i].second - a[j].second;

      if (!p && !q) continue;

      //printf("%d -> %d\n", i, j);
      //printf("p:%d q:%d\n\n", p, q);
      max = std::max(max, ++map[{p, q}]);
    }
  }

  printf("%d\n", n - max);
  return 0;
}


Measured memory_bytes: 384
import sys

a, b, c, d = list(input())
ops = ['+', '-']
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            expr = ''.join([a, op1, b, op2, c, op3, d])
            if eval(expr) == 7:
                print(expr + '=7')
                sys.exit()

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int[] b = new int[a];
		for (int i = 0; i < a; i++)
			b[i] = scanner.nextInt();
		for (int i = b.length - 1; i >= 0; i--) {
			if (i == b.length - 1)
				System.out.print(b[i]);
			else
				System.out.print(" " + b[i]);
		}
		System.out.println();
	}
}


Measured memory_bytes: 26260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  string s;
  cin >> s;
  
  int t = 0, ans = 0;
  rep(i, 3) {
    if(s[i] == 'R') {
      t++;
    }
    else {
      ans = max(ans, t);
      t = 0;
    }
  }
  
  cout << max(t, ans) << endl;
}


Measured memory_bytes: 3580
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000010007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
long long p[1100][1100];
long long t[1100];
int main(){

	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++)scanf("%lld",&p[i][j]);
	}
	for(int i=0;i<a-1;i++)if(p[i][0]>p[i+1][0]){
		printf("-1\n");
		return 0;
	}
	if(b==1){
		for(int i=0;i<a-1;i++)if(p[i][0]>=p[i+1][0]){
			printf("-1\n");
			return 0;
		}
		printf("0\n");	return 0;
	}
	long long ret=0;
	long long cur=0;
	for(int i=1;i<a;i++){
		if(p[i-1][0]!=p[i][0]){cur=0;continue;}
		long long now=p[i-1][0]*cur+p[i-1][1];
		if(p[i][1]>now){
			cur=0;continue;
		}
		long long req=(now-p[i][1]+p[i][0]-1)/p[i][0];

		if(p[i][1]+p[i][0]*req>now){
			cur=req;
			ret+=req;
			continue;
		}
		bool ok=false;
		long long P=ABS(cur-req);
		if(P>mod)return 1;
		if(P==0){

			for(int j=0;j<b;j++){
				if(p[i-1][j]<p[i][j]){ok=true;break;}
				if(p[i-1][j]>p[i][j]){break;}
			}

		}else{
			t[0]=1;
			for(int j=1;j<b;j++){
				if(t[j-1]==mod){t[j]=mod;continue;}
				t[j]=t[j-1]*(P-1+j)/j;
				if(t[j]>mod){
					t[j]=mod;
				}
			}
			for(int j=2;j<b;j++){
				if(req<cur){	
					long long tmp=p[i][j];
					for(int k=j;k>=0;k--){
						tmp-=t[k]*p[i-1][j-k];
						if(tmp<0)break;
					}
					if(tmp<0){
						break;
					}
					if(tmp>0){
						ok=true;break;
					}
				}else{
					long long tmp=p[i-1][j];
					for(int k=j;k>=0;k--){
						tmp-=t[k]*p[i][j-k];
						if(tmp<0)break;
					}
					if(tmp<0){
						ok=true;break;
					}
					if(tmp>0){
						break;
					}
				}
			}			
		}

		if(!ok){
			req++;
		}
		ret+=req;
		cur=req;
	//	printf("%lld %lld\n",ret,cur);
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 10368
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[50];
int main()
{
    int i,j,p,q,r;scanf("%d%d%d",&p,&q,&r);
    a[1]=p;a[2]=q;a[3]=r;int minn=500;
    do
    {
        char c1,c2,c3;
//        if(a[1]==p&&a[2]==q&&a[3]==r) c1='A',c2='B',c3='C';
//        if(a[1]==p&&a[2]==r&&a[3]==q) c1='B',c2='A',c3='C';
//        if(a[1]==r&&a[2]==q&&a[3]==p) c1='A',c2='C',c3='B';
//        if(a[1]==r&&a[2]==p&&a[3]==q) c1='C',c2='A',c3='B';
//        if(a[1]==q&&a[2]==p&&a[3]==r) c1='C',c2='B',c3='A';
//        if(a[1]==q&&a[2]==r&&a[3]==p) c1='B',c2='C',c3='A';
//        printf("The sum of the flight times in the route%c\\rightarrow%c\\rightarrow%c:",c1,c2,c3);
        //printf("%d + %d = %d hours",a[1],a[2],a[1]+a[2]);
      //  printf("\n");
        if(a[1]+a[2]<minn) minn=a[1]+a[2];
    }while(next_permutation(a+1,a+4));
  //  printf("The minimum of these is %d hours.\n",a[1]+a[2]);
  printf("%d\n",a[1]+a[2]);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	char ch[20];
	int n,k;
	cin>>n;
	cin>>ch;
	cin>>k;
	char temp=ch[k-1];
	for(int i=0;i<strlen(ch);i++)
		if(ch[i]!=temp)cout<<'*';
		else cout<<ch[i];
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

B = 4
F = 3
R = 10
SHARPS = 20

def main():
    """
    The function to be called when this script is run as a script.
    
    """
    
    info_number = int(input())
    given_info_str = (info.split() for info in (
        input() for _ in range(info_number)))
    given_info_int = (list(map(int, info)) for info in given_info_str)
    houses = [[[0 for i in range(R)] for j in range(F)] for k in range(B)]
    for info in given_info_int:
        houses[info[0] - 1][info[1] - 1][info[2] - 1] += info[3]
    for num, building in enumerate(houses):
        for floor in building:
            print (" " + " ".join(map(str, floor)))
        if num < (B - 1):
            print("#" * 20)

if __name__ == "__main__":
    main()

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

int main() {
    int N, M;   cin >> N >> M;
    int low=0, high=100000, ans = 0;
    vector<vector<int>> id(M);

    for (int i = 0; i < M; ++i) {
        int a, b;   cin >> a >> b;
        if(a>=low) low = a;
        if(b <= high) high = b;
    }

    if(low <= high) ans = high - low + 1;

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

Measured memory_bytes: 2560
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
B = np.array(list(map(int,input().split())))

if sum(A) < sum(B):
	print(-1)
else:
    dif = A-B
    ans = np.sum(dif<0)
    minus = [dif[i]*-1 for i in range(N) if dif[i] < 0]
    minus_sum = np.sum(minus)
    plus = [dif[i] for i in range(N) if dif[i] > 0]
    plus_sort = np.sort(plus)[::-1]

    for i in plus_sort:
        if minus_sum == 0:
            print(ans)
            break
        minus_sum -= i
        ans += 1
        if minus_sum < 0:
            print(ans)
            break
    else:
        print(-1)

Measured memory_bytes: 23984
N=int(input())
n=len(str(N))
res=0
for a in range(1,N+1):
    a0=str(a)[0]
    a1=str(a)[-1]
    if a0=='0' or a1=='0':
        a_res=res
        continue
    for i in range(1,n+1):
        if i==1:
            if a0==a1:
                res+=1
        elif i==2:
            if 10*int(a1)+int(a0)<=N:
                res+=1
        elif i==n:
            n0=str(N)[0]
            n1=str(N)[-1]
            if n0<a1:
                res+=0
            elif n0>a1:
                res+=10**(i-2)
            else:
                res+=(N-int(a1)*10**(i-1))//10+1
                if n1<a0:
                    res-=1
        else:
            res+=10**(i-2)
print(res)

Measured memory_bytes: 74148
#include<iostream>
using namespace std;
int main()
{
	int i=0,n,s=0,t,pret=0,T;
	for(cin>>n>>T;i<n;i++)
	{
		cin>>t;
		if(t-pret>T)s+=T;
		else s+=t-pret;
		pret=t;
	}
	cout<<s+T<<endl;
	return 0;
}

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

int n,m,a[1010],b,num[1010];

int main(){
  cin >> n >> m;
  for(int i=0;i<n;i++)cin >> a[i];
  for(int j=0;j<m;j++){
    cin >> b;
    for(int i=0;i<n;i++){
      if(a[i]<=b){
	num[i]++; break;
      }
    }
  }

  int id = 0;
  for(int i=0;i<n;i++){
    if(num[i]>num[id])id = i;
  }
  cout << id+1 << endl;
}

Measured memory_bytes: 1168
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

class Combination(object):
	def __init__(self, N, con):
		self.fac = [0] * (N + 1)
		self.inv = [0] * (N + 1)
		self.finv = [0] * (N + 1)
		self.fac[0], self.fac[1] = 1, 1
		self.inv[1] = 1
		self.finv[0], self.finv[1] = 1, 1

		# 前計算
		for i in range(2, N + 1):
			self.fac[i] = self.fac[i - 1] * i % con
			self.inv[i] = self.inv[con % i] * (con - (con // i)) % con
			self.finv[i] = self.finv[i - 1] * self.inv[i] % con

	def com(self, N, k):
		return (self.fac[N] * self.finv[k] * self.finv[N - k]) % con


#処理内容
def main():
	N, M = getlist()
	ComM = Combination(M, con)
	ComN = Combination(N, con)
	anspre = (ComM.fac[M] * ComM.finv[M - N]) % con

	anspre2 = 0
	for i in range(N + 1):
		val = (ComN.com(N, i) * ComM.fac[M - i] * ComM.finv[M - N]) % con
		if i % 2 == 0:
			anspre2 += val
		else:
			anspre2 -= val

	ans = anspre * anspre2 % con
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 91256
#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
    cin >> N;
    vector<int> a;
    for(int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        a.push_back(x-1);
    }

    int now = 0, c = 0;
    while(1) {
        if(now == 1) {
            cout << c << endl;
            return 0;
        }
        if(c >= N) {
            cout << -1 << endl;
            return 0;
        }
        c++;
        now = a.at(now);
    }
}

Measured memory_bytes: 892
#
#	106 D - AtCoder Express 2
#

N, M, Q = [int(_) for _ in input().split()]
listN = [[0] * (N+1) for i in range(N+1)]
listNsum = [[0] * (N+1) for i in range(N+1)]

for i in range(M):
	L, R = [int(_) for _ in input().split()]
	listN[L][R] += 1

#累積和計算
for iIdx, iList in enumerate(listN):
	for jIdx, jList in enumerate(iList):
		if jIdx == 0:
			listNsum[iIdx][jIdx] = listN[iIdx][jIdx]
		else:
			listNsum[iIdx][jIdx] = listNsum[iIdx][jIdx-1] + listN[iIdx][jIdx]


retList = []
for i in range(Q):
	p, q = [int(_) for _ in input().split()]
	sumv = 0
	for j in range(p, q+1):
		sumv += listNsum[j][q] - listNsum[j][p-1]
	retList.append(sumv)

for i in retList:
	print(i)

Measured memory_bytes: 67800
import math

n = int(input())
a = [0 for _ in range(n+1)]

x = 1
y = 1
z = 1

for x in range(1,int(math.sqrt(n))+1):
  for y in range(1,int(math.sqrt(n - x**2))+1):
    for z in range(1,int(math.sqrt(n - x**2 - y**2))+1):
      left = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if left <= n:
        a[left] += 1
#        print(x,y,x,left)
      z += 1
    y += 1
  x += 1

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

Measured memory_bytes: 74568
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#include<math.h>
#define Max 1000
#define INF 1000000000000000000
using namespace std;


bool found(vector<int>&vec,vector<int>&v){
	for(int i=0;i<vec.size();i++){
		if(vec[i] != v[i])
			return false;
	}
	return true;
}

int main(){

	vector<int>vec1,vec2,vec3;


	int n,x;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		vec1.push_back(i+1);
		vec2.push_back(x);
	}

	for(int i=0;i<n;i++){
		scanf("%d",&x);
		vec3.push_back(x);
	}

	int c = 0,a,b,flag=0;
	do{
		c++;
		if(found(vec1,vec2)){
			a = c;
			flag++;
		}

		if(found(vec1,vec3)){
			b = c;
			flag++;
		}



	}while(next_permutation(vec1.begin(),vec1.end()) && flag < 2);	

	printf("%d\n",abs(a-b));

	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
//main function
fn main() {
    let h: i32 = read();
    let a: i32 = read();
    if h%a==0 {
	println!("{}",h/a);
    }else{
	println!("{}",h/a+1);
    }

}


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

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  
  if (s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define y first
#define x second

using namespace std;
typedef long long ll;

int main()
{

    int n;
    ll x;
    cin >> n >> x;
    ll a[n];

    fr(i, 0, n) cin >> a[i];
    ll ans = 0;
    if(a[0] + a[1] > x){
        if(a[0] > x){
            ans += a[0] - x;
            ans += a[1];
            a[1] = 0;
        }
        else{


            ans += (a[0] + a[1]) - x;
            a[1] -= (a[0] + a[1]) - x;
        }
    }
    fr(i, 1, n - 1){
        if(a[i] + a[i + 1] > x){
            if(a[i] > x){
                ans += a[i] - x;
                ans += a[i + 1];
                a[i + 1] = 0;
            }
            else{
                ans += (a[i] + a[i + 1]) - x;
                a[i + 1] -= (a[i] + a[i + 1]) - x;
            }
        }

    }

    cout <<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }


int n, m;

int main() {
	while (cin >> n >> m) {
		if (n == 0 && m == 0) break;
		vint vec;
		vec.push_back(0);
		for (int i = 0; i < n+m; ++i) {
			int a; cin >> a; vec.push_back(a);
		}
		sort(ALL(vec));
		int res = 0;
		for (int i = 0; i < vec.size()-1; ++i) chmax(res, vec[i+1] - vec[i]);
		cout << res << endl;
	}
    return 0;
}


Measured memory_bytes: 1348
#include <iostream>
using namespace std;
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <cstdlib>

int Board[100][100] = {};
int dx[8] = {1, 2, 1, 2, -1, -2, -1, -2}, dy[8] = {2, 1, -2, -1, -2, -1, 2, 1};

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

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        int serch = 1;
        int breakk = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            if (a[i] == serch) {
                serch++;
            } else {
                breakk++;
            }
        }
        if (serch == 1) {
            breakk = -1;
        }
        System.out.println(breakk);
        sc.close();
    }
}


Measured memory_bytes: 65544
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var to, tp, order, point int
	for i := 0; i < n; i++ {
		fmt.Scan(&to, &tp)
		if to > order {
			order = to
			point = tp
		}
	}
	fmt.Println(order + point)
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 1;
            while (true)
            {
                string input = Console.ReadLine();
                int x = int.Parse(input);
                if(x == 0)
                {
                    break;
                }
                Console.WriteLine("Case " + i + ": " + x);
                i = i+1;
            }

        }
    }
}



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

int main() {
    int n;
    cin >> n;
    vector<P> p(n);
    rep(i,n) cin >> p[i].second >> p[i].first;
    sort(p.begin(), p.end());
    ll t = 0;
    rep(i,n) {
      t += p[i].second;
      if (t > p[i].first) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e9;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll h, w, k;
  cin >> h >> w >> k;

  char tmp[h + 5][w + 5];

  ll arr[h + 5][w + 5];
  memset(arr, 0, sizeof(arr));
  for (ll i = 1; i <= h; i++) {
    cin >> (tmp[i] + 1);
    for (ll j = 1; j <= w; j++)
      arr[i][j] = tmp[i][j] - '0';
  }

  ll pre[h + 5][w + 5];

  memset(pre, 0, sizeof(pre));
  for (ll i = 1; i <= h; i++) {
    for (ll j = 1; j <= w; j++) {
      pre[i][j] = arr[i][j] + pre[i - 1][j];
    }
  }

  ll ans = inf;

  for (ll mask = 0; mask < (1 << (h - 1)); mask++) {
    vector<ll> cuts;
    for (ll j = 0; j < (h - 1); j++) {
      if ((mask >> j) & 1) {
        cuts.push_back(j + 1);
      }
    }

    ll prev1 = 0;
    vector<vector<ll>> arr2;
    bool bad = false;
    for (ll &x : cuts) {
      vector<ll> tmp(w + 1, 0);
      for (ll j = 1; j <= w; j++) {
        tmp[j] = pre[x][j] - pre[prev1][j];
        if (tmp[j] > k)
          bad = true;
      }
      prev1 = x;
      arr2.push_back(tmp);
    }
    vector<ll> tmp(w + 1, 0);
    for (ll j = 1; j <= w; j++) {
      tmp[j] = pre[h][j] - pre[prev1][j];
      if (tmp[j] > k)
        bad = true;
    }
    if (bad)
      continue;
    arr2.push_back(tmp);

    ll res = cuts.size();
    ll sum1[10];
    memset(sum1, 0, sizeof(sum1));
    for (ll j = 1; j <= w; j++) {

      bool bad = false;
      for (ll i = 0; i < arr2.size(); i++) {
        sum1[i] += arr2[i][j];
        if (sum1[i] > k) {
          bad = true;
        }
      }
      if (bad) {
        res++;
        j--;
        memset(sum1, 0, sizeof(sum1));
      }
    }
    ans = min(ans, res);
  }
  cout << ans << en;

  return 0;
}


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

int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a;
    int b;

    cin >> a >> b;

    string re = "";

    int max = std::max(a, b);
    int min = std::min(a, b);

    for(int i=0; i < max; i++) {
        re = re + to_string(min);
    }

    cout << re;

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    string s;
    cin >> s;
    if ((s.find('a') != string::npos) && (s.find('b') != string::npos) && (s.find('c') != string::npos)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef long long ll;

const int MAXN = 101010;
int nextPos[MAXN][26];
int latestPos[26];

int main() {
    string S, T;
    cin >> S;
    cin >> T;
    const int N = S.size();
    S = S + S;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 26; j++) {
            nextPos[i][j] = -1;
            latestPos[j] = -1;
        }
    }
    for (int i = 2*N-1; i >= 0; i--) {
        if (i < N) {
            for (int j = 0; j < 26; j++) {
                nextPos[i+1][j] = latestPos[j];
            }
        }
        const int alpha = S[i] - 'a';
        latestPos[alpha] = i + 1;
    }
    for (int i = 0; i < 26; i++) {
        nextPos[0][i] = latestPos[i];
    }
    long long ans = 0;
    int index = 0;
    for (int i = 0; i < T.size(); i++) {
        const int alpha = T[i] - 'a';
        const int nextIndex = nextPos[index][alpha];
        if (nextIndex == -1) {
            cout << -1 << endl;
            return 0;
        }
        ans += nextIndex - index;
        index = (nextIndex >= N ? nextIndex - N : nextIndex);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11008
from collections import deque

n = int(input())
a = list(map(int, input().split()))
b = deque()

for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

if n % 2 == 1:
    b.reverse()

print(" ".join(map(str, b)))


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

using namespace std;

int main(){
    int N, K, S;
    while(cin >> N >> K >> S){
        vector<int> res;
        for(int i=0;i<K;i++) res.push_back(S);
        for(int i=K;i<N;i++) res.push_back(S == 1000000000 ? 1 : S+1);
        cout << res[0];
        for(int i=1;i<N;i++) cout << " " << res[i];
        cout << endl;
    }
}

Measured memory_bytes: 1784
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
int a,b,c;
cin>>a>>b>>c;
cout<<c<<" "<<a<<" "<<b<<endl;
}

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

int main(){
	int N;
	vector<int> H;
	cin >> N;
	for (int i = 0; i < N; i++){
		int tmp;
		cin >> tmp;
		H.push_back(tmp);
	}

	int score = 0;
	int tmp = 0;
	for (int i = 0; i < N - 1; i++){
		if (H[i] >= H[i + 1]){
			tmp++;
			if (tmp > score){
				score = tmp;
			}
		}
		else{
			if (score < tmp){
				score = tmp;
			}
			tmp = 0;
		}
	}
	

	cout << score << endl;

	return 0;
}

Measured memory_bytes: 892
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
cnt1 = 0
for i in range(n):
    if i % 2:
        if s[i] == '0':
            cnt1 += 1
    else:
        if s[i] == '1':
            cnt1 += 1
cnt2 = 0
for i in range(n):
    if i % 2:
        if s[i] == '1':
            cnt2 += 1
    else:
        if s[i] == '0':
            cnt2 += 1
ans = min(cnt1, cnt2)
print(ans) 

Measured memory_bytes: 73928