akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        WriteLine((cin.scanint.Sum() + 2 - 1) / 2);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11220
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class Sample9{

	public static void Main(){

		List <int> resultList = new List<int> ();

		while (true) {

			string line = Console.ReadLine ();

			if (line != null) {

				resultList.Add (getPrimeNumCount(int.Parse(line)));
			} else {
				break;
			}
		}

		foreach (var r in resultList) {
		
			Console.WriteLine (r);
		}

	}


	public static int getPrimeNumCount(int a){

		int i, j, k;
		int count = 0;

		if (a == 2) {
			return 1;
		} else if (a < 2) {
			return 0;
		}


		for (i = 3; i <= a; i += 2) {
			k = 0;

			double n = Math.Sqrt (i);
			for (j = 3; j <= n; j += 2) {
				if (i % j == 0) {
					k = 1;
					break;
				}
			}

			if (k == 0) {

				//Console.WriteLine ("Prime:" + i);
				count++;
			}
		}


		return (count+1);

	}
}

Measured memory_bytes: 5680
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

vector<ll> DIS;
vector<vector<pair<int, int>>> V;

int main(){

	ll M, K;
	cin >> M >> K;
	ll M_max = pow((ll)2, M);
	if(K >= M_max){
		cout << "-1" << endl;
		return 0;
	}
	if(M == 1){
		if(K == 0){
			cout << "0 0 1 1" << endl;
		}
		if(K == 1){
			cout << "-1" << endl;
		}
		return 0;
	}
	vector<ll> ANS;
	for(ll i = 0; i < M_max; i ++){
		if(i == K)continue;
		ANS.pb(i);
	}
	ANS.pb(K);
	for(ll i = M_max - 1; i >= 0; i --){
		if(i == K)continue;
		ANS.pb(i);
	}
	ANS.pb(K);
	for(int i = 0; i < ANS.size(); i ++){
		cout << ANS[i];
		if(i == ANS.size() - 1)break;
		cout << SPACE;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3952
while True:
    n, m = map(int, input().split())
    if n == m == 0:
        break
    taro = [int(input()) for i in range(n)]
    hanako = [int(input()) for i in range(m)]

    #??????????????¨????¨?????\???°????????????
    if (sum(taro) + sum(hanako)) % 2 == 1:
        print(-1)
        continue
    half = (sum(taro) + sum(hanako)) // 2
    #???????????????????????????????????±???????????????????????????
    taro_ex = hanako_ex = half
    #??????????????°
    ex_flag = False

    for i in taro:
        for j in hanako:
            #??????????????????????????????????????§??????????°???????????????´??°
            if sum(taro) + j -i == half and sum(hanako) + i - j == half:
                if i + j < taro_ex + hanako_ex:
                    taro_ex = i
                    hanako_ex = j
                    ex_flag = True

    if ex_flag:
        print(taro_ex, hanako_ex)
    else:
        print(-1)

Measured memory_bytes: 7688
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define u128 __int128
#define ss second
#define pb push_back

#define N 100010
#define MOD 1000000007

// ll n, m, k;

ll bexp(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if(b & 1)
			res = res * a;
		a *= a;
		b >>= 1;
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	sort(a, a + n);

	int k = n/2;
	ll ans = a[n/2] - a[n/2 - 1];
	cout << ans;
	return 0;
}

// int dpf(int last, int sum0, int sum1, int k)
// {
// 	if(k == m)
// 		return 1;
// 	for (int j = 0; j < n; ++j)
// 	{
// 		if(j != last && sum0 + vi[j] > sum1)
// 		{
// 			if(dpf(j, sum1, sum0 + vi[j], k + 1))
// 			{
// 				path[sum1] = j;
// 				return 1;
// 			}
// 		}
// 	}
// 	return 0;
// }


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF 1LL<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    vl ans(n);
    if(n%2==1){
        ll index;
        if(a[n/2]-a[n/2-1] <= a[n/2+1]-a[n/2]) index = 1;
        else index = 0;
        rep(i,n/2){
            ans[index] = a[n/2+i+1];
            ans[index+1] = a[i];
            index += 2;
        }
        if(index==n) ans[0] = a[n/2];
        else ans[n-1] = a[n/2];
    }else{
        ll index = 0;
        rep(i,n/2){
            ans[index] = a[n/2+i];
            ans[index+1] = a[i];
            index += 2;
        }
    }
    ll sum = 0;
    rep(i,n-1){
        sum += abs(ans[i+1]-ans[i]);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
tmp=[]
all_sum=sum(a)
tmp_sum=0
tmp_sum2=all_sum
for i in range(n-1):
    tmp_sum+=a[i]
    tmp_sum2-=a[i]
    tmp.append(abs(tmp_sum-tmp_sum2))
print(min(tmp))


Measured memory_bytes: 24828
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    N, Q = map(int, input().split())
    edge = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        edge[a].append(b)
        edge[b].append(a)
    node = [0 for _ in range(N)]
    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        node[p] += x

    que = queue.Queue()
    que.put(0)
    res = [0 for _ in range(N)]
    unvisit = [True for _ in range(N)]
    while not que.empty():
        s = que.get()
        unvisit[s] = False
        res[s] += node[s]
        for ns in edge[s]:
            if unvisit[ns]:
                res[ns] += res[s]
                que.put(ns)

    print(*res)


Measured memory_bytes: 102344
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
#define akioi long long
using namespace std;

akioi n, ans = 1;
int main() {
	cin >> n;
	for (akioi i = 1; i <= n; i++) {
		ans *= i;
		ans %= 1000000007;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;
	template<class T>using pair = std::pair<T, T>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
	
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		auto ret = T(1);
		auto s = 1ULL;
		for (auto i = 0; i < 63; ++i, s <<= 1)
		{
			if (p & s)
			{
				ret *= val;
			}
			val *= val;
		}
		return ret;
	}
	template<class Range>void sort(Range& rng)
	{
		std::sort(std::begin(rng), std::end(rng));
	}
	template<class Range, class Pred>void sort(Range& rng, Pred pred)
	{
		std::sort(std::begin(rng), std::end(rng), pred);
	}
}

void Main()
{
	std::int64_t a, b, c, d;
	std::cin >> a >> b >> c >> d;
	std::cout << std::max({ a * c,a * d,b * c,b * d }) << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

string S;
bool flag = false;

int main(){
  cin >> S;
  rep(i, 3){
    if (S[i]==S[i+1]) flag=true;
  }
  if (flag==false) cout << "Good" << endl;
  else cout << "Bad" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include<list>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    int* p;
    p = new int[n];
    rep(i, n) cin >> p[i];
    sort(p, p+n);

    int ans = 0;
    for(int i = 1; i <= n; ++i){
        if(p[n-i] < i){
            break;
        }else{
            ++ans;
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3156
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

iter = [[]]
for i in range(n):
  temp = []
  for cand in iter:
    temp.append(cand + [0])
    temp.append(cand + [1])
  iter = temp

Ans = []
for cand in iter:
  ans = 0
  for i in range(n):
    ans += cand[i] * A[i]
  Ans.append(ans)

for m in M:
  if m in Ans:
    print("yes")
  else:
    print("no")


Measured memory_bytes: 369508
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(int i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    ll n; cin >> n;
    ll a = sqrt(n) + 1;
    for(ll b=a; b>=1; b--) {
        if(n % b == 0) {
            cout << b-1 + n/b-1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<vector>
#include<cstdio>
#include<cmath>
#include<algorithm>

using namespace std;

vector<int> total;
vector<int> coin;
const int INF = 10000000;
int n, m;

int main()
{
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		int c;
		scanf("%d", &c);
		coin.push_back(c);
	}
	for (int i = 0; i <= n; i++)
	{
		total.push_back(INF);
	}
	total[0] = 0;
	for (int i = 0; i < m; i++)
	{
		for (int j = coin[i]; j <= n; j++)
		{
			total[j] = min(total[j], total[j - coin[i]] + 1);
		}
	}
	printf("%d\n", total[n]);
	return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
int main(){
long int n,k;
  cin >> n >> k;
  long int count =0;
  if (k%2==0){
  	count = (n/k)*(n/k)*(n/k)+((n+k/2)/k)*((n+k/2)/k)*((n+k/2)/k);
  }
  else {
  	count = (n/k)*(n/k)*(n/k);
  }
  cout << count <<endl;
}

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

using namespace std;

int main() {

	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;

	int counter = 0;
	bool okflg = true;
	while (1) {
		okflg = true;
		if (b <= a) {
			b *= 2;
			counter++;
			okflg = false;
		}
		if (c <= b) {
			c *= 2;
			counter++;
			okflg = false;
		}
		if (counter > k) {
			cout << "No" << endl;
			return 0;
		}
		if (okflg == true) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}


int main(){
    ll n,ans=0;
    cin >> n;
    string s[n];
    for (ll i=0;i<n;i++)cin >> s[i];
    for (ll i=0;i<n;i++){
        sort(s[i].begin(),s[i].end());
    }
    sort(s,s+n);
    ll c=1;
    for (ll i=1;i<n;i++){
        if (s[i]==s[i-1]){
            c++;
        }else{
            ans+=c*(c-1)/2;
            c=1;
        }
    }
    ans+=c*(c-1)/2;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

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


ll H, W;
ll sx, sy, gx, gy;
ll d[1111][1111];
ll clr[1111][1111];
string s[1111];

void solve() {
  ll i, j, k;
  priority_queue<pair<ll, pll>> q;
  
  for(i=0; i<H; i++) for(j=0; j<W; j++) d[i][j]=INF;
  d[sx][sy]=0;
  q.push(make_pair(0, pll(sx, sy)));
  
  while(q.size()) {
    ll x=q.top().sc.ft;
    ll y=q.top().sc.sc;
    ll u=-q.top().ft;
    q.pop();
    
    if(clr[x][y]) continue;
    clr[x][y]=1;
    
    for(i=-2; i<=2; i++) {
      for(j=-2; j<=2; j++) {
        ll tx=x+i, ty=y+j;
        if(tx<0 || tx>=H || ty<0 || ty>=W) continue;
        if(s[tx][ty]=='#') continue;
        
        if(abs(i)<=1 && abs(j)<=1 && abs(i+j)==1) {
          q.push(make_pair(-u, pll(tx, ty)));
          chmin(d[tx][ty], u);
        }else {
          q.push(make_pair(-u-1, pll(tx, ty)));
          chmin(d[tx][ty], u+1);
        }
        
      }
    }
    
  }
  
}


int main(void) {
  ll i, j, k;
  
  
  cin >> H >> W;
  cin >> sx >> sy >> gx >> gy;
  sx--; sy--; gx--; gy--;
  for(i=0; i<H; i++) cin >> s[i];
  
  solve();
  if(d[gx][gy]==INF) pt(-1);
  else pt(d[gx][gy]);
  
}
 
 




Measured memory_bytes: 25496
from fractions import gcd
import sys
input = sys.stdin.readline


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


def main():
    A, B = map(int, input().split())

    P = set(prime_decomposition(gcd(A, B)))
    
    print(len(P) + 1)
    

 
if __name__ == '__main__':
    main()


Measured memory_bytes: 5052
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll x, y, z;
  cin >> x >> y >> z;
  
  cout << z << " " << x << " " << y << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define re return

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

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define popcount __builtin_popcount
#define mp make_pair
#define pb push_back
#define ins insert
#define sc second
#define fr first
#define endl "\n"
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)

int n, v[N], dp[N],k;

void solve(){
    cin >> n >> k;
    forn(i,0,n)cin >> v[i];
    dp[n-1]=0;
    for(int i=n-2;i>=0;i--){
        dp[i] = MOD;
        for(int j=1,h=i+1;j<=k;j++,h++){
            if(h==n)break;
            dp[i] = min(dp[i], abs(v[i]-v[h])+dp[h]);
        }
    }
    cout << dp[0] << endl;
}
int main(){_
    solve();
    /*
    int t; cin >> t;
    while(t--){
        solve();
    }
    */
}


Measured memory_bytes: 1024
line = require('fs').readFileSync('/dev/stdin', 'ascii').split("\n");
a = line[1].split(" ").map(Number);
min = a.reduce(function(prev, cur, i, ary) {
    return (cur < prev) ? cur : prev;
}, Number.MAX_VALUE);
max = a.reduce(function(prev, cur, i, ary) {
    return (cur > prev) ? cur : prev;
}, -Number.MAX_VALUE);
sum = a.reduce(function(prev, cur, i, ary) { return prev + cur; }, 0);
console.log(min, max, sum);

Measured memory_bytes: 17352
import sys
input = sys.stdin.readline

N, M = map(int, input().split())

G = [tuple(map(int, input().split())) for _ in range(M)]
G.sort(key = lambda x: x[0])

check = [False] * (N + 1)

for a, b in G:
    if a == 1:
        check[b] = True
    else:
        if check[a] and b == N:
            print ('POSSIBLE')
            exit()

print ('IMPOSSIBLE')

Measured memory_bytes: 33480
import java.util.*;
import java.util.Arrays;
import java.util.Set;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        int a=0;
        for(int i=0;i<3;i++){
            if(S.charAt(i)=='1'){
                a++;
            }
        }
        System.out.println(a);


}
        
        
    }


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;

inline int read(){
	re int ans = 0;re bool f = 1;re char ch = getchar();
	while(ch<'0'||ch>'9'){if (ch=='-')f = 0;ch = getchar();}
	while(ch>='0'&&ch<='9'){
		ans = (ans<<3)+(ans<<1)+(ch^48);
		ch = getchar();
	}
	return f?ans:~(ans-1);
}

signed main(void){
	int a,b,c;
	a = read(),b = read(),c = read();
	
	if((4*a*b)<((c-a-b)*(c-a-b))&&(c-a-b)>0)printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
	
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
	
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
	
class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
	
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}
	
bool solve() {
	int n; cin >> n;
	int a[n]; REP (i,n) cin >> a[i];
	pair<int,int> b[n]; REP (i,n) {b[i].second = i; b[i].first = a[i];}
	sort(b,b+n);
	REP (i,n) {
		if (i != b[n-1].second) {
			cout << b[n-1].first << endl;
		} else {
			cout << b[n-2].first << endl;
		}
	}
}
	
signed main() {
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 6272
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int min = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++){
			int count = 0;
			Long x = scan.nextLong();
			while((x % 2)==0){
				x /= 2;
				count++;
			}
			
			if(count <= min)min = count;
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 21332
#include<stdio.h>
#include<string>
using namespace std;

int N;
string s="99999999999", dap="";

bool quest(string k){
	char c;
	printf("? %s\n", k.c_str()); fflush(stdout);
	scanf("\n%c", &c);
	if(c == 'Y') return 1;
	return 0;
}

int main(){
	int chk=1;
	for(int i=0; i<10; i++){
		int mi='1', mx='9', md;
		if(i) mi='0';
		while(1){
			md=(mi+mx)/2;
			s[i]=md;
			if(mi == mx) break;
			if(quest(s)) mx=md; // jarisu <= md
			else mi=md+1;
		}
		dap += md;
		if(md != '9') chk=0;
		if(chk){ // 999999
			string g="1";
			for(int j=0; j<=i; j++) g += '0';
			if(!quest(g)) break;
		}
		else{
			string g=dap;
			for(int j=0; j<g.size(); j++) if(g[j]!='9') g[j]++;
			if(quest(g)) break;
		}
	}
	printf("! %s\n", dap.c_str()); fflush(stdout);
	return 0;
}


Measured memory_bytes: 596
def solve(n, a):
    b = [0] * n
    v = 0
    ans = 0
    for i in range(n):
        v += a[i]
        b[i] = v
        if v == 0:
            ans += 1
    D = {}
    for v in b:
        if not v in D:
            D[v] = 0
        D[v] += 1
    for k, v in D.items():
        if v > 1:
            ans += v * (v-1) / 2
    return ans

assert solve(6, [1,3,-4,2,2,-2]) == 3
assert solve(7, [1,-1,1,-1,1,-1,1]) == 12
assert solve(5, [1,-2,3,-4,5]) == 0
n = input()
a = map(int, raw_input().split())
print solve(n, a)

Measured memory_bytes: 48140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define overload4(_1, _2, _3, _4, name, ...) name
#define overload3(_1, _2, _3, name, ...) name
#define rep1(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
template <class T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
typedef pair<int, int> P;

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);
vector<ll> prime;
vector<ll> eratosthenes(long long n) {
  vector<ll> is_prime(n + 1, true);
  for (ll i = 2; i * i <= n; i++) {
    if (is_prime[i]) {
      for (ll j = i + i; j <= n + 1; j += i) {
        is_prime[j] = false;
      }
    }
  }
  for (ll i = 2; i < is_prime.size(); i++) {
    if (is_prime[i]) {
      prime.push_back(i);
    }
  }
  return prime;
}

int main() {  // TODO
  int N;
  cin >> N;
  vector<ll> A(1000005, 0);
  vector<int> V(N);
  ll gmax = 1000005;
  rep(N) {
    ll a;
    cin >> a;
    A[a]++;
    V[i] = a;
  }

  bool is_pc = true;
  for (int i = 2; i < gmax; i++) {
    int cnt = 0;
    for (int j = i; j < gmax; j += i) {
      cnt += A[j];
    }
    if (cnt > 1) is_pc = false;
  }

  if (is_pc == true) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  int g = 0;
  rep(i, N) g = gcd(g, V[i]);
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }

  cout << "not coprime" << endl;
  return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n, a, b;
    cin >> n >> a >> b;

    cout << min(b, a * n) << endl;
}


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

int main()
{
    int no,i,cnt=0;
    cin >> no;
    int a[no];
    for(i=0;i<no;i++)
    {
        cin >> a[i];
    }
    sort(a,a+no);
    for(i=0;i<no-1;i++)
    {
        if(a[i]==a[i+1])
        {
            cnt++;
        }
    }
    cout << no-cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    static int inf = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int v = Integer.parseInt(scan.next());
        int e = Integer.parseInt(scan.next());
        int[][] dist = new int[v][v];
        for (int i = 0; i < v; i++) {
            for (int j = 0; j < v; j++) {
                dist[i][j] = inf;
            }
        }
        for (int i = 0; i < e; i++) {
            int s = Integer.parseInt(scan.next());
            int t = Integer.parseInt(scan.next());
            int d = Integer.parseInt(scan.next());
            dist[s][t] = d;
        }
        scan.close();

        int[][] dp = new int[1 << v][v];
        for (int i = 0; i < (1 << v); i++) {
            for (int j = 0; j < v; j++) {
                dp[i][j] = inf;
            }
        }
        dp[1][0] = 0;

        for (int i = 0; i < (1 << v); i++) {
            for (int j = 0; j < v; j++) {
                if (dp[i][j] == inf) {
                    continue;
                }

                for (int k = 0; k < v; k++) {
                    if ((i & (1 << k)) != 0) {
                        continue;
                    }

                    if (dist[j][k] == inf) {
                        continue;
                    }
                    int nextI = i | (1 << k);
                    dp[nextI][k] = Math.min(dp[nextI][k], dp[i][j] + dist[j][k]);
                }
            }
        }

        int ans = inf;
        for (int i = 0; i < v; i++) {
            if (dp[(1 << v) - 1][i] == inf) {
                continue;
            }
            if (dist[i][0] == inf) {
                continue;
            }
            int result = dp[(1 << v) - 1][i] + dist[i][0];
            ans = Math.min(ans, result);
        }

        if (ans == inf) {
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }

    }

}



Measured memory_bytes: 33080
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
#define MOD 1e9+7

int main(){
    int n;
    cin >> n;
    vi a(n);
    ll ans=0;
    int count=0;
    int mini=1e9+1;
    rep(i,n){
        cin >> a[i];
        if(a[i]<0){
            count++;
            a[i]*=-1;
        }
        ans+=a[i];
        mini=min(mini,a[i]);
    }
    if(count%2==0) cout << ans << endl;
    else cout << ans-2*mini << endl;

}

Measured memory_bytes: 3760
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

H, W, K = map(int, input().split())

S = []
n = "."*W
l = []
for i in range(H):
    s = input().strip()
    if s != n:
        l.append(i)
    else:
        l.append(-1)
    S.append(list(s))


A = [[0 for j in range(W)]for i in range(H)]
num = 1
for i in l:
    if i == -1:
        continue
    f = 0
    for j in range(W):
        if S[i][j] == ".":
            A[i][j] = str(num)
        else:
            if f == 1:
                num += 1
            else:
                f = 1
            A[i][j] = str(num)
    num += 1


tmp = -1
for i in range(H):
    if l[i] != -1:
        tmp = l[i]
    else:
        if tmp == -1:
            continue
        else:
            l[i] = tmp

for i in range(H-1, -1, -1):
    if l[i] != -1:
        tmp = l[i]
    else:
        if tmp == -1:
            continue
        else:
            l[i] = tmp

for i in l:
    print(" ".join(A[i]))

Measured memory_bytes: 10100
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        List<Character> output = new ArrayList<Character>();
        for (char c : s.toCharArray()) {
            if (c != 'B') {
                output.add(c);
            } else {
                if (output.size() != 0) {
                    output.remove(output.size() - 1);
                }
            }
        }

        String ans = output.stream().map(String::valueOf).collect(Collectors.joining());
        System.out.println(ans);
    }
}

Measured memory_bytes: 28372
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextInt();
        long k = scanner.nextInt();
        long ans = 0;
        for(long i = k; i <= n+1; i++){
            long l = sum(0, i-1);
            long r = sum(n-i+1, n);
            ans += r-l+1;
        }
        System.out.println((int) (ans % (Math.pow(10, 9) + 7)));
    }

    public static long sum(long l, long r){
        return (l+r) * (r - l + 1) / 2;
    }
}

Measured memory_bytes: 35736
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        char[]  s = sc.next().toCharArray();
        int ct = 0;
        for (int i = 0; i < 11; i++) {
            char c1 = (char) ('0' + i);
            //探索
            for (int j = 0; j < n; j++) {
                if (s[j] == c1){//一致したら次の配列の文字を探す
                    for (int k = 0; k < 11; k++) {
                        char c2 = (char) ('0' + k);
                        for (int l = j+1; l < n; l++) {
                            if (s[l] == c2){
                                for (int m = 0; m < 11; m++) {
                                    char c3 = (char) ('0' + m);
                                    for (int o = l + 1; o < n; o++) {
                                        if (s[o] == c3){
                                            ct++;
                                            break;
                                        }
                                    }
                                }
                                break;
                            }
                        }
                    }
                    break;
                }
            }
        }
        System.out.println(ct);
    }
}

Measured memory_bytes: 24192
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<cstdlib>
//#include<algorithm>
//#include<vector>
//#include<queue>
//#include<stack>
//#include<map>
//#include<set>
using namespace std;
#define SC scanf
#define PR printf
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define uint unsigned
#define ll long long
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef map<int,int> mii;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const int xx[4]={1,-1,0,0};
const int yy[4]={0,0,1,-1};
int inline in(){
	int x=0,c;
	for(;(uint)((c=getchar())-'0')>=10;){
		if(c=='-')return -in();
		if(!~c)throw ~0;
	}
	do{
		x=(x<<3)+(x<<1)+(c-'0');
	}while((uint)((c=getchar())-'0')<10);
	return x;
}
int main(){
    ios::sync_with_stdio(false);
	int r;
	cin>>r;
	cout<<3*r*r<<endl;
	return 0;
}


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

int main() {
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    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 R[2*H][W];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            R[2*i][j] = C[i][j];
            R[2*i+1][j] = C[i][j];
        }
    }

    for (int i = 0; i < 2*H; i++) {
        for (int j = 0; j < W; j++) {
            cout << R[i][j];
        }
        cout << endl;
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1e16
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll int
#define vi vector<ii>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 40003;
ll a,b,c;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a>>b>>c;
    cout<<(a * b) / 2;
    return 0;
}

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

