akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
using PII = pair<ll, ll>;
#define FOR(i,a,n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i,n) FOR(i,0,n)

struct Edge {
	int to, sttime, cost, index;
	Edge(const int t, const int s, const int c, const int i) {
		to = t, sttime = s, cost = c, index = i;
		return;
	}
	bool operator<(const Edge&e)const {
		return sttime < e.sttime;
	}
};

int main() {
	int N, M, S, G;
	cin >> N >> M >> S >> G;
	S--, G--;
	vector<vector<Edge>>edge(N);
	for (int i = 0; i < M; i++) {
		int l, r, s, t;
		cin >> l >> r >> s >> t;
		l--, r--;
		edge[l].push_back(Edge(r, s, t, i));
	}
//cout << "JHIJHI" << endl;
	for (int i = 0; i < N; i++)sort(edge[i].begin(), edge[i].end());
	vector<vector<pair<int, int>>>dis_edge(M + 1);
//	cout << "GUUG" << endl;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < (int)(edge[i].size()) - 1; j++) {
			dis_edge[edge[i][j].index].push_back({ edge[i][j + 1].index,edge[i][j + 1].sttime - edge[i][j].sttime });
		}
		vector<pair<int, int>>box;
		for (auto j : edge[i]) {
			if (j.to == G) {
				dis_edge[j.index].push_back({ M,0 });
				continue;
			}
			if (edge[j.to].empty())continue;
			int L = -1, R = edge[j.to].size();
			while (R - L > 1) {
				int mid = (R + L) / 2;
				if (edge[j.to][mid].sttime >= j.sttime + j.cost)R = mid;
				else L = mid;
			}
			if (R == edge[j.to].size())continue;
			dis_edge[j.index].push_back({ edge[j.to][R].index,edge[j.to][R].sttime - j.cost - j.sttime });
		}
	}
	//cout << "Ho" << endl;
	vector<int>dis(M+1, MOD);
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>PQ;
	for (auto i : edge[S]) {
		dis[i.index] = i.sttime;
		PQ.push({ i.sttime,i.index });
	}
	while (!PQ.empty()) {
		int cn = PQ.top().second;
		int c = PQ.top().first;
		PQ.pop();
		for (auto j : dis_edge[cn]) {
			if (dis[j.first] > c + j.second) {
				dis[j.first] = c + j.second;
				PQ.push({ dis[j.first],j.first });
			}
		}
	}
	cout << dis[M] << endl;
}


Measured memory_bytes: 21236
// Last Change: 10/27/2019 14:53:59.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

struct Cards {
  ll s, t;
  Cards(ll a, ll b) : s(a), t(b) {
  }
  ll getSize() {
    return t - s + 1;
  }
};

ll count(vector<Cards> &c, ll pos, ll val) {
  ll res = 0;
  ll total = 0;
  size_t i = 0, cSize = c.size();
  for (i = 0; i < cSize; ++i) {
    if (total + c[i].getSize() > pos) {
      break;
    }
    total += c[i].getSize();
    res += max(0LL, val - c[i].s + 1) - max(0LL, val - c[i].t);
  }
  if (total != pos) {
    ll diff = pos - total - 1;
    res += max(0LL, val - c[i].s + 1) - max(0LL, val - (c[i].s + diff));
  }
  return res;
}

void shuffle(vector<Cards> &cards, ll x, ll y) {
  // split
  vector<Cards> a, b, c;
  ll total = 0;
  size_t i = 0, cardSize = cards.size();
  for (i = 0; i < cardSize; ++i) {
    if (total + cards[i].getSize() > x) {
      break;
    }
    total += cards[i].getSize();
    a.push_back(cards[i]);
  }
  if (total != x) {
    a.push_back(Cards(cards[i].s, cards[i].s + x - total - 1));
    cards[i] = Cards(cards[i].s + x - total, cards[i].t);
    total = x;
  }

  for (; i < cardSize; ++i) {
    if (total + cards[i].getSize() > y) {
      break;
    }
    total += cards[i].getSize();
    b.push_back(cards[i]);
  }
  if (total != y) {
    b.push_back(Cards(cards[i].s, cards[i].s + y - total - 1));
    cards[i] = Cards(cards[i].s + y - total, cards[i].t);
    total = y;
  }

  for (; i < cardSize; ++i) {
    c.push_back(cards[i]);
  }

  // shuffle
  cards.clear();
  for (auto &&e : c) {
    cards.push_back(e);
  }
  for (auto &&e : b) {
    cards.push_back(e);
  }
  for (auto &&e : a) {
    cards.push_back(e);
  }
}

