akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define log(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  ll n;cin>>n;
  for(ll i = -200;i < 200;++i){
    for(ll j = -200;j < 200;++j){
      ll tmp = power(i,5ll)-power(j,5ll);
      if(tmp == n){
        cout<<i<<" "<<j<<endl;
        return 0;
      }
    }
  }
  return 0; 
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(void)
{
  int a,b,c,d;
  int i;
  
  do {
  	scanf("%d %d %d %d",&a,&b,&c,&d);
  } while((a<1 || a>100)||(b<1 || b>100)||(c<1 || c>100)||(d<1 || d>100));
  
  for(i=0; a>0 && c>0; i++){
    if(i % 2 == 0)
      c -= b;
    else
      a -= d;
  }
      
  if(a<=0)
    puts("No");
  else
    puts("Yes");
  
  return 0;
}


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

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void run(void){
  int n,k,q;
  scanf("%d%d%d",&n,&k,&q);
  int *a=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int *tmp=(int *)calloc(n,sizeof(int));
  int *pop=(int *)calloc(n,sizeof(int));
  int ans=1000000000;
  for(i=0;i<n;i++){
    int plen=0;
    int j=0;
    while(j<n){
      int tlen=0;
      while(j<n && a[j]>0) tmp[tlen++]=a[j++];
      if(tlen>=k){
	qsort(tmp,tlen,sizeof(int),cmp);
	for(int p=0;p<tlen-k+1;p++) pop[plen++]=tmp[p];
      }
      j++;
    }
    if(plen<q) break;
    qsort(pop,plen,sizeof(int),cmp);
    int t=pop[q-1]-pop[0];
    if(ans>t) ans=t;
    for(j=0;a[j]==0;j++);
    int min=j;
    for(j++;j<n;j++) if(a[j]>0 && a[j]<a[min]) min=j;
    a[min]=0;
  }
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


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

using namespace std;

int main() {
    int n;
    int s;
    cin>>n;
    vector<int> A(n);
    for(int i = 0; i < n; i++) {
        cin>>A.at(i);
    }
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            s+=A.at(i)*A.at(j);        
          }   
    }

    cout << s << endl;

    return 0;
}

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

int main() {
  long long zero = 0;
  int N;
  cin >> N;
  vector<long long> sum(N,0);
  int now;
  cin >> now;
  sum[0] = now;
  for (int i=1; i<N; i++) {
    cin >> now;
    sum[i] = sum[i-1] + now;
  }
  
  long long change = 0;
  long long ansp = 0;
  int i = 0;
  while (i<N) {
    ansp += max(1-(sum[i]+change),zero);
    change += max(1-(sum[i]+change),zero);
    i++;
    if (i==N) {
      break;
    }
    ansp += max((sum[i]+change)+1,zero);
    change -= max((sum[i]+change)+1,zero);
    i++;
  }
  change = 0;
  long long ansm = 0;
  i = 0;
  while (i<N) {
    ansm += max((sum[i]+change)+1,zero);
    change -= max((sum[i]+change)+1,zero);
    i++;
    if (i==N) {
      break;
    }
    ansm += max(1-(sum[i]+change),zero);
    change += max(1-(sum[i]+change),zero);
    i++;
  }
  cout << min(ansp,ansm) << endl;
}

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

using namespace std;

int main(void)
{
	int n, k;
	cin >> n >> k;
	int p[n];
	long long s[n-k+1];
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	s[0] = 0;
	for (int i = 0; i < k; i++)
		s[0] += p[i];
	for (int i = 1; i < n-k+1; i++) {
		s[i] = s[i-1] - p[i-1] + p[i+k-1];
	}
	long long max = s[0];
	for (int i = 0; i < n-k+1; i++) {
		if (s[i] > max)
			max = s[i];
	}
	cout << fixed << setprecision(10) << (max + k)/2.0 << endl;

	return 0;
}

Measured memory_bytes: 6056
#include <stdio.h>

#define N 100

int v[N][N];

int n,m,k,clear;

void Graph(void){
  int i,j;
  
  for(i=0;i<n;i++){
    scanf("%d%d",&clear,&m);
    if(m != 0){
      for(j = 0; j < m; j++){
	scanf("%d",&k);
	v[i][k-1] = 1;
	
      }
      
    }
  }
}


