akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M;
pair<Pii, int> PYi[int(1e5 + 5)];
int ansP[int(1e5 + 5)], ansY[int(1e5 + 5)];

int main(){
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++){
    int P, Y; scanf("%d%d", &P, &Y);
    PYi[i].fi = mp(P, Y); PYi[i].se = i; 
    ansP[i] = P;
  }
  sort(PYi, PYi + M);

  int now = 1;
  ansY[PYi[0].se] = 1;
  for (int i = 1; i < M; i++){
    if (PYi[i].fi.fi == PYi[i - 1].fi.fi) now++;
    else now = 1;
    ansY[PYi[i].se] = now;
  }

  for (int i = 0; i < M; i++){
    printf("%06d%06d\n", ansP[i], ansY[i]);
  }
  
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (i % 2 == 0) {
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 512
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
const ll INF = 1LL << 60;

int main()
{

  string S;
  cin >> S;
  // vector<int> odd(S.size() / 2, 0), even(S.size() / 2);
  int odd = 0, even = 0;
  int half = S.size() / 2;

  rep(i, S.size())
  {
    if ((i + 1) % 2 == 1)
    {
      if (S[i] == '0')
        odd++;
    }
    else
    {
      if (S[i] == '0')
        even++;
    }
  }

  int a, b;
  if (S.size() % 2 == 1)
  {
    a = odd + half - even;
    b = half + 1 - odd + even;
  }
  else
  {
    a = odd + half - even;
    b = half - odd + even;
  }
  cout << min(a, b) << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
<url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2729>
?????????============================================================
=================================================================
?§£??¬=============================================================
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<char> D(N);
	vector<int> L(N);
	vector<pii> DL;
	ll res = 0;
	for (int i = 0; i < N;i++) {
		cin >> D[i] >> L[i];
		if (D[i] == 'y') {
			DL.push_back({ L[i],i });
		}
	}
	sort(DL.begin(), DL.end());
	vector<int> f(N, 0);
	for (int i = 0; i < (int)DL.size();i++) {
		int idx = DL[i].second;
		if (f[idx] == 1)continue;
		res++;
		int l = DL[i].first;
		for (int j = idx - 1; j >= 0;j--) {
			if (D[j] == 'y') f[j] = 1;
			else if (L[j] >= l)break;
		}
		for (int j = idx + 1; j < N;j++) {
			if (D[j] == 'y')f[j] = 1;
			else if (L[j] >= l)break;
		}
	}
	cout << res << endl;
	return 0;
}

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

int main(void) {
  int k,x;
  cin >> k >> x;
  int count=0;
  for(int i=k-1; i> 0; i--) {
  cout << x-i << " ";
  }
  cout << x << " ";
  for(int i=1; i<k;i++){
    cout << x+i << " ";
  }
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

#include <vector>
#include <iostream>
#include <algorithm>
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 100005;
const int P = 1000000007;
const int INF = 1000000007;
const double eps = 1e-6;
using namespace std;
inline int getint() {
    int r = 0; bool b = true; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') b = false; c = getchar(); }
    while (c >= '0' && c <= '9') { r = (r<<1)+(r<<3) + c - '0'; c = getchar(); }
    return b ? r : -r;
}
vector<int> v[450];
int n, k = -1;
int main() {
    n = getint();
    for (int i = 1; i * (i - 1) <= n * 2; ++i) {
        if (i * (i - 1) == n * 2) {
            k = i;
            break;
        }
    }
    if (k == -1) puts("No");
    else {
        int tot = 0;
        for (int i = 1; i < k; ++i)
            for (int j = i + 1; j <= k; ++j) {
                ++tot;
                v[i].push_back(tot);
                v[j].push_back(tot);
            }
        printf("Yes\n%d\n", k);
        for (int i = 1; i <= k; ++i) {
            printf("%d", k - 1);
            for (auto &j : v[i])
                printf(" %d", j);
            putchar('\n');
        }
    }
}

Measured memory_bytes: 2304
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia;
		int p=0;
		var h=new int[n];
		for(int i = 1;i<n;i++) {
			p^=a[i];
		}
		h[0]=p;
		for(int i = 1;i<n;i++) {
			p^=a[i-1];
			p^=a[i];
			h[i]=p;
		}
		Console.WriteLine("{0}",String.Join(" ",h));
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

using namespace std;

#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> P(n);
  rep(i, n) cin >> P[i];

  int ans = 0;
  for (int i = 1; i < n - 1; ++i) {
    vector<int> tmp;
    tmp.push_back(P[i - 1]);
    tmp.push_back(P[i]);
    tmp.push_back(P[i + 1]);
    sort(all(tmp));
    if (tmp[1] == P[i]) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int N,A,B,C,D;
	char S[200005];
	int i,j,maxDC;
	scanf("%d %d %d %d %d",&N,&A,&B,&C,&D);
	scanf("%s",&S);
	maxDC=D;
	if(C>D) maxDC=C;
        for(i=A-1;i<C-1;i++)
        {
                if((S[i]=='#')&&(S[i+1]=='#'))
                {
                        printf("No\n");
                        return 0;
                }
        }
	for(i=B-1;i<D-1;i++)
        {
                if((S[i]=='#')&&(S[i+1]=='#'))
                {
                        printf("No\n");
                        return 0;
                }
        }

	if(C<D)
	{
		printf("Yes\n");
		return 0;
	}else{
		// Find a spot where A can pass B
		for(i=B-1;i<D;i++) 
		{
			if((S[i-1]=='.')&&(S[i]=='.')&&(S[i+1]=='.'))
			{
			   printf("Yes\n");
			   return 0;
			}
		}
		printf("No\n");
		return 0;
	}
}


Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);

  char c; cin >> c;
  if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    cout << "vowel";
  } else {
    cout << "consonant";
  }



  return 0;
}


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