int main(){
	vector<int> v(1001);
	int cnt=0;
	for(int i=1; i<1002; i++){
		if(i%3==0) cnt++;
		v[i]=cnt;
	}
	int n; cin>>n;
	cout<<v[n]<<endl;
}

Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#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++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
const ll inf = 1000000007;
int main() {
  ll n; cin >>n;
  vector<string> s(n);
  map<char,ll> mpans;
  rep(i,n) cin>>s[i];
  rep(i,s[0].size())mpans[s[0][i]]++;
  rep2(i,1,n){
    map<char,ll> mp;
    rep(j,s[i].size())mp[s[i][j]]++;
    for( char a='a';a<='z';a++)mpans[a]=min(mpans[a],mp[a]);
  }
  string ans ="";
  for( char a='a';a<='z';a++)if(mpans[a]>0)rep(i,mpans[a])ans+=a;
  cout <<ans<<endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

// 爆弾マスは-1
// 空きマスは0

int main() {
  int h, w;
  cin >> h >> w;
  V<V<int>> field(h, V<int>(w, 0));
  V<string> s_list;
  s_list.resize(h);

  rep(i, h) {
    cin >> s_list[i];
  }

  rep(hi, h) {
    rep(wi, w) {
      if(s_list[hi][wi] == '#') {
        field[hi][wi] = -1;

        repf(hj, hi - 1, hi + 2) {
          repf(wj, wi - 1, wi + 2) {
            if(hj >= 0 && hj < h && wj >= 0 && wj < w) {
              if(field[hj][wj] == -1) {
                continue;
              }

              field[hj][wj]++;
            }
          }
        }
      }
    }
  }

  rep(hi, h){
    rep(wi, w) {
      if(field[hi][wi] == -1) {
        cout << "#";
      } else {
        cout << field[hi][wi];
      }
    }
    cout << endl;
  }
}

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

int main(){
    string N;
    cin >> N;
    unsigned mod = 0, sz = N.size();
    for(auto i : N){
        mod = (mod + (i - '0'))%9;
    }
    if(mod) printf("No\n");
    else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(){
  ll n,vl=1e9,vr=1e9,a[11];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
      ll w; cin>>w;
      if(a[i]==0)vl=min(vl,w);
      if(a[i]==1)vr=min(vr,w);
  }
  if(vl==1e9||vr==1e9)cout<<0<<endl;
  else cout<<vl+vr<<endl;
  return 0;
}



Measured memory_bytes: 3092
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + K + 1 - s_z)
  else:
    ans.append(s_z + 1)
 
