akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(ll i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w,d;
  cin>>h>>w>>d;
  string clr = "RYGB";
  if (d % 2 == 1) {
    REP(i,h){
      REP(j,w) {
        cout<<clr[(i+j)%2];
      }
      cout<<"\n";
    }
  } else {
    REP(i,h){
      REP(j,w) {
        int a = (i+j) / d;
        int b = (i+w-j) / d;
        cout<<clr[(a%2)*2 + b%2];
      }
      cout<<"\n";
    }
  }
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
using namespace std;
string a;
int c;
char t;
int main()
{
    int i;
    cin >> a;
    t = a[0];
    c = 1;
    for (i = 1; i < a.size(); i++) {
        if (t != a[i]) c++;
        t = a[i];
    }
    cout << c - 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 1004
#define mod 998244353
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define out(s) cout<<s
#define outs(s,a) cout<<s<<a
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
void solve(){
    ll k,n,i;
    in2(k,n);
    vector<ll>vec(n);
    nfl(i,n)
    in(vec[i]);
    ll ans=INT_MAX,tmp;
    nfl(i,n){
        tmp=0;
        ll end=vec[n-1];
        tmp+=end-vec[i];
        if(i!=0){
            tmp+=k-vec[n-1];
            tmp+=vec[i-1];
        }
        ans=min(ans,tmp);
    }
    cout<<ans<<'\n';
}
int main(){
    clock_t t1=clock();
    gear_change;
    ll test=1;
    // in(test);
    while(test--){
        solve();
    }
    clock_t t2=clock();
    cerr<<"Time elapsed:- "<<(double)(t2-t1)/CLOCKS_PER_SEC<<'\n';
}    

Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int a[5000],i,j,sum=0,max = -999999,n;
	
	while(1){
		scanf("%d",&n);
		if( n == 0)
			break;
		for(i=0;i<n;i++)
			scanf("%d",&a[i]);

		for(i=0;i<n;i++){
			for(j=i;j<n;j++){
				sum = sum + a[j];
				if(max < sum)
					max = sum;
			}
			sum = 0;
		}
		printf("%d\n",max);
		max = -999999;
	}
	return 0;
}

Measured memory_bytes: 616
private fun naiveSolver(s:String,t:String):Int {
    // ここに書き込む
    val arr_s = s.toCharArray()
    val arr_t = t.toCharArray()
    val kakikaeArr = IntArray(s.length - t.length + 1)
    for (i in kakikaeArr.indices) {
        val sliced = arr_s.sliceArray(0+i until arr_t.size+i)
        var count = 0
        for (j in arr_t.indices) {
            if (arr_t[j] != sliced[j]) {
                count++
            }
        }
        kakikaeArr[i]=count
    }
    return kakikaeArr.min()!!
}

fun main(){
    val s = readLine()!!
    val t = readLine()!!
    print(naiveSolver(s,t))
}

Measured memory_bytes: 39860
import math
n , d = map(int,input().split())
xy = [list(map(int,input().split())) for i in range(n)]

count = 0
for i in range(n):
    dis = math.sqrt((xy[i][0]**2)+(xy[i][1]**2))
    if dis <= d:
        count += 1
print(count)

Measured memory_bytes: 45460
nums = gets.split.map(&:to_i)
set = {nums[1] => nums[2], nums[3] => nums[4]}
totals = []
i = 0
set.each do |num, value|
  sets = nums[0] % num == 0 ? nums[0]/num : nums[0]/num + 1
  totals[i] = sets * value
  i += 1
end
puts totals.min


Measured memory_bytes: 6872
program agc036a
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: s,x1,y2,xy,i,x2,y1


    read*, s
    x1 = ceiling(sqrt(dble(s)))
    y2 = x1

    xy = x1*y2 - s
    x2 = 0
    y1 = 0
    do i=ceiling(sqrt(dble(xy))),1,-1
        if (mod(xy,i) == 0) then
            x2 = i
            y1 = xy/x2
            exit
        end if
    end do

    print'(*(i0,1x))',0,0,x1,y1,x2,y2

end program agc036a

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import heapq
import copy
import itertools

inf = float('inf')

class Graph_dijkstra(object):
    def __init__(self, V: "List[int]", E: "Set[Tuple[int, int]]", L: "Dict[Tuple[int, int], int]"):
        self.V = V
        self.E = E
        self.L = L
        self.adjacent = self.init_adjacent() # type: Dict[int: List[int]]
        self.shortest_path = self.init_shortest_path() # type: Dict[FrozenSet[int, int], int]
    
    def init_adjacent(self):
        ret = {v: [] for v in self.V}
        for e in self.E:
            ret[e[0]].append(e[1])
        return ret
    
    def init_shortest_path(self):
        ret = {(s, g): inf for s, g in itertools.permutations(self.V, 2)}
        for v in self.V:
            ret[(v, v)] = 0
        return ret
    
    def dijkstra(self, s: int):
        D = {v: inf for v in self.V}
        D[s] = 0
        prev = {v: None for v in self.V}
        Q = [(0, s)]

        while len(Q) > 0:
            du, u = heapq.heappop(Q)
            for v in self.adjacent[u]:
                e = (u, v)
                alt = du + self.L[e]
                if alt < D[v]:
                    D[v] = alt
                    prev[v] = u
                    heapq.heappush(Q, (D[v], v))

        for v in self.V:
            self.shortest_path[(s, v)] = D[v]

    def find_shortest_path(self, s: int, g:int):
        d = self.shortest_path[(s, g)]
        if d < inf:
            return d
        self.dijkstra(s)
        return self.shortest_path[(s, g)]


def solve(H: int, W: int, c: "List[List[int]]", A: "List[List[int]]"):
    V = list(range(10))
    E = set()
    L = dict()

    for i in range(10):
        for j in range(10):
            e = (i, j)
            E.add(e)
            L[e] = c[i][j]
    
    G = Graph_dijkstra(V, E, L)

    count = [0 for _ in range(10)]
    for h in range(H):
        for w in range(W):
            if A[h][w] == -1:
                continue
            count[A[h][w]] += 1
    
    total = 0
    for i in range(10):
        total += G.find_shortest_path(i, 1) * count[i]

    print(total)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    c = [ [ int(next(tokens)) for _ in range(9-0+1) ] for _ in range(9-0+1) ]  # type: "List[List[int]]"
    A = [ [ int(next(tokens)) for _ in range(W) ] for _ in range(H) ]  # type: "List[List[int]]"
    solve(H, W, c, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3824
# 二分探索
# ALDS1_4_B

n = int(input())
S = list(map(int, input().split(" ")))
q = int(input())
T = list(map(int, input().split(" ")))


def binarySearch(t, S, n1, n2):
    ret = False
    n3 = n1 + int((n2 - n1)/2)
    if n3 >= len(S) or n2 < n1:
        return False
    elif t == S[n3]:
        return True
    elif n1 == n2:
        return False
    elif t > S[n3]:
        ret = binarySearch(t, S, n3 + 1, n2)
    elif t < S[n3]:
        ret = binarySearch(t, S, n1, n3 - 1)
    return ret


cnt = 0
for t in T:
    if binarySearch(t, S, 0, len(S) - 1):
        cnt += 1

print(cnt)



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


int main() {
    ll n,d;
    cin>>n>>d;
    vector<ll> x(n);
    vector<ll> y(n);
    rep(i,n){
        cin>>x[i]>>y[i];
    }
    ll count=0;
    rep(i,n){
        ll rr=x[i]*x[i]+y[i]*y[i];
        if(rr<=d*d){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 6420
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(0, min(b,d) - max(a,c)) << endl;
}

Measured memory_bytes: 256
import std;

void main() {
    long a; string b; scan(a, b);

    int x = b[0] - '0';
    int y = b[2] - '0';
    int z = b[3] - '0';

    long ans = a * 100 * x;
    ans += a * 10 * y;
    ans += a * z;
    writeln(ans / 100);
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;


Measured memory_bytes: 3636
#include<stdio.h>

#define MAX 100005
#define NIL -1

typedef struct { int parent, left, right; } Node;

Node T[MAX];
int n, D[MAX];

void print(int u){
	int i, c;
	printf("node %d: parent = %d, depth = %d, ", u, T[u].parent, D[u]);
	
	if(T[u].parent == NIL) printf("root, ");
	else if(T[u].left == NIL) printf("leaf, ");
	else printf("internal node, ");
	
	printf("[");
	
	for(i = 0, c = T[u].left; c != NIL; i++, c = T[c].right){
		if(i) printf(", ");
		printf("%d", c);
	}
	
	printf("]\n");
}

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

int main(void){
	
	int i, j, d, v, c, l, r;
	
	scanf("%d",&n);
	
	for(i = 0; i < n; i++) T[i].parent = T[i].left = T[i].right = NIL;
	
	for(i = 0; i < n; i++){
		scanf("%d %d",&v,&d);
		for(j = 0; j < d; j++){
			scanf("%d",&c);
			if(j == 0) T[v].left = c;
			else T[l].right = c;
			l = c;
			T[c].parent = v;
		}
	}
	
	for(i = 0; i < n; i++){
		if(T[i].parent == NIL) r = i;
	}
	
	setDepth(r, 0);
	
	for(i = 0; i < n; i++) print(i);
	
	return 0;
}



Measured memory_bytes: 6364
n = int(input())

for i in range(1, 3501):
    for j in range(1, 3501):
        if 4*i*j - n*j - n*i != 0:
            if 4*i*j - n*j - n*i != 0 and n*i*j % (4*i*j - n*j - n*i) == 0 and n*i*j // (4*i*j - n*j - n*i) > 0:
                print(str(i) + " " + str(j) + " " + str(n*i*j // (4*i*j - n*j - n*i)))
                exit()
        

Measured memory_bytes: 41068
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m,k;
    cin>>n>>m>>k;
    vector<int>a(n),b(m);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin>>b[i];
    }
    vector<int>ruia(n+1,0),ruib(m+1,0);
    for (int i = 0; i <n; i++)
    {
        ruia[i+1]=ruia[i]+a[i];
    }
    for (int i = 0; i < m; i++)
    {
        ruib[i+1]=ruib[i]+b[i];
    }
    int ans=0;
   // show(ruia);
   // show(ruib);
    for (int i = 0; i <= n; i++)
    {
        int c=k-ruia[i];
        if(c<0){
            break;
        }
        int tmp1=i;
        int tmp2=upper_bound(ALL(ruib),c)-ruib.begin()-1;
     //   cerr<<tmp1<<" "<<tmp2<<endl;
        chmax(ans,tmp1+tmp2);
    }
    cout<<ans<<endl;
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 9516
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


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


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper

y, m, d = map(int, input().split('/'))
if m <= 4:
    print('Heisei')
else:
    print('TBD')


Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) { cout << ", "; first = false; }
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n);
  for (lli i=0; i<n; ++i) cin >> v[i];
}


int main() {
  string s;
  cin >> s;
  int ans=0;
  for (auto c:s) ans += c=='2' ? 1 : 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n>>i;
    j=max(n+i,n-i);
    j=max(j,n*i);
    cout<<j;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    int n,t;cin>>n>>t;
    vector<int> v;
    for(int i = 0; i< n; i++){
        int c,a;cin>>c>>a;
        if(a <= t) v.push_back(c);
    }
    sort(v.begin(),v.end());
    if(v.empty())cout << "TLE" <<endl;
    else cout<< v[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int mod;
int dp[303][303];
int sum[303][303];
int c[303][303];
int main()
{
	int n,k;
	scanf("%d%d%d",&n,&k,&mod);
	memset(c,0,sizeof(c));
	c[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		c[i][0]=1;
		for(int j=1;j<=i;j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	}
	memset(dp,0,sizeof(dp));
	for(int i=0;i<=k;i++)
		dp[0][i]=1;
	memset(sum,0,sizeof(sum));
	for(int i=k;i>=0;i--)
		sum[0][i]=(sum[0][i+1]+dp[0][i])%mod;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=k;j++)
			for(int kk=1;kk<=i;kk++)
				dp[i][j]=((long long)sum[kk-1][j+1]*dp[i-kk][j]%mod*c[i-1][kk-1]+dp[i][j])%mod;
		for(int j=k;j>=0;j--)
			sum[i][j]=(sum[i][j+1]+dp[i][j])%mod;
	}
	printf("%d",dp[n][0]);
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a, b, c, sum1,sum2;
	sum1 = 0;
	sum2 = 0;
	while (scanf("%d,%d,%d",&a,&b,&c)!=EOF) {
		if (a*a + b*b == c*c) {
			sum1 += 1;
		}
		if (a == b) {
			sum2 += 1;
		}
	}
	cout << sum1 << endl;
	cout << sum2 << endl;
	return 0;
}

Measured memory_bytes: 3016
#! usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    S = input()

    for i in range(len(S)-1):
        if S[i] == "A" and S[i+1] == "C":
            print("Yes")
            exit()

    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
import sys
import fractions
sys.setrecursionlimit(1000000)

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


a,b,c,d = map(int,input().split())

c_w = (b)//c - (a+c-1)//c + 1
d_w = (b)//d - (a+d-1)//d + 1

#cd = int(c*d) / int(fractions.gcd(c,d))



cd = lcm(c,d)

cd_w = (b)//(cd) - (a+cd-1)//(cd) + 1


print(int(b-a+1 - c_w - d_w + cd_w))


Measured memory_bytes: 5048
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#include <set>
#include <map>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

string s,s1,s2;

int main(){
    cin>>s>>s1>>s2;
    cout<<s[0]<<s1[0]<<s2[0]<<endl;
}

Measured memory_bytes: 256
m,d = map(int,input().split(" "))
if d <= 19:
    print(0)
    exit()
count = 0
for i in range(22,d+1):
    if i // 10 >= 2 and i % 10 >= 2:
        if (i // 10) * (i % 10) <= m:
            count += 1
print(count)

Measured memory_bytes: 3060
# 12-Structured_Program_II-How_many_ways.py

# ????????????????????°
# 1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????
# ????????????????????°????±???????????????°?????????????????????????????????
# ????????°???1 ?????? 5 ?????§?????°???????????????????????§????????????????¨???? 9 ??¨???????????????????????????

# 1 + 3 + 5 = 9
# 2 + 3 + 4 = 9
# ??????????????????????????????

# Input
# ?????°??????????????????????????\?????¨???????????????????????????
# ???????????????????????§??????????????§??????????????? n???x ??? 1 ???????????????????????????

# n???x ?????¨?????? 0 ?????¨?????\?????????????????¨????????????
# n ??? 3 ??\??? 100?????\?????¨????????????

# Output
# ????????????????????????????????????????????????????????°????????????????????????????????????

# Sample Input
# 5 9
# 0 0
# Sample Output
# 2

result = []
n=[]
x=[]

while 1:
	temp = input().split() 
	if temp[0]=="0" and temp[1]=="0":
		break;
	else:
		n.append( int( temp[0] ))
		x.append( int( temp[1] ))

for i in range( len(n) ):
	count =0
	for n1 in range(1,n[i]+1-2):
		for n2 in range(n1+1, n[i]+1-1):
			for n3 in range(n2+1, n[i]+1):
				sum = n1+n2+n3
				if sum == x[i]:
					count+=1
	result.append(count)

for i in range( len(result) ):
	print(result[i])
	# if i == len(result)-1:
	# 	print(result[i])
	# else:
	# 	print("{0} ".format(result[i]), end="")

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

int main(){
        int i = 0;
        
        while(cin >> i && !(i == 0)){
                int a[i];
                int j = 0;              

                for(j=0; j<i; j++){
                        cin >> a[j];
                }
        
                //sum
                int sum = 0;
                for (j=0; j<i; j++) {
                        sum += a[j];
                }
        
                //largest,smallest
                int largest = 0;
                int smallest = 1000;
                for (j=0; j<i; j++){
                        if (a[j] > largest)
                                largest = a[j];
                        if (a[j] < smallest)
                                smallest = a[j];
                }
                
                //average
                int average = 0;
                average = (sum - largest - smallest) / (i - 2);
                cout << average << endl;
        }

}

Measured memory_bytes: 1160
require 'matrix'
$stdin = DATA if $stdin.eof?

ARGF.each_line do |line|
  a, b, c, d, e, f = line.split.map(&:to_r)

  mat_a = Matrix[ [a, b], [d, e]].inverse
  mat_b = Matrix[ [c], [f]]

  mat_s = mat_a * mat_b
  puts mat_s.column(0).to_a.map(&:to_f).map{|e| "%1.3f" % e.round(3)}.join("\s")
end

Measured memory_bytes: 9448
import sys
from collections import deque,defaultdict

I=sys.stdin.readline

def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))

def mi():
	return map(int,I().strip().split())


def main():
	a,b,c=mi()
	k=ii()
	x=k
	for i in range(k):
		if b<=a:
			b*=2
			x-=1
	for i in range(x):
		if c<=b:
			c*=2
	if b>a and c>b:
		print("Yes")
	else:
		print("No")








		


		










		






if __name__ == '__main__':
	main()

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

int main()
{
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<int> num(n, -1); //町を何番目に通ったか
    vector<int> seen;       //通った町
    int now = 1; //現在の街

    while (num[now - 1] == -1)
    {
        num[now - 1] = seen.size();
        seen.push_back(now);
        now = a[now - 1];
    }
    int head = num[now - 1];
    int loop = seen.size() - head;
    int ans;
    if (k < head)
        ans = seen[k];
    else
    {
        int mod = (k - head) % loop;
        ans = seen[head + mod];
    }

    cout << ans << endl;
}


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

typedef long long LL;
typedef unsigned long long ULL;

template <typename T>
void ri(T& x);

const int MAXN = 2e3+4;

int n, a[MAXN], ans = 0;

int main() {
    #ifdef DEBUG
        freopen("in", "r", stdin);
        // freopen("out", "w", stdout);
    #endif

    ri(n);
    for (int i=0; i<n; ++i)
        ri(a[i]);
    sort(a, a+n);
    
    
    
    for (int i=0; i+2<n; ++i) {
        int k = i+2;
        for (int j=i+1; j+1<n; ++j) {
            const int lim = (a[i]+a[j]);
            while (k<n && a[k] < lim) ++k;
            ans += k - j - 1;
        }
    }
    
    printf("%d\n", ans);

    return 0;
}





template <typename T>
void ri(T& x) {
    char c;
    bool minus = false;
    while ((c=getchar())<'0' || '9'<c)
        if (c == '-') minus = true;
    x = c-'0';
    while ('0'<=(c=getchar()) && c<='9')
        x = 10*x - '0' + c;
    if (minus) x = -x;
}

Measured memory_bytes: 256
N , M = map(int, input().split())
L = 0
R = N
for x in range(M):
    Lx,Rx =map(int, input().split())
    if L < Lx:
        L = Lx
    if R > Rx:
        R = Rx
ans = R - L + 1
if ans < 0:
    ans = 0
print(ans)

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

int main()
{
	int64_t n, k, mod = 1000000007;
	cin >> n >> k;
	vector<int64_t> as(n - 1), bs(n - 1);
	for (int64_t i = 0; i < n - 1; i++)
	{
		cin >> as[i] >> bs[i];
		as[i]--;
		bs[i]--;
	}

	vector<vector<int64_t>> g(n);
	for (int64_t i = 0; i < n - 1; i++)
	{
		g[as[i]].emplace_back(bs[i]);
		g[bs[i]].emplace_back(as[i]);
	}

	vector<int64_t> cnt(n, 0), parent(n, -1);

	int64_t ans = 1;

	auto f = [&](auto &h, int64_t now = 0, int64_t par = -1) -> void {
		parent[now] = par;

		int64_t other = 0;
		if (par != -1)
		{
			other += cnt[par];
		}
		if (par != -1 && parent[par] != -1)
		{
			other++;
		}

		(ans *= max(int64_t(0), k - other)) %= mod;

		for (auto &next : g[now])
		{
			if (next == par)
			{
				continue;
			}
			cnt[now]++;
			h(h, next, now);
		}
	};

	f(f);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 11648
N = int(input())
l = [0] * N
r = [0] * N
for i in range(N):
    l[i], r[i] = map(int, input().split())

count = [0] * N
for i in range(N):
    count[i] = r[i] - l[i] + 1

print(sum(count))


Measured memory_bytes: 3188
#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<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!

	int a,b;
	cin>>a>>b;
	if(b%a==0) cout << a+b << endl;
	else cout << b-a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int a, b; cin >> a >> b;
    int cnt = a;
    int ans = 1;
    while(cnt < b) {
        cnt += a-1;
        ans++;
    }
    if(b == 1) ans = 0;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque
n, m = map(int, input().split())
E = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)
dis = [200000 for i in range(n)]
dis[0] = 0
Q = deque([0])
while Q:
    now = deque.popleft(Q)
    for i in E[now]:
        if dis[i] == 200000:
            dis[i] = dis[now]+1
            deque.append(Q, i)
print("POSSIBLE" if dis[-1] == 2 else "IMPOSSIBLE")

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

public class Program {
  public static void Main() {
    int N = int.Parse(Console.ReadLine());
    Dictionary<int, bool> dic = new Dictionary<int, bool>();
    for (int i = 0; i < N; i++) {
      int input = int.Parse(Console.ReadLine());
      if (dic.ContainsKey(input)) {
        dic[input] = !dic[input];
      } else {
        dic.Add(input, true);
      }
    }
    Console.WriteLine(dic.Values.Count(x => x));
  }
}


Measured memory_bytes: 20316
#include <stdio.h>

int main(void)
{
    int a, b, c;
    int t;

    scanf("%d %d %d", &a, &b, &c);

        while(1){
        if(a > b) {
            t = a;
            a = b;
            b = t;
        }

        if(b > c) {
            t = b;
            b = c;
            c = t;
        }

        if(a > c) {
            t = a;
            a = c;
            c = t;
        }
        
        if(a <= b && b <= c){break;}

}
       
    printf("%d %d %d\n", a, b, c);

    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, M, Q; cin >> N >> M >> Q; 
	int A[55], B[55], C[55], D[55]; 
	for(int i = 0; i < Q; i++){
		cin >> A[i] >> B[i] >> C[i] >> D[i]; 
		A[i] --; B[i] --; 
	}
	int X[25] = {}; 
	for(int i = N; i < N + M - 1; i++) X[i] = 1; 
	int ans = 0; 
	do{
		vector<int> T; 
		int tmp = 1; 	
		for(int j = 0; j < N + M - 1; j++){
			if(X[j] == 1) tmp ++; 
			else T.push_back(tmp); 
		}if(T.size() != N){
			cout << T.size() << endl; return 0;
		}
		int sum = 0; 
		for(int q = 0; q < Q; q++){
			if(T.at(B[q]) - T.at(A[q]) == C[q]) sum += D[q]; 
		}
		ans = max(ans, sum); 
	}while(next_permutation(X, X+N+M-1)); 
	cout << ans << endl; 
}


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


int lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

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


int main()
{
    int K, A, B;
    cin >> K >> A >> B;
    string ans = "NG";
    for (int i = 1; i <= 1000;i++)
    {
        if(K * i <= B && K * i >= A){
            ans = "OK";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
n = int(input())
status = [[[0] * 10 for i in range(3)] for j in range(4)]
for i in range(n):
    b, f, r, v = map(int, input().split())
    status[b-1][f-1][r-1] += v

for i in range(4): # b
    for j in range(3): # f
        print("", " ".join(map(str, status[i][j])))
    if i != 3:
        print("####################")


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

int main(){
  int N;
  ll K;
  cin >> N >> K;
  int log_K = floor(log2(K));
  // cerr << N << " " << log_K << endl;
  vector<vector<int>> next(log_K + 1, vector<int>(N));

  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    // cerr << i << " : " << tmp << endl;
    next.at(0).at(i) = tmp-1;
  }

  for(int k = 0; k < log_K; k++){
    for(int i = 0; i < N; i++){
      if(next[k][i] == -1){
        next[k+1][i] = -1;
      } else { 
        next[k+1][i] = next[k][next[k][i]];
        // cerr << k+1 << " " << i << " " << next[k+1][i] << endl;
      }
    }
  }

  int ans = 0;
  for(ll k = log_K; k >= 0; k--){
    if((K>>k)&1){
      ans = next[k][ans];
    }
  }
  cout << ans+1<< endl;

}


Measured memory_bytes: 51268
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

bool pairCompare(const pair<ll, ll>& firstElof, const pair<ll, ll>& secondElof)
{
    return firstElof.second < secondElof.second;
}

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

    ll N, M;
    cin >> N >> M;
    pair<ll, ll> ab[M];
    for (ll i = 0; i < M; ++i) {
        ll a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }

    sort(ab, ab + M, pairCompare);


    ll last = -1;
    ll ans = 0;
    for (ll i = 0; i < M; ++i) {
        if (ab[i].first <= last && ab[i].second >= last) {
            continue;
        }
        last = ab[i].second - 1;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1920
// template version 1.8

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
const int INF=1e18;
const int MOD=1e9+7;
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}

int solve(){
  int a,b,t;
  cin>>a>>b>>t;
  dump(t/a);
  cout << t/a * b << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

using std::cin;
using std::cout;
using std::endl;

int
main()
{
  int N, K;
  cin >> N >> K;
  int one = 0;
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    if (a == 1)
    {
      one = i;
    }
  }
  int count = 0;
  int lower = one;
  count += lower / (K - 1);
  int b = one;
  int lgap = lower % (K - 1);
  if (lgap != 0)
  {
    count++;
    b = one - lgap + K - 1;
  }
  int upper = N - b - 1;
  if (0 < upper)
  {
    count += (upper + K - 2) / (K - 1);
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
vector<ll> data1;
vector<ll> memo;
string s;
ll n;
ll dp(ll u)
{
  if (u == n)
    {
        return 0;
    }
    if (memo[u] != 0)
    {
        return memo[u];
    }
    ll res = 0;
    res = dp(u + 1) + (s[u] - '0') * data1[n - 1 - u];
    memo[u] = res % 2019;
    return memo[u];
}
int main()
{
    cin >> s;
    n = s.size();
    data1.resize(s.size());
    memo.resize(s.size());
    rep(i, n)
    {
        if (i == 0)
        {
            data1[i] = 1;
            continue;
        }
        data1[i] = data1[i - 1] * 10 % 2019;
    }      //0からn-1まで入ったはず。
    dp(0); //0個以上の数字を文字列とした時に、
    rep(i, n)
    {
      //    cout << memo[i] << endl;
    }
    map<ll, ll> h;
    rep(i, n)
    {
        h[memo[i]] += 1;
    }
  
    h[0] += 1;
    ll count = 0;
    for (auto x : h)
    {
      //  cout << x.first << " " << x.second << endl;
        count += x.second*(x.second-1)/2;
    }
    cout << count << endl;
}
//カウントするのは同じものが何個あるかと0が何個あるかだけ。

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if((abs(b-a)<=d && abs(c-b)<=d) || abs(c-a)<=d) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
L = int(input())
As = [int(input()) for _ in range(L)]

Xs = [0, 2, 1, 2, 0]
dp = [[0]*(5) for _ in range(L+1)]
for i, A in enumerate(As, 1):
    A2 = 2 - A%2 if A > 2 else A
    for t, (X, A0) in enumerate(zip(Xs, [A, A2, A2, A2, A])):
        dp[i][t] = min(dp[i-1][:t+1]) + abs(A0-X)
print(min(dp[-1]))


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

int main(){
	int N, count=0;
  	cin >> N;
  for(int i=N; i != 0; i /= 10){
	count += i%10;
  }
  
  if(N % count == 0){
  cout << "Yes" << endl;
  }else{
  cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	double v, y, t;
	int floor;
	while(scanf("%lf", &v)!=EOF){
		t = v / 9.8;
		y = 4.9*t*t;
		floor = (y + 5) / 5 + 1;
		printf("%d\n", floor);
	}
	return 0;
}

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

int main() {
  int h,w;
  string str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  cin >> h >> w;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      string s;
      cin >> s;
      if(s == "snuke"){
        cout << str[j];
        cout << i+1 << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
cnt_all = 0

if N >=106:
    for i in range(1,N+1):
        cnt =0
        for j in range(1,i+1):
            if i%j ==0:
                cnt +=1
        if cnt ==8 and i%2 ==1:
            cnt_all+=1
    print(cnt_all)

elif N==105:
    print(1)
else:
    print(0)

Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let s = get!(String);
    let k = get!(usize);
    let ck = s.chars().nth(k-1).unwrap();

    for c in s.chars() {
        if c == ck {
            print!("{}",c);
        } else {
            print!("*");
        }
    }
    println!("");
}


Measured memory_bytes: 8572
import java.util.Scanner;

public class Main {
	static long count;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] monster = new long[n+1];
		long[] saver = new long[n];

		for (int i = 0; i < n+1; i++) {
			monster[i] = sc.nextLong();
		}

		for (int i = 0; i < n; i++) {
			saver[i] = sc.nextLong();
		}

		long leftOver = monster[0];
		for (int i = 0; i < n; i++) {
			leftOver = attack(leftOver, i, saver, monster);
		}

		System.out.println(count);

	}

	private static long attack(long leftOver, int town, long[] saver, long[] monster) {
		long killFirst = Math.min(leftOver, saver[town]);
		long killSecondPoten = saver[town] - killFirst > 0 ? saver[town] - killFirst : 0;
		long killSecond = Math.min(killSecondPoten, monster[town+1]);
		long secondLeft = monster[town+1] - killSecondPoten > 0 ? monster[town+1] - killSecondPoten : 0;
		count += (killFirst + killSecond);
		return secondLeft;
	}

}

Measured memory_bytes: 87712
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: &Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let A = read::<usize>();
    let B = read::<usize>();
    let C = read::<usize>();
    let X = read::<usize>();
    let mut sum = 0;

    for a in 0..A+1 {
        for b in 0..B+1 {
            for c in 0..C+1 {
                if 500*a + 100*b + 50*c == X {
                    sum += 1;
                }
            }
        }
    }
    println!("{}", sum);

}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int n;
int a[111];
int s;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s += a[i];
	}
	int e = 1e9;
	for (int i = 0; i < n; i++) {
		if (abs(a[i]*n-s) < e) {
			e = abs(a[i]*n-s);
		}
	}
	for (int i = 0; i < n; i++) {
		if (abs(a[i]*n-s) == e) {
			cout << i << "\n";
			break;
		}
	}
}

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

int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    for(int i=0;i<ty-sy;i++) cout<<"U";
    for(int i=0;i<tx-sx;i++) cout<<"R";
    for(int i=0;i<ty-sy;i++) cout<<"D";
    for(int i=0;i<tx-sx;i++) cout<<"L";
    cout<<"L";
    for(int i=0;i<ty-sy+1;i++) cout<<"U";
    for(int i=0;i<tx-sx+1;i++) cout<<"R";
    cout<<"D";
    cout<<"R";
    for(int i=0;i<ty-sy+1;i++) cout<<"D";
    for(int i=0;i<tx-sx+1;i++) cout<<"L";
    cout<<"U"<<endl;
}

Measured memory_bytes: 256
//D - Disjoint Set of Common Divisors
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    if(a>=1 && a<=9 && b>=1 && b<=9){
        cout << a*b;
    }else{
        cout << -1;
    }
}


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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T>
inline T LCM(T a, T b) { return (a + (b - 1)) / b; }
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

vl calc_divisor(ll n) {
	vl res;
	for (ll i = 1LL; i * i <= n; i++) {
		if (n % i == 0) {
			res.push_back(i);
			ll j = n / i;
			if (j != i) res.push_back(j);
		}
	}
	sort(ASC(res));
	return res;
}

int main() {
	ll n, m;
	cin >> n >> m;

	vl div = calc_divisor(m);

	ll res = 1;
	for (auto d : div) {
		if (d * n <= m) res = max(res, d);
	}
	cout << res << endl;
}

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

ans = 0
cnt = 0

for n in A:
  if cnt == 0:
    ans += B[n-1]
    cnt += 1
  else:
    ans += B[n-1]
    if A[cnt] - A[cnt-1] == 1:
      ans += C[A[cnt-1]-1]
    cnt += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	long long n,k,a,b,c,ans=0;
	cin>>n>>k;
	if(k%2==0){
		long long s=0;
		for(int i=1;i<=n;i++){
			if(i%k==k/2)
				s++;
		}
		ans=(n/k)*(n/k)*(n/k)+s*s*s;
	}
	else{
		ans=(n/k)*(n/k)*(n/k);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a,b,c,d;
  cin>>a>>b>>c>>d;
int count=0;
  if(a==1||b==1||c==1||d==1){
    count++;
  
    }
  if(a==9||b==9||c==9||d==9){
    count++;
  
    }
  if(a==7||b==7||c==7||d==7){
    count++;
  
    }if(a==4||b==4||c==4||d==4){
    count++;
  
    }
  if(count==4)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}

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

const ll mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0) : x((x%mod+mod)%mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> A(n, 0);
  ll maxdist = 0;
  bool ok = true;
  rep(i,n) {
    ll d;
    cin >> d;
    A[d]++;
    maxdist = max(maxdist, d);
    if (i == 0 && d != 0) ok = false;
  }
  if (A[0] != 1 || !ok) {
    cout << 0 << endl;
    return 0;
  }
  mint ans(1);
  for (ll dist = 1; dist <= maxdist; ++dist) {
    mint res(A[dist-1]);
    ans *= res.pow(A[dist]);
  }
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 1024