typedef long double ld;

const ld EPS = 1e-9;
const ld INF = 1e10;
const ld PI = M_PI;

struct Point{
  ld x, y;
  Point(ld x, ld y):x(x), y(y){}
  Point(){}
};

Point operator+(const Point &a, const Point &b){
  return Point(a.x + b.x, a.y + b.y);
}
Point operator-(const Point &a, const Point &b){
  return Point(a.x - b.x, a.y - b.y);
}
Point operator*(const Point &a, const ld b){
  return Point(a.x * b, a.y * b);
}
Point operator*(const Point &a, const Point &b){
  return Point(a.x*b.x-a.y*b.y, a.x*b.y+a.y*b.x);
}
Point operator/(const Point &a, const ld b){
  return Point(a.x / b, a.y / b);
}

ld cross(const Point &a, const Point &b){
  return a.x*b.y - a.y*b.x;
}

ld dot(const Point &a, const Point &b){
  return a.x*b.x + a.y*b.y;
}

ld norm(const Point &a){
  return dot(a, a);
}

struct Line:vector<Point>{
  Line(Point a = Point(0, 0), Point b = Point(0, 0)){
    this->push_back(a);
    this->push_back(b);
  }
};

int ccw(Point a, Point b, Point c){
  b = b - a;
  c = c - a;
  if(cross(b, c) > EPS) return +1; // 反時計周り
  if(cross(b, c) < -EPS) return -1; // 時計周り
  if(dot(b, c) < 0) return +2; // c -- a -- b がこの順番に一直線上
  if(norm(b) < norm(c)) return -2; // a -- b -- c がこの順番に一直線上
  return 0; // a -- c -- b が一直線上
}

int main(){  
  Point p0, p1;
  cin >> p0.x >> p0.y >> p1.x >> p1.y;  
  int q;
  cin >> q;
  
  Point p2;
  while(q--){
    cin >> p2.x >> p2.y;
    
    int ans = ccw(p0, p1, p2);
    
    if(ans == 1) cout << "COUNTER_CLOCKWISE" << endl;
    if(ans == -1) cout << "CLOCKWISE" << endl;
    if(ans == 2) cout << "ONLINE_BACK" << endl;
    if(ans == -2) cout << "ONLINE_FRONT" << endl;
    if(ans == 0) cout << "ON_SEGMENT" << endl;
  }
  
  return 0;
}

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

int tax8(int n) {
  int t = (n * 8) / 100;
  return t;
}

int tax10(int n) {
  int t = (n * 10) / 100;
  return t;
}

int main(){
  
  int A,B;
  cin >> A >> B;
  
  rep1(i,1010) {
    if (tax8(i) == A && tax10(i) == B) {
      cout << i << endl;
      return 0;
    }
    
  }
  
  cout << -1 << endl;
  

}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc094/tasks/arc095_b
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll n; cin>>n;
    vector<ll> an(n);    
    for(auto&& a: an){
        cin>>a;
    }
    sort(an.begin(),an.end());
    ll ai=*(an.end()-1);
    ll aj;
    ll max=-1;    
    REP(i,an.size()-1){
        ll candidate = an.at(i);
        assert(ai>candidate);
        ll tmp=min(candidate,ai-candidate);
        if (tmp > max){
            max = tmp;
            aj=candidate;
        }
    }
    cout<<ai<<" "<<aj<<endl;
    return 0;
}

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

#define ll long long
#define endl '\n'
#define For(i,l,r) for(int i=l;i<=r;i++)
#define ForR(i,l,r) for(int i=l;i>=r;i--)

int main() {
	//freopen(".inp","r",stdin);
	//freopen(".out","w",stdout);
	ll a,b;
	cin >> a >> b;
	string aa="",bb="";
	For(i,1,b) aa+=(char)(a+48);
	For(i,1,a) bb+=(char)(b+48);
	cout << min(aa,bb);
	return 0;
}


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

typedef long long ll;

const ll LLINF = 4e18;
const int INF = 1e9;
const ll SHIFT = 2.01e9;

const int MAXK = 1010;
int K;

const int MAXN = 2 * MAXK;
int N, M;
int S, T;

struct edge {
	int nxt, rev, cap; ll dist;
	edge() {}
	edge(int nxt_, int rev_, int cap_, ll dist_) : nxt(nxt_), rev(rev_), cap(cap_), dist(dist_) { }
};

vector<edge> adj[MAXN];