print(sum(ans))

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(long long i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
ll l,r;
cin>>l>>r;
if(r-l>2200)
{
	ol("0");
	return 0;
}
ll ans=1e9+7;
rep(i,l,r)
{
	rep(j,i+1,r)
	{
		ll x=i%2019,y=j%2019;
		ans=min(ans,(x*y)%2019);
	}
}
ol(ans);
return 0;
}



Measured memory_bytes: 256
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
sys.setrecursionlimit(500000)

S = list(input())[::-1]
N = len(S)
D = [1]
for i in range(N):
    D.append(D[-1]*10%2019)
M = [(int(S[i])*D[i])%2019 for i in range(N)]
SS = [M[0]]
for i in range(1,N):
    SS.append((SS[-1]+M[i])%2019)
count = [0]*2019
for i in range(N):
    count[SS[i]] += 1

ans = 0
for c in range(len(count)):
    if c==0:
        ans += count[c]
    ans += (count[c] * (count[c] - 1)) // 2

print(ans)


Measured memory_bytes: 98080
import Control.Monad (replicateM)

calc :: [Int] -> Int
calc [a, b, c, x] = sum [1| a'<-[0..a], b'<-[0..b], c'<-[0..c], 500*a'+100*b'+50*c' == x]

main :: IO ()
main = print . calc =<< replicateM 4 readLn


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define SUM(v) accumulate((v).begin(),(v).end(),0ll)
#define range(i,left,right) (left<=i && i<right)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int iscount(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int n,m;
    cin>>n>>m;
    Vi a(m);
    REP(i,0,m) cin>>a[i];

    int SUM=SUM(a);
    if(SUM<=n) cout<<n-SUM<<endl;
    else cout<<-1<<endl;
    return 0;
}


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

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int sum = 0;
    if(a+b>=k) sum=min(a,k);
    else sum=a-min(c,k-b-a);
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3580