void solve(ll n) {
  ll m, p, q, r;
  cin >> m >> p >> q >> r;
  vector<Cards> cards(1, Cards(1, n));
  {
    // shuffle
    ll x, y;
    for (ll i = 0; i < m; ++i) {
      cin >> x >> y;
      shuffle(cards, x, y);
    }
  }
  // count and output
  ll res1 = count(cards, q, r);
  ll res2 = count(cards, p - 1, r);
  cout << res1 - res2 << endl;
}

int main() {
  ll n;
  while (cin >> n and n) {
    solve(n);
  }
}


Measured memory_bytes: 3348
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in).useDelimiter("[^0-9]+");
        BigInteger r = BigInteger.ZERO;
        while (sc.hasNextBigInteger())
            r = r.add(sc.nextBigInteger());
        System.out.println(r.toString());
    }
}

Measured memory_bytes: 12000
import copy
N = int(input())
A = list()
for i in range(N):
    A.append(int(input()))
s = sorted(A)[::-1]
m1 = s[0]
m2 = s[1]

for j in A:
    if j == m1:
        print(m2)
    else:
        print(m1)

Measured memory_bytes: 14648
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

struct UnionFind { // {{{
    vector<int> u;
    explicit UnionFind(int n): u(n+5, -1) {}
    int  size(int x)        { return -u[root(x)]; }
    int  root(int x)        { return (u[x] < 0)? x : (u[x] = root(u[x])); }
    bool same(int x, int y) { return (root(x) == root(y)); }
    bool unite(int x, int y){ return (x=root(x)) == (y=root(y))? false : (u[x]+=u[y], u[y]=x, true); }
}; // }}}

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

    int N, M;
    read(N, M);

    vector<pii> es(M);

    rep(i, M) {
        int a, b;
        read(a, b);
        --a, --b;
        es[i] = pii(a, b);
    }

    int cnt = 0;

    rep(i, M) {
        UnionFind uf(N);

        rep(j, M) {
            if (j == i) continue;
            trace(es[j]);
            uf.unite(es[j].first, es[j].second);
        }

        bool ok = true;
        reps(u, 0, N-1) reps(v, u+1, N-1) {
            // trace(i, u, v, uf.same(u, v));
            ok &= uf.same(u, v);
        }
        if (!ok) ++cnt;
    }

    print(cnt);

    return 0;
}


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

int main()
{
    long long N;
    long long Y;
    cin >> N >> Y;
    Y /= 1000;
    
    long long a, b, c;
    b = Y - N;
    b *= 7;
    b %= 9;
    if (b < 0) b += 9;

    Y -= 5 * b;
    N -= b;

    if (Y-N >= 0 && 10*N-Y >= 0 && ((Y-N)%9) == 0) {
        a = (Y-N)/9;
        c = N-a;
    } else {
        a = b = c = -1;
    }

    cout << a << " " << b << " " << c << endl;

    return 0;
}

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

int n;
vector<int>h(100000);
vector<int>cost(100000);

int Ans(int n){
    if (cost[n] != -1) return cost[n];
    cost[n] = min((Ans(n-1) + abs(h[n-1] - h[n])),
                  (Ans(n-2) + abs(h[n-2] - h[n])));
    return cost[n];
}

int main(){
    cin>>n;
    rep(i,n){
        cin>>h[i];
        cost[i] = -1;
    }
    cost[0] = 0;
    cost[1] = abs(h[1] - h[0]);
    cout << Ans(n-1) << endl;
}

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

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

    vector<int> a(n);
    rep(i, n){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    
    string s = "YES";
    rep(i, n-1){
        if(a.at(i) == a.at(i+1)) s = "NO";
    }
    
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;

public class Main{

static PrintWriter out;
static InputReader ir;

static void solve(){
 long a=ir.nextLong();
 long b=ir.nextLong();
 out.println(gcd(a,b));
}

public static long gcd(long a,long b){
 if(b==0) return a;
 else return gcd(b,a%b);
}

public static void main(String[] args) throws Exception{
 ir=new InputReader(System.in);
 out=new PrintWriter(System.out);
 solve();
 out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;

 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
 
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }

 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
 
 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
 
 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }

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

 public BigInteger nextBigInteger(){return new BigInteger(next());}

 public int[] nextIntArray(int n){
  int[] a=new int[n];
  for(int i=0;i<n;i++) a[i]=nextInt();
  return a;
 }

 public long[] nextLongArray(int n){
  long[] a=new long[n];
  for(int i=0;i<n;i++) a[i]=nextLong();
  return a;
 }

 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}

Measured memory_bytes: 24316
package main

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