void add_edge(int a, int b, int c, ll d) {
	adj[a].push_back(edge(b, int(adj[b].size()), c, d));
	adj[b].push_back(edge(a, int(adj[a].size()) - 1, 0, -d));
}

bool vis[MAXN];
ll dist[MAXN];
int ptr[MAXN];

bool reach() {
	vector<int> q;
	q.push_back(S);
	fill_n(dist, N, -LLINF);
	fill_n(vis, N, false);
	dist[S] = 0;
	for (size_t i = 0; i < q.size(); i++) {
		int cur = q[i]; vis[cur] = false;
		for (size_t j = 0; j < adj[cur].size(); j++) {
			edge& e = adj[cur][j];
			if (!e.cap || dist[e.nxt] >= dist[cur] + e.dist) {
				continue;
			}
			dist[e.nxt] = dist[cur] + e.dist;
			if (!vis[e.nxt]) {
				vis[e.nxt] = true;
				q.push_back(e.nxt);
			}
		}
	}
	return dist[T] != -LLINF;
}

int dfs(int cur, int rem) {
	if (cur == T) {
		return rem;
	}
	int tot = 0;
	vis[cur] = true;
	for (int& i = ptr[cur]; i < int(adj[cur].size()); i++) {
		edge& e = adj[cur][i];
		if (!e.cap || vis[e.nxt] || dist[e.nxt] != dist[cur] + e.dist) {
			continue;
		}
		ll d = dfs(e.nxt, min(rem - tot, e.cap));
		tot += d;
		e.cap -= d;
		adj[e.nxt][e.rev].cap += d;
		if (tot == rem) {
			vis[cur] = false;
			break;
		}
	}
	return tot;
}

ll mcf(int rem = INF) {
	int totflow = 0; ll totcost = 0;
	while (reach()) {
		fill_n(ptr, N, 0);
		int d = dfs(S, rem - totflow);
		totflow += d;
		totcost += d * dist[T];
	}
	return totcost;
}

int main() {
	scanf("%d", &K);
	S = 0, T = 1;
	N = 2 * K + 6;
	int tot = 0;
	for (int i = 0; i < K; i++) {
		ll x, y; int c; scanf("%lld %lld %d", &x, &y, &c);
		tot += c;
		add_edge(S, 6+i, c, 0);
		add_edge(6+i, 2, INF, x + y);
		add_edge(6+i, 3, INF, x - y);
		add_edge(6+i, 4, INF, -x + y);
		add_edge(6+i, 5, INF, -x - y);
	}
	for (int i = 0; i < K; i++) {
		ll x, y; int c; scanf("%lld %lld %d", &x, &y, &c);
		add_edge(6+K+i, T, c, 0);
		add_edge(2, 6+K+i, INF, -x - y);
		add_edge(3, 6+K+i, INF, -x + y);
		add_edge(4, 6+K+i, INF, x - y);
		add_edge(5, 6+K+i, INF, x + y);
	}

	ll ans = mcf(tot);
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


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

	ll a,b,c;
	cin >> a >> b >> c;
	if(max(a,b)>c && min(a,b)<c){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
}

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

int n;

int m[101][101];

int p[101];


void matrix(){
  for(int i = 1; i < n; i++){
    m[i][i] = 0;
  }

  for(int l = 2; l <= n; l++){
    for(int i = 1; i <= n - l + 1; i++){
      int j = i + l - 1;
      m[i][j] = 1000000;
      for(int k = i; k <= j - 1; k++){
        m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
      }
    }
  }
}

int main(){

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> p[i] >> p[i + 1];
  }

  matrix();

  cout << m[1][n] << endl;



  return 0;
}



Measured memory_bytes: 3124
import sys
input=sys.stdin.readline
N,M=map(int,input().split())
k_a=[None for i in range(N)]
cnt=0
for i in range(N):
  k_a[i] = list(map(int,input().split()))[1:]
for inde in k_a[0]:
  c = 0
  for j in range(1,N):
    for k in k_a[j]:
      if inde == k:
        c+=1
        break
    if c >= N-1:
      cnt+=1
if N==1:
  print(len(k_a[0]))
else:
  print(cnt)



Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int a,b,c,d; cin >> a >> b >> c  >> d;
    int e = 1;
    while(a > 0 && c > 0) {
        if (e) c -= b, e = 0;
        else a -= d, e = 1;
    }
    if (a > 0) cout << "Yes\n";
    else cout << "No\n";
}

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

public class Main {
  public static void main(String[] args) {
	  FastReader sc = new FastReader();
	  int a = sc.nextInt();
	  int b = sc.nextInt();
	  int h = sc.nextInt();
	  
	  System.out.println((a + b) * (h / 2));
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

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

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

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

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

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


Measured memory_bytes: 21204
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

int main() {
    int dest = 90;
    double x = 0;
    double y = 0;
    int d, t;

    while(scanf("%d,%d", &d, &t), d) {
        double rad = dest * M_PI / 180.0;
        x += d * cos(rad);
        y += d * sin(rad);
        dest -= t;
    }
    cout << (int) x << endl;
    cout << (int) y << endl;
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================




int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================

	int N;
	cin >> N;

	vvint F(N);
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			int t;
			cin >> t;
			F[i].emplace_back(t);
		}
	}