int main(){
  int i,j;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      v[i][j]=0;
    }
  }
  
 
  Graph();
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(j == n-1){
	printf("%d",v[i][j]);
      }
      else printf("%d ",v[i][j]);
    }
    printf("\n");
  }
  return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N;
    cin >> N;

    vector<int> A(N);
    rep(i,0,N) cin >> A[i];

    bitset<4000001> dp;
    dp[0]=1;
    rep(i,0,N) dp|=dp<<A[i];

    rep(i,(accumulate(begin(A),end(A),i64(0))+1)/2,inf64) if(dp[i]){
        cout << i << endl;
        return;
    }
}

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


Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define cerr                                                                   \
  if (false)                                                                   \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

void solve(long long A, string op, long long B) {
  cout << (op == "-" ? A - B : A + B) << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long A;
  string op;
  long long B;
  cin >> A;
  cin >> op;
  cin >> B;
  solve(A, op, B);
  return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import qualified Data.IntMap.Strict as IM

count :: [IM.Key] -> IM.IntMap Int
count [] = IM.empty
count (x:xs) = IM.insertWith (+) x 1 $ count xs

func :: Int -> Int -> Int -> Int
func k v t
    | k < v = t + v - k
    | k > v = t + v
    | otherwise = t

main :: IO ()
main = do
    _ <- getLine
    as <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    print $ IM.foldrWithKey func 0 (count as)


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

int main() {
	int n;
	cin >> n;
	int min = 1000000000;
	int max = 0;
	// int a[n];
	for(int i = 0; i < n; i++) {
		// cin >> a[i];
		int a;
		cin >> a;
		if(min > a) min = a;
		if(max < a) max = a;
	}
	cout << max - min << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;

int main(void){
    int x,a,b,c,temp_ab,ans=0;
    cin>>x;
    for(a=1;a<=x;a++){
        for(b=1;b<=x;b++){
            for(c=1;c<=x;c++){
                temp_ab=gcd(a,b);
                ans+=gcd(temp_ab,c);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>

/* 比較関数 */
int comp( const void *c1, const void *c2 )
{
  int tmp1 = *(int *)c1;
  int tmp2 = *(int *)c2;

  if( tmp1 < tmp2 )  return -1;
  if( tmp1 == tmp2 ) return  0;
  if( tmp1 > tmp2 )  return  1;
}

int main(){
	int i,j;
	int m[10];
	
	for(i=0;i<10;i++){
		scanf("%d",&m[i]);
	}
	
	qsort(m,10,sizeof(int),comp);
	
	for(i=0;i<3;i++){
		printf("%d\n",m[9-i]);
	}

	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>

using namespace std;

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

  int max_length = 1;
  int cur_length = 1;
  for (int i = 1; i < n; i++) {
    if (q[i] < q[i + 1]) {
      cur_length++;
    }
    else {
      max_length = max(max_length, cur_length);
      cur_length = 1;
    }
  }
  max_length = max(max_length, cur_length);
  cout << n - max_length;
}


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

int main(void){
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	int res = (int) 1e9;
	for(int i = 0; i <= 2 * max(x, y); i+=2){
		int p = c*i;
		if(x-i/2 >= 0) p += a*(x-i/2);
		if(y-i/2 >= 0) p += b*(y-i/2);
		res = min(res, p);
	}

	cout << res << endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;
typedef unsigned int i64;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define bye(x) return void (cout <<(x) << endl);
#define all(e) (e).begin(), (e).end()
#define pb push_back

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

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


template <typename T>
void printV(vector<T> A) {
  if (A.empty()) cerr << "EMTPY\n";
  else { 
    cerr << "[";
    for (int i = 0; i < A.size() -1 ; ++i) {
      cerr << A[i] << ", ";
    }
    if (A.size()) cerr << A.back() << "]\n";
  }
}


template <typename T>
void printVV(vector<vector<T>> A) {
  cerr << "[";
  for (auto v : A) {
    printV<T>(v);
  }
  cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

int main(int argc, char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k; cin >> n >> m >> k;
  vector<ll> a(n);
  vector<ll> b(m);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> b[i];

  vector<ll> sum_a = { 0 };
  vector<ll> sum_b = { 0 };
  for (int i = 0; i < n; i++) {
    sum_a.push_back(sum_a.back() + a[i]);
  }

  for (int i = 0; i < m; i++) {
    sum_b.push_back(sum_b.back() + b[i]);
  }

  int ans = 0;
  int j = sum_b.size() - 1;
  for (int i = 0; i < sum_a.size(); i++) {
    if (sum_a[i] > k) break;
    while (j >= 0 && sum_b[j] > k - sum_a[i]) j--;
    ans = max(ans, i + j);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 11032
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    int a[10][10]={};
    REP(i,1,n){
        string s=to_string(i);
        int l=s.length();
        a[s[0]-'0'][s[l-1]-'0']++;
    }
    int ans=0;
    rep(i,10)rep(j,10)ans+=a[i][j]*a[j][i];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc045/tasks/abc045_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b, c;
    cin >> a >> b >> c;
    int pa = 0, pb = 0, pc = 0, state = 0;
    while (true) {
        char t;
        if (state == 0) {
            t = a[pa++];
            if (pa > a.length()) {
                cout << "A\n";
                return 0;
            }
        } else if (state == 1) {
            t = b[pb++];
            if (pb > b.length()) {
                cout << "B\n";
                return 0;
            }
        } else {
            t = c[pc++];
            if (pc > c.length()) {
                cout << "C\n";
                return 0;
            }
        }
        if (t == 'a') {
            state = 0;
        } else if (t == 'b') {
            state = 1;
        } else {
            state = 2;
        }
    }

    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef int Weight;
struct Edge
{
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight)
	{
	}
};
bool operator < (const Edge& e, const Edge& f)
{
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef pair<Weight, int> Result;
Result visit(int p, int v, const Graph& g)
{
	Result r(0, v);
	FOR(e, g[v]) if (e->dst != p)
	{
		Result t = visit(v, e->dst, g);
		t.first += e->weight;
		if (r.first < t.first) r = t;
	}
	return r;
}
Weight diameter(const Graph& g)
{
	Result r = visit(-1, 0, g);
	Result t = visit(-1, r.second, g);
	return t.first; // (r.second, t.second) is farthest pair
}

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

	Graph E(N);

	for (int i = 0; i < N - 1; i++)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		E[a].push_back(Edge(a, b, 1));
		E[b].push_back(Edge(b, a, 1));
	}

	int dist = diameter(E) + 1;

	cout << ((dist - 2) % 3 ? "First" : "Second") << endl;

	return 0;
}

Measured memory_bytes: 29952
using System;

public class p0000{
	public static int Main (string[] args)
	{
		for (int i = 1; i <= 9; ++i)
			for (int j = 1; j <= 9; ++j)
				Console.WriteLine ("{0}x{1}={2}", i, j, i*j);
		return 0;
	}
}

Measured memory_bytes: 5556
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int M = input.nextInt();
		String[] big = new String[N];
		String[] small = new String[M];
		boolean YES=false;
		for (int i = 0; i < N; i++) {
			big[i] = input.next();
		}
		for (int i = 0; i < M; i++) {
			small[i] = input.next();
		}
		for (int level = 0; level <= N-M; level++) { //Vertical shift
			for (int index = 0; index <= N-M; index++) { //Horizontal shift
				boolean bad = false;
				for (int r = level; r < level+M; r++) { //Checking subcomponent
					for (int c = index; c < index+M; c++) {
						char BigMatrix = big[r].charAt(c);
						char SmallMatrix = small[r-level].charAt(c-index);
						if (BigMatrix!=SmallMatrix) {
							bad=true;
							break;
						}
					}
					if (bad) break;
				}
				if (!bad) {
					YES=true;
					break;
				}
			}
			if (YES) break;
		}
		System.out.println(YES?"Yes":"No");
	}
}

Measured memory_bytes: 21588
s=input()
sb=int(s[:2])
sa=int(s[2:])
if sb<=12 and sb!=0:
  if sa<=12 and sa!=0:
    print('AMBIGUOUS')
  else:
    print('MMYY')
elif sa<=12 and sa!=0:
  if sb<=12 and sb!=0:
    print('AMBIGOUS')
  else:
    print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3060
N, K = gets.split.map(&:to_i)
dots = Array.new(N) { gets.split.map(&:to_i) }

area =Float::INFINITY
dots.combination([4, K].min) do |set|
  x, y = set.transpose
  min_x = x.min
  max_x = x.max
  min_y = y.min
  max_y = y.max
  count = dots.select { |xi, yi| min_x <= xi and xi <= max_x and min_y <= yi and yi <= max_y }.size
  if count >= K
    if temp = (max_x - min_x) * (max_y - min_y) and temp < area
      area = temp
    end
  end
end

puts area


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

int main(){
    long N,K; cin >> N >> K;
    vector<long> A(N);
    for(int i=0;i<N;++i) cin >> A[i];
    long X = 0;
    for(int i=40;i>=0;--i){
        int cnt = 0;
        for(int j=0;j<N;++j) if(A[j] & (1L << i)) ++cnt ;
        if(2*cnt < N && (X | (1L << i)) <= K) X |= (1L << i);   
    }
    long ans = 0;
    for(int i=0;i<N;++i) ans += X ^ A[i];
    cout << ans << endl;
}

Measured memory_bytes: 1024
import Control.Applicative

import Control.Monad
    (replicateM)
    
type Match = (String, String)

type Judge = (Int, Int)

type Problem = [Match]

type Result = Judge

judge :: Match -> Judge

judge (taro, hanako)
    | taro > hanako
        = (3, 0)
        
    | taro < hanako
        = (0, 3)
        
    | otherwise
        = (1, 1)
        
solve :: Problem -> Result

solve problem
    = foldl1 (\(t, h) (nt, nh) -> (t + nt, h + nh)) $ map judge problem

output :: Result -> String

output (taro, hanako)
    = show taro ++ " " ++ show hanako
    
input :: IO Problem

input
    = do
        n <- read <$> getLine
        replicateM n inputMatch
        
inputMatch :: IO Match

inputMatch
    = do
        [taro, hanako] <- words <$> getLine
        return (taro, hanako)

main :: IO ()

main
    = putStrLn.output =<< solve <$> input

Measured memory_bytes: 4208
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if i*500 + j*100 + k*50 == X:
                ans += 1
print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        sc.close();
        int count = 0;
        for (int i = 0; i < s.length()/2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - i - 1)) {
                count++;
            }
        }
        System.out.println(count);
    }
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N,M;

    Scd2(N,M);

    int l,r,L=1,R=N;
    Rep(i,M){
        Scd2(l,r);
        L = max(l,L);
        R = min(r,R);
    }

    printf ("%d\n", max(R-L+1,0) );

    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from bisect import bisect_left

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

A.sort()
ans = 0
for i in range(N):
    a = A[i]
    for j in range(i+1, N):
        # 小さい方2本a,bを決めておく(a < b)
        b = A[j]
        # 条件を満たすcの範囲は b < c < a+b の間
        k = bisect_left(A, a+b)
        ans += k - (j+1)
print(ans)


Measured memory_bytes: 3188
n = int(input())
s = input()
#n = 45
#s = "tgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir"
ans = 0
alphabet = [chr(i) for i in range(97, 97+26)]
def count(i):
    num = 0
    a=list(set(list(s[:i])))
    b=list(set(list(s[i:])))
    for i in alphabet:
        if (i in a) & (i in b):
            num += 1
    return num
for j in range(1,len(s)-1):
    if ans < count(j): ans = count(j)
print(ans)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define ll long long
#define rg register
using namespace std;
const int MAXN=1e5+10;
char A[MAXN],B[MAXN];
ll La,Lb,GCD,Lcm,Ja,Jb,Len;
inline int Gcd(rg int A,rg int B){   return B?Gcd(B,A%B):A;   }
int main()
{   scanf("%lld%lld%s%s",&La,&Lb,A+1,B+1);
	Lcm=La*Lb/Gcd(La,Lb),Ja=Lcm/La,Jb=Lcm/Lb;
	Len=Ja*Jb/Gcd(Ja,Jb);
	for(rg ll i=1;i<=Lcm;i+=Len)
		if(A[(i-1)/Ja+1]!=B[(i-1)/Jb+1]) puts("-1"),exit(0);
	printf("%lld\n",Lcm);
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() { 
  ll a,b,x;
  cin >> a >> b >> x;

  ll ans = b/x - a/x;
  ans+=(a%x == 0);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

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

func main() {
	sc.Split(bufio.ScanWords)

	x := nextInt()

	max := 1
	for i := 2; i <= x; i++ {
		for j := 2; true; j++ {
			y := int(math.Pow(float64(i), float64(j)))
			if y > x {
				break
			}
			if y > max {
				max = y
			}
		}
	}
	fmt.Println(max)
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    Vec v(3);
    cin>>v[0]>>v[1]>>v[2];
    sort(ALL(v));
    Yes(v[0]==v[1]&&v[1]==v[2]);
    return  0;
}


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

int main() {
	int n,l,i;
	std::cin >> n >> l;
	std::vector<std::string> s(n);
	for (i = 0; i < n; i++) {
		std::cin >> s[i];
	}
	std::sort(s.begin(), s.end());
	for (i = 0; i < n; i++) {
		std::cout << s[i];
	}
	return 0;
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) n * m / gcd(n, m)
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数

int main() {
  int N;
  ci(N);
  ve<int> A(N);
  rep(i, N){
    ci(A.at(i));
  }
  map<int, int> B;
  rep(i, N){
    B[A.at(i)] = i + 1;
  }
  each(i, B){
    co(i.sc);
  }
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll mod=1e9+7;
int t[1<<17][10];
ll dp[41][1<<17];
void add(ll &x,ll y){
	x+=y;
	x%=mod;
}
bool B(int x,int y){
	return (x>>y)&1;
}
int main(){
	int N,X,Y,Z;
	cin>>N>>X>>Y>>Z;
	int K=X+Y+Z;
	rep(i,1<<K){
		rep1(j,10){
			int b=0;
			if(j<=X) b|=(1<<(j-1));
			rep(k,X) if(B(i,k)){
				if(k==X-1){
					if(j<=Y) b|=(1<<(k+j));
				}else{
					if(k+1+j<=X) b|=(1<<(k+j));
				}
			}
			rep(k,Y) if(B(i,k+X)){
				if(k==Y-1){
					if(j<=Z) b|=(1<<(k+j+X));
				}else{
					if(k+1+j<=Y) b|=(1<<(k+j+X));
				}
			}
			rep(k,Z) if(B(i,k+X+Y)){
				if(k==Z-1){
					continue;
				}
				if(k+1+j<=Z) b|=(1<<(k+j+X+Y));
			}
//			if(B(b,X+Y+Z-1)) b=-1;
			t[i][j-1]=b;
//			printf("t[%d][%d]=%d\n",i,j,b);
		}
	}
	dp[0][0]=1;
	rep(i,N){
		rep(j,1<<(K-1)) if(dp[i][j]){
			rep(k,10) add(dp[i+1][t[j][k]],dp[i][j]);
		}
	}
	ll ans=1;
	rep(i,N) ans=ans*10%mod;
	rep(j,1<<(K-1)) add(ans,-dp[N][j]);
	if(ans<0) ans+=mod;
	cout<<ans<<endl;
}


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

int main(){
  int n;
  cin >> n;
  
  vector<int> p(n);
  
  for (int i = 0; i < n; i++){
    cin >> p.at(i);
  }
  
  int count = 0;
  
  for (int i = 0; i < n; i++){
    if (p.at(i) != i+1){
      count++;
    }
  }
  
  if (count == 0 || count == 2) {
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

int n,a[105],vis[10005];
int main(){
  //freopen("aa.in","r",stdin);
  int n;scanf("%d",&n);
  for(int i=1;i<=n;i++){
    scanf("%d",a+i);
    vis[a[i]]=1;
  }
  int p=1;
  int ans=0;
  for(int i=2;i<=n;i++){
    if(a[i]==a[i-1]){
      for(;vis[p];p++);
      vis[p]=1;
      a[i]=p;
      ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200010
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;  
 
int main(){
  int n,m;
  cin>>n>>m;
  P A[N];
  for(int i=0,x,y;i<m;i++)cin>>x>>y,A[i]=P(x,y-1);
  sort(A,A+m);
 
  int u[N],d[N];
  for(int i=0;i<n;i++) u[i]=d[i]=i;
 
  for(int i=0;i<m;i++){
    int y=A[i].s;
    u[y]=max(u[y],u[y+1]);
    d[y+1]=min(d[y+1],d[y]);
  }
 
  for(int i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<(u[i]-i)+(i-d[i])+1;
  }
  cout<<endl;
  return 0;
}

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

const int N = 3005;

int n;
char s;
set<char> st;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n; 
	while (n--){
		cin >> s;
		st.insert(s);
	}
	
	if (st.size() == 3) cout << "Three";
	else cout << "Four";
	
	return 0;
}

Measured memory_bytes: 256
# AC (faster) ###############################################################
mod = 10**9 + 7
dp = [0, 0, 0, 1]
for s in input()[::-1]:
    tmp = dp[:]

    dp[3] = tmp[3] * 3 if s == '?' else tmp[3]
    dp[3] %= mod

    for j in range(2, -1, -1):
        dp[j] = tmp[j] * 3 + tmp[j + 1] if s == '?' else \
                tmp[j] + tmp[j + 1] if s == 'ABC'[j] else \
                tmp[j]
        dp[j] %= mod

print(dp[0] % (10**9 + 7))


Measured memory_bytes: 3188
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	int a[27]={0},f=-1,i;
	cin >> s;
	for(i=0;i<s.size();i++){
		a[s[i]-'a']=1;
	}
	for(i=0;i<26;i++){
		if(a[i]==0){
			cout<< char(i+'a') << endl;
			f=0;
			break;
		}
	}
	if(f==-1)
		cout << "None\n";
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int r[101];
    for(int i=0;i<=100;i++)
    {
        r[i]=0;
    }
    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        r[k]=1;
    }
    int max;
    for(int i=0;i<=100;i++)
    {
        max+=r[i];
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 256
// Ala be zekrellah tatmaenolgholoob ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
#define MP make_pair
const int maxn = 2e5+9;
const ll mod = 1e9+7;

int a[maxn], pos[maxn];

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		pos[a[i]] = i;
	}
	int cur = n, ans = 0;
	while (true) {
		int f = 1;
		while (true) {
			if (cur == 1 || pos[cur - 1] > pos[cur])
				break;
			cur--;
			f++;
		}
		ans = max(ans, f);
		if (cur == 1) break;
		cur--;
	}
	cout << n - ans << "\n";
}



Measured memory_bytes: 1792
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	fractional_knapsack
# CreatedDate:  2020-06-08 21:46:16 +0900
# LastModified: 2020-06-08 21:53:14 +0900
#


import os
import sys
#import numpy as np
#import pandas as pd


def main():
    N,W = map(int,input().split())
    p = []
    for _ in range(N):
        v,w = map(int,input().split())
        p.append([v/w,v,w])
#    print(p)
    p.sort(reverse=True)
    index=0
    profit=0
    while W>0 and index<N:
        if W>=p[index][2]:
            profit+=p[index][1]
            W-=p[index][2]
        else:
            profit+=p[index][1]*W/p[index][2]
            W-=W
        index+=1
    print(profit)


if __name__ == "__main__":
    main()



Measured memory_bytes: 23784
#include<stdio.h>
int main(void){
  int r,D,x,i,num;
  scanf("%d %d %d",&r,&D,&x);
  for(i=1;i<=10;i++){
    num=r*x-D;
    x=num;
    printf("%d\n",num);
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;

#define REP(i,a) for(int i=0;i<(int)(a);i++)
#define pb push_back
#define sz size()
#define INF (1<<25)
#define all(a) (a).begin(),(a).end()
#define V 3030
typedef pair<int,int> P;

struct edge{
  int from,to,cost,cap,rev;
  bool operator<(const edge x)const{return cost>x.cost;}
};

vector<edge> G[V];
int d[V];
bool use[V];
int pv[V],pe[V];
int v,e;

void add_edge(int s,int g,int c,int p){
  G[s].pb((edge){s,g,c,p,G[g].sz});
  G[g].pb((edge){g,s,-c,0,G[s].sz-1});
}

int min_cost_flow(int s,int t,int f){
  int res = 0;
  while(f>0){
    fill(d,d+v,INF);
    d[s] = 0;
    bool up = true;
    while(up){
      up = false;
      REP(i,v){
	if(d[i]==INF)continue;
	REP(j,G[i].sz){
	  edge &e = G[i][j];
	  if(e.cap > 0 && d[e.to] > d[i] + e.cost){
	    d[e.to] = d[i] + e.cost;
	    pv[e.to] = i; pe[e.to] = j;
	    up = true;
	  }
	}
      }
    }

    if(d[t]==INF)return -1;

    int x = f;
    for(int u=t;u!=s;u=pv[u])x = min(x,G[pv[u]][pe[u]].cap);
    f -= x;
    res += x*d[t];
    for(int u=t;u!=s;u=pv[u]){
      edge &e = G[pv[u]][pe[u]];
      e.cap -= x; G[u][e.rev].cap += x;
    }
  }
  return res;
}

int n;
int a[1010],b[1010];
vector<int> len;

int main(){
  scanf("%d",&n);
  len.clear();

  REP(i,n){
    scanf("%d%d",&a[i],&b[i]);
    len.pb(a[i]); len.pb(b[i]);
  }
  
  sort(all(len));
  len.erase(unique(all(len)),len.end());
  
  v = n + len.size() + 3;
  REP(i,v)G[i].clear();

  REP(i,n){
    add_edge(v-2,i,0,1); add_edge(i,v-3,0,1);

    int tmp = lower_bound(all(len),a[i])-len.begin() + n;
    add_edge(i,tmp,-b[i],1);

    tmp = lower_bound(all(len),b[i])-len.begin() + n;
    add_edge(i,tmp,-a[i],1);
  }

  REP(i,len.sz)add_edge(n+i,v-1,0,1);
  add_edge(v-3,v-1,0,INF);

  printf("%d\n",-1*min_cost_flow(v-2,v-1,n));
}

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

#define MAX 500000
#define inf 2000000000

int A[MAX];
int L[MAX/2 + 2], R[MAX/2 + 2];
int cnt = 0;

void merge(int A[], int n, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for ( int i = 0; i < n1; i++ )
		L[i] = A[left + i];
	for ( int i = 0; i < n2; i++ )
		R[i] = A[mid + i];
	L[n1] = inf;
	R[n2] = inf;
	int i = 0, j = 0;
	for ( int k = left; k < right; k++ ) {
		if ( L[i] <= R[j] ) {
			A[k] = L[i++];
			cnt++;
		} else {
			A[k] = R[j++];
			cnt++;
		}
	}
}

void mergesort(int A[], int n, int left, int right) {
	if ( left + 1 < right ) {
		int mid = (left + right)/2;
		mergesort(A, n, left, mid);
		mergesort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}


int main() {
	int n;
	cin >> n;
	for ( int i = 0; i < n; i++ )
	 	cin >> A[i];

	mergesort(A, n, 0, n);
	
	for ( int i = 0; i < n; i++ ) {
		if ( i ) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 6916
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;

const int INF = 100000000;



map<int, char> mp;

int t[10010];
int main() {
    //cout << fixed << setprecision(15);

    int N = readInt(), M = readInt(), T = readInt();

    REP(i, N){
        int a = readInt();
        for(int j=a-M+1; j<=min(T,a+M); ++j) t[j]--;
    }

    int cnt=0;
    for(int i=1; i<=T; ++i){

        if(t[i]==0) cnt++;
    }

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


Measured memory_bytes: 3260
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int A[N];
	rep(i, N) cin >> A[i];
	int ans = 0;
	rep(i, N) {
		ans += A[i] / 2;
		A[i] %= 2;
		if (i + 1 == N) break;
		if (A[i + 1] > 0 && A[i] > 0) {
			ans++;
			A[i]--;
			A[i + 1]--;
		}
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
N, M = gets.split.map(&:to_i)
lr_list = M.times.map { gets.split.map(&:to_i) }
max_l = -1
min_r = N + 1
lr_list.each do |(l, r)|
  max_l = l if l > max_l
  min_r = r if r < min_r
end
diff = min_r - max_l
ans = if diff >= 0
  diff + 1
  else
    0
  end
puts ans


Measured memory_bytes: 9596
#include <iostream>

using namespace std;

int
main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l = a + b;
  int r = c + d;
  if (l > r) {
    cout << "Left" << endl;
  }
  else if (l < r) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7

h, w, k = map(int, input().split())
k -= 1

dp = [0] * w
dp[0] = 1

ndp = [0] * w

for cur in range(h):
    for bits in range(1 << (w - 1)):
        if '11' in bin(bits): continue
        # print(*map(lambda x: '-' if x == '1' else '.', bin(bits)[2:].zfill(w - 1)), sep='')
        for i in range(w):
            # print(bits >> i)
            if i < (w - 1) and (bits >> i) & 1:
                ndp[i + 1] += dp[i]
                ndp[i + 1] %= MOD
            elif i >= 1 and (bits >> (i - 1)) & 1:
                ndp[i - 1] += dp[i]
                ndp[i - 1] %= MOD
            else:
                ndp[i] += dp[i]
                ndp[i] %= MOD
    dp = ndp.copy()
    ndp = [0] * w
print(dp[k])


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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a.at(a.size()-1)==b.at(0)&&b.at(b.size()-1)==c.at(0)){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb2l(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
long long int ncr(int n, int r){
  // space O(1) time O(min(r,n-r));
       if(n-r<r){
           r=n-r;
       }
        long long int res=1;
        for(int i=0;i<r;i++){
           res*=(n-i);
            res/=(i+1);
        }
        return res;
    }

void solve(){
   ll n;
   cin>>n;
   ll k,f=1;
 fr(i,0,n){
     cin>>k;
     if(!(k&1)){
         if(k%3==0 || k%5==0)
         continue;
         else f=0;
     }
 }
 if(f){
     cout<<"APPROVED";
 }
 else cout<<"DENIED";
  }
int main(){
    ll t=1;
   // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
    int i, j, k, y, n;
    cin>>n;
    ll sum = 0;
    for(i = 1; i<=n; i++)
    {
        for(j = 1; j<=n; j++)
        {
            for(k = 1; k<=n; k++)
            {
                y = __gcd(i, j);
                y = __gcd(y, k);
                sum+=y;
            }
        }
    }

    cout<<sum<<endl;
}


Measured memory_bytes: 3512
//#include <bits/stdc++.h>                          //include all library
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <string.h>
#include <functional> // greater<int> はfunctionalヘッダ
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)          //REP(i, 10){...} //i=0～i=9までのループ
#define REPR(i, n) for(int i = n;i >= 0;i--)        //REPR(i, 10){...} //i=10～i=0までのループ
#define FOR(i, m, n) for(int i = m;i < n;i++)       //FOR(i, 3, 10){...} //i=3～i=9までのループ
#define FORR(i, m, n) for(int i = m;i >= n;i--)     //FORR(i, 10, 3){...} //i=10～i=3までのループ
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define PI 3.141592653589
#define npos -1


int main(){
	int h, w;
	string str;
	cin >> h >> w;

	vector< vector<int> > a(h+2, vector<int>(w+2, 0));    //壁が0,通路が1 (あらかじめ外側に壁をつけておく)

	for(int i=0; i<h; i++){
		cin >> str;
		for(int j=0; j<w; j++){
			if(str[j]=='.'){a[i+1][j+1]=1;}
		}
	}

	int maximum = 0;
	vector< vector< vector<int> > > s(h+2, vector< vector<int> >(w+2, vector<int>(2, 0)));    //一番最下層のベクトルはその点の縦方向と横方向の空きマス数を表している
	for(int i=1; i<h+1; i++){
		for(int j=1; j<w+1; j++){
			int num=0;
			if(a[i][j]==1){
				s[i][j][0]++;

				if(a[i-1][j]==1){                  //一つ上おんマスが壁ではなかったら
					s[i][j][0] = s[i-1][j][0];
				} else{
					for(int k=1; k<INF; k++){
						if(a[i+k][j]==0){break;}
						s[i][j][0]++;
					}
				}

				if(a[i][j-1]==1){
					s[i][j][1] = s[i][j-1][1];
				} else{
					for(int k=1; k<INF; k++){
						if(a[i][j+k]==0){break;}
						s[i][j][1]++;
					}
				}

				maximum = max(s[i][j][0]+s[i][j][1], maximum);
				//cout << s[i][j][0]+s[i][j][1] << " "; //
			}//else {cout << 0 << " ";}  //

		}//cout << endl; //
	}
	cout << maximum << endl;
}

Measured memory_bytes: 235392
#include <algorithm>
#include <chrono>
#include <cmath>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int INF = 2000000009;
const ll INFL = 1e18 + 5LL;
const ld EPS = 1e-11;

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

    int k;
    cin >> k;
    for (int i = 0; i < k; ++i) {
        cout << "ACL";
    }

    return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  int b=0;
  
  while(true){
    bool o=false;
    for(int i =0;i<N;i++){
      if(a.at(i)%2!=0){
        o=true;
      }
    }
      if(o){
        break;
      }
      for(int i=0;i<N;i++){
        a.at(i)=a.at(i)/2;
      }
        b++;
       
      }
    cout<<b<< endl;
  }
    
      
      
  


Measured memory_bytes: 256