func main() {
	A, B, C := ReadString(), ReadString(), ReadString()
	if A[len(A)-1] == B[0] && B[len(B)-1] == C[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 1840
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_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 inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int x,a,b;
    cin >> x >> a >> b;
    if(abs(a-x)>abs(b-x))
    {
        cout << "B" << endl;
    }
    else
    {
        cout << "A" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int



using namespace std;

int main(){
   int N;cin>>N;
   int ue = N/100;
   int sita = N%100;
   if( (ue>12 or ue==0) and (sita>12 or sita ==0)){ cout<<"NA"<<endl;return 0;}
   if(ue<=12 and ue >=1 and sita <=12 and sita >=1) cout<<"AMBIGUOUS"<<endl;
   else if(ue > 12 or ue == 0) cout<<"YYMM"<<endl;
   else cout<<"MMYY"<<endl;

   

    return 0;
}

Measured memory_bytes: 256
import math

n=int(input())
a=[int(i) for i in input().split()]
a.sort()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr


def setwise_coprime(a):
    b=a.copy()
    one=b.pop()
    for i in range(n-1):
        two=b.pop()
        one=math.gcd(one,two)
    if one==1:
        return True
    return False

def pairwise_coprime(an):
    frui=[0]*(10**6+1)
    for a in an:
        if a==1:
            continue
        soinnsuu_list=factorization(a)
        for i in soinnsuu_list:
            if frui[i]==1:
                return False
            for k in range(1,int(10**6/i)+1):
                frui[i*k]=1
    return True


if pairwise_coprime(a):
    print("pairwise coprime")
elif setwise_coprime(a):
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 196952
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


class Bisect:
    def __init__(self, func):
        self.__func = func

    def bisect_left(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if self.__func(mid) < x:
                lo = mid+1
            else:
                hi = mid
        return lo

    def bisect_right(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if x < self.__func(mid):
                hi = mid
            else:
                lo = mid+1
        return lo


@mt
def slv(N, T, AB):
    AB.sort()
    memo = [-1] * (T + max(a for a, b in AB))

    memo[0] = 0
    for a, b in AB:
        nm = memo[:]
        for t in range(T):
            if memo[t] == -1:
                continue
            nm[t+a] = max(nm[t+a], memo[t]+b)
        memo = nm
    # print(memo)
    return max(memo)


def main():
    N, T = read_int_n()
    AB = [read_int_n() for _ in range(N)]
    print(slv(N, T, AB))


if __name__ == '__main__':
    main()


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


using namespace std;

int main(void)
{
	long long int A, B, C, D, CD;
	long long int AC, BC, AD, BD, ACD, BCD;
	long long int c, d, x;

	long long int ans1, ans2;

	cin >> A >> B >> C >> D;

	c = C;
	d = D;
	CD = c * d;
	x = d % c;
	while(x != 0) {
		d = c;
		c = x;
		x = d % c;
	}
	CD = CD / c;


	BC = B / C;
	BD = B / D;
	BCD = B / CD;

	ans1 = BC + BD - BCD;

	A -= 1; //A未満の計算したいから-1
	AC = A / C;
	AD = A / D;
	ACD = A / CD;

	ans2 = AC + AD - ACD;

	A += 1; //戻す




	cout.precision(20);
	cout << (B - A + 1) - ans1 + ans2;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,result;
	
	scanf("%d %d",&a,&b);
	
	result=a*b;
	
	if(result%2!=0){
		printf("Odd\n");
	}else{
		printf("Even\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
n = int(input())
lis = [0] * 5
name = ['M','A','R','C','H']

for i in range(n):
    s = list(input())
    for j in range(5):
        if s[0] == name[j]:
            lis[j] += 1

ans = 0
#print(lis)
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans += lis[i] * lis[j] * lis[k]
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(int i = 0; i < N; i++)
#define repa(i, a, N) for(int i = a; i < N; i++)
#define repr(i, N) for(int i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

const int M = 60;
ll f[M+1][2][2][2];

int main() {
	ll L, R;
	cin >> L >> R;

	int lb[M], rb[M];
	rep(i, M) {
		lb[i] = L % 2;
		rb[i] = R % 2;
		L /= 2;
		R /= 2;
	}
	// for (auto l : lb) { cout << l; } cout << endl;
	// for (auto l : rb) { cout << l; } cout << endl;

	trep(lf, 2, rf, 2, cf, 2) {
		f[0][lf][rf][cf] = 1;
	}
	
	repa(i, 1, M+1) {
		int l = lb[i-1], r = rb[i-1];

		trep(lf, 2, rf, 2, cf, 2) {
			// 0, 0
			if (lf || l == 0) {
				f[i][lf][rf][cf] += f[i - 1][lf][(r == 0) ? rf : 1][cf];
			}

			// 0, 1
			if (lf || l == 0)
				if(rf || r == 1)
					if (cf)
						f[i][lf][rf][cf] += f[i - 1][lf][rf][cf];

			// 1, 1
			if (rf || r == 1) {
				f[i][lf][rf][cf] += f[i - 1][(l == 1) ? lf : 1][rf][1];
			}

			// 1, 0
			// no operation

			f[i][lf][rf][cf] %= mod;
		}
	}

	cout << f[M][0][0][0] << endl;

	return 0;
}

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

int main()
{
    int a,b,c,x;
    int i,j,k;
    int ans=0;
    cin>>a>>b>>c>>x;

    for(int i=0;i<a+1;i++){
        for(int j=0;j<b+1;j++){
            for(int k=0;k<c+1;k++){
                if(500*i+100*j+50*k==x) ans++;
            }
        }
    }

    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int h,n;
int a[10000];

int main()
{
    std::cin>>h>>n;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int tmp;
        std::cin>>tmp;
        sum+=tmp;
    }
    if(sum>=h)std::cout<<"Yes"<<std::endl;
    else std::cout<<"No"<<std::endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate など
#include <stdexcept>
#include <cassert> // assert
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll MOD = 1'000'000'007;
constexpr int MAX_N = 200'000 + 9;
int n,m;
array<vector<int>, MAX_N> vs;
array<int, MAX_N> ans;
queue<int> mins;

int main()
{
    // 入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;
    REP(i, m)
    {
        int a,b;
        cin >> a >> b;
        vs.at(a).push_back(b);
        vs.at(b).push_back(a);
    }

    // bfs
    ans.at(1) = 1;
    mins.push(1);
    while (!mins.empty())
    {
        int v = mins.front(); mins.pop();
        for (int u : vs.at(v))
        {
            if (ans.at(u) != 0)
            {
                continue;
            }
            ans.at(u) = v;
            mins.push(u);
        }
    }

    cout << "Yes" << endl;
    REP(i, n - 1)
    {
        cout << ans.at(i + 2) << endl;
    }

    return 0;
}


Measured memory_bytes: 12832
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  unordered_map< int, int > a, b;
  for (int i=0; i<n/2; ++i) {
    int ai, bi;
    cin >> ai >> bi;
    if (a.count(ai)==0) a[ai]=1;
    else a[ai]++;
    if (b.count(bi)==0) b[bi]=1;
    else b[bi]++;
  }
  int a1i=0, a1v=0, a2i=0, a2v=0;
  int b1i=0, b1v=0, b2i=0, b2v=0;
  for (auto itr : a) {
    if (itr.second > a1v) {
      a2v=a1v; a2i=a1i;
      a1v=itr.second; a1i=itr.first;
    } else if (itr.second > a2v) {
      a2v=itr.second; a2i=itr.first;
    }
  }
  for (auto itr : b) {
    if (itr.second > b1v) {
      b2v=b1v; b2i=b1i;
      b1v=itr.second; b1i=itr.first;
    } else if (itr.second > b2v) {
      b2v=itr.second; b2i=itr.first;
    }
  }
  if (a1i!=b1i) {
    cout << n-a1v-b1v << endl;
    return 0;
  }
  cout << min(n-a2v-b1v, n-a1v-b2v) << endl;
  return 0;
}


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

int main()
{
	int A, B, K;
	cin >> A >> B >> K;
	for (int i = A; i <= B; i++)
	{
		if ((A <= i && i < A + K) || (B - K + 1 <= i && i <= B))
			cout << i << endl;
	}
	return 0;
}

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

using namespace std;

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

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

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

int n;
int m;
string s[50];
int d[50][50];
ii q[50 * 50];

int main () {
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> s[i];
	int l = 0, r = 1;
	q[0] = mp (0, 0);
	d[0][0] = 1;
	while (l < r) {
		int x = q[l].fi;
		int y = q[l].se;
		l++;
		for (int t = 0; t < 4; t++) {
			int nx = x + int (t == 0) - int (t == 1);
			int ny = y + int (t == 2) - int (t == 3);
			if (nx < 0 || ny < 0 || nx >= n || ny >= m || d[nx][ny] != 0 || s[nx][ny] != '.') continue;
			d[nx][ny] = d[x][y] + 1;
			q[r++] = mp (nx, ny);
		}
	}
	if (d[n - 1][m - 1] == 0) cout << -1 << endl; else {
		int ans = n * m - d[n - 1][m - 1];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				ans -= int (s[i][j] == '#');
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<cmath>
#include<deque>
#include<set>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000

const double PI = 3.14159265358979323846;
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }

char m[10][10];
int main() {
	int W, H, x = 0, y = 0;
	scanf("%d%d", &H, &W);
	rep(i, 0, H)scanf("%s", m[i]);
	m[0][0] = '.';
	while (1) {
		if (m[x][y + 1] == '#')m[x][y + 1] = '.', y++;
		else if (m[x + 1][y] == '#')m[x + 1][y] = '.', x++;
		else break;
		if (x == H - 1 && y == W - 1)break;
	}
	rep(i, 0, H)rep(i2, 0, W)if (m[i][i2] == '#') { puts("Impossible"); return 0; }
	puts("Possible");
	return 0;
}


Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
typedef long long ll;
const int Imx=2147483647;
const int mod=1000000007;
const ll Lbg=2e18;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
int n,m;
vector<pair<int,int> > v[311];
int dp[302][302][302];
bool check(int x,int y,int z)
{
	int p=max(max(x,y),z);
	for(int i=0;i<v[p].size();i++)
	{
		int cnt=0;
		if(x>=v[p][i].FF)cnt++;
		if(y>=v[p][i].FF)cnt++;
		if(z>=v[p][i].FF)cnt++;
		if(cnt!=v[p][i].SS)return false;
	}
	return true;
}
int main()
{
	getii(n,m);
	for(int i=1;i<=m;i++)
	{
		int l,r,x;
		getiii(l,r,x);
		v[r].PB(MP(l,x));
	}
	dp[0][0][0]=1;
	ll ans=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int k=0;k<=n;k++)
			{
				int v=dp[i][j][k];
				if(v==0)continue;
				if(!check(i,j,k))
				{
					dp[i][j][k]=0;
					continue;
				}
				int p=max(max(i,j),k);
				if(p==n)
				{
					ans+=v;
				}
				else
				{
					p++;
					dp[p][j][k]=(dp[p][j][k]+v)%mod;
					dp[i][p][k]=(dp[i][p][k]+v)%mod;
					dp[i][j][p]=(dp[i][j][p]+v)%mod;
				}
			}
		}
	}
	cout<<ans%mod<<endl;
	return 0;
}

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

string s;
vector<int> x(2);
vector<vector<int> > vec(2);

int main()
{
    cin >> s;
    cin >> x[0] >> x[1];
    int mode = 0;
    int len = 0;
    vec[1].push_back(0);
    for (auto c : s)
    {
        if (c == 'F')
        {
            len++;
        }
        else
        {
            vec[mode].push_back(len);
            len = 0;
            mode = 1 - mode;
        }
    }
    vec[mode].push_back(len);
    
    for (int dim=0; dim<2; dim++)
    {
        vector<bool> dp_now(32001, false);
        dp_now[16000] = true;
        for (int i=0; i<vec[dim].size(); i++)
        {
            vector<bool> dp_next = vector<bool>(32001, false);
            if (i==0) dp_next[16000+vec[dim][0]] = true;
            else
            {
                for (int j=8000; j<=24000; j++)
                {
                    if (dp_now[j-vec[dim][i]] || dp_now[j+vec[dim][i]]) dp_next[j] = true;
                }
            }
            dp_now = dp_next;
        }
        if (!dp_now[16000+x[dim]])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

int main()
{
	long N, K;
	cin >> N >> K;
	
	long ans = 0;
	for(long k = K; k <= N + 1; k++){
		ans += (2 * N + 1 - k) * k / 2  - k * (k - 1) / 2 + 1;
	}
	
	cout << ans % (10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 + 7) << endl;

	return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  cin>>s;

  auto res = vec<int>(h,w);
  constexpr ll dx[]={1,0,-1,0,1,1,-1,-1};
  constexpr ll dy[]={0,1,0,-1,1,-1,1,-1};
  rep(i,h)rep(j,w){
    if(s[i][j]=='.')continue;
    rep(k,8){
      int ny = i+dy[k];
      int nx = j+dx[k];
      if(ny==-1||ny==h||nx==-1||nx==w)continue;
      res[ny][nx]++;
    }
  }
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#')cout<<s[i][j];
      else cout<<res[i][j];
    }
    cout<<endl;
  }

}

Measured memory_bytes: 256
# 解説AC
from collections import defaultdict

N,M = map(int, input().split())
S = [int(i) for i in input().split()]
T = [int(i) for i in input().split()]

MOD = 10 ** 9 + 7

# dp[i][j]: S[:i]とT[:j]での共通部分列の個数
dp = [[0] * (M + 1) for _ in range(N + 1)]

# 初期条件
for i in range(N + 1):
    dp[i][0] = 1
for j in range(M + 1):
    dp[0][j] = 1

# 貰うDP
for i, s in enumerate(S):
    for j, t in enumerate(T):
        dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j]

        if s == t:
            dp[i + 1][j + 1] += dp[i][j]
        
        # ダブルカウントを除く
        dp[i + 1][j + 1] -= dp[i][j]

        dp[i + 1][j + 1] %= MOD

print(dp[N][M])

Measured memory_bytes: 73820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string t,s;
	cin>>t>>s;
	vector<ll>ch[26];
	for(ll i=0;i<t.size();i++){
		ll now=t[i]-'a';
		ch[now].push_back(i+1);
	}
	ll cnt=1,ans=0;
	for(ll i=0;i<s.size();i++){
		ll now=s[i]-'a';
		auto itr=lower_bound(ch[now].begin(),ch[now].end(),cnt);
		if(itr==ch[now].end()){
			ans+=t.size()-cnt+1;
			cnt=1;
		}
		itr=lower_bound(ch[now].begin(),ch[now].end(),cnt);
		if(itr==ch[now].end()){
			cout << -1;
			return 0;
		}
		ans+=*itr-(cnt-1);
		cnt=*itr+1;
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 4632
import java.util.Scanner;

//Blood Groups
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] c = new int[4];
		while(sc.hasNext()){
			String b = sc.next().split(",")[1];
			if(b.equals("A"))c[0]++;
			else if(b.equals("B"))c[1]++;
			else if(b.equals("AB"))c[2]++;
			else c[3]++;
		}
		for(int i=0;i<4;i++)System.out.println(c[i]);
	}
}

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

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

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

    cout << (N == M ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int m, d;
    cin >> m >> d;

    int ans  = 0;

    srep(i,1,d+1){
        srep(j,1,m+1){
            if((i%10)>=2 && ((i/10)%10)>=2 && (i%10)*((i/10)%10) == j){
                ans++;
            }
        }
    }


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


Measured memory_bytes: 764
#include <iostream>
using namespace std;
const int NIL=-1;
const int MAXt=100000;

class Node{
public:
	int parent;
	int left;
	int right;
};

Node T[MAXt];
int Depth[MAXt];

int getDepth(int u)
{
	int d=0,ub=u;
	while(T[u].parent!=NIL)
	{
		u=T[u].parent;
		d++;
	}
	return Depth[ub]=d;
}

void setDepth(int u,int p)
{
	Depth[u]=p;
	if(T[u].right!=NIL)setDepth(T[u].right,p);
	if(T[u].left!=NIL)setDepth(T[u].left,p+1);
	return;
}

void print(int u)
{
	cout<<"node "<<u<<": parent = "<<T[u].parent<<", depth = "<<Depth[u]<<", ";
	if(T[u].parent==NIL)cout<<"root";
	else if(T[u].left==NIL)cout<<"leaf";
	else cout<<"internal node";
	cout<<", [";
	for(int i=0,c=T[u].left;c!=NIL;i++,c=T[c].right)
	{
		if(i)cout<<", ";
		cout<<c;
	}
	cout<<"]"<<endl;
	return;
}

int main() {
	int n;cin>>n;
	int id,k,c,l,root;
	for(int i=0;i<n;i++)T[i].parent=T[i].left=T[i].right=NIL;
	for(int i=0;i<n;i++)
	{
		cin>>id>>k;
		for(int j=0;j<k;j++)
		{
			cin>>c;
			if(j)
			{
				T[l].right=c;
				T[c].parent=id;
				l=c;
			}
			else
			{
				T[id].left=c;
				T[c].parent=id;
				l=c;
			}
		}
	}
	for(int i=0;i<n;i++)if(T[i].parent==NIL){root=i;break;}
	setDepth(root,0);
	for(int i=0;i<n;i++)print(i);
	return 0;
}

Measured memory_bytes: 7756
n,k=map(x->parse(Int,x),split(readline()))
c=0
n+=1
for b=k+1:n-1
	c+=div(n,b)*(b-k)
	if k==0
		c-=1
	end
	if div(n,b)*b+k<n
		c+=n-div(n,b)*b-k
	end
end
println(c)


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


const ll MOD = (ll)(1e9 + 7);
const int MAX_H = 1005;
const int MAX_W = 1005;
ll dp[MAX_H][MAX_W];

int main2() {
  int H, W; cin >> H >> W;
  vector<string> s(H);
  REP(i, H) cin >> s[i];

  CLR(dp, 0);
  REP(i, H) REP(j, W) {
    if (i == 0 && j == 0) { dp[i][j] = 1; continue; }
    if (s[i][j] == '#') continue;
    ll cur = 0;
    if (i-1 >= 0 && s[i-1][j] == '.') cur += dp[i-1][j];
    if (j-1 >= 0 && s[i][j-1] == '.') cur += dp[i][j-1];
    dp[i][j] = cur % MOD;
  }
  cout << dp[H-1][W-1] << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

#define ll long long

int main(){
	ll n;
	cin >> n;
	vector<ll> A(n+1, 1e9);
	for(ll i=0;i<n;i++){
		ll x;
		cin >> x;
		*upper_bound(A.begin(), A.end(), -x) = -x;	
	}
	for(ll i=0;i<=n;i++) if(A[i]==1e9) { cout<<i<<"\n"; break; }
	
}

Measured memory_bytes: 1024
coin = 0
def check(Pn,a,coin):
    if Pn[a - 1] < Pn[a] < Pn[a + 1]:
        coin = coin + 1
    elif Pn[a + 1] < Pn[a] < Pn[a - 1]:
        coin = coin + 1
    else:
        coin = coin + 0
    return coin
n = int(input())
Pn = list(map(int,input().split()))
for a in range(1,n-1):
    coin = check(Pn,a,coin)
print(coin)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int h,w;
    cin>>h>>w;
    char c[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>c[i][j];
        }
    }
    char v[2*h][w];
    int k=0;
    int cnt=0;
    for(int i=0;i<2*h;i++){
            if(cnt==2){
                k++;
                cnt=0;
            }
        for(int j=0;j<w;j++){
            v[i][j]=c[k][j];

        }
        cnt++;
    }
    for(int i=0;i<2*h;i++){
        for(int j=0;j<w;j++){
            cout<<v[i][j];
        }
        cout<<endl;
    }
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int a[n];

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

    int q;
    cin >> q;
    while (q--)
    {
        int k;
        cin >> k;
        cout << distance(a, lower_bound(a, a + n, k)) << endl;
    }
    return 0;
}


Measured memory_bytes: 3488
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;
using namespace std;
int main(){
  mp::cpp_dec_float_100 a, b;
  cin >> a >> b;
  cout << (int64_t)(a*b);
  return 0;
}

Measured memory_bytes: 3692
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

n, k = map(int, input().split())
P = list(sorted(map(int, input().split())))

print(sum(P[:k]))



Measured memory_bytes: 9544
#include <bits/stdc++.h>
#define int long long
//#define double long double
#define endre getchar();getchar();return 0
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int cnt[30], cnt1[30];
signed main() {
	string s;
	cin >> s;
	rep(i, s.size()) {
		cnt[s[i] - 'a']++;
	}
	if (s.size() < 26) {
		rep(i, 27) {
			if (!cnt[i]) {
				cout << s << (char)(i + 'a') << endl;
				endre;
			}
		}
	}
	else if (s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
	}
	else {
		for (int i = s.size() - 1; i > 0; i--) {
			if (s[i] > s[i - 1]) {
				rep(j, i) {
					cnt1[s[j] - 'a']++;
				}
				for (int j = s[i - 1] - 'a'; j < 26; j++) {
					if (!cnt1[j]) {
						cout << s.substr(0, i - 1) + (char)('a' + j) << endl;
						endre;
					}
				}
			}
		}
	}
	endre;
}

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

using namespace std;


int main(){
    int n,y;
    cin>>n>>y;

    int m10000;
    int m5000;
    int m1000;

    int a=-1;
    int b=-1;
    int c=-1;

    bool flag = false;

    for(int m10000=0;m10000<=n;m10000++){
        for(int m5000=0;m5000<=(n-m10000);m5000++){
            m1000 = n-m10000-m5000;
            //cout<<m10000<<" "<<m5000<<" "<<m1000<<" "<<m10000*10000 + m5000*5000 + m1000*1000<<endl;
            if(y == (m10000*10000 + m5000*5000 + m1000*1000)){
                a=m10000;
                b=m5000;
                c=m1000;
                flag = true;
                break;
            }
        }
        if(flag==true)break;
    }

    cout<<a<<" "<<b<<" "<<c<<endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int d,l,r,count=0;
  cin>>l>>r>>d;
  for(int i=l;i<=r;i++)
  {
    if(i%d==0)
    {
      count++;
    }
  }
  cout<<count<<"\n";
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<iostream>
#include<cstring>

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr,__VA_ARGS__)

using namespace std;


inline char nc(){ static char buf[100000] , *p1,*p2; return p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,100000,stdin),p1 == p2) ? EOF : *p1++;}
template<class T>inline void rd(T & x){ x = 0;char ch = nc();for(;!isdigit(ch);ch = nc()); for(;isdigit(ch);ch = nc()) x = x * 10 - 48 + ch;} 
inline int rdstring(char * s){ int len = 0; char ch = nc(); for(;isspace(ch);ch = nc()); for(;!isspace(ch);ch = nc()) s[len++] = ch;return len;}
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}