	vvint P(N);
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < 11; j++)
		{
			ll t;
			cin >> t;
			P[i].emplace_back(t);
		}
	}

	ll ans = -LLINF;
	for (int bit = 1; bit < 1 << 10; bit++)
	{
		vint open(10);
		for (int i = 0; i < 10; i++)
		{
			if ((bit >> i) & 1)
			{
				open[i] = 1;
			}
			else
			{
				open[i] = 0;
			}
		}


		ll local = 0;
		for (int i = 0; i < N; i++)
		{
			int count = 0;
			for (int d = 0; d < 10; d++)
			{
				if (open[d] == F[i][d] && open[d] == 1)
				{
					count++;
				}
			}

			local += P[i][count];

		}


		ans = max(ans, local);
	}



	cout << ans << endl;





}





Measured memory_bytes: 256
//--https://kenkoooo.com/atcoder/#/table/soma62jp
 
 
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
 
using namespace std;
 
int main(int argc, char* argv[])
{
 
	int A,B;
	int a,b;
 
	cin >> A >> B;
 
	a=A;b=B;
 
	if(a==1) a=14;
	if(b==1) b=14;
 
	if(a-b>0){
		cout << "Alice" << endl;
	}else if(b-a>0){
		cout << "Bob" << endl;
	}else{
		cout << "Draw" << endl;
	}
 
	return 0;
 
}

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

int main(){
  int n;
  long int sum=0,a[100000];
  cin >> n;
  
  for(int i=0; i<n+1; i++){
    if(i%3==0 || i%5==0)
      continue;
    else
      sum += i;
  }
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	int a = sca.nextInt();
	int b = sca.nextInt();
	int m = sca.nextInt();
	int[] a_price = new int[a];
	int[] b_price = new int[b];
	int[] xi = new int[m];
	int[] yi = new int[m];
	int[] ci = new int[m];
	int min_a = 1000000;
	int min_b = 1000000;
	int ans = 1000000;

	for(int i = 0; i < a; i++) {
		a_price[i] = sca.nextInt();
		if(a_price[i] < min_a) {
			min_a = a_price[i];
		}
	}
	for(int i = 0; i < b; i++) {
		b_price[i] = sca.nextInt();
		if(b_price[i] < min_b) {
			min_b = b_price[i];
		}
	}
	ans = min_a + min_b;  // 最小値の候補
	for(int i = 0; i < m; i++) {
		xi[i] = sca.nextInt();
		yi[i] = sca.nextInt();
		ci[i] = sca.nextInt();
		if((a_price[xi[i]-1] + b_price[yi[i]-1] - ci[i]) < ans) {
			ans = a_price[xi[i]-1] + b_price[yi[i]-1] - ci[i];
		}
	}
	System.out.println(ans);

	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 139252
import java.util.concurrent.LinkedBlockingDeque

fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main() {
    val (h, w) = intList()
    val matrix = 0.until(h).map {
        readLine() ?: return
    }
    val minimum = Array(h + 1) { Array(w + 1) { 0 } }
    val queue = LinkedBlockingDeque<Pair<Int, Int>>()
    queue.offer(Pair(0, 0))
    while (queue.isNotEmpty()) {
        val (y, x) = queue.poll()
        val s = minimum[y][x]
        if (x - 1 >= 0 && matrix[y][x - 1] == '.') {
            if (minimum[y][x - 1] == 0 || minimum[y][x - 1] > s + 1) {
                minimum[y][x - 1] = s + 1
                queue.offer(Pair(y, x - 1))
            }
        }
        if (x + 1 < w && matrix[y][x + 1] == '.') {
            if (minimum[y][x + 1] == 0 || minimum[y][x + 1] > s + 1) {
                minimum[y][x + 1] = s + 1
                queue.offer(Pair(y, x + 1))
            }
        }
        if (y - 1 >= 0 && matrix[y - 1][x] == '.') {
            if (minimum[y - 1][x] == 0 || minimum[y - 1][x] > s + 1) {
                minimum[y - 1][x] = s + 1
                queue.offer(Pair(y - 1, x))
            }
        }
        if (y + 1 < h && matrix[y + 1][x] == '.') {
            if (minimum[y + 1][x] == 0 || minimum[y + 1][x] > s + 1) {
                minimum[y + 1][x] = s + 1
                queue.offer(Pair(y + 1, x))
            }
        }
    }
    val minimumStep = minimum[h - 1][w - 1]
    if (minimumStep == 0) {
        println("-1")
        return
    }
    val white = matrix.sumBy {
        it.count { it == '.' }
    } - 1
    println((white - minimumStep).toString())
}

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

const int MAXH = 501;
const int MAXW = 501;
int H, W;
char G[MAXH][MAXW];
int h[MAXH][MAXW];

int main() {
  while(cin >> H >> W && (H|W)) {
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        cin >> G[i][j];
      }
    }
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        if(G[i][j] == '.') {
          if(j) h[i][j] = h[i][j-1] + 1;
          else  h[i][j] = 1;
        } else {
          h[i][j] = 0;
        }
      }
    }
    int res = 0;
    for(int j = 0; j < W; ++j) {
      for(int i = 0; i < H; ++i) {
        int s = 0;
        int mini = 1<<28;
        for(int p = i; p < H; ++p) {
          ++s;
          mini = min(mini, h[p][j]);
          res = max(res, s*mini);
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 2384
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
using namespace std;

const int maxn = 300010,inf = 1<<29;
int W,H,N,ans,tree[maxn*4],tag[maxn*4];

inline int gi()
{
	char ch; int ret = 0,f = 1;
	do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');
	if (ch == '-') f = -1,ch = getchar();
	do ret = ret*10+ch-'0',ch = getchar(); while (ch >= '0'&&ch <= '9');
	return ret*f;
}

struct node
{
	int x,y;
	inline node(int _x = 0,int _y = 0):x(_x),y(_y) {}
	inline void read() { x = gi(); y = gi(); }
	friend inline bool operator <(const node &a,const node &b) { return a.x < b.x; }
}P[maxn];

inline void build(int now,int l,int r)
{
	tree[now] = -inf; tag[now] = 0; if (l == r) return;
	int mid = (l+r) >> 1;
	build(now<<1,l,mid); build(now<<1|1,mid+1,r);
}

inline void pushdown(int now,int l,int r)
{
	if (l != r)
	{
		tree[now<<1] += tag[now]; tag[now<<1] += tag[now];
		tree[now<<1|1] += tag[now]; tag[now<<1|1] += tag[now];
	}
	tag[now] = 0;
}

inline void modify(int now,int l,int r,int ql,int qr,int key)
{
	if (tag[now]) pushdown(now,l,r);
	if (l == ql&&r == qr) { tree[now] += key; tag[now] = key; return; }
	int mid = (l+r) >> 1;
	if (qr <= mid) modify(now<<1,l,mid,ql,qr,key);
	else if (ql > mid) modify(now<<1|1,mid+1,r,ql,qr,key);
	else modify(now<<1,l,mid,ql,mid,key),modify(now<<1|1,mid+1,r,mid+1,qr,key);
	tree[now] = max(tree[now<<1],tree[now<<1|1]);
}

inline void change(int now,int l,int r,int pos,int key)
{
	if (tag[now]) pushdown(now,l,r);
	if (l == r) { tree[now] = key; return; }
	int mid = (l+r) >> 1;
	if (pos <= mid) change(now<<1,l,mid,pos,key);
	else change(now<<1|1,mid+1,r,pos,key);
	tree[now] = max(tree[now<<1],tree[now<<1|1]);
}

inline void work()
{
	sort(P+1,P+N+1); build(1,1,N+1);
	stack <node> S1,S2; int mid = H>>1;
	change(1,1,N+1,1,H); S1.push(node(mid,0)); S2.push(node(H-mid,0));
	for (int i = 1;i <= N;++i)
	{
		ans = max(ans,(P[i].x+tree[1])<<1); int h,last;
		if (P[i].y <= mid)
		{
			for (h = mid,last = i;!S1.empty()&&mid-P[i].y < (S1.top()).x;h = (S1.top()).x,last = (S1.top()).y,S1.pop())
				modify(1,1,N+1,(S1.top()).y+1,last,mid-P[i].y-h);
			if (S1.empty()) S1.push(node(mid-P[i].y,0));
			else modify(1,1,N+1,(S1.top()).y+1,last,mid-P[i].y-h);
			S1.push(node(mid-P[i].y,i));
		}
		else
		{
			for (h = H-mid,last = i;!S2.empty()&&P[i].y-mid < (S2.top()).x;h = (S2.top()).x,last = (S2.top()).y,S2.pop())
				modify(1,1,N+1,(S2.top()).y+1,last,P[i].y-mid-h);
			if (S2.empty()) S2.push(node(P[i].y-mid,0));
			else modify(1,1,N+1,(S2.top()).y+1,last,P[i].y-mid-h);
			S2.push(node(P[i].y-mid,i));
		}
		change(1,1,N+1,i+1,H-P[i].x);
	}
	ans = max(ans,(W+tree[1])<<1);
}

int main()
{
	//freopen("D.in","r",stdin);
	//freopen("D.out","w",stdout);
	W = gi(); H = gi(); N = gi();
	for (int i = 1;i <= N;++i) P[i].read();
	ans = max((H+1)<<1,(W+1)<<1);
	work();
	for (int i = 1;i <= N;++i) swap(P[i].x,P[i].y); swap(H,W);
	work();
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12672
import java.util.Scanner


object Main{
  def read() = {
    val sc = new Scanner(System.in)
    val s = sc.next()
    s
  }

  def isATGCStr(s:String): Boolean = s.forall(c => "ATGC".contains(c))

  def solve(s:String): Int = {
    val subStrs = for(
    i<- 0 to s.length;
    j <- i to s.length )yield s.substring(i,j)
    subStrs.filter(isATGCStr).map(_.length).max
  }



  def main(args: Array[String]): Unit = {
    val s = read()
    println(solve(s))
  }
}

Measured memory_bytes: 27188
#include <bits/stdc++.h>
 
#define INF INT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
 
typedef long long ll;
typedef std::pair<int,int> pii;
 
using namespace std;
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    vector<vector<ll>> abc(n,vector<ll>(3,0)),dp(n,vector<ll>(3,0));
    REP(i,n)cin >> abc[i][0] >> abc[i][1] >> abc[i][2];

    dp[0][0] = abc[0][0];
    dp[0][1] = abc[0][1];
    dp[0][2] = abc[0][2];

    for(int i = 1;i < n;i++){
        for(int k = 0;k < 3;k++){
            for(int other = 0;other < 3;other++){
                if(k == other)continue;
                dp[i][k] = max(dp[i-1][other] + abc[i][k],dp[i][k]);
            }
        }
    }

    ll ans = 0;
    REP(i,3){
        ans = max(dp[n-1][i],ans);
    }
    cout << ans << endl;

    return 0;
}

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

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

int main() {
  int n;
  std::cin >> n;
  std::vector<long> data(n);
  std::vector<long> sum(n);
  rep(i, n) std::cin >> data[i];

  long t = 0;
  rep(i, n) {
    t += data[i];
    sum[i] = t;
  }

  std::sort(sum.begin(), sum.end());
  // rep(i, n) { std::cout << sum[i] << " "; }
  long res = 0, cnt = 1, tmp = sum[0];
  rep(i, n) {
    if (sum[i] == 0) res++;
  }
  for (int i = 1; i < n; i++) {
    if (sum[i] == tmp) {
      cnt++;
    } else {
      tmp = sum[i];
      res += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  res += cnt * (cnt - 1) / 2;
  std::cout << res << std::endl;

  return 0;
}

Measured memory_bytes: 3328
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	int n,m;
	cin>>n>>m;
	rb(i,1,m){
		int ai;
		cin>>ai;
		n-=ai;
		
	}
	n=max(n,-1);
	cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 3652
m,d = map(int,input().split())

ans = 0
for mi in range(1,m+1):
    for di in range(1,d+1):
        if di<10: continue
        di1 = di%10
        di10 = di//10
        if di1 >=2 and di10>=2 and di1*di10==mi:
            ans += 1
        # print(mi,di10,di1, di, ans)
print(ans)

Measured memory_bytes: 39664
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    flg = False
    if len(set(A)) == 1 and 0 in set(A):
        flg = True
    else:
        if n % 3 == 0:
            D = Counter(A)
            if len(D) == 3:
                t = 0
                V = set()
                for k, v in D.items():
                    t ^= k
                    V.add(v)
                if len(V) == 1 and t == 0:
                    flg = True
            elif len(D) == 2 and D.get(0, -1) != -1:
                v = D[0]
                if n - v == n * 2 // 3:
                    flg = True
    print("Yes" if flg else "No")


if __name__ == '__main__':
    resolve()


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

const int N = 200005;

int n;
char s[N];

int cnt[2019];

int solve() {
  scanf("%s", s);
  n = strlen(s);

  ++cnt[0];

  long long ans = 0;

  int sum = 0;
  int ten = 1;
  for (int i = n-1; i >= 0; --i) {
    sum = (sum + ten * (s[i] - '0')) % 2019;
    ten = ten * 10 % 2019;

    ans += cnt[sum];
    ++cnt[sum];
  }

  printf("%lld\n", ans);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    // printf("Case #%d: ", tc+1);
    solve();
  }
  return 0;
}


Measured memory_bytes: 4020
using System.Collections.Generic;
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        var dict = new Dictionary<int, int>();
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var n= int.Parse(line.Trim());
            if (dict.ContainsKey(n)) dict[n] += 1;
            else dict[n] = 1;
        }
        foreach (var x in dict.OrderBy(x => x.Key).Where(y => y.Value == dict.Max(x => x.Value)))
            Console.WriteLine(x.Key);
   }
}

Measured memory_bytes: 10088
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    string wa;
    cin>>n>>wa;
    lli e=0,w=0;
    rep(i,n){
        if(wa[i]=='W'){
            w++;
        }
        else{
            e++;
        }
    }
    lli pw=0;
    lli ans=INF;
    rep(i,n){
        if(wa[i]=='E'){
            e--;
        }
        ans=min(pw+e,ans);
        if(wa[i]=='W'){
            pw++;
        }
    }
    out(ans);
}

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