const int maxn = 1e5 + 10;
typedef long long ll;
char a[maxn] , b[maxn];
int n,m;
ll check(){
	ll len = (ll) n * m / gcd(n,m);	
	ll stepa = len / n,stepb = len / m;
	ll step = (ll) stepa * stepb / gcd(stepa,stepb);
	for(ll i = 1;i <= len;i += step){
		ll x = (i - 1) / stepa + 1;
		ll y = (i - 1) / stepb + 1;
		if(x > n || y > m) break;
		if(a[x] != b[y]) return -1;
	}
	return len;
}
int main(){
	rd(n); rd(m);
	rdstring(a + 1);
	rdstring(b + 1);
	printf("%lld\n",check());
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;

/////////////         qsortのラッピング
class pairClass { // ペアのソート
public:
	pairClass() { key = 0, value = 0; }
	long key, value;
};
int qsort_int_compare_ascend(const void* a, const void* b) {//keyを見比べる
	long x = ((pairClass*)a)->key - ((pairClass*)b)->key;
	return (x > 0) ? 1 : ((x < 0) ? -1 : 0);
}
int qsort_int_compare_descend(const void* a, const void* b) {//keyを見比べる
	long x = ((pairClass*)b)->key - ((pairClass*)a)->key;
	return (x > 0) ? 1 : ((x < 0) ? -1 : 0);
}
void ascendOrder(int size, pairClass* array) {//昇順
	qsort(array, size, sizeof(pairClass), qsort_int_compare_ascend);
}
void descendOrder(int size, pairClass* array) {//降順
	qsort(array, size, sizeof(pairClass), qsort_int_compare_descend);
}

class compareClass {
public:
	compareClass() {
		ID = 0;
		content = 0;
	}
	int ID;
	int content;
};
int qsort_compareClass_ascend(const void* a, const void* b) {
	return ((compareClass*)a)->content - ((compareClass*)b)->content;
}
void getAscendRanking(int size, int* array, int* buf) {// 昇順のランキングを得る
	compareClass* c = new compareClass[size];
	for (int i = 0; i < size; i++) {
		c[i].content = array[i];
		c[i].ID = i;
	}
	qsort(c, size, sizeof(compareClass), qsort_compareClass_ascend);
	for (int i = 0; i < size; i++) {
		buf[c[i].ID] = i;
	}
	delete[] c;
}

int main() {
	int N, M; cin >> N >> M;
	pairClass* p = new pairClass[N];
	for (int i = 0; i < N; i++) {
		cin >> p[i].key >> p[i].value;
		p[i].key = M - p[i].key;
	}
	descendOrder(N, p);
	priority_queue<int> que; // 降順に出力
	int c = 0;
	int sum = 0;
	for (int m = M; m >= 0; m--) {
		while (c < N && p[c].key >= m) {
			que.push(p[c].value);
			c++;
		}
		if (que.size() != 0) {
			sum += que.top();
			que.pop();
		}
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3324
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(0,a+1):
    for j in range(0,b+1):
        for k in range(0,c+1):
            if 500 * i + 100 * j + 50 * k == x:
                count += 1
print(count)

Measured memory_bytes: 3060
#include<stdio.h>
#define INF 200000000
int dp[2][2][5001];
int min(int a,int b){return a<b?a:b;}
int main(){
	int n;
	scanf("%d",&n);
	int i,j;
	for(i=0;i<=n/2;i++){
		dp[1][0][i]=INF;
		dp[1][1][i]=INF;
	}
	dp[1][0][0]=0;
	for(i=0;i<n-1;i++){
		int cost;
		scanf("%d",&cost);
		for(j=0;j<=n/2;j++){
			dp[i%2][0][j]=INF;
			dp[i%2][1][j]=INF;
		}
		for(j=0;j<n/2;j++){
			dp[i%2][0][j+1]=min(dp[i%2][0][j+1],dp[(i+1)%2][0][j]);
			dp[i%2][1][j+1]=min(dp[i%2][1][j+1],dp[(i+1)%2][0][j]+cost);
		}
		for(j=0;j<=n/2;j++){
			dp[i%2][0][j]=min(dp[i%2][0][j],dp[(i+1)%2][1][j]+cost);
			dp[i%2][1][j]=min(dp[i%2][1][j],dp[(i+1)%2][1][j]);
		}
	}
	printf("%d\n",min(dp[n%2][0][n/2-1],dp[n%2][1][n/2]));
	return 0;
}
			

Measured memory_bytes: 1100