vector<int> e[100010];
int x[100010];
int d[100010]; int y[100010];

void search(int curr, int prev, int ter) {
    x[curr] = x[prev]+1;
    if (curr == ter) return;
    for (auto &to: e[curr]) {
        if (to != prev) {
            search(to, curr, ter);
        }
    }
}

void search2(int curr, int prev, int u) {
    if (prev != 0) {
        if (x[curr] && x[prev] > x[curr]) {
            d[curr] = d[prev] - 2;
        } else d[curr] = d[prev];
        y[curr] = y[prev] + 1;
    }
    if (d[curr] <= 0) return;
    for (auto &to: e[curr]) {
        if (to != prev) {
            search2(to, curr, u);
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, u, v; cin >> n >> u >> v;
    for (int i = 0; i < n-1; i++) {
        int a, b; cin >> a >> b;
        e[a].emplace_back(b);
        e[b].emplace_back(a);
    }
    x[0] = 0; y[0] = -1;
    search(v, 0, u);
    d[u] = x[u] - 1;
    search2(u, 0, u);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, y[i] + d[i] - 1);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 10624
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const S = args[0][0]
	if (/^YAKI/.test(S)) console.log('Yes')
	else console.log('No')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7500
N, M, X = map(int, input().split())

L = []
for _ in range(N):
    L.append(list(map(int, input().split())))

a = 10000000000
for v in range(2 ** N):
    tv, tk = 0, [0 for _ in range(M)]
    for i in range(N):
        if v & (1 << i) != 0:
            tv += L[i][0]
            for p in range(M):
                tk[p] += L[i][p + 1]

    f = True
    for p in range(M):
        if tk[p] < X:
            f = False
            break

    if f:
        a = min(a, tv)

if a == 10000000000:
    print(-1)
else:
    print(a)



Measured memory_bytes: 9220
import math

N, A, B = map(int, input().split())

ans = 0

ONE_BLOCK_NUM = A + B

if ONE_BLOCK_NUM != 0:
    ans += math.floor(N / ONE_BLOCK_NUM) * A # ひとかたまり丸々ある部分
    res = N % ONE_BLOCK_NUM                  # ひとかたまり丸々は無い、最後の部分
    if res >= A:
        ans += A
    else:
        ans += res

print(ans)

Measured memory_bytes: 3060
#include <utility>
#include <stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define YES(b) std::cout<< (b ? "Yes" : "No")
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n = 0, m;
	cin >> n >> m;
	if (n > 8 || m > 8) {
		cout << ":(";
	}
	else {
		cout << "Yay!";
	}
}


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

long long a[200010];
int n;
long long getans(int x){
  long long ans = 0;
  for(int i = 0;i < n;i++){
    ans += llabs(a[i]-x);
  }
  return ans;
}

int main(){
  cin >> n;

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

  sort(a, a+n);

  if(n % 2 == 0){
    cout << min(getans(a[n/2]), getans(a[n/2-1])) << endl;
  }else{
    cout << getans(a[n/2]) << endl;
  }

  return 0;
}


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

int main() {
  long long N, cnt = 0;
  cin >> N;

  if (N < 10)
    cnt += N;
  else if (N >= 10) {
    cnt += 9;
    if (N >= 100 && N < 1000)
      cnt = cnt + N - 99;
    else if (N >= 1000) {
      cnt += 900;
      if (N >= 10000 && N < 100000)
        cnt = cnt + N - 9999;
      else if (N >= 100000)
        cnt += 90000;
    }
  }
    cout << cnt << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int h, w;
int r1[550][550],r2[550][550];
char s[550][550];
int main() {
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++) scanf("%s", s + i);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') r1[i][j] = r2[i][j] = 1;
		}
	}
	for (int j = 0; j < w; j++) r1[0][j] = r2[h - 1][j] = 1;
	for (int j = 0; j < w; j++) {
		if (j & 1) for (int i = 0; i < h - 1; i++) r1[i][j] = 1;
		else for (int i = h - 1; i > 0; i--) r2[i][j] = 1;
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) putchar(r1[i][j] ? '#' : '.');
		puts("");
	}
	puts("");
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) putchar(r2[i][j] ? '#' : '.');
		puts("");
	}
	return 0;
}

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

using namespace std;

void fast()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
}
const int mxA = 1e7;
int freq [mxA+1] ;
int pref [mxA+1];

int main()
{
    fast();
    int a ,b;
    cin >> a>>b;
    int z = a*b ;
    if((z*1)%2!=0) return cout <<"Yes",0;
    else if((z*2)%2!=0) return cout <<"Yes",0;
    else if((z*3)%2!=0) return  cout <<"Yes",0;
    cout << "No";
}


Measured memory_bytes: 256
M=10**9+7;n,k,*a=`dd`.split.map &:to_i;m=(n+1).times.map{[0]*256};m[0][r=0]=q=1;n.times{|i|(i+1).downto(1){|l|256.times{|j|m[l][j]+=m[l-1][a[i]^j]}}};1.upto(n){|l|r+=m[l][k]*q=q*l%M};p r%M

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int lg(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int n;
int p[200000];
int ans=0;
signed main(){
    cin>>n;
    rep(i,n)cin>>p[i];
    for(int i=0;i<n;i++){
        if(p[i]==i+1){
            if(i==n-1)swap(p[i],p[i-1]);
            else swap(p[i],p[i+1]);
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

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

	vector<int>vec1(N);
	vector<int>vec2(N);

	int M = 0;
	for (int i = 0; i < N; i++) {
		cin >> vec1[i];
		cin >> vec2[i];
		M = vec2[i] - vec1[i] + M + 1;
	}

	cout << M << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

void binarySearch(vector< vector< pair<int,int> > > A, int N)
{
    int ans = 0;
    for (ll bit=0; bit<(1<<N); ++bit)
    {
        vector<int> res(N,-1);
        vector<int> vec;
        bool can = true;
        int sum = 0;

        for (int i=0; i<N; ++i)
        {
            if(bit & (1<<i))
            {
                vec.push_back(1);
                sum ++;
                if(res[i] == 0)
                {
                    can = false;
                    break;
                }
                res[i] = 1;
                for (int j=0; j<A[i].size(); ++j)
                {
                    if(res[A[i][j].first -1] != A[i][j].second)
                    {
                        if (res[A[i][j].first -1] == -1)
                        {
                            res[A[i][j].first -1] = A[i][j].second;
                        }
                        else
                        {
                            can = false;
                            break;
                        }
                    }
                }
                if(!can) break;
            }
            else
            {
                vec.push_back(0);
            }
            
            if(!can) break;
        }

        for (int i=0; i<N; ++i)
        {
            if(res[i] == -1) continue;
            if(res[i] != vec[i]) can = false;
        }
        
        if(can)
        {
            if(ans <= sum) ans = sum;
        }
    }
    cout << ans << endl;
}

int main()
{
    int N;
    cin >> N;
    vector< vector< pair<int,int> > > A(N);
    int tmp,x,y;
    for ( int i=0; i<N; ++i)
    {
        cin >> tmp;
        for ( int j=0; j<tmp; j++)
        {
            cin >> x >> y;
            A[i].push_back(make_pair(x,y));
        }
    }

    binarySearch(A,N);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <bitset>
#define ll long long
using namespace std;


int main(){//cout<<1<<endl;
  int baketu[100]={};
  
  for(int i=0;i<3;i++){
    int a,b;
    cin>>a>>b;
    baketu[a]++;
    baketu[b]++;
    
  }
  
  for(int i=0;i<100;i++){
  //  cout<<baketu[i]<<endl;
  }
  
  for(int i=1;i<=4;i++){
    //cout<<baketu[i]<<endl;
    if(baketu[i]==3) {
      cout<<"NO"<<endl;return 0;
    }
  }
  
  cout<<"YES"<<endl;return 0;
  
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math


def solve(a: int, b: int, x: int):
    h = 2 * (b - (x / (a*a)))
    if b < h:
        h = b
        a = 2 * (x / (a*b))
    print(math.degrees(math.atan(h / a)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    solve(a, b, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int a,b,c; cin >>a >>b >>c;
	int sum=a;
	for(int i=0;i<b;i++){
		if(sum%b==c){
			cout << "YES"<<endl;
			return 0;
		}
		sum+=a;
	}
	cout << "NO"<< endl;
}

Measured memory_bytes: 256
// In The Name Of The Queen
#include<bits/stdc++.h>
using namespace std;
const int N = 2009, MXN = N * N, Mod = 1e9 + 7;
int n, k, dp[N][N], F[MXN], I[MXN];
inline int Power(int a, int b)
{
    int ret = 1;
    for (; b; b >>= 1, a = 1LL * a * a % Mod)
        if (b & 1) ret = 1LL * ret * a % Mod;
    return (ret);
}
inline void Add(int &a, int b)
{
    a += b;
    if (a >= Mod)
        a -= Mod;
}
inline int nCr(int n, int r)
{
    if (r < 0 || n < r)
        return 0;
    return (F[n] * 1LL * I[r] % Mod * I[n - r] % Mod);
}
int main()
{
    scanf("%d%d", &n, &k);
    if (k == 1)
        return !printf("1\n");
    for (int i = F[0] = 1; i < MXN; i ++)
        F[i] = 1LL * F[i - 1] * i % Mod;
    I[MXN - 1] = Power(F[MXN - 1], Mod - 2);
    for (int i = MXN - 2; ~ i; i --)
        I[i] = 1LL * I[i + 1] * (i + 1) % Mod;
    dp[0][0] = 1;
    for (int i = 0; i <= n; i ++)
        for (int j = 0; j <= i; j ++)
        {
            if (i < n)
                Add(dp[i + 1][j], dp[i][j]);
            if (j < i)
                Add(dp[i][j + 1], dp[i][j] * 1LL * nCr(n * k - j * (k - 1) - i - 1, k - 2) % Mod);
        }
    return !printf("%lld\n", dp[n][n] * 1LL * F[n] % Mod);
}

Measured memory_bytes: 47488
$cnt = 0
$g = []
 
def i_sort(ca, n)
  c = ca.dup
  n.upto(c.size - 1) do |i|
    v = c[i]
    j = i - n
    while j >= 0 && c[j] > v
      c[j+n] = c[j]
      j -= n
      $cnt += 1
    end
    c[j+n] = v
  end
  c
end
 
def shell_sort(ca)
  m = 1
  n = ca.size / 9
  while m <= n
    m = m * 3 + 1
  end
  while m > 0
    ca = i_sort(ca, m)
    $g << m
    m /= 3
  end
  ca
end
 
gets
arr = shell_sort($<.read.split("\n").map &:to_i)
puts format("%d\n%s\n", $g.size, $g.join(' '))
puts $cnt
puts arr


Measured memory_bytes: 172904